Debugging with GDB Manual The GNU Source-Level Debugger (769148-001, March 2014)

Debugging MPI Programs
You can attach the debugger to Message Passing Interface (MPI) programs for debugging. You
must set the one of the following environment variables before you launch the MPI process:
set MPI_FLAGS= egdb for invoking GDB
or
set MPI_FLAGS= ewdb for invoking WDB
For more information, see the mpidebug(1) and mpienv(1) manpages.
Attaching the debugger to an MPI process (or to any other process that has not been compiled for
debugging) can result in the following warning:
warning: reading 'r3' register: No data
Debugging multiple processes (programs with fork and vfork calls)
Ask mode for set follow-fork-mode
The ask command prompts the user to select between parent and child as the debugger response
to a program call of fork/vfork. Based on the user selection, the parent or the child process is
debugged.
For example,
(gdb) set follow-fork-mode ask (gdb) show follow-fork-mode
The debugger response to a program call to fork or vfork is ask.
(gdb) run Starting program: sample [New process 4941] Select follow-fork-
mode: [0] parent [1] child
Serial mode for set follow-fork-mode
The option serial, for the follow-fork-mode command, enables debugging of a parent and
child process within a debugger session. During a debug session, if the parent process forks a
child, the debugger starts debugging the child process. When the child process exits, the debugger
switches back to the parent process. The follow-fork-mode will work only if there is a wait()
call by the parent process. This feature is enabled by setting the follow-fork-mode flag to
serial, as specified in the following example:
(gdb) set follow-fork-mode serial
The follow-fork-mode is not supported under following conditions:
MxN threaded programs
Parent process is 32-bit and child process is 64-bit and vice versa. For the follow-
fork-mode to work both parent and child process must be of the same mode.
Support for showing unwind info
The maint info unwind command prints the unwind information for the regions unwinded at
the given address expression. Usage:
maint info unwind exp
where, exp is an address expression.
For example,
(gdb) maint info unwind $pc
modsched:
0x4000930 .. 0x4000a20, end_prologue@0x4000970
Info block version:0x0, flags:0x0, length:4 * 4 == 16
0x40172b20: (0c) R1prologue rlen=12
0x40172b21: (e8) P7preds_when t=11
0x40172b23: (b1) P3preds_gr gr=41
Debugging MPI Programs 143