f78
Convenience variables
Convenience variables are prefixed with ‘
You can save a value in a convenience variable with an assignment expression,
just as you would set a variable in your program. For example, set
Using a convenience variable for the first time creates it, but its value is
One of the ways to use a convenience variable is as a counter to be
incremented or a pointer to be advanced. For instance, to print a field from successive
elements of an array of structures, use the following as an example.
Some convenience variables are created automatically by GDB and given values
likely to be useful.
Print a list of convenience variables used so far, and their values.
Abbreviated show con.
print bar[$i++]->contents
The variable, $_, is automatically set by the x command to the last address examined (see Examining memory). Other commands which provide a default address for x to examine also set $_ to that address; these commands include info line and info breakpoint. The type of $_ is void * except when set by the x command, in which case it is a pointer to the type of $__.
The variable, $__, is automatically set by the x command to the value found in the last address examined. Its type is chosen
to match the format in which the data was printed.
The variable, $_exitcode, is automatically set to the exit code when the program being debugged
terminates.