The gdb(1) debugger displays information about the process being debugged, about the environment, and about gdb itself.
The help command displays information about gdb commands.
The gdb debugger uses three types of variables: program variables, convenience variables, and register variables. You can use the print command to display the value of a variable.
Convenience variables and macros | Description |
---|---|
$_ | The last examined address. |
$_ _ | The value found in the last examined address. |
$cwd | The current working directory (macro). |
$cdir | The source directory determined from the object file (macro). |
$ | The value printed in the last print command. |
$$ | The value printed in the second-to-last print command. |
$bpnum | The number of the last break-point set. |
Register variable | Description |
---|---|
$fp | Frame pointer |
$pc | Program counter |
$ps | Processor status |
$sp | Stack pointer |
In gdb, objects other than variables can use the dollar sign ($) prefix. Usually they are run-time macros. For example, the entries in the command history use this notation, as do the macros $cwd (current working directory) and $cdir (C source directory).
You can set the value of a variable with either set or print. The print command sets the value of a variable as a byproduct of its evaluation an expression. The set command sets the value of the variable but does not echo the value of the variable to the screen.
The set command also includes a number of subcommands, including args, print, verbose, and write. If you set a program variable whose name is identical to a set subcommand name, you can explicitly name the variable by using the command set variable varname [=value].