Debugging with GDB (September 2007)
318 Debugging with GDB
• -gdb-show output-radix
• -stack-list-arguments
• -stack-list-locals
• -stack-select-frame
Introduction to variable objects in gdb/mi
The basic idea behind variable objects is the creation of a named object to represent a
variable, an expression, a memory location or even a CPU register. For each object created,
a set of operations is available for examining or changing its properties.
Furthermore, complex data types, such as C structures, are represented in a tree for-
mat. For instance, the struct type variable is the root and the children will represent the
struct members. If a child is itself of a complex type, it will also have children of its own.
Appropriate language differences are handled for C, C++ and Java.
When returning the actual values of the objects, this facility allows for the individual
selection of the display format used in the result creation. It can b e chosen among: binary,
decimal, hexadecimal, octal and natural. Natural refers to a default format automatically
chosen based on the variable typ e (like decimal for an int, hex for pointers, etc.).
The following is the complete set of gdb/mi operations defined to access this function-
ality:
Operation Description
-var-create create a variable object
-var-delete delete the variable object and its children
-var-set-format set the display format of this variable
-var-show-format show the display format of this variable
-var-info-num-children tells how many children this object has
-var-list-children return a list of the object children
-var-info-type show the type of this variable object
-var-info-expression print what this variable object represents
-var-show-attributes is this variable editable? does it exist here?
-var-evaluate-expression get the value of this variable
-var-assign set the value of this variable
-var-update update the variable and its children
In the next subsec tion we describe each operation in detail and suggest how it can be
used.
Description and use of operations on variable objects
The -var-create com mand