How to get fullstacktrace using _Unwind_Backtrace on SIGSEGV

前端 未结 4 583
长发绾君心
长发绾君心 2020-12-06 05:41

I handle SIGSEGV by code:

int C()
{
  int *i = NULL;
  *i = 10; // Crash there
}

int B()
{
  return C();
}

int A()
{
   return B();
}

int main(void)
{
  s         


        
4条回答
  •  春和景丽
    2020-12-06 06:11

    You want to backtrace from the signal triggering function, but you backtrace from the signal handler function. That's two different stacks. (Note, the SA_ONSTACK flag in sigaction is irrelevant to your question.)

    To find the stack pointer of the of the triggering function, use the third parameter of the handler, i.e. void *rserved. You can reference to the answer in this question: Getting the saved instruction pointer address from a signal handler

提交回复
热议问题