Skip to content

bpo-45637: Remove broken fallback in gdb helpers to obtain frame variable #29257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/test/test_gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,8 @@ def test_bt_full(self):
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 = '''
Expand Down
18 changes: 7 additions & 11 deletions Tools/gdb/libpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -1801,17 +1801,13 @@ def get_pyop(self):
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():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be impossible for frame to be "optimized out" here?

Copy link
Member Author

@pablogsal pablogsal Oct 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if impossible, because optimized out is a value that GDB cannot read, but I agree is certainly very likely never going to be True but I think is still good for safety. You want to remove the check?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you. I'm just guessing here, really.

return frame
return None
except ValueError:
return None

Expand Down