mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
split functionality into pystack and pystackv commands. The former will
work with core dumps because it avoids calling any Python API routines. The latter prints all the local variable values as well as the stack frames but won't work with core dumps because it relies on _PyObject_Dump to print variables.
This commit is contained in:
parent
03562a5e62
commit
0bb2a65dbd
1 changed files with 20 additions and 5 deletions
25
Misc/gdbinit
25
Misc/gdbinit
|
|
@ -43,14 +43,18 @@ define pylocals
|
|||
end
|
||||
end
|
||||
|
||||
# print the current frame
|
||||
define pyframe
|
||||
set $__fn = PyString_AsString(co->co_filename)
|
||||
set $__n = PyString_AsString(co->co_name)
|
||||
printf "%s (%d): %s\n", $__fn, f->f_lineno, $__n
|
||||
# print the current frame - verbose
|
||||
define pyframev
|
||||
pyframe
|
||||
pylocals
|
||||
end
|
||||
|
||||
define pyframe
|
||||
set $__fn = (char *)((PyStringObject *)co->co_filename)->ob_sval
|
||||
set $__n = (char *)((PyStringObject *)co->co_name)->ob_sval
|
||||
printf "%s (%d): %s\n", $__fn, f->f_lineno, $__n
|
||||
end
|
||||
|
||||
# Here's a somewhat fragile way to print the entire Python stack from gdb.
|
||||
# It's fragile because the tests for the value of $pc depend on the layout
|
||||
# of specific functions in the C source code.
|
||||
|
|
@ -72,3 +76,14 @@ define pystack
|
|||
end
|
||||
select-frame 0
|
||||
end
|
||||
|
||||
# print the entire Python call stack - verbose mode
|
||||
define pystackv
|
||||
while $pc < Py_Main || $pc > Py_GetArgcArgv
|
||||
if $pc > PyEval_EvalFrame && $pc < PyEval_EvalCodeEx
|
||||
pyframev
|
||||
end
|
||||
up-silently 1
|
||||
end
|
||||
select-frame 0
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue