From Wikipedia, the free encyclopedia
SIGTRAP
Description |
Trace/breakpoint trap |
Default action |
Abnormal termination of the process |
|
SA_SIGINFO macros
|
TRAP_BRKPT |
Process breakpoint |
TRAP_TRACE |
Process trace trap |
|
On POSIX-compliant platforms, SIGTRAP is the signal thrown by computer programs when a condition arises that a debugger has requested to be informed of. In source code, SIGTRAP is a symbolic constant defined in the header file signal.h
. Signal names are used instead of bare numbers because signal numbers can vary across platforms.
[edit] Etymology
SIG is a common prefix for signal names. TRAP refers to the intent of a debugger to trap (detect) an interesting condition.
When debugging a program, it is often useful to run the program until a particular condition arises — for example, when a particular function is executed, or when a particular variable changes value. Although the debugger could repeatedly pause the program, checking the condition at each instruction, to do so would be very slow. More efficient is to request that the hardware itself determine when a condition obtains (e.g. when a particular memory segment is read, written or executed) and signal when this happens; this signal is then converted by the kernel into SIGTRAP, sent to the process being debugged. The debugger catches the signal, confirms for itself whether the condition has occurred, and if so pauses execution of the process and informs the developer.