summaryrefslogtreecommitdiffstats
path: root/Tools/gdb
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-09-12 16:37:06 (GMT)
committerGitHub <noreply@github.com>2024-09-12 16:37:06 (GMT)
commitb2afe2aae487ebf89897e22c01d9095944fd334f (patch)
tree3ffa3ebfe3c69cd21968ce76d8d7cb2f325ff6d3 /Tools/gdb
parent4ed7d1d6acc22807bfb5983c98fd59f7cb5061db (diff)
downloadcpython-b2afe2aae487ebf89897e22c01d9095944fd334f.zip
cpython-b2afe2aae487ebf89897e22c01d9095944fd334f.tar.gz
cpython-b2afe2aae487ebf89897e22c01d9095944fd334f.tar.bz2
gh-123923: Defer refcounting for `f_executable` in `_PyInterpreterFrame` (#123924)
Use a `_PyStackRef` and defer the reference to `f_executable` when possible. This avoids some reference count contention in the common case of executing the same code object from multiple threads concurrently in the free-threaded build.
Diffstat (limited to 'Tools/gdb')
-rwxr-xr-xTools/gdb/libpython.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py
index cf03788..946af4b 100755
--- a/Tools/gdb/libpython.py
+++ b/Tools/gdb/libpython.py
@@ -158,8 +158,11 @@ class PyObjectPtr(object):
def __init__(self, gdbval, cast_to=None):
# Clear the tagged pointer
- gdbval = gdb.Value(int(gdbval) & (~USED_TAGS)).cast(gdbval.type)
- if cast_to:
+ if gdbval.type.name == '_PyStackRef':
+ if cast_to is None:
+ cast_to = gdb.lookup_type('PyObject').pointer()
+ self._gdbval = gdb.Value(int(gdbval['bits']) & ~USED_TAGS).cast(cast_to)
+ elif cast_to:
self._gdbval = gdbval.cast(cast_to)
else:
self._gdbval = gdbval
@@ -1052,7 +1055,7 @@ class PyFramePtr:
obj_ptr_ptr = gdb.lookup_type("PyObject").pointer().pointer()
- localsplus = self._gdbval["localsplus"].cast(obj_ptr_ptr)
+ localsplus = self._gdbval["localsplus"]
for i in safe_range(self.co_nlocals):
pyop_value = PyObjectPtr.from_pyobject_ptr(localsplus[i])
@@ -1581,7 +1584,10 @@ class PyObjectPtrPrinter:
return stringify(proxyval)
def pretty_printer_lookup(gdbval):
- type = gdbval.type.unqualified()
+ type = gdbval.type.strip_typedefs().unqualified()
+ if type.code == gdb.TYPE_CODE_UNION and type.tag == '_PyStackRef':
+ return PyObjectPtrPrinter(gdbval)
+
if type.code != gdb.TYPE_CODE_PTR:
return None