diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-09-10 00:10:28 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-09-10 00:10:28 +0200 |
commit | 2554645a86359ec4cf805c8dee0e347b802776e0 (patch) | |
tree | 440bcab7781a42ad3d92c68558d77cc4cf46680f /synchronizer | |
parent | c1e254e894144d08ad2dc560f9c1e3c719eea1f1 (diff) | |
download | sink-2554645a86359ec4cf805c8dee0e347b802776e0.tar.gz sink-2554645a86359ec4cf805c8dee0e347b802776e0.zip |
Stacktrace printing on crash
Diffstat (limited to 'synchronizer')
-rw-r--r-- | synchronizer/main.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/synchronizer/main.cpp b/synchronizer/main.cpp index db74960..e9c17e7 100644 --- a/synchronizer/main.cpp +++ b/synchronizer/main.cpp | |||
@@ -21,13 +21,40 @@ | |||
21 | #include <QLockFile> | 21 | #include <QLockFile> |
22 | 22 | ||
23 | #include <signal.h> | 23 | #include <signal.h> |
24 | #include <execinfo.h> | ||
24 | 25 | ||
25 | #include "listener.h" | 26 | #include "listener.h" |
26 | #include "log.h" | 27 | #include "log.h" |
27 | 28 | ||
28 | void crashHandler(int sig) { | 29 | void crashHandler(int sig) { |
29 | std::fprintf(stderr, "Error: signal %d\n", sig); | 30 | std::fprintf(stderr, "Error: signal %d\n", sig); |
30 | std::system("exec xterm -e gdb -p \"$PPID\""); | 31 | |
32 | QString s; | ||
33 | void *trace[256]; | ||
34 | int n = backtrace( trace, 256 ); | ||
35 | if ( n ) { | ||
36 | char **strings = backtrace_symbols( trace, n ); | ||
37 | |||
38 | s = QLatin1String( "[\n" ); | ||
39 | |||
40 | for ( int i = 0; i < n; ++i ) { | ||
41 | s += QString::number( i ) + | ||
42 | QLatin1String( ": " ) + | ||
43 | QLatin1String( strings[i] ) + QLatin1String( "\n" ); | ||
44 | } | ||
45 | s += QLatin1String( "]\n" ); | ||
46 | std::fprintf(stderr, "Backtrace: %s\n", s.toLatin1().data()); | ||
47 | |||
48 | if ( strings ) { | ||
49 | free( strings ); | ||
50 | } | ||
51 | |||
52 | } | ||
53 | |||
54 | std::system("exec gdb -p \"$PPID\" -ex \"thread apply all bt\""); | ||
55 | //This only works if we actually have xterm and X11 available | ||
56 | // std::system("exec xterm -e gdb -p \"$PPID\""); | ||
57 | |||
31 | std::abort(); | 58 | std::abort(); |
32 | } | 59 | } |
33 | 60 | ||