Re: Pythons scripting API question

Evan Driscoll
2012-05-30T22:42:43Z

On 05/30/2012 04:23 PM, Keith Seitz wrote:
> Frames contain blocks, blocks contain variables. Blocks in python can be
> iterated

Great, it's that information that I was missing.

However, if I do this:

> $ ./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}

then on the last step I get this instead:

(gdb) python print n.value(gdb.selected_frame())
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'gdb.Symbol' object has no attribute 'value'
Error while executing Python code.

Instead, I have to use

(gdb) python print gdb.selected_frame().read_var(n)
{argc = 6742752, argv = 0x0, use_windows = -7696, interpreter_p = 0x0}

Is this just a version difference?

Evan