public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: archer@sourceware.org
Subject: Re: Pretty-printing backtraces when "python" is the inferior process
Date: Wed, 23 Dec 2009 21:28:00 -0000	[thread overview]
Message-ID: <1261603718.2345.39.camel@brick> (raw)
In-Reply-To: <m37hsd4haz.fsf@fleche.redhat.com>

On Wed, 2009-12-23 at 12:32 -0700, Tom Tromey wrote:
> >>>>> "David" == David Malcolm <dmalcolm@redhat.com> writes:
> 
> David> I'm experimenting with archer, and adding python hooks for when the
> David> inferior process is itself Python.
> 
> Awesome.
> 
> David> I've attempted to do this, but am running into an issue.  (this is on
> David> Fedora 12 i386)
> 
> David> $ git checkout --track -b archer-tromey-python origin/archer-tromey-python
> 
> David> (gdb) frame 9
> David> #9  PyEval_EvalFrameEx (f=<value optimized out>, throwflag=<value
> David> optimized out>) at Python/ceval.c:2389
> David> 2389				x = call_function(&sp, oparg);
> 
> I tried this same example on my F11 box.
> 
> I am not sure exactly what bug you are hitting, but I think it is
> something that is fixed either in CVS head or in some other Fedora
> patch.  I say that because the example fails with archer-tromey-python,
> but works with the F11 system gdb.  I think it has to do with the
> representation of inlined frames -- when I trace into lookup_symbol, if
> I look at the blocks I eventually see:
> 
>     (gdb) p *block.superblock.function
>     $5 = {
>       ginfo = {
>         name = 0x92be5e8 "call_function", 
> 
> I don't fully understand this, because I would have expected the
> selected frame to be PyEval_EvalFrameEx, not call_function.  However,
> I'm planning to do a merge from trunk in early January, which may fix
> the problem.  In the meantime, maybe using archer-jankratochvil-fedora12
> would be better.  Or even using the system gdb... though that will make
> it a bit harder if you need to modify the python libraries.

Thanks for looking at this.

Unfortunately it seems to be failing with both the system Fedora 12 gdb
and with archer-jankratochvil-fedora12:

FWIW the function in question (PyEval_EvalFrameEx) is defined in
http://svn.python.org/view/python/trunk/Python/ceval.c?view=markup
and the local I'm most interested in is:
PyCodeObject *co;
this variable contains the interesting information on what's going on at
the python level in a python vm stack frame.

For example:
(gdb) p (char*)((PyStringObject*)co->co_filename)->ob_sval
$3 = 0x810c764 "/usr/lib/python2.6/site-packages/istanbul/main/main.py"
(gdb) p (char*)((PyStringObject*)co->co_name)->ob_sval
$4 = 0xb7fd9374 "main"
(gdb) p co->co_firstlineno
$5 = 87
(gdb) p *co
$6 = {ob_refcnt = 2, ob_type = 0x5039ae0, co_argcount = 1, co_nlocals =
4, co_stacksize = 3, co_flags = 67, co_code = 0xb7fb49e0, co_consts =
0x811f0d4, 
  co_names = 0x810c48c, co_varnames = 0x81261bc, co_freevars =
0xb7fa402c, co_cellvars = 0xb7fa402c, co_filename = 0x810c750, co_name =
0xb7fd9360, 
  co_firstlineno = 87, co_lnotab = 0x811f5d0, co_zombieframe = 0x0}

etc and this could be used to pretty-print the python-level info.

The errors I'm seeing are as before:

Fedora 12 system gdb:
$ /usr/bin/gdb --args /usr/bin/python /usr/bin/istanbul
GNU gdb (GDB) Fedora (7.0-7.fc12)
[snip]
(gdb) frame 9
#9  PyEval_EvalFrameEx (oparg=<value optimized out>, pp_stack=<value
optimized out>) at Python/ceval.c:2389
2389				x = call_function(&sp, oparg);
(gdb) python print gdb.parse_and_eval("co")
0x81274e8
(gdb) python print gdb.selected_frame().read_var('co')
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: variable 'co' not found
Error while executing Python code.


With archer-jankratochvil-fedora12 it fails in the same way: 
$ ./gdb/gdb --args /usr/bin/python /usr/bin/istanbul
GNU gdb (GDB) 7.0
[snip]
(gdb) python print gdb.parse_and_eval("co")
0x81274e8
(gdb) python print gdb.selected_frame().read_var('co')
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: variable 'co' not found
Error while executing Python code.



(this was only a shallow inspection; got to run to catch a plane.  This
could be error on my part of course; I know very little about the
innards of gdb).


Dave


  reply	other threads:[~2009-12-23 21:28 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 [this message]
2011-01-06 14:55 ` Tom Tromey

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=1261603718.2345.39.camel@brick \
    --to=dmalcolm@redhat.com \
    --cc=archer@sourceware.org \
    --cc=tromey@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).