Debugging with GDB Manual The GNU Source-Level Debugger (769148-001, March 2014)
Table 33 GDB/MI Operations (continued)
set the value of this variable-var-assign
update the variable and its children-var-update
In the next subsection we describe each operation in detail and suggest how it can be used.
Description and use of operations on variable objects
The -var-create command
Synopsis
-var-create {name | "-"}
{frame-addr | "*"} expression
This operation creates a variable object, which allows the monitoring of a variable, the result of
an expression, a memory cell or a CPU register.
The name parameter is the string by which the object can be referenced. It must be unique. If '-'
is specified, the varobj system will generate a string “varNNNNNN” automatically. It will be
unique provided that one does not specify name on that format. The command fails if a duplicate
name is found.
The frame under which the expression should be evaluated can be specified by frame-addr. A
'*' indicates that the current frame should be used.
expression is any expression valid on the current language set (must not begin with a '*'), or
one of the following:
• '*addr', where addr is the address of a memory cell
• '*addr-addr' ― a memory address range (TBD)
• '$regname' ― a CPU register name
Result
This operation returns the name, number of children and the type of the object created. Type is
returned as a string as the ones generated by the GDB CLI:
name="name",numchild="N",type="type"
The -var-delete command
Synopsis
-var-delete name
Deletes a previously created variable object and all of its children.
Returns an error if the object name is not found.
The -var-set-format command
Synopsis
-var-set-format name format-spec
Sets the output format for the value of the object name to be format-spec.
The syntax for the format-spec is as follows:
format-spec →
{binary | decimal | hexadecimal | octal | natural}
GDB/MI variable objects 273