相关疑难解决方法(0)

获取生成UNIX信号的故障地址

我对一个信号处理程序感兴趣,它可以识别导致问题的指令的地址.

我知道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 …
Run Code Online (Sandbox Code Playgroud)

c++ unix signals

8
推荐指数
1
解决办法
3728
查看次数

标签 统计

c++ ×1

signals ×1

unix ×1