diff options
author | INADA Naoki <songofacandy@gmail.com> | 2016-11-22 10:43:11 (GMT) |
---|---|---|
committer | INADA Naoki <songofacandy@gmail.com> | 2016-11-22 10:43:11 (GMT) |
commit | ff33c93f23646aacfac42d50d72961b3858f91e8 (patch) | |
tree | b6f646d955e67d99d8dfe75d81ff4fd661bce601 /Tools | |
parent | 1cd91a17a958a7c24cdc9976a950100fd7cd1117 (diff) | |
parent | d7d2bc8798da3b083e383e949ba01d61b78e4e4d (diff) | |
download | cpython-ff33c93f23646aacfac42d50d72961b3858f91e8.zip cpython-ff33c93f23646aacfac42d50d72961b3858f91e8.tar.gz cpython-ff33c93f23646aacfac42d50d72961b3858f91e8.tar.bz2 |
Issue #28023: Fix python-gdb.py didn't support new dict implementation
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/gdb/libpython.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py index 3e95b44..964cc9f 100755 --- a/Tools/gdb/libpython.py +++ b/Tools/gdb/libpython.py @@ -666,8 +666,9 @@ class PyDictObjectPtr(PyObjectPtr): ''' keys = self.field('ma_keys') values = self.field('ma_values') - for i in safe_range(keys['dk_size']): - ep = keys['dk_entries'].address + i + entries, nentries = self._get_entries(keys) + for i in safe_range(nentries): + ep = entries[i] if long(values): pyop_value = PyObjectPtr.from_pyobject_ptr(values[i]) else: @@ -707,6 +708,29 @@ class PyDictObjectPtr(PyObjectPtr): pyop_value.write_repr(out, visited) out.write('}') + def _get_entries(self, keys): + dk_size = int(keys['dk_size']) + try: + # <= Python 3.5 + return keys['dk_entries'], dk_size + except gdb.error: + # >= Python 3.6 + pass + + if dk_size <= 0xFF: + offset = dk_size + elif dk_size <= 0xFFFF: + offset = 2 * dk_size + elif dk_size <= 0xFFFFFFFF: + offset = 4 * dk_size + else: + offset = 8 * dk_size + + 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']) + + class PyListObjectPtr(PyObjectPtr): _typename = 'PyListObject' |