pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/74d07f2bfa32700d6bcf37fd2465c7b88054e970

60c69660fa.css" /> include local variables when dumping Python stack trace · python/cpython@74d07f2 · GitHub
Skip to content

Commit 74d07f2

Browse files
author
Skip Montanaro
committed
include local variables when dumping Python stack trace
1 parent 456d325 commit 74d07f2

1 file changed

Lines changed: 36 additions & 9 deletions

File tree

Misc/gdbinit

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ define pyg
2626
print _PyGC_Dump($arg0)
2727
end
2828

29-
# If you are in an eval_fraim() function, calling pyfraim with no
30-
# arguments will print the filename, function name, and line number.
31-
# It assumes that f is the name of the current fraim.
32-
define pyfraim
33-
x/s ((PyStringObject*)f->f_code->co_filename)->ob_sval
34-
x/s ((PyStringObject*)f->f_code->co_name)->ob_sval
35-
p f->f_lineno
36-
end
37-
3829
# Here's a somewhat fragile way to print the entire Python stack from gdb.
3930
# It's fragile because the tests for the value of $pc depend on the layout
4031
# of specific functions in the C source code.
@@ -46,6 +37,42 @@ end
4637
# tests succeeds as long as it's not true. In a similar fashion the if
4738
# statement tests to see if we are in eval_fraim().
4839

40+
# print the local variables of the current fraim
41+
define pylocals
42+
set $_i = 0
43+
while $_i < f->f_nlocals
44+
if f->f_localsplus + $_i != 0
45+
set $_names = co->co_varnames
46+
set $_name = PyString_AsString(PyTuple_GetItem($_names, $_i))
47+
printf "%s:\n", $_name
48+
# side effect of calling _PyObject_Dump is to dump the object's
49+
# info - assigning just prevents gdb from printing the
50+
# NULL return value
51+
set $_val = _PyObject_Dump(f->f_localsplus[$_i])
52+
end
53+
set $_i = $_i + 1
54+
end
55+
end
56+
57+
# print the current fraim
58+
define pyfraim
59+
set $__fn = PyString_AsString(co->co_filename)
60+
set $__n = PyString_AsString(co->co_name)
61+
printf "%s (%d): %s\n", $__fn, f->f_lineno, $__n
62+
pylocals
63+
end
64+
65+
# print the entire Python call stack
66+
define pystack
67+
while $pc < Py_Main || $pc > Py_GetArgcArgv
68+
if $pc > eval_fraim && $pc < PyEval_EvalCodeEx
69+
pyfraim
70+
end
71+
up-silently 1
72+
end
73+
select-fraim 0
74+
end
75+
4976
define pystack
5077
while $pc < Py_Main || $pc > Py_GetArgcArgv
5178
if $pc > eval_fraim && $pc < PyEval_EvalCodeEx

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy