- Revision
- 124215
- Author
- commit-qu...@webkit.org
- Date
- 2012-07-31 09:42:20 -0700 (Tue, 31 Jul 2012)
Log Message
Add a mechanism to dump the stack trace in case of a crash
https://bugs.webkit.org/show_bug.cgi?id=92666
Patch by Thiago Marcos P. Santos <thiago.san...@intel.com> on 2012-07-31
Reviewed by Csaba Osztrogonác.
Source/WTF:
Unix based ports can make use of signal handlers to dump the stack
trace in case of a crash. This is specially handy when a test crashes on
the bot without hitting an assertion, we might have a chance to see
some insightful information at the reports.
* wtf/Assertions.cpp:
* wtf/Assertions.h:
Tools:
Move crash signal handlers to WTFInstallReportBacktraceOnCrashHook()
and eliminate some duplicated code.
* DumpRenderTree/qt/main.cpp:
(main):
* WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp:
(WTR::InjectedBundle::platformInitialize):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (124214 => 124215)
--- trunk/Source/WTF/ChangeLog 2012-07-31 16:21:12 UTC (rev 124214)
+++ trunk/Source/WTF/ChangeLog 2012-07-31 16:42:20 UTC (rev 124215)
@@ -1,3 +1,18 @@
+2012-07-31 Thiago Marcos P. Santos <thiago.san...@intel.com>
+
+ Add a mechanism to dump the stack trace in case of a crash
+ https://bugs.webkit.org/show_bug.cgi?id=92666
+
+ Reviewed by Csaba Osztrogonác.
+
+ Unix based ports can make use of signal handlers to dump the stack
+ trace in case of a crash. This is specially handy when a test crashes on
+ the bot without hitting an assertion, we might have a chance to see
+ some insightful information at the reports.
+
+ * wtf/Assertions.cpp:
+ * wtf/Assertions.h:
+
2012-07-31 Stephen Chenney <schen...@chromium.org>
xmlserializer strips xlink from xlink:html svg image tag
Modified: trunk/Source/WTF/wtf/Assertions.cpp (124214 => 124215)
--- trunk/Source/WTF/wtf/Assertions.cpp 2012-07-31 16:21:12 UTC (rev 124214)
+++ trunk/Source/WTF/wtf/Assertions.cpp 2012-07-31 16:42:20 UTC (rev 124215)
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007-2009 Torch Mobile, Inc.
+ * Copyright (C) 2011 University of Szeged. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -33,12 +34,17 @@
#include "config.h"
#include "Assertions.h"
+#include "Compiler.h"
#include "OwnArrayPtr.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
+#if HAVE(SIGNAL_H)
+#include <signal.h>
+#endif
+
#if PLATFORM(MAC)
#include <CoreFoundation/CFString.h>
#include <asl.h>
@@ -355,6 +361,42 @@
globalHook();
}
+#if HAVE(SIGNAL_H)
+static NO_RETURN void dumpBacktraceSignalHandler(int sig)
+{
+ WTFReportBacktrace();
+ exit(128 + sig);
+}
+
+static void installSignalHandlersForFatalErrors(void (*handler)(int))
+{
+ 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.
+}
+
+static void resetSignalHandlersForFatalErrors()
+{
+ installSignalHandlersForFatalErrors(SIG_DFL);
+}
+#endif
+
+void WTFInstallReportBacktraceOnCrashHook()
+{
+#if HAVE(SIGNAL_H)
+ // Needed otherwise we are going to dump the stack trace twice
+ // in case we hit an assertion.
+ WTFSetCrashHook(&resetSignalHandlersForFatalErrors);
+ installSignalHandlersForFatalErrors(&dumpBacktraceSignalHandler);
+#endif
+}
+
void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...)
{
#if PLATFORM(BLACKBERRY)
Modified: trunk/Source/WTF/wtf/Assertions.h (124214 => 124215)
--- trunk/Source/WTF/wtf/Assertions.h 2012-07-31 16:21:12 UTC (rev 124214)
+++ trunk/Source/WTF/wtf/Assertions.h 2012-07-31 16:42:20 UTC (rev 124215)
@@ -152,6 +152,7 @@
typedef void (*WTFCrashHookFunction)();
WTF_EXPORT_PRIVATE void WTFSetCrashHook(WTFCrashHookFunction);
WTF_EXPORT_PRIVATE void WTFInvokeCrashHook();
+WTF_EXPORT_PRIVATE void WTFInstallReportBacktraceOnCrashHook();
#ifdef __cplusplus
}
Modified: trunk/Tools/ChangeLog (124214 => 124215)
--- trunk/Tools/ChangeLog 2012-07-31 16:21:12 UTC (rev 124214)
+++ trunk/Tools/ChangeLog 2012-07-31 16:42:20 UTC (rev 124215)
@@ -1,3 +1,18 @@
+2012-07-31 Thiago Marcos P. Santos <thiago.san...@intel.com>
+
+ Add a mechanism to dump the stack trace in case of a crash
+ https://bugs.webkit.org/show_bug.cgi?id=92666
+
+ Reviewed by Csaba Osztrogonác.
+
+ Move crash signal handlers to WTFInstallReportBacktraceOnCrashHook()
+ and eliminate some duplicated code.
+
+ * DumpRenderTree/qt/main.cpp:
+ (main):
+ * WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp:
+ (WTR::InjectedBundle::platformInitialize):
+
2012-07-31 Jochen Eisinger <joc...@chromium.org>
[chromium] move EventSender into TestRunner.a
Modified: trunk/Tools/DumpRenderTree/qt/main.cpp (124214 => 124215)
--- trunk/Tools/DumpRenderTree/qt/main.cpp 2012-07-31 16:21:12 UTC (rev 124214)
+++ trunk/Tools/DumpRenderTree/qt/main.cpp 2012-07-31 16:42:20 UTC (rev 124215)
@@ -53,7 +53,6 @@
#endif
#include <limits.h>
-#include <signal.h>
#include <wtf/ExportMacros.h>
#include <wtf/Assertions.h>
@@ -95,34 +94,6 @@
fflush(stderr);
}
-#if HAVE(SIGNAL_H)
-typedef void (*SignalHandler)(int);
-
-static NO_RETURN void crashHandler(int sig)
-{
- WTFReportBacktrace();
- exit(128 + sig);
-}
-
-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 */
-}
-
-static void WTFCrashHook()
-{
- setupSignalHandlers(SIG_DFL);
-}
-#endif
-
int main(int argc, char* argv[])
{
#ifdef Q_OS_WIN
@@ -174,10 +145,7 @@
QApplication::setFont(QWidget().font());
#endif
-#if HAVE(SIGNAL_H)
- setupSignalHandlers(&crashHandler);
- WTFSetCrashHook(&WTFCrashHook);
-#endif
+ WTFInstallReportBacktraceOnCrashHook();
QStringList args = app.arguments();
if (args.count() < (!suppressQtDebugOutput ? 3 : 2)) {
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp (124214 => 124215)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp 2012-07-31 16:21:12 UTC (rev 124214)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp 2012-07-31 16:42:20 UTC (rev 124215)
@@ -34,40 +34,8 @@
#include <wtf/AlwaysInline.h>
#include <wtf/Assertions.h>
-#if HAVE(SIGNAL_H)
-#include <signal.h>
-#endif
-
namespace WTR {
-#if HAVE(SIGNAL_H)
-typedef void (*SignalHandler)(int);
-
-static NO_RETURN void crashHandler(int sig)
-{
- WTFReportBacktrace();
- exit(128 + sig);
-}
-
-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 */
-}
-
-static void crashHook()
-{
- setupSignalHandlers(SIG_DFL);
-}
-#endif
-
void InjectedBundle::platformInitialize(WKTypeRef)
{
QWindowsStyle* styleForTests = new QWindowsStyle;
@@ -79,10 +47,7 @@
if (qgetenv("QT_WEBKIT2_DEBUG") == "1")
return;
-#if HAVE(SIGNAL_H)
- setupSignalHandlers(&crashHandler);
- WTFSetCrashHook(&crashHook);
-#endif
+ WTFInstallReportBacktraceOnCrashHook();
}
} // namespace WTR