|
|
682939d |
Add a hack to the fatal signal handlers to invoke gdb and get a full stack
|
|
|
682939d |
trace on crash. This won't fix anything, but by activating this mode
|
|
|
682939d |
in the testsuite, we can get more detail on the alpha and sparc FTBFSes.
|
|
|
682939d |
|
|
|
682939d |
Index: monotone-1.0/src/unix/main.cc
|
|
|
682939d |
===================================================================
|
|
|
682939d |
--- monotone-1.0.orig/src/unix/main.cc 2009-04-12 13:39:49.000000000 -0700
|
|
|
682939d |
+++ monotone-1.0/src/unix/main.cc 2009-04-12 13:42:56.000000000 -0700
|
|
|
682939d |
@@ -36,12 +36,21 @@
|
|
|
682939d |
|
|
|
682939d |
#include "../base.hh"
|
|
|
682939d |
#include <signal.h>
|
|
|
682939d |
-#include <time.h>
|
|
|
682939d |
+#include <stdlib.h>
|
|
|
682939d |
#include <string.h>
|
|
|
682939d |
#include <sys/resource.h>
|
|
|
682939d |
#include <unistd.h>
|
|
|
682939d |
+#include <time.h>
|
|
|
682939d |
+
|
|
|
682939d |
+#if __GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
|
|
|
682939d |
+# define HAVE_BACKTRACE
|
|
|
682939d |
+# include <execinfo.h>
|
|
|
682939d |
+#endif
|
|
|
682939d |
|
|
|
682939d |
static char const * argv0;
|
|
|
682939d |
+#ifdef HAVE_BACKTRACE
|
|
|
682939d |
+static bool backtrace_on_crash = false;
|
|
|
682939d |
+#endif
|
|
|
682939d |
|
|
|
682939d |
// a convenient wrapper
|
|
|
682939d |
inline void
|
|
|
682939d |
@@ -75,6 +84,18 @@
|
|
|
682939d |
write_str_to_stderr("do not send a core dump, but if you have one, "
|
|
|
682939d |
"\nplease preserve it in case we ask you for "
|
|
|
682939d |
"information from it.\n");
|
|
|
682939d |
+#ifdef HAVE_BACKTRACE
|
|
|
682939d |
+ if (backtrace_on_crash)
|
|
|
682939d |
+ {
|
|
|
682939d |
+ void *tracebuf[20];
|
|
|
682939d |
+ int frames = backtrace(tracebuf, 20);
|
|
|
682939d |
+ if (frames)
|
|
|
682939d |
+ {
|
|
|
682939d |
+ write_str_to_stderr("stack trace:\n");
|
|
|
682939d |
+ backtrace_symbols_fd(tracebuf, frames, 2);
|
|
|
682939d |
+ }
|
|
|
682939d |
+ }
|
|
|
682939d |
+#endif
|
|
|
682939d |
|
|
|
682939d |
raise(signo);
|
|
|
682939d |
// The signal has been reset to the default handler by SA_RESETHAND
|
|
|
682939d |
@@ -129,6 +150,12 @@
|
|
|
682939d |
|
|
|
682939d |
argv0 = argv[0];
|
|
|
682939d |
|
|
|
682939d |
+#ifdef HAVE_BACKTRACE
|
|
|
682939d |
+ char *ev = getenv("MTN_STACKTRACE_ON_CRASH");
|
|
|
682939d |
+ if (ev && ev[0])
|
|
|
682939d |
+ backtrace_on_crash = true;
|
|
|
682939d |
+#endif
|
|
|
682939d |
+
|
|
|
682939d |
bug_signal_action.sa_flags = SA_RESETHAND;
|
|
|
682939d |
bug_signal_action.sa_handler = &bug_signal;
|
|
|
682939d |
sigemptyset(&bug_signal_action.sa_mask);
|