void Logger :: writeELogMsg(logLevelType level, const char *_func, const char *_file, int _line, const char *format, ...) { va_list args; FILE *stream = this->logStream; if ( level == LOG_LEVEL_FATAL || level == LOG_LEVEL_ERROR ) { numberOfErr++; stream = this->errStream; } else if ( level == LOG_LEVEL_WARNING ) { numberOfWrn++; stream = this->errStream; } if ( level <= this->logLevel ) { if ( _file ) { fprintf(stream, "%s\n%s: (%s:%d)\n", LOG_ERR_HEADER, giveLevelName(level), _file, _line); } else { fprintf(stream, "%s\n%s:\n", LOG_ERR_HEADER, giveLevelName(level) ); } if ( _func ) { fprintf(stream, "In %s:\n", _func ); } va_start(args, format); vfprintf(stream, format, args); va_end(args); fprintf(stream, "\n%s", LOG_ERR_TAIL); } if ( level == LOG_LEVEL_FATAL || level == LOG_LEVEL_ERROR ) { print_stacktrace(this->errStream, 10); } }
int OTLog::Assert(const char * szFilename, int nLinenumber) { if ((NULL != szFilename)) { #ifndef ANDROID // if NOT android std::cerr << "OT_ASSERT in " << szFilename << " at line " << nLinenumber << "\n"; // ----------------------------- // Grab this if we can, too... // OTString strTemp; strTemp.Format("OT_ASSERT in %s at line %d\n", szFilename, nLinenumber); LogToFile(strTemp.Get()); // ----------------------------- #else // if Android OTString strAndroidAssertMsg; strAndroidAssertMsg.Format("\nOT_ASSERT in %s at line %d\n", szFilename, nLinenumber); __android_log_write(ANDROID_LOG_FATAL,"OT Assert", (const char *)strAndroidAssertMsg.Get()); #endif #ifndef _WIN32 print_stacktrace(); #endif } abort(); return -1; }
static void log_stacktrace (void) { void * buf [MAX_FRAMES_CNT]; int cnt; cnt = stacktrace (buf, MAX_FRAMES_CNT); print_stacktrace (buf, cnt); }
int funca() { int a = 0; int b = a+1; std::cout << "result from funca is " << a+b << std::endl; print_stacktrace(stdout); }
bool operator==(const pure_pointer &rhs) const { if (int_id_ == rhs.int_id_) { if (ptr_ != rhs.ptr_) { print_stacktrace(); } VERIFY(ptr_ == rhs.ptr_); return true; } return false; }
void *operator new(size_t size) { static std::bad_alloc ex; void *ret = operator new(size, std::nothrow); if (ret == NULL) { fprintf(stderr, "Warning: allocation of %ld bytes failed\n", size) ; print_stacktrace(stderr, 10) ; throw ex; } return ret; }
void BoxClass::AppendToBoxList (Box b) { #ifdef DEBUG DEBUGLOG2(routing,_T("Adding box %p"),b.get()); print_stacktrace(isDebugFlag(smartptr)); typename listtype::iterator i = FindInBoxList(b); if (i != boxList.end()) { UNREACHABLECT(listtype); } #endif boxList.push_back(b); }
void dump_stacktrace(void) { struct stack_trace trace; unsigned long entries[12]; trace.nr_entries = 0; trace.max_entries = 12; trace.entries = entries; trace.skip = 2; arch_save_stacktrace(&trace); print_stacktrace(&trace); }
void fatal_exit(const char* message, stacktrace_t& stacktrace) { if( fatal_exception_handler ) { fatal_exception_handler(); } std::ostringstream tmp; tmp << saved_exe_name << ": " << message << std::endl; if( stacktrace.size() > 0 ) print_stacktrace(stacktrace, tmp); tmp << "aborting" << std::endl; tinfra::err.write(tmp.str()); uninstall_abort_handler(); abort(); }
void umem_panic(const char *format, ...) { va_list va; va_start(va, format); umem_vprintf(format, va); va_end(va); if (format[strlen(format)-1] != '\n') umem_error_enter("\n"); print_stacktrace(); umem_do_abort(); }
void sigabrtHandler(int) { signal(SIGABRT, 0); signal(SIGSEGV, 0); #if !defined Q_OS_WIN && !defined Q_OS_HAIKU std::cerr << "\n\n*************************************************************\n"; std::cerr << "Catching SIGABRT, please report a bug at http://bug.qbittorrent.org\nand provide the following backtrace:\n"; std::cerr << "qBittorrent version: " << VERSION << std::endl; print_stacktrace(); #else #ifdef STACKTRACE_WIN StraceDlg dlg; dlg.setStacktraceString(straceWin::getBacktrace()); dlg.exec(); #endif #endif raise(SIGABRT); }
void sigAbnormalHandler(int signum) { #if !defined Q_OS_WIN && !defined Q_OS_HAIKU const char str1[] = "\n\n*************************************************************\nCatching signal: "; const char *sigName = sysSigName[signum]; const char str2[] = "\nPlease file a bug report at http://bug.qbittorrent.org and provide the following information:\n\n" "qBittorrent version: " QBT_VERSION "\n"; write(STDERR_FILENO, str1, strlen(str1)); write(STDERR_FILENO, sigName, strlen(sigName)); write(STDERR_FILENO, str2, strlen(str2)); print_stacktrace(); // unsafe #endif // !defined Q_OS_WIN && !defined Q_OS_HAIKU #ifdef STACKTRACE_WIN StraceDlg dlg; // unsafe dlg.setStacktraceString(straceWin::getBacktrace()); dlg.exec(); #endif // STACKTRACE_WIN signal(signum, SIG_DFL); raise(signum); }
const EVP_PKEY * OTAsymmetricKey_OpenSSL::OTAsymmetricKey_OpenSSLPrivdp::GetKey(OTPasswordData * pPWData/*=NULL*/) { OT_ASSERT_MSG(NULL != backlink->m_p_ascKey, "OTAsymmetricKey_OpenSSL::GetKey: NULL != m_p_ascKey\n"); if (NULL == backlink->m_p_ascKey) { OTLog::vError("%s: Unexpected NULL m_p_ascKey. Printing stack trace (and returning NULL):\n", __FUNCTION__); print_stacktrace(); return NULL; } // ---------------------------------------- if (backlink->m_timer.getElapsedTimeInSec() > OT_KEY_TIMER) backlink->ReleaseKeyLowLevel(); // This releases the actual loaded key, but not the ascii-armored, encrypted version of it. // (Thus forcing a reload, and thus forcing the passphrase to be entered again.) // ---------------------------------------- if (NULL == m_pKey) return InstantiateKey(pPWData); // this is the ONLY place, currently, that this private method is called. return m_pKey; }
int OTLog::Assert(const char * szFilename, int nLinenumber, const char * szMessage) { if (NULL != szMessage) { #ifndef ANDROID // if NOT android std::cerr << szMessage << "\n"; // ----------------------------- LogToFile(szMessage); LogToFile("\n"); // ----------------------------- #else // if Android __android_log_write(ANDROID_LOG_FATAL,"OT Assert", szMessage); #endif #ifndef _WIN32 print_stacktrace(); #endif } return OTLog::Assert(szFilename, nLinenumber); }
void sigAbnormalHandler(int signum) { const char *sigName = sysSigName[signum]; #if !defined Q_OS_WIN && !defined Q_OS_HAIKU const char msg[] = "\n\n*************************************************************\n" "Please file a bug report at http://bug.qbittorrent.org and provide the following information:\n\n" "qBittorrent version: " QBT_VERSION "\n\n" "Caught signal: "; reportToUser(msg); reportToUser(sigName); reportToUser("\n"); print_stacktrace(); // unsafe #endif // !defined Q_OS_WIN && !defined Q_OS_HAIKU #ifdef STACKTRACE_WIN StraceDlg dlg; // unsafe dlg.setStacktraceString(QLatin1String(sigName), straceWin::getBacktrace()); dlg.exec(); #endif // STACKTRACE_WIN signal(signum, SIG_DFL); raise(signum); }
void umem_panic(const char *format, ...) { va_list va; va_start(va, format); umem_vprintf(format, va); va_end(va); if (format[strlen(format)-1] != '\n') umem_error_enter("\n"); #ifdef ECELERITY va_start(va, format); ec_debug_vprintf(DCRITICAL, DMEM, format, va); va_end(va); #endif print_stacktrace(); umem_do_abort(); }
/* * Entry pointer for signal handlers * It uses functions which are not safe to be called from a signal handler, * (http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04 has a whitelist) * but when ending up here something went terribly wrong anyway. * And all which is left is just printing some information and terminate. */ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) { int type = -1; pid_t killid = getpid(); #if defined(__linux__) && defined(REG_ERR) const ucontext_t* const uc = reinterpret_cast<const ucontext_t*>(context); killid = (pid_t) syscall(SYS_gettid); if (uc) { type = (int)uc->uc_mcontext.gregs[REG_ERR] & 2; } #endif const Signalmap_t::const_iterator it=listofsignals.find(signo); const char * const signame = (it==listofsignals.end()) ? "unknown" : it->second.c_str(); bool printCallstack=true; bool lowMem=false; bool unexpectedSignal=true; const bool isaddressonstack = IsAddressOnStack(info->si_addr); FILE* output = CppCheckExecutor::getExceptionOutput(); switch (signo) { case SIGABRT: fputs("Internal error: cppcheck received signal ", output); fputs(signame, output); fputs(" - out of memory?\n", output); lowMem=true; // educated guess break; case SIGBUS: fputs("Internal error: cppcheck received signal ", output); fputs(signame, output); switch (info->si_code) { case BUS_ADRALN: // invalid address alignment fputs(" - BUS_ADRALN", output); break; case BUS_ADRERR: // nonexistent physical address fputs(" - BUS_ADRERR", output); break; case BUS_OBJERR: // object-specific hardware error fputs(" - BUS_OBJERR", output); break; #ifdef BUS_MCEERR_AR case BUS_MCEERR_AR: // Hardware memory error consumed on a machine check; fputs(" - BUS_MCEERR_AR", output); break; #endif #ifdef BUS_MCEERR_AO case BUS_MCEERR_AO: // Hardware memory error detected in process but not consumed fputs(" - BUS_MCEERR_AO", output); break; #endif default: break; } fprintf(output, " (at 0x%lx).\n", (unsigned long)info->si_addr); break; case SIGFPE: fputs("Internal error: cppcheck received signal ", output); fputs(signame, output); switch (info->si_code) { case FPE_INTDIV: // integer divide by zero fputs(" - FPE_INTDIV", output); break; case FPE_INTOVF: // integer overflow fputs(" - FPE_INTOVF", output); break; case FPE_FLTDIV: // floating-point divide by zero fputs(" - FPE_FLTDIV", output); break; case FPE_FLTOVF: // floating-point overflow fputs(" - FPE_FLTOVF", output); break; case FPE_FLTUND: // floating-point underflow fputs(" - FPE_FLTUND", output); break; case FPE_FLTRES: // floating-point inexact result fputs(" - FPE_FLTRES", output); break; case FPE_FLTINV: // floating-point invalid operation fputs(" - FPE_FLTINV", output); break; case FPE_FLTSUB: // subscript out of range fputs(" - FPE_FLTSUB", output); break; default: break; } fprintf(output, " (at 0x%lx).\n", (unsigned long)info->si_addr); break; case SIGILL: fputs("Internal error: cppcheck received signal ", output); fputs(signame, output); switch (info->si_code) { case ILL_ILLOPC: // illegal opcode fputs(" - ILL_ILLOPC", output); break; case ILL_ILLOPN: // illegal operand fputs(" - ILL_ILLOPN", output); break; case ILL_ILLADR: // illegal addressing mode fputs(" - ILL_ILLADR", output); break; case ILL_ILLTRP: // illegal trap fputs(" - ILL_ILLTRP", output); break; case ILL_PRVOPC: // privileged opcode fputs(" - ILL_PRVOPC", output); break; case ILL_PRVREG: // privileged register fputs(" - ILL_PRVREG", output); break; case ILL_COPROC: // coprocessor error fputs(" - ILL_COPROC", output); break; case ILL_BADSTK: // internal stack error fputs(" - ILL_BADSTK", output); break; default: break; } fprintf(output, " (at 0x%lx).%s\n", (unsigned long)info->si_addr, (isaddressonstack)?" Stackoverflow?":""); break; case SIGINT: unexpectedSignal=false; // legal usage: interrupt application via CTRL-C fputs("cppcheck received signal ", output); fputs(signame, output); printCallstack=true; fputs(".\n", output); break; case SIGSEGV: fputs("Internal error: cppcheck received signal ", output); fputs(signame, output); switch (info->si_code) { case SEGV_MAPERR: // address not mapped to object fputs(" - SEGV_MAPERR", output); break; case SEGV_ACCERR: // invalid permissions for mapped object fputs(" - SEGV_ACCERR", output); break; default: break; } fprintf(output, " (%sat 0x%lx).%s\n", (type==-1)? "" : (type==0) ? "reading " : "writing ", (unsigned long)info->si_addr, (isaddressonstack)?" Stackoverflow?":"" ); break; case SIGUSR1: case SIGUSR2: fputs("cppcheck received signal ", output); fputs(signame, output); fputs(".\n", output); break; default: fputs("Internal error: cppcheck received signal ", output); fputs(signame, output); fputs(".\n", output); break; } if (printCallstack) { print_stacktrace(output, true, -1, lowMem); } if (unexpectedSignal) { fputs("\nPlease report this to the cppcheck developers!\n", output); } fflush(output); // now let things proceed, shutdown and hopefully dump core for post-mortem analysis signal(signo, SIG_DFL); kill(killid, signo); }
static long __stdcall exception_filter(struct _EXCEPTION_POINTERS *info) { static const struct { DWORD code; const char *string; } exception_table[] = { { EXCEPTION_ACCESS_VIOLATION, "ACCESS VIOLATION" }, { EXCEPTION_DATATYPE_MISALIGNMENT, "DATATYPE MISALIGNMENT" }, { EXCEPTION_BREAKPOINT, "BREAKPOINT" }, { EXCEPTION_SINGLE_STEP, "SINGLE STEP" }, { EXCEPTION_ARRAY_BOUNDS_EXCEEDED, "ARRAY BOUNDS EXCEEDED" }, { EXCEPTION_FLT_DENORMAL_OPERAND, "FLOAT DENORMAL OPERAND" }, { EXCEPTION_FLT_DIVIDE_BY_ZERO, "FLOAT DIVIDE BY ZERO" }, { EXCEPTION_FLT_INEXACT_RESULT, "FLOAT INEXACT RESULT" }, { EXCEPTION_FLT_INVALID_OPERATION, "FLOAT INVALID OPERATION" }, { EXCEPTION_FLT_OVERFLOW, "FLOAT OVERFLOW" }, { EXCEPTION_FLT_STACK_CHECK, "FLOAT STACK CHECK" }, { EXCEPTION_FLT_UNDERFLOW, "FLOAT UNDERFLOW" }, { EXCEPTION_INT_DIVIDE_BY_ZERO, "INTEGER DIVIDE BY ZERO" }, { EXCEPTION_INT_OVERFLOW, "INTEGER OVERFLOW" }, { EXCEPTION_PRIV_INSTRUCTION, "PRIVILEGED INSTRUCTION" }, { EXCEPTION_IN_PAGE_ERROR, "IN PAGE ERROR" }, { EXCEPTION_ILLEGAL_INSTRUCTION, "ILLEGAL INSTRUCTION" }, { EXCEPTION_NONCONTINUABLE_EXCEPTION,"NONCONTINUABLE EXCEPTION" }, { EXCEPTION_STACK_OVERFLOW, "STACK OVERFLOW" }, { EXCEPTION_INVALID_DISPOSITION, "INVALID DISPOSITION" }, { EXCEPTION_GUARD_PAGE, "GUARD PAGE VIOLATION" }, { EXCEPTION_INVALID_HANDLE, "INVALID HANDLE" }, { 0, "UNKNOWN EXCEPTION" } }; static int already_hit = 0; int i; // if we're hitting this recursively, just exit if (already_hit) return EXCEPTION_CONTINUE_SEARCH; already_hit = 1; // flush any debugging traces that were live debugger_flush_all_traces_on_abnormal_exit(); // find our man for (i = 0; exception_table[i].code != 0; i++) if (info->ExceptionRecord->ExceptionCode == exception_table[i].code) break; // print the exception type and address fprintf(stderr, "\n-----------------------------------------------------\n"); auto diagnostics = downcast<diagnostics_win32 *>(get_instance()); fprintf(stderr, "Exception at EIP=%p%s: %s\n", info->ExceptionRecord->ExceptionAddress, diagnostics->m_symbols->symbol_for_address((FPTR)info->ExceptionRecord->ExceptionAddress), exception_table[i].string); // for access violations, print more info if (info->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) fprintf(stderr, "While attempting to %s memory at %p\n", info->ExceptionRecord->ExceptionInformation[0] ? "write" : "read", (void *)info->ExceptionRecord->ExceptionInformation[1]); // print the state of the CPU fprintf(stderr, "-----------------------------------------------------\n"); #ifdef PTR64 fprintf(stderr, "RAX=%p RBX=%p RCX=%p RDX=%p\n", (void *)info->ContextRecord->Rax, (void *)info->ContextRecord->Rbx, (void *)info->ContextRecord->Rcx, (void *)info->ContextRecord->Rdx); fprintf(stderr, "RSI=%p RDI=%p RBP=%p RSP=%p\n", (void *)info->ContextRecord->Rsi, (void *)info->ContextRecord->Rdi, (void *)info->ContextRecord->Rbp, (void *)info->ContextRecord->Rsp); fprintf(stderr, " R8=%p R9=%p R10=%p R11=%p\n", (void *)info->ContextRecord->R8, (void *)info->ContextRecord->R9, (void *)info->ContextRecord->R10, (void *)info->ContextRecord->R11); fprintf(stderr, "R12=%p R13=%p R14=%p R15=%p\n", (void *)info->ContextRecord->R12, (void *)info->ContextRecord->R13, (void *)info->ContextRecord->R14, (void *)info->ContextRecord->R15); #else fprintf(stderr, "EAX=%p EBX=%p ECX=%p EDX=%p\n", (void *)info->ContextRecord->Eax, (void *)info->ContextRecord->Ebx, (void *)info->ContextRecord->Ecx, (void *)info->ContextRecord->Edx); fprintf(stderr, "ESI=%p EDI=%p EBP=%p ESP=%p\n", (void *)info->ContextRecord->Esi, (void *)info->ContextRecord->Edi, (void *)info->ContextRecord->Ebp, (void *)info->ContextRecord->Esp); #endif // reprint the actual exception address fprintf(stderr, "-----------------------------------------------------\n"); fprintf(stderr, "Stack crawl:\n"); diagnostics->print_stacktrace(info->ContextRecord, GetCurrentThread()); // flush stderr, so the data is actually written when output is being redirected fflush(stderr); // exit return EXCEPTION_CONTINUE_SEARCH; }
/* * Entry pointer for signal handlers */ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * /*context*/) { const char * const signame = signal_name(signo); const char * const sigtext = strsignal(signo); bool bPrintCallstack=true; FILE* f=CppCheckExecutor::getExceptionOutput()=="stderr" ? stderr : stdout; fputs("Internal error: cppcheck received signal ", f); fputs(signame, f); fputs(", ", f); fputs(sigtext, f); switch (signo) { case SIGBUS: switch (info->si_code) { case BUS_ADRALN: // invalid address alignment fprintf(f, " - BUS_ADRALN"); break; case BUS_ADRERR: // nonexistent physical address fprintf(f, " - BUS_ADRERR"); break; case BUS_OBJERR: // object-specific hardware error fprintf(f, " - BUS_OBJERR"); break; #ifdef BUS_MCEERR_AR case BUS_MCEERR_AR: // Hardware memory error consumed on a machine check; fprintf(f, " - BUS_MCEERR_AR"); break; #endif #ifdef BUS_MCEERR_AO case BUS_MCEERR_AO: // Hardware memory error detected in process but not consumed fprintf(f, " - BUS_MCEERR_AO"); break; #endif default: break; } fprintf(f, " (at 0x%p).\n", info->si_addr); break; case SIGFPE: switch (info->si_code) { case FPE_INTDIV: // integer divide by zero fprintf(f, " - FPE_INTDIV"); break; case FPE_INTOVF: // integer overflow fprintf(f, " - FPE_INTOVF"); break; case FPE_FLTDIV: // floating-point divide by zero fprintf(f, " - FPE_FLTDIV"); break; case FPE_FLTOVF: // floating-point overflow fprintf(f, " - FPE_FLTOVF"); break; case FPE_FLTUND: // floating-point underflow fprintf(f, " - FPE_FLTUND"); break; case FPE_FLTRES: // floating-point inexact result fprintf(f, " - FPE_FLTRES"); break; case FPE_FLTINV: // floating-point invalid operation fprintf(f, " - FPE_FLTINV"); break; case FPE_FLTSUB: // subscript out of range fprintf(f, " - FPE_FLTSUB"); break; default: break; } fprintf(f, " (at 0x%p).\n", info->si_addr); break; case SIGILL: switch (info->si_code) { case ILL_ILLOPC: // illegal opcode fprintf(f, " - ILL_ILLOPC"); break; case ILL_ILLOPN: // illegal operand fprintf(f, " - ILL_ILLOPN"); break; case ILL_ILLADR: // illegal addressing mode fprintf(f, " - ILL_ILLADR"); break; case ILL_ILLTRP: // illegal trap fprintf(f, " - ILL_ILLTRP"); break; case ILL_PRVOPC: // privileged opcode fprintf(f, " - ILL_PRVOPC"); break; case ILL_PRVREG: // privileged register fprintf(f, " - ILL_PRVREG"); break; case ILL_COPROC: // coprocessor error fprintf(f, " - ILL_COPROC"); break; case ILL_BADSTK: // internal stack error fprintf(f, " - ILL_BADSTK"); break; default: break; } fprintf(f, " (at 0x%p).\n", info->si_addr); break; case SIGINT: bPrintCallstack=false; fprintf(f, ".\n"); break; case SIGSEGV: switch (info->si_code) { case SEGV_MAPERR: // address not mapped to object fprintf(f, " - SEGV_MAPERR"); break; case SEGV_ACCERR: // invalid permissions for mapped object fprintf(f, " - SEGV_ACCERR"); break; default: break; } fprintf(f, " (at 0x%p).\n", info->si_addr); break; default: fputs(".\n", f); break; } if (bPrintCallstack) { print_stacktrace(f, true); fputs("\nPlease report this to the cppcheck developers!\n", f); } abort(); }
void func(Type) { print_stacktrace(); }
void Gamma::unroll<0>(double) { print_stacktrace(); }
/* * Entry pointer for signal handlers * It uses functions which are not safe to be called from a signal handler, * but when ending up here something went terribly wrong anyway. * And all which is left is just printing some information and terminate. */ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) { int type = -1; pid_t killid = getpid(); const ucontext_t* uc = reinterpret_cast<const ucontext_t*>(context); #ifdef __linux__ killid = (pid_t) syscall(SYS_gettid); if (uc) { type = (int)uc->uc_mcontext.gregs[REG_ERR] & 2; } #endif const char * const signame = signal_name(signo); const char * const sigtext = strsignal(signo); bool bPrintCallstack=true; FILE* f=CppCheckExecutor::getExceptionOutput()=="stderr" ? stderr : stdout; fputs("Internal error: cppcheck received signal ", f); fputs(signame, f); fputs(", ", f); fputs(sigtext, f); switch (signo) { case SIGBUS: switch (info->si_code) { case BUS_ADRALN: // invalid address alignment fputs(" - BUS_ADRALN", f); break; case BUS_ADRERR: // nonexistent physical address fputs(" - BUS_ADRERR", f); break; case BUS_OBJERR: // object-specific hardware error fputs(" - BUS_OBJERR", f); break; #ifdef BUS_MCEERR_AR case BUS_MCEERR_AR: // Hardware memory error consumed on a machine check; fputs(" - BUS_MCEERR_AR", f); break; #endif #ifdef BUS_MCEERR_AO case BUS_MCEERR_AO: // Hardware memory error detected in process but not consumed fputs(" - BUS_MCEERR_AO", f); break; #endif default: break; } fprintf(f, " (at 0x%p).\n", info->si_addr); break; case SIGFPE: switch (info->si_code) { case FPE_INTDIV: // integer divide by zero fputs(" - FPE_INTDIV", f); break; case FPE_INTOVF: // integer overflow fputs(" - FPE_INTOVF", f); break; case FPE_FLTDIV: // floating-point divide by zero fputs(" - FPE_FLTDIV", f); break; case FPE_FLTOVF: // floating-point overflow fputs(" - FPE_FLTOVF", f); break; case FPE_FLTUND: // floating-point underflow fputs(" - FPE_FLTUND", f); break; case FPE_FLTRES: // floating-point inexact result fputs(" - FPE_FLTRES", f); break; case FPE_FLTINV: // floating-point invalid operation fputs(" - FPE_FLTINV", f); break; case FPE_FLTSUB: // subscript out of range fputs(" - FPE_FLTSUB", f); break; default: break; } fprintf(f, " (at 0x%p).\n", info->si_addr); break; case SIGILL: switch (info->si_code) { case ILL_ILLOPC: // illegal opcode fputs(" - ILL_ILLOPC", f); break; case ILL_ILLOPN: // illegal operand fputs(" - ILL_ILLOPN", f); break; case ILL_ILLADR: // illegal addressing mode fputs(" - ILL_ILLADR", f); break; case ILL_ILLTRP: // illegal trap fputs(" - ILL_ILLTRP", f); break; case ILL_PRVOPC: // privileged opcode fputs(" - ILL_PRVOPC", f); break; case ILL_PRVREG: // privileged register fputs(" - ILL_PRVREG", f); break; case ILL_COPROC: // coprocessor error fputs(" - ILL_COPROC", f); break; case ILL_BADSTK: // internal stack error fputs(" - ILL_BADSTK", f); break; default: break; } fprintf(f, " (at 0x%p).\n", info->si_addr); break; case SIGINT: bPrintCallstack=false; fputs(".\n", f); break; case SIGSEGV: switch (info->si_code) { case SEGV_MAPERR: // address not mapped to object fputs(" - SEGV_MAPERR", f); break; case SEGV_ACCERR: // invalid permissions for mapped object fputs(" - SEGV_ACCERR", f); break; default: break; } fprintf(f, " (%sat 0x%p).\n", (type==-1)? "" : (type==0) ? "reading " : "writing ", info->si_addr); break; default: fputs(".\n", f); break; } if (bPrintCallstack) { print_stacktrace(f, true); fputs("\nPlease report this to the cppcheck developers!\n", f); } // now let the system proceed, shutdown and hopefully dump core for post-mortem analysis signal(signo, SIG_DFL); kill(killid, signo); }
void throwError(const char *msg) { print_stacktrace(stdout); throw new Exception(NULL,msg); }
void myTerminate() { print_stacktrace(); oldTerminate(); }
static void sigsegv_handler(int signum) { print_stacktrace(signum); //g_on_error_stack_trace(g_get_prgname()); abort(); /* trigger a SIGABRT instead of just exiting */ }
void func() { print_stacktrace(); }
void cxx_handler(int sig) { print_stacktrace(); exit(1); }