Код: Выделить всё
constexpr size_t MAX_STACK_FRAMES{ 64 };
static void* stack_traces[MAX_STACK_FRAMES];
void posix_print_stack_trace()
{
int i, trace_size = 0;
char** messages = (char**)NULL;
char buffer[1024]{}; // buffer for error message
trace_size = backtrace(stack_traces, MAX_STACK_FRAMES);
messages = backtrace_symbols(stack_traces, trace_size);
/* skip the first couple stack frames (as they are this function and
our handler) and also skip the last frame as it's (always?) junk. */
// for (i = 3; i < (trace_size - 1); ++i)
// we'll use this for now so you can see what's going on
for (i = 0; i < trace_size; ++i)
{
if (addr2line(global_program_name, stack_traces[i]) != 0)
Код: Выделить всё
/* have addr2line map the address to the relevant line in the code */
#ifdef __APPLE__
/* apple does things differently... */
sprintf(addr2line_cmd, "atos -o %.256s %p", program_name, addr);
#else
sprintf(addr2line_cmd, "addr2line -f -p -e %.256s %p", program_name, addr);
#endif
Код: Выделить всё
?? ??:0
?? ??:0
?? ??:0
?? ??:0
?? ??:0
?? ??:0
?? ??:0
Подробнее здесь: https://stackoverflow.com/questions/791 ... e-on-linux