how to use linux backtrace and backtrace_symbols API to find thread causing segmentation fault

621 views Asked by At

Hello my fellow Developers,

I am trying to analyse stack-dump from a C++ program, in this particular program we are creating signal handlers and and inside signal handler we have code something like below

res = backtrace(arr, size);
if (res > 0)
{
  btrace = backtrace_symbols(arr, size);
}
for ( unsigned int i =0; i < size ; ++i )
{
    log_error(" trace: %s", btrace[i] );
}

I am able to get traces however unable to find address which i am expecting, now I am wondering if there is any possibility that other threads might have filled the stacktrace buffer(as it is an embedded device and we have limited buffer size), if so how i can identify/filter stacktraces thread wise or is there any option to restrict stacktraces to only thread which caught segmentation fault.

Note: I am able to identify 2 addresses from my executable which are present in stacktrace, very recent one is the address of signal handler itself and 2nd one is from another thread.

I tried to googling resources on how backtrace works in multi threaded env. on but not able to find much info, so I am here.

Thanks

0

There are 0 answers