python pystack gdb macro |
2010-10-17
|
As mentioned before, I ended up getting a working pystack macro again for use in gdb. Someone commented I should make it public so here it is:
# THOMAS: the test for between Py_Main and Py_GetArgcArgv is because
# code is in that order in the C file; see Modules/main.c and its comment
# print the entire Python call stack
# same for eval in Python/ceval.c
# in 2.6, PyEval_EvalFrame is only bw compatible, and code now calls
# PyEval_EvalFrameEx
define pystack
set $__lastpc = $pc
set $__same = -1
while 1 == 1
# select the highest frame with the same $pc
# this will automatically terminate if we reach the top
while $pc == $__lastpc
up-silently
end
down-silently
if $pc > PyEval_EvalFrameEx && $pc < PyEval_EvalCodeEx
pyframe
else
# frame
end
up-silently 1
set $__lastpc = $pc
end
select-frame 0
end
I also posted it in the upstream bug but I doubt that’s going to achieve much in this case…
![[lang]](/images/eye.png)

You may like this:
https://fedoraproject.org/wiki/Features/EasierPythonDebugging
Comment by Tom Tromey — 2010-10-19 @ 7:32 pm