This is the mail archive of the
mailing list for the GDB project.
Re: Python API iterate through the arguments of a frame
- From: Tom Tromey <tromey at redhat dot com>
- To: Cristian Zamfir <cristian dot zamfir at epfl dot ch>
- Cc: gdb at sourceware dot org
- Date: Tue, 21 Feb 2012 11:14:35 -0700
- Subject: Re: Python API iterate through the arguments of a frame
- References: <3EDCC9ED-AD12-42B4-854E-3404A8EBCF70@epfl.ch>
>>>>> "Cristian" == Cristian Zamfir <email@example.com> 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.
I see that gdb.Block is under-documented in this area. Sorry about
that, I will write a patch.
Here's a quick example:
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
>for sym in gdb.newest_frame().block():
> print sym
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.