#include #include #include #include using namespace std; void cxx_abort () { raise (SIGABRT); exit (1); } void abort_handler (int signal, siginfo_t* info, void* unused) { void* trace[25]; int depth; int i; char** symbols; depth = backtrace (trace, 25); symbols = backtrace_symbols (trace, depth); cout << "abort handler invoked, depth " << depth << endl; for (i = 0; i < depth; ++i) cout << symbols[i] << endl; } void bar () throw () { cout << "bar calling abort" << endl; cxx_abort (); } void foo () { bar (); } int main (int argc, char **argv) { struct sigaction sa; sa.sa_flags = SA_SIGINFO; sigemptyset (&sa.sa_mask); sa.sa_sigaction = abort_handler; sigaction (SIGABRT, &sa, NULL); foo (); return 0; }