gdb Cheat Sheet
Note on Supported Commands
Most valid gdb commands can be used in mdb (as long as they run in remote execution mode –
but that’s nearly all the useful ones I can think of). The main exceptions are start and run
and these wouldn’t work in MPI mode anyway because you cannot (as far as I know) restart and MPI
application from within the process.
mdb launches the binary to stop at main by default, which can optionally overridden to any
other valid breakpoint if this is not suitable (see Quick Start for more info). Therefore
instead of using start or run commands, as you can non-MPI applications, mdb will
already be waiting at the breakpoint specified by -b/--breakpt.
For MPI debugging gdb’s reverse commands (e.g., reverse-next, reverse-step etc.) are not
supported. Each gdb instance is not MPI-aware and you cannot step backwards through
MPI_init(), for example. If you want to “go backwards” you should restart the mdb debug
session.
Useful Commands
The following commands may be helpful when using mdb. All of these can be passed to gdb
using the command command [gdb command] (or optionally specify which ranks to run the command on
with command [ranks] [gdb command]). A full list of gdb commands can be found in gdb’s
manual.
Command |
Action |
Example |
Aliases |
|---|---|---|---|
|
run to next line |
|
|
|
step into function |
|
|
|
print backtrace |
|
|
|
continue running program |
|
|
|
run until |
|
|
|
move up one frame |
|
|
|
move down one frame |
|
|
Command |
Action |
Example |
Aliases |
|---|---|---|---|
|
set a breakpoint |
|
|
|
|||
(conditional) |
|
||
|
set a watchpoint |
|
|
(on write) |
|
||
(on read) |
|
||
(on read-write) |
|
||
|
delete breakpoint #2 |
|
|
Command |
Action |
Example |
Aliases |
|---|---|---|---|
|
print variable |
|
|
|
show variable |
|
|
|
print information for: |
||
(breakpoints) |
|
|
|
(locals) |
|
|
Command |
Action |
Example |
Aliases |
|---|---|---|---|
|
change value of variable |
|
|
Single Key Mode (TUI)
This can be used inside an interactive gdb session when the tui is activated. To enter
Single Key Mode press CTRL-x s. To exit press q. This allows you to use a single key press
to issue the following commands:
Key |
Command |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(exit Single Key Mode) |