From: Cristian Zamfir <cristian.zamfir@epfl.ch>
To: Tom Tromey <tromey@redhat.com>
Cc: <gdb@sourceware.org>
Subject: Re: Python API iterate through the arguments of a frame
Date: Tue, 21 Feb 2012 22:52:00 -0000 [thread overview]
Message-ID: <D0F808C0-DC0A-4B88-B548-7202E4F8BFAD@epfl.ch> (raw)
In-Reply-To: <87obsst5o4.fsf@fleche.redhat.com>
On Feb 21, 2012, at 7:14 PM, Tom Tromey wrote:
>>>>>> "Cristian" == Cristian Zamfir <cristian.zamfir@epfl.ch> writes:
>
> Cristian> I would like to write a Python script that iterates through the
> Cristian> arguments of a frame. I was hoping I can retrieve these arguments from
> Cristian> a Frame object, but I did not find a way to do this, unless I know the
> Cristian> name of the variables. Similarly, I would like to iterate through all
> Cristian> the locals of the frame.
>
> Cristian> Is this possible with the current Python API? If not, can you please
> Cristian> point me to where I could add additional functions to the Python API?
>
> You can find the locals and arguments via Frame.block.
Great, this worked.
>
> I see that gdb.Block is under-documented in this area. Sorry about
> that, I will write a patch.
Thank you, that would be very useful. Is there a quick way to see the names of all available API functions, just in case there are more undocumented ones, other than looking into the gdb/python/ directory and infer from the Python bindings (e.g., py-block.c)?
Somehow unrelated to this, I just noticed that I can retrieve the type of a symbol while running a program inside gdb, but not when loading a dumped core. In the latter case I get this error:
AttributeError: 'gdb.Symbol' object has no attribute 'type'.
I can however still retrieve the name and the value of the symbol when loading a core. Is it possible to also get the type?
I should mention that I also see these two warnings when loading the core:
warning: core file may not match specified executable file.
warning: Can't read pathname for load map: Input/output error.
Thanks,
Cristi
>
> Here's a quick example:
>
> (top-gdb) start
> [...]
> Temporary breakpoint 3, main (argc=
> During symbol reading, incomplete CFI data; unspecified registers (e.g., rax) at 0x488914.
> 1, argv=0x7fffffffe558) at ../../archer/gdb/gdb.c:26
> (top-gdb) python
>> for sym in gdb.newest_frame().block():
>> print sym
>> end
> argc
> argv
> args
>
>
> In order to find all the locals in scope, and the arguments, you may
> have to iterate upwards over blocks via Block.superblock. The block
> with a non-None 'function' attribute will hold the arguments.
>
> Tom
next prev parent reply other threads:[~2012-02-21 22:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-21 15:55 Cristian Zamfir
2012-02-21 19:54 ` Tom Tromey
2012-02-21 22:52 ` Cristian Zamfir [this message]
2012-02-22 1:52 ` Paul_Koning
2012-02-22 8:54 ` Joachim Protze
2012-02-22 15:07 ` Tom Tromey
2012-02-22 15:41 ` Cristian Zamfir
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=D0F808C0-DC0A-4B88-B548-7202E4F8BFAD@epfl.ch \
--to=cristian.zamfir@epfl.ch \
--cc=gdb@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).