Working With Signals |
16 |
![]() |
The dbx commands cont, step, and next support the -sig signal_name option, which allows you to resume execution of a program with the program behaving as if it had received the signal specified in the cont -sig command.
This chapter is organized into the following sections.
Understanding Signal Events
When a signal is to be delivered to a process that is being debugged, the signal is redirected to dbx by the kernel. When this happens, you usually get a prompt. You then have two choices:
ignore sig # "ignore" |
However, the sig is still forwarded to the process. A default set of signals is automatically forwarded in this manner, see ignore.
Catching Signals
By default, the catch list contains many of the more than 33 detectable signals. (The numbers depend upon the operating system and version.) You can change the default catch list by adding signals to or removing them from the default catch list.
![]() | Type catch with no signal-name argument:
|
![]() | Type ignore with no signal-name argument:
|
![]() | Supply a signal-name argument that currently appears on one list as an argument to the other list. |
(dbx) ignore QUIT ABRT |
Since a reasonable answer for floating point exceptions is returned, exceptions do not automatically trigger the signal SIGFPE.
To find the cause of an exception, you need to set up a trap handler in the program so that the exception triggers the signal SIGFPE. (See ieee_handler(3m) for an example of a trap handler.) When you set up a trap handler using ieee_handler, the trap enable mask in the hardware floating point status register is set. This trap enable mask causes the exception to raise SIGFPE at run time.
Once you have compiled the program with the trap handler, load the program into dbx. Before you can catch the SIGFPE, you must add FPE to the dbx signal catch list, using the command:
(dbx) catch FPE |
By default, FPE is on the ignore list.
Sending a Signal in a Program
The dbx cont command supports the -sig signal_name option, which allows you to resume execution of a program with the program behaving as if it had received the system signal signal_name.
(dbx) cont -sig int |
The stop, next, and detach commands accept -sig as well.
Automatically Handling Signals
The event management commands can also deal with signals as events. These tow commands have the same effect:
(dbx) stop sig signal (dbx) catch signal |
Having the signal event is more useful if you need to associate some pre-programmed action:
(dbx) when sig SIGCLD {echo Got $sig $signame;} |
In this case make sure to first move SIGCLD to the ignore list:
(dbx) ignore SIGCLD |