Skip to content

Commit

Permalink
Issue python#28023: Fix python-gdb.py on old GDB versions
Browse files Browse the repository at this point in the history
Replace int(value.address)+offset with value.cast(unsigned char*)+offset.

It seems like int(value.address) fails on old versions of GDB.
  • Loading branch information
vstinner committed Nov 22, 2016
1 parent d7d2bc8 commit 3a5d79f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Tools/gdb/libpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ def write_repr(self, out, visited):
out.write('}')

def _get_entries(self, keys):
dk_nentries = int(keys['dk_nentries'])
dk_size = int(keys['dk_size'])
try:
# <= Python 3.5
Expand All @@ -726,9 +727,12 @@ def _get_entries(self, keys):
else:
offset = 8 * dk_size

ent_addr = keys['dk_indices']['as_1'].address
ent_addr = ent_addr.cast(_type_unsigned_char_ptr()) + offset
ent_ptr_t = gdb.lookup_type('PyDictKeyEntry').pointer()
ent_addr = int(keys['dk_indices']['as_1'].address) + offset
return gdb.Value(ent_addr).cast(ent_ptr_t), int(keys['dk_nentries'])
ent_addr = ent_addr.cast(ent_ptr_t)

return ent_addr, dk_nentries


class PyListObjectPtr(PyObjectPtr):
Expand Down

0 comments on commit 3a5d79f

Please sign in to comment.