Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0bb2a65

Browse files
author
Skip Montanaro
committed
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.
1 parent 03562a5 commit 0bb2a65

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

Misc/gdbinit

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@ define pylocals
4343
end
4444
end
4545

46-
# print the current frame
46+
# print the current frame - verbose
47+
define pyframev
48+
pyframe
49+
pylocals
50+
end
51+
4752
define pyframe
48-
set $__fn = PyString_AsString(co->co_filename)
49-
set $__n = PyString_AsString(co->co_name)
53+
set $__fn = (char *)((PyStringObject *)co->co_filename)->ob_sval
54+
set $__n = (char *)((PyStringObject *)co->co_name)->ob_sval
5055
printf "%s (%d): %s\n", $__fn, f->f_lineno, $__n
51-
pylocals
5256
end
5357

5458
# Here's a somewhat fragile way to print the entire Python stack from gdb.
@@ -72,3 +76,14 @@ define pystack
7276
end
7377
select-frame 0
7478
end
79+
80+
# print the entire Python call stack - verbose mode
81+
define pystackv
82+
while $pc < Py_Main || $pc > Py_GetArgcArgv
83+
if $pc > PyEval_EvalFrame && $pc < PyEval_EvalCodeEx
84+
pyframev
85+
end
86+
up-silently 1
87+
end
88+
select-frame 0
89+
end

0 commit comments

Comments
 (0)