src/crashCatcher.cc

changeset 739
152b33a6d51b
parent 662
2f1bd9112408
child 765
6d8ca5219a57
equal deleted inserted replaced
738:16b63398aa1f 739:152b33a6d51b
35 35
36 // Is the crash catcher active now? 36 // Is the crash catcher active now?
37 static bool g_crashCatcherActive = false; 37 static bool g_crashCatcherActive = false;
38 38
39 // If an assertion failed, what was it? 39 // If an assertion failed, what was it?
40 static QString g_assertionFailure; 40 static String g_assertionFailure;
41 41
42 // List of signals to catch and crash on 42 // List of signals to catch and crash on
43 static QList<int> g_signalsToCatch ({ 43 static QList<int> g_signalsToCatch ({
44 SIGSEGV, // segmentation fault 44 SIGSEGV, // segmentation fault
45 SIGABRT, // abort() calls 45 SIGABRT, // abort() calls
66 g_crashCatcherActive = true; 66 g_crashCatcherActive = true;
67 67
68 if (commandsFile.open()) 68 if (commandsFile.open())
69 { 69 {
70 commandsFile.write (format ("attach %1\n", pid).toLocal8Bit()); 70 commandsFile.write (format ("attach %1\n", pid).toLocal8Bit());
71 commandsFile.write (QString ("backtrace full\n").toLocal8Bit()); 71 commandsFile.write (String ("backtrace full\n").toLocal8Bit());
72 commandsFile.write (QString ("detach\n").toLocal8Bit()); 72 commandsFile.write (String ("detach\n").toLocal8Bit());
73 commandsFile.write (QString ("quit").toLocal8Bit()); 73 commandsFile.write (String ("quit").toLocal8Bit());
74 commandsFile.flush(); 74 commandsFile.flush();
75 commandsFile.close(); 75 commandsFile.close();
76 } 76 }
77 77
78 QStringList args ({"-x", commandsFile.fileName()}); 78 QStringList args ({"-x", commandsFile.fileName()});
85 #ifdef Q_OS_LINUX 85 #ifdef Q_OS_LINUX
86 prctl (PR_SET_PTRACER, proc.pid(), 0, 0, 0); 86 prctl (PR_SET_PTRACER, proc.pid(), 0, 0, 0);
87 #endif 87 #endif
88 88
89 proc.waitForFinished (1000); 89 proc.waitForFinished (1000);
90 QString output = QString (proc.readAllStandardOutput()); 90 String output = String (proc.readAllStandardOutput());
91 QString err = QString (proc.readAllStandardError()); 91 String err = String (proc.readAllStandardError());
92 92
93 bombBox (format ("<h3>Program crashed with signal %1</h3>\n\n" 93 bombBox (format ("<h3>Program crashed with signal %1</h3>\n\n"
94 "%2" 94 "%2"
95 "<p><b>GDB <tt>stdout</tt>:</b></p><pre>%3</pre>\n" 95 "<p><b>GDB <tt>stdout</tt>:</b></p><pre>%3</pre>\n"
96 "<p><b>GDB <tt>stderr</tt>:</b></p><pre>%4</pre>", 96 "<p><b>GDB <tt>stderr</tt>:</b></p><pre>%4</pre>",
120 // signal handler, which will cause the usual bomb box with GDB diagnostics. 120 // signal handler, which will cause the usual bomb box with GDB diagnostics.
121 // Said prompt will embed the assertion failure information. 121 // Said prompt will embed the assertion failure information.
122 // 122 //
123 void assertionFailure (const char* file, int line, const char* funcname, const char* expr) 123 void assertionFailure (const char* file, int line, const char* funcname, const char* expr)
124 { 124 {
125 QString errmsg = format ( 125 String errmsg = format (
126 "<p><b>File</b>: <tt>%1</tt><br />" 126 "<p><b>File</b>: <tt>%1</tt><br />"
127 "<b>Line</b>: <tt>%2</tt><br />" 127 "<b>Line</b>: <tt>%2</tt><br />"
128 "<b>Function:</b> <tt>%3</tt></p>" 128 "<b>Function:</b> <tt>%3</tt></p>"
129 "<p>Assertion <b><tt>`%4'</tt></b> failed.</p>", 129 "<p>Assertion <b><tt>`%4'</tt></b> failed.</p>",
130 file, line, funcname, expr); 130 file, line, funcname, expr);

mercurial