Skip to content

Commit

Permalink
Keep py-next/step working in gdb script even when in native code
Browse files Browse the repository at this point in the history
Summary: When I was testing this I only ever interrupted code directly in the interperter loop. It turns out that if we're in native code (called from the interpreter) we need to manually crank the handle a bit to get to a valid Python frame.

Reviewed By: alexmalyshev

Differential Revision: D57707850

fbshipit-source-id: a9990e0833240053c7fbddf223fa5b1ce369618e
  • Loading branch information
jbower-fb authored and facebook-github-bot committed Jun 14, 2024
1 parent 4f40895 commit a869a48
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Tools/gdb/libpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -2042,11 +2042,18 @@ def invoke(self, args, from_tty):
global _PyRunningTargetFrameBackAddress

frame = Frame.get_selected_python_frame()
# Aparently this frame is not actually a Python frame, so we need to
# walk to find it. This is based on the implementation around the
# PyUp/PyDown commands.
while frame:
if frame.is_python_frame():
pyop_frame = frame.get_pyop()
if pyop_frame:
break
frame = frame.older()
if not frame:
print('Unable to locate python frame')
return

pyop_frame = frame.get_pyop()
if not pyop_frame:
print(UNABLE_READ_INFO_PYTHON_FRAME)
return
Expand All @@ -2066,4 +2073,3 @@ def invoke(self, args, from_tty):
# gdb.execute('call (void*)dlopen("gdb_dbg.cpython-312-x86_64-linux-gnu.so", 2)')

# PyRunningInit()

0 comments on commit a869a48

Please sign in to comment.