42 SIGFPE, // floating point exceptions (e.g. division by zero) |
42 SIGFPE, // floating point exceptions (e.g. division by zero) |
43 SIGILL, // illegal instructions |
43 SIGILL, // illegal instructions |
44 }); |
44 }); |
45 |
45 |
46 // ============================================================================= |
46 // ============================================================================= |
47 // ----------------------------------------------------------------------------- |
47 // ============================================================================= |
48 static void handleCrash (int sig) |
48 static void handleCrash (int sig) |
49 { |
49 { |
50 printf ("%s: crashed with signal %d, launching gdb\n", __func__, sig); |
50 printf ("%s: crashed with signal %d, launching gdb\n", __func__, sig); |
51 |
51 |
52 if (g_crashCatcherActive) |
52 if (g_crashCatcherActive) |
90 "<p><b>GDB <tt>stderr</tt>:</b></p><pre>%4</pre>", |
90 "<p><b>GDB <tt>stderr</tt>:</b></p><pre>%4</pre>", |
91 sig, (!g_assertionFailure.isEmpty()) ? g_assertionFailure : "", output, err)); |
91 sig, (!g_assertionFailure.isEmpty()) ? g_assertionFailure : "", output, err)); |
92 } |
92 } |
93 |
93 |
94 // ============================================================================= |
94 // ============================================================================= |
95 // ----------------------------------------------------------------------------- |
95 // ============================================================================= |
96 void initCrashCatcher() |
96 void initCrashCatcher() |
97 { |
97 { |
98 struct sigaction sighandler; |
98 struct sigaction sighandler; |
99 sighandler.sa_handler = &handleCrash; |
99 sighandler.sa_handler = &handleCrash; |
100 sighandler.sa_flags = 0; |
100 sighandler.sa_flags = 0; |
110 // ============================================================================= |
110 // ============================================================================= |
111 // This function must be readily available in both Windows and Linux. We display |
111 // This function must be readily available in both Windows and Linux. We display |
112 // the bomb box straight in Windows while in Linux we let abort() trigger the |
112 // the bomb box straight in Windows while in Linux we let abort() trigger the |
113 // signal handler, which will cause the usual bomb box with GDB diagnostics. |
113 // signal handler, which will cause the usual bomb box with GDB diagnostics. |
114 // Said prompt will embed the assertion failure information. |
114 // Said prompt will embed the assertion failure information. |
115 // ----------------------------------------------------------------------------- |
115 // ============================================================================= |
116 void assertionFailure (const char* file, int line, const char* funcname, const char* expr) |
116 void assertionFailure (const char* file, int line, const char* funcname, const char* expr) |
117 { |
117 { |
118 QString errmsg = fmt ( |
118 QString errmsg = fmt ( |
119 "<p><b>File</b>: <tt>%1</tt><br />" |
119 "<p><b>File</b>: <tt>%1</tt><br />" |
120 "<b>Line</b>: <tt>%2</tt><br />" |
120 "<b>Line</b>: <tt>%2</tt><br />" |