char * ctime (const time_t *timep) { struct timespec start, end; static char * (*fn)(const time_t *); __sync_fetch_and_add(&entered, 1); if (fn == NULL) *(void **)(&fn) = dlsym(RTLD_NEXT, "ctime"); if (fn == NULL){ fprintf(stderr, "dlsym: Error while loading symbol: <%s>\n", "ctime"); goto out; } char * rval; if (entered == 1) { _backtrace(); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start); rval = fn(timep); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end); _timespec_sub(&end, &start); _logtime("ctime", end); } else { rval = fn(timep); } out: __sync_fetch_and_sub(&entered, 1); return rval; }
int timer_settime (timer_t timerid, int flags, const struct itimerspec *new_value, struct itimerspec * old_value) { struct timespec start, end; static int (*fn)(timer_t , int , const struct itimerspec *, struct itimerspec * ); __sync_fetch_and_add(&entered, 1); if (fn == NULL) *(void **)(&fn) = dlsym(RTLD_NEXT, "timer_settime"); if (fn == NULL){ fprintf(stderr, "dlsym: Error while loading symbol: <%s>\n", "timer_settime"); goto out; } int rval; if (entered == 1) { _backtrace(); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start); rval = fn(timerid, flags, new_value, old_value); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end); _timespec_sub(&end, &start); _logtime("timer_settime", end); } else { rval = fn(timerid, flags, new_value, old_value); } out: __sync_fetch_and_sub(&entered, 1); return rval; }
int utimes (const char *filename, const struct timeval times[2]) { struct timespec start, end; static int (*fn)(const char *, const struct timeval times[2]); __sync_fetch_and_add(&entered, 1); if (fn == NULL) *(void **)(&fn) = dlsym(RTLD_NEXT, "utimes"); if (fn == NULL){ fprintf(stderr, "dlsym: Error while loading symbol: <%s>\n", "utimes"); goto out; } int rval; if (entered == 1) { _backtrace(); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start); rval = fn(filename, times); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end); _timespec_sub(&end, &start); _logtime("utimes", end); } else { rval = fn(filename, times); } out: __sync_fetch_and_sub(&entered, 1); return rval; }
int clock_getcpuclockid (pid_t pid, clockid_t *clock_id) { struct timespec start, end; static int (*fn)(pid_t , clockid_t *); __sync_fetch_and_add(&entered, 1); if (fn == NULL) *(void **)(&fn) = dlsym(RTLD_NEXT, "clock_getcpuclockid"); if (fn == NULL){ fprintf(stderr, "dlsym: Error while loading symbol: <%s>\n", "clock_getcpuclockid"); goto out; } int rval; if (entered == 1) { _backtrace(); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start); rval = fn(pid, clock_id); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end); _timespec_sub(&end, &start); _logtime("clock_getcpuclockid", end); } else { rval = fn(pid, clock_id); } out: __sync_fetch_and_sub(&entered, 1); return rval; }
int getitimer (int which, struct itimerval *curr_value) { struct timespec start, end; static int (*fn)(int , struct itimerval *); __sync_fetch_and_add(&entered, 1); if (fn == NULL) *(void **)(&fn) = dlsym(RTLD_NEXT, "getitimer"); if (fn == NULL){ fprintf(stderr, "dlsym: Error while loading symbol: <%s>\n", "getitimer"); goto out; } int rval; if (entered == 1) { _backtrace(); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start); rval = fn(which, curr_value); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &end); _timespec_sub(&end, &start); _logtime("getitimer", end); } else { rval = fn(which, curr_value); } out: __sync_fetch_and_sub(&entered, 1); return rval; }
void cu_debug_abort() { if (cu_debug_is_enabled(cu_debug_soft_exit_flag)) exit(1); #ifdef CUCONF_HAVE_LIBUNWIND else _backtrace(); #endif raise(SIGABRT); abort(); }
static LONG WINAPI exception_filter (LPEXCEPTION_POINTERS info) { struct output_buffer ob; SYSTEMTIME timeInfo; OSVERSIONINFOEX osInfo; FILE* crash; const char* dumpFile = "crashdump.txt"; int ret; GetSystemTime(&timeInfo); OBJZERO(osInfo); osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if (!GetVersionEx((OSVERSIONINFO*)&osInfo)) { osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx((OSVERSIONINFO*)&osInfo); } output_init(&ob, g_output, BUFFER_MAX); if (!SymInitialize(GetCurrentProcess(), 0, TRUE)) { output_print(&ob, "Failed to init symbol context\n"); } else { struct bfd_set *set = (struct bfd_set *)calloc(1, sizeof(*set)); bfd_init(); _backtrace(&ob, set, 128, info->ContextRecord); release_set(set); SymCleanup(GetCurrentProcess()); } crash = fopen(dumpFile, "w"); if (crash != nullptr) { fprintf(crash, "======start======\n"); fprintf(crash, "Date: %.4d-%.2d-%.2d\n", timeInfo.wYear, timeInfo.wMonth, timeInfo.wDay); fprintf(crash, "Windows version %lu.%lu (Build %lu) %s\n", osInfo.dwMajorVersion, osInfo.dwMinorVersion, osInfo.dwBuildNumber, osInfo.szCSDVersion); fprintf(crash, BUILDSTRING ", cpu: " CPUSTRING ", version: " UFO_VERSION "\n\n"); fprintf(crash, "%s", g_output); fprintf(crash, "======end========\n"); fclose(crash); } fputs(g_output, stderr); ret = MessageBox(nullptr, "Would you like to upload this crash dump and your ufoconsole.log? This will help the developers to fix the problem.", GAME_TITLE_LONG" Fatal Error", MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2); if (ret == IDYES) Com_UploadCrashDump(dumpFile); return 0; }
void backtrace(char *btarg) { int pid; /* Fork so we can backtrace the child. Keep this stack * frame minimal, so the trace is fairly clean. */ Debug(DStack) switch(pid = fork()) { case -1: return; case 0: kill(getpid(), SIGSTOP); _exit(0); default: _backtrace(pid, btarg); break; } }
static LONG CALLBACK ctrl_handler_w32(LPEXCEPTION_POINTERS info) { switch (info->ExceptionRecord->ExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: switch (info->ExceptionRecord->ExceptionInformation[0]) { case 0: LbErrorLog("Attempt to read from inaccessible memory address.\n"); break; case 1: LbErrorLog("Attempt to write to inaccessible memory address.\n"); break; case 8: LbErrorLog("User-mode data execution prevention (DEP) violation.\n"); break; default: LbErrorLog("Memory access voilation, code %d.\n",(int)info->ExceptionRecord->ExceptionInformation[0]); break; } break; case EXCEPTION_INT_DIVIDE_BY_ZERO: LbErrorLog("Attempt of integer division by zero.\n"); break; default: LbErrorLog("Failure code %x received.\n",info->ExceptionRecord->ExceptionCode); break; } if (!SymInitialize(GetCurrentProcess(), 0, TRUE)) { LbErrorLog("Failed to init symbol context\n"); } else { _backtrace(16 , info->ContextRecord); SymCleanup(GetCurrentProcess()); } LbScreenReset(); LbErrorLogClose(); return EXCEPTION_EXECUTE_HANDLER; }
static LONG WINAPI exception_filter(LPEXCEPTION_POINTERS info) { struct output_buffer ob; output_init(&ob, g_output, BUFFER_MAX); if (!SymInitialize(GetCurrentProcess(), 0, TRUE)) { output_print(&ob,"Failed to init symbol context\n"); } else { struct bfd_ctx bc; _backtrace(&ob , &bc , 128 , info->ContextRecord); close_bfd_ctx(&bc); SymCleanup(GetCurrentProcess()); } fputs(g_output , stderr); exit(1); return 0; }
static LONG WINAPI exception_filter(LPEXCEPTION_POINTERS info) { struct output_buffer ob; output_init(&ob, g_output, BUFFER_MAX); if (!SymInitialize(GetCurrentProcess(), 0, TRUE)) { output_print(&ob,"Failed to init symbol context\n"); } else { bfd_init(); struct bfd_set *set = calloc(1,sizeof(*set)); _backtrace(&ob , set , 128 , info->ContextRecord); release_set(set); SymCleanup(GetCurrentProcess()); } fputs(g_output , stderr); exit(1); return 0; }
LONG WINAPI exceptionFilter(LPEXCEPTION_POINTERS info) { if (g_output == NULL) { g_output = (char*) malloc(BUFFER_MAX); } struct output_buffer ob; output_init(&ob, g_output, BUFFER_MAX); if (!SymInitialize(GetCurrentProcess(), 0, TRUE)) { output_print(&ob,"Failed to init symbol context\n"); } else { bfd_init(); struct bfd_set *set = (bfd_set*)calloc(1,sizeof(*set)); _backtrace(&ob , set , 128 , info->ContextRecord); release_set(set); SymCleanup(GetCurrentProcess()); } // Dump a stack trace to a file. QFile stackTraceFile; stackTraceFile.setFileName(QString("%1/openmodelica.stacktrace.%2").arg(OpenModelica::tempDirectory()).arg(Helper::OMCServerName)); if (stackTraceFile.open(QIODevice::WriteOnly | QIODevice::Text)) { QTextStream out(&stackTraceFile); out.setCodec(Helper::utf8.toStdString().data()); out.setGenerateByteOrderMark(false); out << g_output; out.flush(); stackTraceFile.close(); } CrashReportDialog *pCrashReportDialog = new CrashReportDialog; pCrashReportDialog->exec(); exit(1); }
void _signal_handler(int signo) { _backtrace(signo); exit(0); }