我对一个信号处理程序感兴趣,它可以识别导致问题的指令的地址.
我知道siginfo_t并且__builtin_return_address似乎都没有工作:
#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);
    int * i = NULL;
before:
    *i = 0;
after:
    std :: cout << "End.\n";
}
void handler (int, siginfo_t …