Title: [105267] trunk
Revision
105267
Author
[email protected]
Date
2012-01-18 05:35:57 -0800 (Wed, 18 Jan 2012)

Log Message

[Qt] Consolidate layout test crash logging
https://bugs.webkit.org/show_bug.cgi?id=75088

Reviewed by Simon Hausmann.

Move backtrace generating logic into WTFReportBacktrace
and add a way to deinstall signal handlers if we know
that we have already printed the backtrace.

.:

* Source/qtwebkit-export.map:

Source/_javascript_Core:

* _javascript_Core.exp:
* _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
* wtf/Assertions.cpp:
(WTFLogLocker::WTFReportBacktrace):
(WTFLogLocker::WTFSetCrashHook):
(WTFLogLocker::WTFInvokeCrashHook):
* wtf/Assertions.h:

Tools:

* DumpRenderTree/qt/main.cpp:
(crashHandler):
(setupSignalHandlers):
(WTFCrashHook):
(main):
* WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp:
(WTR::crashHandler):
(WTR::setupSignalHandlers):
(WTR::crashHook):
(WTR::InjectedBundle::platformInitialize):

Modified Paths

Diff

Modified: trunk/ChangeLog (105266 => 105267)


--- trunk/ChangeLog	2012-01-18 13:26:54 UTC (rev 105266)
+++ trunk/ChangeLog	2012-01-18 13:35:57 UTC (rev 105267)
@@ -1,3 +1,16 @@
+2012-01-18  Balazs Kelemen  <[email protected]>
+
+        [Qt] Consolidate layout test crash logging
+        https://bugs.webkit.org/show_bug.cgi?id=75088
+
+        Reviewed by Simon Hausmann.
+
+        Move backtrace generating logic into WTFReportBacktrace
+        and add a way to deinstall signal handlers if we know
+        that we have already printed the backtrace.
+
+        * Source/qtwebkit-export.map:
+
 2012-01-18  Tor Arne Vestbø  <[email protected]>
 
         [Qt] Move OTHER_FILES from WebKit.pro to Tools.pro

Modified: trunk/Source/_javascript_Core/ChangeLog (105266 => 105267)


--- trunk/Source/_javascript_Core/ChangeLog	2012-01-18 13:26:54 UTC (rev 105266)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-01-18 13:35:57 UTC (rev 105267)
@@ -1,3 +1,22 @@
+2012-01-18  Balazs Kelemen  <[email protected]>
+
+        [Qt] Consolidate layout test crash logging
+        https://bugs.webkit.org/show_bug.cgi?id=75088
+
+        Reviewed by Simon Hausmann.
+
+        Move backtrace generating logic into WTFReportBacktrace
+        and add a way to deinstall signal handlers if we know
+        that we have already printed the backtrace.
+
+        * _javascript_Core.exp:
+        * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
+        * wtf/Assertions.cpp:
+        (WTFLogLocker::WTFReportBacktrace):
+        (WTFLogLocker::WTFSetCrashHook):
+        (WTFLogLocker::WTFInvokeCrashHook):
+        * wtf/Assertions.h:
+
 2012-01-17  Geoffrey Garen  <[email protected]>
 
         Factored out some code into a helper function.

Modified: trunk/Source/_javascript_Core/_javascript_Core.exp (105266 => 105267)


--- trunk/Source/_javascript_Core/_javascript_Core.exp	2012-01-18 13:26:54 UTC (rev 105266)
+++ trunk/Source/_javascript_Core/_javascript_Core.exp	2012-01-18 13:35:57 UTC (rev 105267)
@@ -91,6 +91,7 @@
 _JSWeakObjectMapRemove
 _JSWeakObjectMapSet
 _WTFGetBacktrace
+_WTFInvokeCrashHook
 _WTFLog
 _WTFLogVerbose
 _WTFReportArgumentAssertionFailure
@@ -99,6 +100,7 @@
 _WTFReportBacktrace
 _WTFReportError
 _WTFReportFatalError
+_WTFSetCrashHook
 __ZN14OpaqueJSString6createERKN3JSC7UStringE
 __ZN3JSC10HandleHeap12writeBarrierEPNS_7JSValueERKS1_
 __ZN3JSC10HandleHeap4growEv

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (105266 => 105267)


--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2012-01-18 13:26:54 UTC (rev 105266)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2012-01-18 13:35:57 UTC (rev 105267)
@@ -367,6 +367,7 @@
     ?writeBarrier@HandleHeap@JSC@@QAEXPAVJSValue@2@ABV32@@Z
     ?yield@WTF@@YAXXZ
     WTFGetBacktrace
