src/crashCatcher.cc

changeset 765
6d8ca5219a57
parent 739
152b33a6d51b
child 778
0ed96169b8c0
equal deleted inserted replaced
764:335d929c673e 765:6d8ca5219a57
30 #endif 30 #endif
31 31
32 #include "crashCatcher.h" 32 #include "crashCatcher.h"
33 #include "basics.h" 33 #include "basics.h"
34 #include "dialogs.h" 34 #include "dialogs.h"
35 #include "mainWindow.h"
35 36
36 // Is the crash catcher active now? 37 // Is the crash catcher active now?
37 static bool g_crashCatcherActive = false; 38 static bool g_crashCatcherActive = false;
38 39
39 // If an assertion failed, what was it? 40 // If an assertion failed, what was it?
56 if (g_crashCatcherActive) 57 if (g_crashCatcherActive)
57 { 58 {
58 printf ("caught signal while crash catcher is active!\n"); 59 printf ("caught signal while crash catcher is active!\n");
59 exit (149); 60 exit (149);
60 } 61 }
62
63 if (g_win != null)
64 g_win->hide();
61 65
62 const pid_t pid = getpid(); 66 const pid_t pid = getpid();
63 QProcess proc; 67 QProcess proc;
64 QTemporaryFile commandsFile; 68 QTemporaryFile commandsFile;
65 69
87 #endif 91 #endif
88 92
89 proc.waitForFinished (1000); 93 proc.waitForFinished (1000);
90 String output = String (proc.readAllStandardOutput()); 94 String output = String (proc.readAllStandardOutput());
91 String err = String (proc.readAllStandardError()); 95 String err = String (proc.readAllStandardError());
96 QFile f ("ldforge-crash.log");
97
98 if (f.open (QIODevice::WriteOnly))
99 {
100 fprint (f, format ("=== Program crashed with signal %1 ===\n\n%2"
101 "GDB stdout:\n%3\n"
102 "GDB stderr:\n%4\n",
103 sig, (not g_assertionFailure.isEmpty()) ? g_assertionFailure + "\n\n" : "", output, err));
104 f.close();
105 }
92 106
93 bombBox (format ("<h3>Program crashed with signal %1</h3>\n\n" 107 bombBox (format ("<h3>Program crashed with signal %1</h3>\n\n"
94 "%2" 108 "%2"
95 "<p><b>GDB <tt>stdout</tt>:</b></p><pre>%3</pre>\n" 109 "<p><b>GDB <tt>stdout</tt>:</b></p><pre>%3</pre>\n"
96 "<p><b>GDB <tt>stderr</tt>:</b></p><pre>%4</pre>", 110 "<p><b>GDB <tt>stderr</tt>:</b></p><pre>%4</pre>",
97 sig, (not g_assertionFailure.isEmpty()) ? g_assertionFailure : "", output, err)); 111 sig, g_assertionFailure, output, err));
98 } 112 }
99 113
100 // ============================================================================= 114 // =============================================================================
101 // 115 //
102 void initCrashCatcher() 116 void initCrashCatcher()

mercurial