Convenience variables are prefixed with ‘$’. Any name preceded by ‘$’ can be used for a convenience variable, unless it is one of the predefined machine-specific register names (see Registers). (Value history references, in contrast, are numbers preceded by ‘$’. See Value history.)
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 $foo = *object_ptr would save in $foo the value contained in the object pointed to by object_ptr.
Using a convenience variable
for the first time creates it, but its value is void
until you assign a new value. You can alter the value with another assignment
at any time. Convenience variables have no fixed types. You can assign
a convenience variable any type of value, including structures and arrays,
even if that variable already has a value of a different type. The convenience
variable, when used as an expression, has the type of its current value.
Repeat that command by using the Return key. The following convenience variables are created automatically by GDB and given values likely to be useful.