14.13Debugging multiple processes ( programs with fork and vfork

calls)

14.13.1Ask 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

14.13.2Serial mode for set follow-fork-mode

The option serial, for the follow-fork-modecommand, 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-modewill work only if there is a wait() call by the parent process. This feature is enabled by setting the follow-fork-modeflag to serial, as specified in the following example:

(gdb) set follow-fork-mode serial

The follow-fork-modeis 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-modeto work both parent and child process must be of the same mode.

14.13.3Support 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

0x40172b25: (ea) P7lc_when t=7

14.13 Debugging multiple processes ( programs with fork and vfork calls) 195

Page 195
Image 195
HP gnu source-level debugger 5992-4701 manual Ask mode for set follow-fork-mode, Serial mode for set follow-fork-mode