[Python-Dev] How to debug pyexpat SIGSEGV with GDB?
Skip Montanaro
skip at pobox.com
Mon Mar 1 10:09:07 EST 2004
>> So, how can I figure out where in the Python source the function call
>> is coming from using gdb? I'm sure it involves "print" and some
>> casts.. I couldn't find a howto on python.org
Jeremy> First, make sure that the code from Misc/gdbinit is in your
Jeremy> .gdbinit file. Get the stack trace in gdb and move up/down
Jeremy> until you get to an eval_frame() frame. Then call the function
Jeremy> pyframe. It will print the filename, function name, and line
Jeremy> number of the current frame. The lineno usually points to the
Jeremy> first line of the function.
I have this in my .gdbinit file:
define ppystack
while $pc < Py_Main || $pc > Py_GetArgcArgv
if $pc > eval_frame && $pc < PyEval_EvalCodeEx
set $__fn = PyString_AsString(co->co_filename)
set $__n = PyString_AsString(co->co_name)
printf "%s (%d): %s\n", $__fn, f->f_lineno, $__n
end
up-silently 1
end
select-frame 0
end
Skip
More information about the Python-Dev
mailing list