3.3.6. Using GDB to intercept handling of signals by applications
To stop the execution of a program under specific circumstances, you can use the GNU Debugger (GDB). To stop the execution when the program receives a signal from the operating system, use a GDB catchpoint.
Prerequisites
Procedure
Set the catchpoint:
(gdb) catch signal signal-typeThe command
catch signalsets a special type of a breakpoint that halts execution when a signal is received by the program. Thesignal-typeoption specifies the type of the signal. Use the special value'all'to catch all signals.Let the program run.
If the program has not started execution, start it:
(gdb) rIf the program execution is halted, resume it:
(gdb) c
- GDB halts execution after the program receives any specified signal.
- Continue by debugging the program code handling the signal, or resume execution with the knowledge of the signal being received.
Later, to exit the GDB debugging session:
(gdb) q