| Store | Cart

Debugging with gdb: pystack macro for gdb to show python stack trace

From: Timothy Madden <term...@gmail.com>
Thu, 17 Sep 2009 14:47:26 +0300
Timothy Madden wrote:
> Hello>[...]> > Can I get the python stack trace working under gdb ?>[...]

Ok I found some other gdb macros on linked from the wiki page and I had 
to change them to get the stack trace work.

I had to change the symbol PyEval_EvalFrame to PyEval_EvalFrameEx and 
then I could see the stack trace. The resulting gdb macro was:

define pbt
  set $i = 0
  set $j = 0
  while $i < 1000
   select $i
   if $eip >= &PyEval_EvalFrameEx
    if $eip < &PyEval_EvalCodeEx
     echo c frame #
     p $i
     echo py frame #
     p $j
     set $j = $j+1
     x/s ((PyStringObject*)f->f_code->co_filename)->ob_sval
     x/s ((PyStringObject*)f->f_code->co_name)->ob_sval
     echo line #
     p f->f_lineno
    end
   end
   set $i = $i+1
  end
end
document pbt
show python backtrace
end

Thank you,
Timothy Madden

Recent Messages in this Thread
Timothy Madden Sep 16, 2009 09:27 pm
Timothy Madden Sep 17, 2009 11:47 am
Messages in this thread
Previous post: SQLite or files?