This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Re: Pretty-printing backtraces when "python" is the inferior process
- From: Tom Tromey <tromey at redhat dot com>
- To: David Malcolm <dmalcolm at redhat dot com>
- Cc: archer at sourceware dot org
- Date: Thu, 06 Jan 2011 07:54:54 -0700
- Subject: Re: Pretty-printing backtraces when "python" is the inferior process
- References: <1261524321.2228.70.camel@brick>
>>>>> "David" == David Malcolm <dmalcolm@redhat.com> writes:
[ replying to an old thread ]
David> I'm trying to use a freshly-built gdb to debug a pygtk app named
David> "istanbul" (using system python and system copy of instanbul):
[...]
David> I'd like to access the local "PyCodeObject *co" at this point:
David> (gdb) p co
David> $5 = (PyCodeObject *) 0x81274e8
David> This API hook works:
David> (gdb) python print gdb.parse_and_eval("co")
David> 0x81274e8
David> But this one doesn't:
David> (gdb) python print gdb.selected_frame().read_var('co')
David> Traceback (most recent call last):
David> File "<string>", line 1, in <module>
David> ValueError: variable 'co' not found
David> Error while executing Python code.
I looked at this again and I found a bug in py-frame.c that accounts for
this behavior. I am testing a patch.
The above isn't quite right though, even with the fix in place. The
problem is that a given frame may have multiple blocks associated with
it ("block" is basically just a block in C). In this case there are a
couple, and "co" appears in one of the outer ones.
I used this snippet to look at what symbols were in which block in the
frame:
b = gdb.selected_frame().block()
while True:
for sym in b:
print sym.name
if b.function is not None:
break
print "== new block"
b = b.superblock
I think you have to find the right block to pass to read_var.
Tom