summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2021-11-09 11:19:47 +0000
committerGitHub <noreply@github.com>2021-11-09 11:19:47 +0000
commitf4c03484da59049eb62a9bf7777b963e2267d187 (patch)
treea1c9d1da40c919a7852e5c690d149d83a135cdf6
parent6a1cc8bf8a0d88af9c7891c6577508ae9f70e3ef (diff)
downloadcpython-git-f4c03484da59049eb62a9bf7777b963e2267d187.tar.gz
bpo-45637: Remove broken fallback in gdb helpers to obtain frame variable (GH-29257)
-rw-r--r--Lib/test/test_gdb.py2
-rwxr-xr-xTools/gdb/libpython.py18
2 files changed, 9 insertions, 11 deletions
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index 2805eaf9f9..eaeb6fb8ff 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -823,6 +823,8 @@ Traceback \(most recent call first\):
foo\(1, 2, 3\)
''')
+ @unittest.skipIf(python_is_optimized(),
+ "Python was compiled with optimizations")
def test_threads(self):
'Verify that "py-bt" indicates threads that are waiting for the GIL'
cmd = '''
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py
index 54f72320cd..f4b27f1152 100755
--- a/Tools/gdb/libpython.py
+++ b/Tools/gdb/libpython.py
@@ -1801,17 +1801,13 @@ class Frame(object):
frame = PyFramePtr(frame)
if not frame.is_optimized_out():
return frame
- # gdb is unable to get the "frame" argument of PyEval_EvalFrameEx()
- # because it was "optimized out". Try to get "frame" from the frame
- # of the caller, _PyEval_Vector().
- orig_frame = frame
- caller = self._gdbframe.older()
- if caller:
- frame = caller.read_var('frame')
- frame = PyFramePtr(frame)
- if not frame.is_optimized_out():
- return frame
- return orig_frame
+ cframe = self._gdbframe.read_var('cframe')
+ if cframe is None:
+ return None
+ frame = PyFramePtr(cframe["current_frame"].dereference())
+ if frame and not frame.is_optimized_out():
+ return frame
+ return None
except ValueError:
return None