I made a quick test program,
#include <signal.h> #include <stdio.h> #include <unistd.h> void handler (int in) { puts ("signal received"); } int main () { signal (SIGSEGV, handler); kill (getpid (), SIGSEGV); return 0; }
Then I will try to debug it, where I will tell lldb so that it stops at SIGSEGV :
(lldb) br s -n main (lldb) r (lldb) pr h -p true -n true -s true SIGSEGV NAME PASS STOP NOTIFY ========== ===== ===== ====== SIGSEGV true true true (lldb) c Process 5024 resuming Process 5024 stopped (lldb) bt * thread #1: tid = 0x19d6ae, 0x00007fff8f27fc7e libsystem_kernel.dylib`__kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSEGV * #0: 0x00007fff8f27fc7e libsystem_kernel.dylib`__kill + 10 #1: 0x0000000100000f25 a.out`main + 53 at ac:13 #2: 0x00007fff8c0e65c9 libdyld.dylib`start + 1 (lldb) c Process 5024 resuming signal received Process 5024 exited with status = 0 (0x00000000) (lldb)
OK, so it looks like we expected. I can also ask lldb to just send a signal without stopping:
(lldb) br s -n main (lldb) r (lldb) pr h -p true -n true -s false SIGSEGV NAME PASS STOP NOTIFY ========== ===== ===== ====== SIGSEGV true false true (lldb) c Process 5055 resuming Process 5055 stopped and restarted: thread 1 received signal: SIGSEGV signal received Process 5055 exited with status = 0 (0x00000000) (lldb)
and it looks like he did what we wanted: lldb notified us that the signal was received and then sent to the program.
This is on Mac OS X with Xcode 6 installed.
source share