summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2021-06-18 10:00:29 (GMT)
committerGitHub <noreply@github.com>2021-06-18 10:00:29 (GMT)
commit0982ded179f280176868c1c4eccf77bf70687816 (patch)
tree961c9e5ce60cffb79260fbc5a5b8ff321f68cc1b /Tools
parent7f01f77f8fabcfd7ddb5d99f12d6fc99af9af384 (diff)
downloadcpython-0982ded179f280176868c1c4eccf77bf70687816.zip
cpython-0982ded179f280176868c1c4eccf77bf70687816.tar.gz
cpython-0982ded179f280176868c1c4eccf77bf70687816.tar.bz2
bpo-44032: Move pointer to code object from frame-object to frame specials array. (GH-26771)
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/gdb/libpython.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py
index 756b52c..0198500 100755
--- a/Tools/gdb/libpython.py
+++ b/Tools/gdb/libpython.py
@@ -856,6 +856,8 @@ class PyNoneStructPtr(PyObjectPtr):
FRAME_SPECIALS_GLOBAL_OFFSET = 0
FRAME_SPECIALS_BUILTINS_OFFSET = 1
+FRAME_SPECIALS_CODE_OFFSET = 3
+FRAME_SPECIALS_SIZE = 4
class PyFrameObjectPtr(PyObjectPtr):
_typename = 'PyFrameObject'
@@ -864,7 +866,7 @@ class PyFrameObjectPtr(PyObjectPtr):
PyObjectPtr.__init__(self, gdbval, cast_to)
if not self.is_optimized_out():
- self.co = PyCodeObjectPtr.from_pyobject_ptr(self.field('f_code'))
+ self.co = self._f_code()
self.co_name = self.co.pyop_field('co_name')
self.co_filename = self.co.pyop_field('co_filename')
@@ -890,11 +892,18 @@ class PyFrameObjectPtr(PyObjectPtr):
pyop_name = PyObjectPtr.from_pyobject_ptr(self.co_localsplusnames[i])
yield (pyop_name, pyop_value)
+ def _f_specials(self, index, cls=PyObjectPtr):
+ f_valuestack = self.field('f_valuestack')
+ return cls.from_pyobject_ptr(f_valuestack[index - FRAME_SPECIALS_SIZE])
+
def _f_globals(self):
- f_localsplus = self.field('f_localsptr')
- nlocalsplus = int_from_int(self.co.field('co_nlocalsplus'))
- index = nlocalsplus + FRAME_SPECIALS_GLOBAL_OFFSET
- return PyObjectPtr.from_pyobject_ptr(f_localsplus[index])
+ return self._f_specials(FRAME_SPECIALS_GLOBAL_OFFSET)
+
+ def _f_builtins(self):
+ return self._f_specials(FRAME_SPECIALS_BUILTINS_OFFSET)
+
+ def _f_code(self):
+ return self._f_specials(FRAME_SPECIALS_CODE_OFFSET, PyCodeObjectPtr)
def iter_globals(self):
'''
@@ -907,12 +916,6 @@ class PyFrameObjectPtr(PyObjectPtr):
pyop_globals = self._f_globals()
return pyop_globals.iteritems()
- def _f_builtins(self):
- f_localsplus = self.field('f_localsptr')
- nlocalsplus = int_from_int(self.co.field('co_nlocalsplus'))
- index = nlocalsplus + FRAME_SPECIALS_BUILTINS_OFFSET
- return PyObjectPtr.from_pyobject_ptr(f_localsplus[index])
-
def iter_builtins(self):
'''
Yield a sequence of (name,value) pairs of PyObjectPtr instances, for