c++ stack trace from unhandled exception? [duplicate]
Edited Answer: You can use std::set_terminate #include <cstdlib> #include <iostream> #include <stdexcept> #include <execinfo.h> void handler() { void *trace_elems[20]; int trace_elem_count(backtrace( trace_elems, 20 )); char **stack_syms(backtrace_symbols( trace_elems, trace_elem_count )); for ( int i = 0 ; i < trace_elem_count ; ++i ) { std::cout << stack_syms[i] << “\n”; } free( stack_syms ); exit(1); } int … Read more