+    WTFInvokeCrashHook
     WTFLog
     WTFLogVerbose
     WTFReportArgumentAssertionFailure
@@ -374,3 +375,4 @@
     WTFReportAssertionFailureWithMessage
     WTFReportBacktrace
     WTFReportError
+    WTFSetCrashHook

Modified: trunk/Source/_javascript_Core/wtf/Assertions.cpp (105266 => 105267)


--- trunk/Source/_javascript_Core/wtf/Assertions.cpp	2012-01-18 13:26:54 UTC (rev 105266)
+++ trunk/Source/_javascript_Core/wtf/Assertions.cpp	2012-01-18 13:35:57 UTC (rev 105267)
@@ -272,6 +272,16 @@
 #endif
 }
 
+#if OS(DARWIN) || OS(LINUX)
+#  if PLATFORM(QT) || PLATFORM(GTK)
+#    if defined(__GLIBC__) && !defined(__UCLIBC__)
+#      define WTF_USE_BACKTRACE_SYMBOLS 1
+#    endif
+#  else
+#    define WTF_USE_DLADDR 1
+#  endif
+#endif
+
 void WTFReportBacktrace()
 {
     static const int framesToShow = 31;
@@ -281,11 +291,18 @@
 
     WTFGetBacktrace(samples, &frames);
 
+#if USE(BACKTRACE_SYMBOLS)
+    char** symbols = backtrace_symbols(samples, frames);
+    if (!symbols)
+        return;
+#endif
+
     for (int i = framesToSkip; i < frames; ++i) {
         const char* mangledName = 0;
         char* cxaDemangled = 0;
-
-#if !PLATFORM(GTK) && !PLATFORM(QT) && (OS(DARWIN) || OS(LINUX))
+#if USE(BACKTRACE_SYMBOLS)
+        mangledName = symbols[i];
+#elif USE(DLADDR)
         Dl_info info;
         if (dladdr(samples[i], &info) && info.dli_sname)
             mangledName = info.dli_sname;
@@ -299,8 +316,28 @@
             printf_stderr_common("%-3d %p\n", frameNumber, samples[i]);
         free(cxaDemangled);
     }
+
+#if USE(BACKTRACE_SYMBOLS)
+    free(symbols);
+#endif
 }
 
+#undef WTF_USE_BACKTRACE_SYMBOLS
+#undef WTF_USE_DLADDR
+
+static WTFCrashHookFunction globalHook = 0;
+
+void WTFSetCrashHook(WTFCrashHookFunction function)
+{
+    globalHook = function;
+}
+
+void WTFInvokeCrashHook()
+{
+    if (globalHook)
+        globalHook();
+}
+
 void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...)
 {
 #if PLATFORM(BLACKBERRY)

Modified: trunk/Source/_javascript_Core/wtf/Assertions.h (105266 => 105267)


--- trunk/Source/_javascript_Core/wtf/Assertions.h	2012-01-18 13:26:54 UTC (rev 105266)
+++ trunk/Source/_javascript_Core/wtf/Assertions.h	2012-01-18 13:35:57 UTC (rev 105267)
@@ -147,6 +147,10 @@
 WTF_EXPORT_PRIVATE void WTFGetBacktrace(void** stack, int* size);
 WTF_EXPORT_PRIVATE void WTFReportBacktrace();
 
+typedef void (*WTFCrashHookFunction)();
+WTF_EXPORT_PRIVATE void WTFSetCrashHook(WTFCrashHookFunction);
+WTF_EXPORT_PRIVATE void WTFInvokeCrashHook();
+
 #ifdef __cplusplus
 }
 #endif
@@ -163,12 +167,14 @@
 #if COMPILER(CLANG)
 #define CRASH() do { \
     WTFReportBacktrace(); \
+    WTFInvokeCrashHook(); \
     *(int *)(uintptr_t)0xbbadbeef = 0; \
     __builtin_trap(); \
 } while (false)
 #else
 #define CRASH() do { \
     WTFReportBacktrace(); \
+    WTFInvokeCrashHook(); \
     *(int *)(uintptr_t)0xbbadbeef = 0; \
     ((void(*)())0)(); /* More reliable, but doesn't say BBADBEEF */ \
 } while (false)

Modified: trunk/Source/qtwebkit-export.map (105266 => 105267)


