This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Pretty-printing backtraces when "python" is the inferior process

>>>>> "David" == David Malcolm <> 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

b = gdb.selected_frame().block()
while True:
  for sym in b:
  if b.function is not None:
  print "== new block"
  b = b.superblock

I think you have to find the right block to pass to read_var.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]