3.12 Handling UNIX signals
When debugging a Linux application you can configure the debugger to stop or report when a UNIX signal is raised.
To manage UNIX signals in the debugger, either:
Select Manage Signals from the
Breakpoints view menu.
Select the individual Signal you want to Stop or Print
information, and click OK. The
results are displayed in the Command
Use the handle command and view the
results in the Command view.
|You can also use the info
signals command to display the current signal handler
Figure 3-8 Manage signals dialog (UNIX signals)
SIGTRAP cannot be debugged in the same way as other
signals because they are used internally by the debugger for asynchronous stopping
of the process and breakpoints respectively.
Example 3-3 Managing signals
If you want the application to ignore a signal, but log the event when it is
triggered, then you must enable stopping on a signal.
- Ignoring a
- In the following example, a SIGHUP signal occurs causing the debugger to stop and print a message. No signal handler is invoked when using this setting and the debugged application ignores the signal and continues to operate.
handle SIGHUP stop print # Enable stop and print on SIGHUP signal
- Debugging a
The following example shows how to debug a signal
To do this you must disable stopping on a signal and then
set a breakpoint in the signal handler. This is because if stopping on a
signal is disabled then the handling of that signal is performed by the
process that passes signal to the registered handler. If no handler is
registered then the default handler runs and the application generally
handle SIGHUP nostop noprint # Disable stop and print on SIGHUP signal