Fixes #436 - memory write regression (#437)

* Fix regression made in #432

*This situation pushes me more and more to work on tests engine*

* Fix eX memory write on Python 2

As string literal is unicode, in Py2 the code below would fail if `bytestr` is just a `str`, due to `'0'` being unocide literal:

```
bytestr.rjust(size*2, '0')
```
pull/439/head
Disconnect3d 8 years ago committed by GitHub
parent 99e5b84f58
commit f7eee8fb5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,6 +8,8 @@ from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from builtins import str
import argparse
import codecs
import math
@ -172,9 +174,9 @@ def eX(size, address, data, hex=True):
if address is None:
return
for i,bytestr in enumerate(data):
for i, bytestr in enumerate(data):
if hex:
bytestr = bytestr.rjust(size*2, '0')
bytestr = str(bytestr).rjust(size*2, '0')
data = codecs.decode(bytestr, 'hex')
else:
data = bytestr

@ -100,7 +100,10 @@ def write(addr, data):
addr(int): Address to write
data(str,bytes,bytearray): Data to write
"""
gdb.selected_inferior().write_memory(addr, bytes(data, 'utf8'))
if isinstance(data, str):
data = bytes(data, 'utf8')
gdb.selected_inferior().write_memory(addr, data)
def peek(address):

Loading…
Cancel
Save