Skip to content
The Signal Belfry

/static/campanario/en/sino/sigtrap/

Menu

SIG-015 · Program faults

SIGTRAP

The debugger's bell: every breakpoint is a pre-arranged ring.

When you set a breakpoint, the debugger swaps the instruction at that address for a trap — int3, on x86. The process runs, falls into the trap, the kernel rings SIGTRAP, and ptrace hands control to the debugger before the signal travels on.

Outside a debugger the ring is fatal: a core dump like the other faults. It is also the bell of single-stepping — the CPU's single-step mode rings it at every instruction — and the reason a process under gdb stops exactly where you asked.

$ gdb ./exemplo
(gdb) break main
Breakpoint 1 at 0x1139: file exemplo.c, line 5.
(gdb) run
Breakpoint 1, main () at exemplo.c:5
5         int n = conta();
The trap agreed between debugger and kernel.