Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Debugging with gdb: pystack macro for gdb to show python stack trace

Reply
Thread Tools

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

 
 
Timothy Madden
Guest
Posts: n/a
 
      09-16-2009
Hello

I have an application with several threads that sometimes just freezes.

I installed the debug symbols for python interpreter, and the gdb
macros, as instructed on the wiki
http://wiki.python.org/moin/DebuggingWithGdb
so I can debug with gdb.

gdb loads many files with python debugging simbols, and it is loading
the macros file ~/.gdbinit, but still the macros for working with python
are not working. The pystack command just freezes the debugger until I
press ^C, and other macros complain about undefined symbols. I would
like to see the python stack trace so I know where my application
freezes. All I could see from the gdb native stack trace (with bt) was
that my 3 threads were waiting to acquire a lock, but I could not figure
out where and my program logic should not allow this to happen.

Can I get the python stack trace working under gdb ?

Synaptic Package Manager on my Ubuntu netbook shows packages
python2.6 (2.6.2-0ubuntu1)
python2.6-dbg (2.6.2-0ubuntu1)
as installed, and I extracted the Misc/gdbinit file from
Python-2.6.2.tar.bz2 source archive from python.org. I have gdb 6.8-debian.
So I suppose everything should be right ...


Thank you,
Timothy Madden
 
Reply With Quote
 
 
 
 
Timothy Madden
Guest
Posts: n/a
 
      09-17-2009
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"No symbol" error using pystack gdb macro debby@josesmex.com Python 1 03-02-2013 07:08 AM
Why doesn't Trace.axd show trace output after Server.Transfer? Chris Newby ASP .Net 0 07-28-2008 05:08 AM
GDB - no debugging symbols found (GDB Vs GCC?) seba C++ 1 03-22-2007 02:02 PM
Stack trace provided. Help needed in debugging rajatag Java 4 02-20-2007 12:48 AM
Capturing gdb output in pyhton script using gdb -batch -x arguments Surendra Python 0 03-23-2006 02:47 PM



Advertisments