--- trunk/Source/qtwebkit-export.map	2012-01-18 13:26:54 UTC (rev 105266)
+++ trunk/Source/qtwebkit-export.map	2012-01-18 13:35:57 UTC (rev 105267)
@@ -40,6 +40,8 @@
     WTFReportArgumentAssertionFailure;
     WTFReportAssertionFailure;
     WTFReportBacktrace;
+    WTFInvokeCrashHook;
+    WTFSetCrashHook;
     extern "C++" {
         # WebKit 1 API
         *QGraphicsWebView;

Modified: trunk/Tools/ChangeLog (105266 => 105267)


--- trunk/Tools/ChangeLog	2012-01-18 13:26:54 UTC (rev 105266)
+++ trunk/Tools/ChangeLog	2012-01-18 13:35:57 UTC (rev 105267)
@@ -1,3 +1,25 @@
+2012-01-18  Balazs Kelemen  <[email protected]>
+
+        [Qt] Consolidate layout test crash logging
+        https://bugs.webkit.org/show_bug.cgi?id=75088
+
+        Reviewed by Simon Hausmann.
+
+        Move backtrace generating logic into WTFReportBacktrace
+        and add a way to deinstall signal handlers if we know
+        that we have already printed the backtrace.
+
+        * DumpRenderTree/qt/main.cpp:
+        (crashHandler):
+        (setupSignalHandlers):
+        (WTFCrashHook):
+        (main):
+        * WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp:
+        (WTR::crashHandler):
+        (WTR::setupSignalHandlers):
+        (WTR::crashHook):
+        (WTR::InjectedBundle::platformInitialize):
+
 2012-01-18  Ilya Tikhonovsky  <[email protected]>
 
         Unreviewed build fix after r105256.

Modified: trunk/Tools/DumpRenderTree/qt/main.cpp (105266 => 105267)


--- trunk/Tools/DumpRenderTree/qt/main.cpp	2012-01-18 13:26:54 UTC (rev 105266)
+++ trunk/Tools/DumpRenderTree/qt/main.cpp	2012-01-18 13:35:57 UTC (rev 105267)
@@ -53,9 +53,8 @@
 #include <limits.h>
 #include <signal.h>
 
-#if defined(__GLIBC__) && !defined(__UCLIBC__)
-#include <execinfo.h>
-#endif
+#include <wtf/ExportMacros.h>
+#include <wtf/Assertions.h>
 
 void messageHandler(QtMsgType type, const char *message)
 {
@@ -93,38 +92,31 @@
     fflush(stderr);
 }
 
-QString get_backtrace() {
-    QString s;
+#if HAVE(SIGNAL_H)
+typedef void (*SignalHandler)(int);
 
-#if defined(__GLIBC__) && !defined(__UCLIBC__)
-    void* array[256];
-    size_t size; /* number of stack frames */
+static NO_RETURN void crashHandler(int sig)
+{
+    WTFReportBacktrace();
+    exit(128 + sig);
+}
 
-    size = backtrace(array, 256);
-
-    if (!size)
-        return s;
-
-    char** strings = backtrace_symbols(array, size);
-    for (int i = 0; i < int(size); ++i) {
-        s += QString::number(i) +
-             QLatin1String(": ") +
-             QLatin1String(strings[i]) + QLatin1String("\n");
-    }
-
-    if (strings)
-        free (strings);
-#endif
-
-    return s;
+static void setupSignalHandlers(SignalHandler handler)
+{
+    signal(SIGILL, handler);    /* 4:   illegal instruction (not reset when caught) */
+    signal(SIGTRAP, handler);   /* 5:   trace trap (not reset when caught) */
+    signal(SIGFPE, handler);    /* 8:   floating point exception */
+    signal(SIGBUS, handler);    /* 10:  bus error */
+    signal(SIGSEGV, handler);   /* 11:  segmentation violation */
+    signal(SIGSYS, handler);    /* 12:  bad argument to system call */
+    signal(SIGPIPE, handler);   /* 13:  write on a pipe with no reader */
+    signal(SIGXCPU, handler);   /* 24:  exceeded CPU time limit */
+    signal(SIGXFSZ, handler);   /* 25:  exceeded file size limit */
 }
 
-#if HAVE(SIGNAL_H)
-static NO_RETURN void crashHandler(int sig)
+static void WTFCrashHook()
 {
-    fprintf(stderr, "%s\n", strsignal(sig));
-    fprintf(stderr, "%s\n", get_backtrace().toLatin1().constData());
-    exit(128 + sig);
+    setupSignalHandlers(SIG_DFL);
 }
 #endif
 
@@ -175,15 +167,8 @@
     QApplication::setFont(QWidget().font());
 
 #if HAVE(SIGNAL_H)
-    signal(SIGILL, crashHandler);    /* 4:   illegal instruction (not reset when caught) */
-    signal(SIGTRAP, crashHandler);   /* 5:   trace trap (not reset when caught) */
-    signal(SIGFPE, crashHandler);    /* 8:   floating point exception */
-    signal(SIGBUS, crashHandler);    /* 10:  bus error */
-    signal(SIGSEGV, crashHandler);   /* 11:  segmentation violation */
-    signal(SIGSYS, crashHandler);    /* 12:  bad argument to system call */
-    signal(SIGPIPE, crashHandler);   /* 13:  write on a pipe with no reader */
-    signal(SIGXCPU, crashHandler);   /* 24:  exceeded CPU time limit */
-    signal(SIGXFSZ, crashHandler);   /* 25:  exceeded file size limit */
+    setupSignalHandlers(&crashHandler);
+    WTFSetCrashHook(&WTFCrashHook);
 #endif
 
     QStringList args = app.arguments();

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp (105266 => 105267)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp	2012-01-18 13:26:54 UTC (rev 105266)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp	2012-01-18 13:35:57 UTC (rev 105267)
@@ -31,43 +31,39 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <wtf/AlwaysInline.h>
+#include <wtf/Assertions.h>
 
 #if HAVE(SIGNAL_H)
 #include <signal.h>
 #endif
 
-#if defined(__GLIBC__) && !defined(__UCLIBC__)
-#include <execinfo.h>
-#endif
-
 namespace WTR {
 
-static inline void printBacktrace()
+#if HAVE(SIGNAL_H)
+typedef void (*SignalHandler)(int);
+
+static NO_RETURN void crashHandler(int sig)
 {
-#if defined(__GLIBC__) && !defined(__UCLIBC__)
-    void* frames[256];
-    size_t size = backtrace(frames, 256);
-    if (!size)
-        return;
+    WTFReportBacktrace();
+    exit(128 + sig);
+}
 
-    char** symbols = backtrace_symbols(frames, size);
-    if (!symbols)
-        return;
-
-    for (unsigned i = 0; i < size; ++i)
-        fprintf(stderr, "%u: %s\n", i, symbols[i]);
-
-    fflush(stderr);
-    free(symbols);
-#endif
+static void setupSignalHandlers(SignalHandler handler)
+{
+    signal(SIGILL, handler);    /* 4:   illegal instruction (not reset when caught) */
+    signal(SIGTRAP, handler);   /* 5:   trace trap (not reset when caught) */
+    signal(SIGFPE, handler);    /* 8:   floating point exception */
+    signal(SIGBUS, handler);    /* 10:  bus error */
+    signal(SIGSEGV, handler);   /* 11:  segmentation violation */
+    signal(SIGSYS, handler);    /* 12:  bad argument to system call */
+    signal(SIGPIPE, handler);   /* 13:  write on a pipe with no reader */
+    signal(SIGXCPU, handler);   /* 24:  exceeded CPU time limit */
+    signal(SIGXFSZ, handler);   /* 25:  exceeded file size limit */
 }
 
-#if HAVE(SIGNAL_H)
-static NO_RETURN void crashHandler(int signal)
+static void crashHook()
 {
-    fprintf(stderr, "%s\n", strsignal(signal));
-    printBacktrace();
-    exit(128 + signal);
+    setupSignalHandlers(SIG_DFL);
 }
 #endif
 
@@ -77,15 +73,8 @@
         return;
 
 #if HAVE(SIGNAL_H)
-    signal(SIGILL, crashHandler);    /* 4:   illegal instruction (not reset when caught) */
-    signal(SIGTRAP, crashHandler);   /* 5:   trace trap (not reset when caught) */
-    signal(SIGFPE, crashHandler);    /* 8:   floating point exception */
-    signal(SIGBUS, crashHandler);    /* 10:  bus error */
-    signal(SIGSEGV, crashHandler);   /* 11:  segmentation violation */
-    signal(SIGSYS, crashHandler);    /* 12:  bad argument to system call */
-    signal(SIGPIPE, crashHandler);   /* 13:  write on a pipe with no reader */
-    signal(SIGXCPU, crashHandler);   /* 24:  exceeded CPU time limit */
-    signal(SIGXFSZ, crashHandler);   /* 25:  exceeded file size limit */
+    setupSignalHandlers(&crashHandler);
+    WTFSetCrashHook(&crashHook);
 #endif
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to