3.14 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 toolbar or the view menu.

    Select the individual Signal you want to Stop or Print information, and click OK. The results are displayed in the Command view.

  • Use the handle command and view the results in the Command view.

Tip:

You can also use the info signals command to display the current signal handler settings.
Figure 3-9 Manage signals dialog (UNIX signals)
Manage signals dialog (UNIX signals)


Note:

UNIX signals SIGINT and 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 SIGHUP signal
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 SIGHUP signal

The following example shows how to debug a signal handler.

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 exits.

handle SIGHUP nostop noprint             # Disable stop and print on SIGHUP signal
Non-ConfidentialPDF file icon PDF versionARM DUI0446Z
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.