gdb provides values it obtains from the inferior program in
an object of type gdb.Value. gdb uses this object
for its internal bookkeeping of the inferior's values, and for
fetching values when necessary.
Inferior values that are simple scalars can be used directly in
Python expressions that are valid for the value's data type. Here's
an example for an integer or floating-point value some_val:
bar = some_val + 2
As result of this, bar will also be a gdb.Value object
whose values are of the same type as those of some_val.
Inferior values that are structures or instances of some class can
be accessed using the Python dictionary syntax. For example, if
some_val is a gdb.Value instance holding a structure, you
can access its foo element with:
bar = some_val['foo']
Again, bar will also be a gdb.Value object.
For pointer data types, gdb.Value provides a method for
dereferencing the pointer to obtain the object it points to.
This method returns a new
gdb.Valueobject whose contents is the object pointed to by the pointer. For example, iffoois a C pointer to anint, declared in your C program asint *foo;then you can use the corresponding
gdb.Valueto access whatfoopoints to like this:bar = foo.dereference ()The result
barwill be agdb.Valueobject holding the value pointed to byfoo.