monotone on Debian

monotone on Debian Mtn Source Tree

Root/patches/90-stacktrace-on-crash.diff

1Add a hack to the fatal signal handlers to invoke gdb and get a full stack
2trace on crash. This won't fix anything, but by activating this mode
3in the testsuite, we can get more detail on the alpha and sparc FTBFSes.
4
5Index: monotone-1.0/src/unix/main.cc
6===================================================================
7--- monotone-1.0.orig/src/unix/main.cc2009-04-12 13:39:49.000000000 -0700
8+++ monotone-1.0/src/unix/main.cc2009-04-12 13:42:56.000000000 -0700
9@@ -36,12 +36,21 @@
10
11 #include "../base.hh"
12 #include <signal.h>
13-#include <time.h>
14+#include <stdlib.h>
15 #include <string.h>
16 #include <sys/resource.h>
17 #include <unistd.h>
18+#include <time.h>
19+
20+#if __GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
21+# define HAVE_BACKTRACE
22+# include <execinfo.h>
23+#endif
24
25 static char const * argv0;
26+#ifdef HAVE_BACKTRACE
27+static bool backtrace_on_crash = false;
28+#endif
29
30 // a convenient wrapper
31 inline void
32@@ -75,6 +84,18 @@
33 write_str_to_stderr("do not send a core dump, but if you have one, "
34 "\nplease preserve it in case we ask you for "
35 "information from it.\n");
36+#ifdef HAVE_BACKTRACE
37+ if (backtrace_on_crash)
38+ {
39+ void *tracebuf[20];
40+ int frames = backtrace(tracebuf, 20);
41+ if (frames)
42+ {
43+ write_str_to_stderr("stack trace:\n");
44+ backtrace_symbols_fd(tracebuf, frames, 2);
45+ }
46+ }
47+#endif
48
49 raise(signo);
50 // The signal has been reset to the default handler by SA_RESETHAND
51@@ -129,6 +150,12 @@
52
53 argv0 = argv[0];
54
55+#ifdef HAVE_BACKTRACE
56+ char *ev = getenv("MTN_STACKTRACE_ON_CRASH");
57+ if (ev && ev[0])
58+ backtrace_on_crash = true;
59+#endif
60+
61 bug_signal_action.sa_flags = SA_RESETHAND;
62 bug_signal_action.sa_handler = &bug_signal;
63 sigemptyset(&bug_signal_action.sa_mask);

Archive Download this file

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status