public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: David Malcolm <dmalcolm@redhat.com>
Cc: archer@sourceware.org
Subject: Re: Pretty-printing backtraces when "python" is the inferior process
Date: Thu, 06 Jan 2011 14:55:00 -0000	[thread overview]
Message-ID: <m3fwt6t741.fsf@fleche.redhat.com> (raw)
In-Reply-To: <1261524321.2228.70.camel@brick> (David Malcolm's message of "Tue, 22 Dec 2009 18:25:21 -0500")

>>>>> "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

      parent reply	other threads:[~2011-01-06 14:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-22 23:24 David Malcolm
2009-12-23 19:33 ` Tom Tromey
2009-12-23 21:28   ` David Malcolm
2011-01-06 14:55 ` Tom Tromey [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3fwt6t741.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=archer@sourceware.org \
    --cc=dmalcolm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).