diff options
Diffstat (limited to 'gprofng/src/ipc.cc')
-rw-r--r-- | gprofng/src/ipc.cc | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/gprofng/src/ipc.cc b/gprofng/src/ipc.cc index edc7025..06ba33d 100644 --- a/gprofng/src/ipc.cc +++ b/gprofng/src/ipc.cc @@ -95,11 +95,6 @@ extern "C" /* * Fatal error handlers */ -extern "C" void fatalErrorHadler (int sig, siginfo_t *info, void *context); -extern "C" void sigSEGV_handler (int sig, siginfo_t *info, void *context); -extern "C" void sigABRT_handler (int sig, siginfo_t *info, void *context); -static char fatalErrorBuffer1[1024 * 8]; -static char fatalErrorBuffer2[1024 * 8]; static int fatalErrorCode = 1; static int fatalErrorCounter = 0; static void *fatalErrorContext = 0; @@ -127,38 +122,24 @@ fatalErrorHadler (int sig, siginfo_t *info, void *context) // Get process ID pid_t pid = getpid (); // Create dump file - snprintf (fatalErrorBuffer1, sizeof (fatalErrorBuffer1), "/tmp/analyzer.%lld", - (long long) pid); - mkdir (fatalErrorBuffer1, 0700); - snprintf (fatalErrorBuffer1, sizeof (fatalErrorBuffer1), - "/tmp/analyzer.%lld/crash.sig%d.%lld", (long long) pid, sig, - (long long) pid); + char fname[128]; + snprintf (fname, sizeof (fname), "/tmp/gprofng.%lld", (long long) pid); + mkdir (fname, 0700); + snprintf (fname, sizeof (fname), "/tmp/gprofng.%lld/crash.sig%d.%lld", + (long long) pid, sig, (long long) pid); // Dump stack trace in background using pstack - snprintf (fatalErrorBuffer2, sizeof (fatalErrorBuffer2), - "/usr/bin/pstack %lld > %s.pstack", (long long) pid, fatalErrorBuffer1); - system (fatalErrorBuffer2); - int fd = creat (fatalErrorBuffer1, 0600); + char buf[256]; + snprintf (buf, sizeof (buf), "/usr/bin/pstack %lld > %s.pstack", + (long long) pid, fname); + system (buf); + int fd = creat (fname, 0600); if (fd >= 0) { // Write error message - snprintf (fatalErrorBuffer2, sizeof (fatalErrorBuffer2), - "A fatal error has been detected by er_print: Signal %lld\n", - (long long) sig); - write (fd, fatalErrorBuffer2, strlen (fatalErrorBuffer2)); -// snprintf (fatalErrorBuffer2, sizeof (fatalErrorBuffer2), -// "If you would like to submit a bug report, please use your support contract.\n")); -// write(fd, fatalErrorBuffer2, strlen(fatalErrorBuffer2)); - snprintf (fatalErrorBuffer2, sizeof (fatalErrorBuffer2), - "Protocol Version: %d\n", IPC_VERSION_NUMBER); - write (fd, fatalErrorBuffer2, strlen (fatalErrorBuffer2)); + dbe_write (fd, "A fatal error has been detected by er_print: Signal %d\n", + sig); + dbe_write (fd, "Protocol Version: %d\n", IPC_VERSION_NUMBER); close (fd); - // Send postmortem error message to the GUI - // snprintf(fatalErrorBuffer1, sizeof (fatalErrorBuffer1), - // "%s: %s: /tmp/analyzer.%lld", - // "Unexpected signal in er_print", - // "Crash dump", - // (long long) pid); - // res = write(2, fatalErrorBuffer2, strlen(fatalErrorBuffer1)); } wait (0); // wait for pstack //sleep(10); // Wait 10 seconds to make sure processing of fatal error is done |