@@ -26,17 +26,6 @@ define pyg
2626print _PyGC_Dump($arg0)
2727end
2828
29- # Here's a somewhat fragile way to print the entire Python stack from gdb.
30- # It's fragile because the tests for the value of $pc depend on the layout
31- # of specific functions in the C source code.
32-
33- # Explanation of while and if tests: We want to pop up the stack until we
34- # land in Py_Main (this is probably an incorrect assumption in an embedded
35- # interpreter, but the test can be extended by an interested party). If
36- # Py_Main <= $pc <= Py_GetArgcArv is true $pc is in Py_Main(), so the while
37- # tests succeeds as long as it's not true. In a similar fashion the if
38- # statement tests to see if we are in eval_frame().
39-
4029# print the local variables of the current frame
4130define pylocals
4231 set $_i = 0
@@ -62,6 +51,17 @@ define pyframe
6251 pylocals
6352end
6453
54+ # Here's a somewhat fragile way to print the entire Python stack from gdb.
55+ # It's fragile because the tests for the value of $pc depend on the layout
56+ # of specific functions in the C source code.
57+
58+ # Explanation of while and if tests: We want to pop up the stack until we
59+ # land in Py_Main (this is probably an incorrect assumption in an embedded
60+ # interpreter, but the test can be extended by an interested party). If
61+ # Py_Main <= $pc <= Py_GetArgcArv is true, $pc is in Py_Main(), so the while
62+ # tests succeeds as long as it's not true. In a similar fashion the if
63+ # statement tests to see if we are in eval_frame().
64+
6565# print the entire Python call stack
6666define pystack
6767 while $pc < Py_Main || $pc > Py_GetArgcArgv
@@ -72,15 +72,3 @@ define pystack
7272 end
7373 select-frame 0
7474end
75-
76- define pystack
77- while $pc < Py_Main || $pc > Py_GetArgcArgv
78- if $pc > eval_frame && $pc < PyEval_EvalCodeEx
79- set $__fn = PyString_AsString(co->co_filename)
80- set $__n = PyString_AsString(co->co_name)
81- printf "%s (%d): %s\n", $__fn, f->f_lineno, $__n
82- end
83- up-silently 1
84- end
85- select-frame 0
86- end
0 commit comments