This is the mail archive of the gdb@sourceware.org mailing list for the GDB 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: Pythons scripting API question


On 30.05.2012 23:23, Keith Seitz wrote:
> Frames contain blocks, blocks contain variables. Blocks in python can
> be iterated, so:
>
> $ ./gdb -nx -q gdb -ex "break main" -ex "run"
> (gdb) python import gdb
> (gdb) python for n in gdb.selected_frame().block(): print n,
> argc argv args
> (gdb) python print n.type
> struct captured_main_args
> (gdb) python print n.name
> args
> (gdb) python print n.is_argument
> False
> (gdb) python print n.value(gdb.selected_frame())
> {argc = 0, argv = 0x488f80 <_start>, use_windows = -8032,
> interpreter_p = 0x0}
>
Thank you for this example!
I never figured out this feature of Blocks :(

> See the relevant sections in the Gdb Users Manual (23.2.2.16, 23.2.2.18).
I totally miss the hint that Blocks drop Value objects on iteration in
the documentation.
How to access the "hierarchically organized" sub-blocks? Or did I
missunderstand the concept of Blocks?

main()
{
    int i;
    for(...)
    {
        int a;
    }
    {
        int i;
    }
}

I would expect a Block for the main function with two children Blocks -
but how to get these children?

- Joachim

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


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