summaryrefslogtreecommitdiffstats
path: root/Tools/gdb
diff options
context:
space:
mode:
authorT. Wouters <thomas@python.org>2024-11-05 14:49:27 (GMT)
committerGitHub <noreply@github.com>2024-11-05 14:49:27 (GMT)
commitbbfd9c92fa3e3d77a86c7858617eb3d09de44fd1 (patch)
treeedfdf391989e4f9de9860e5d2a51663a3228e8b4 /Tools/gdb
parent75872605aa78dbdfc5c4f025b0f90a7f37ba10c3 (diff)
downloadcpython-bbfd9c92fa3e3d77a86c7858617eb3d09de44fd1.zip
cpython-bbfd9c92fa3e3d77a86c7858617eb3d09de44fd1.tar.gz
cpython-bbfd9c92fa3e3d77a86c7858617eb3d09de44fd1.tar.bz2
gh-115999: Fix gdb support for libpython.so after thread-local bytecode change (#126440)
Fix the gdb pretty printer in the face of --enable-shared by delaying the attempt to load the _PyInterpreterFrame definition until after .so files are loaded.
Diffstat (limited to 'Tools/gdb')
-rwxr-xr-xTools/gdb/libpython.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py
index ed25415..698ecbd3b 100755
--- a/Tools/gdb/libpython.py
+++ b/Tools/gdb/libpython.py
@@ -77,10 +77,14 @@ def _managed_dict_offset():
else:
return -3 * _sizeof_void_p()
-def _interp_frame_has_tlbc_index():
- interp_frame = gdb.lookup_type("_PyInterpreterFrame")
- return any(field.name == "tlbc_index" for field in interp_frame.fields())
-
+_INTERP_FRAME_HAS_TLBC_INDEX = None
+def interp_frame_has_tlbc_index():
+ global _INTERP_FRAME_HAS_TLBC_INDEX
+ if _INTERP_FRAME_HAS_TLBC_INDEX is None:
+ interp_frame = gdb.lookup_type("_PyInterpreterFrame")
+ _INTERP_FRAME_HAS_TLBC_INDEX = any(field.name == "tlbc_index"
+ for field in interp_frame.fields())
+ return _INTERP_FRAME_HAS_TLBC_INDEX
Py_TPFLAGS_INLINE_VALUES = (1 << 2)
Py_TPFLAGS_MANAGED_DICT = (1 << 4)
@@ -109,7 +113,6 @@ FRAME_INFO_OPTIMIZED_OUT = '(frame information optimized out)'
UNABLE_READ_INFO_PYTHON_FRAME = 'Unable to read information on python frame'
EVALFRAME = '_PyEval_EvalFrameDefault'
-INTERP_FRAME_HAS_TLBC_INDEX = _interp_frame_has_tlbc_index()
class NullPyObjectPtr(RuntimeError):
pass
@@ -1101,7 +1104,7 @@ class PyFramePtr:
def _f_lasti(self):
codeunit_p = gdb.lookup_type("_Py_CODEUNIT").pointer()
instr_ptr = self._gdbval["instr_ptr"]
- if INTERP_FRAME_HAS_TLBC_INDEX:
+ if interp_frame_has_tlbc_index():
tlbc_index = self._gdbval["tlbc_index"]
code_arr = PyCodeArrayPtr(self._f_code().field("co_tlbc"))
first_instr = code_arr.get_entry(tlbc_index).cast(codeunit_p)