// Define a BREAKPOINT macro that will send the current process a // SIGTRAP, causing a drop into the debugger if you're running under // one. If this is not an i386, then this macro will drop you into the // debugger deep inside a libc function and you'll have to single-step // out (si). #ifdef __i386__ # define BREAKPOINT do { \ int pid = getpid(); \ int signum = SIGTRAP; \ int trapnum = SYS_kill; \ asm("int $0x80" : : "b"(pid), "c"(signum), "a"(trapnum)); \ } while(0) #else # define BREAKPOINT kill(getpid(), SIGTRAP) #endif