Getting fault address that generated a UNIX signal
问题 I am interested in a signal handler which can identify the address of the instruction which caused the problem. I know about siginfo_t and __builtin_return_address and neither seem to work: #include <iostream> #include <signal.h> void handler (int, siginfo_t *, void *); int main () { begin: std :: cerr << &&begin << " ~ " << &&before << " ~ " << &&after << "\n"; struct sigaction s; s .sa_flags = SA_SIGINFO; sigemptyset (& s .sa_mask); s .sa_sigaction = handler; sigaction (SIGSEGV, &s, NULL);