diff options
author | Mark Shannon <mark@hotpy.org> | 2022-08-01 13:34:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-01 13:34:54 (GMT) |
commit | de388c0a7b71c094d36ce40fecef87bdbb8a87d3 (patch) | |
tree | b2318318e6c9a80bc9f45ecf5fc05aa66efb7825 /Tools/gdb/libpython.py | |
parent | fb75d015f487e50079e8d2ea7859750684b124e4 (diff) | |
download | cpython-de388c0a7b71c094d36ce40fecef87bdbb8a87d3.zip cpython-de388c0a7b71c094d36ce40fecef87bdbb8a87d3.tar.gz cpython-de388c0a7b71c094d36ce40fecef87bdbb8a87d3.tar.bz2 |
GH-95245: Store object values and dict pointers in single tagged pointer. (GH-95278)
Diffstat (limited to 'Tools/gdb/libpython.py')
-rwxr-xr-x | Tools/gdb/libpython.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py index 80563ea..d03c637 100755 --- a/Tools/gdb/libpython.py +++ b/Tools/gdb/libpython.py @@ -489,6 +489,8 @@ class HeapTypeObjectPtr(PyObjectPtr): dictptr = self._gdbval.cast(_type_char_ptr()) + dictoffset PyObjectPtrPtr = PyObjectPtr.get_gdb_type().pointer() dictptr = dictptr.cast(PyObjectPtrPtr) + if int(dictptr.dereference()) & 1: + return None return PyObjectPtr.from_pyobject_ptr(dictptr.dereference()) except RuntimeError: # Corrupt data somewhere; fail safe @@ -502,12 +504,14 @@ class HeapTypeObjectPtr(PyObjectPtr): has_values = int_from_int(typeobj.field('tp_flags')) & Py_TPFLAGS_MANAGED_DICT if not has_values: return None - PyDictValuesPtrPtr = gdb.lookup_type("PyDictValues").pointer().pointer() - valuesptr = self._gdbval.cast(PyDictValuesPtrPtr) - 4 - values = valuesptr.dereference() - if int(values) == 0: + charptrptr_t = _type_char_ptr().pointer() + ptr = self._gdbval.cast(charptrptr_t) - 3 + char_ptr = ptr.dereference() + if (int(char_ptr) & 1) == 0: return None - values = values['values'] + char_ptr += 1 + values_ptr = char_ptr.cast(gdb.lookup_type("PyDictValues").pointer()) + values = values_ptr['values'] return PyKeysValuesPair(self.get_cached_keys(), values) def get_cached_keys(self): @@ -527,14 +531,15 @@ class HeapTypeObjectPtr(PyObjectPtr): return ProxyAlreadyVisited('<...>') visited.add(self.as_address()) - pyop_attr_dict = self.get_attr_dict() keys_values = self.get_keys_values() if keys_values: attr_dict = keys_values.proxyval(visited) - elif pyop_attr_dict: - attr_dict = pyop_attr_dict.proxyval(visited) else: - attr_dict = {} + pyop_attr_dict = self.get_attr_dict() + if pyop_attr_dict: + attr_dict = pyop_attr_dict.proxyval(visited) + else: + attr_dict = {} tp_name = self.safe_tp_name() # Class: |