static void fatal_handler(int sig, siginfo_t *info, void *secret) { #ifdef HAVE_BACKTRACE void *trace[50]; #ifdef REG_EIP ucontext_t *uc = (ucontext_t*)secret; #endif size_t size; #endif struct sigaction act; act.sa_handler = SIG_DFL; sigemptyset(&act.sa_mask); act.sa_flags = 0; sigaction(sig, &act, NULL); #ifdef HAVE_BACKTRACE size = backtrace(trace, sizeof(trace) / sizeof(void*)); #ifdef REG_EIP /* overwrite sigaction with caller's address */ trace[1] = (void *) uc->uc_mcontext.gregs[REG_EIP]; #endif gw_backtrace(trace, size, 0); #endif raise(sig); }
void gw_panic(int err, const char *fmt, ...) { /* * we don't want PANICs to spread accross smsc logs, so * this will be always within the main core log. */ FUNCTION_GUTS(GW_PANIC, ""); gw_backtrace(NULL, 0, 0); #ifdef SEGFAULT_PANIC *((char*)0) = 0; #endif exit(EXIT_FAILURE); }