diff --git a/.gitignore b/.gitignore index f8bf0a62..e1725423 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ qrc_* *.o *.swp *.pyc +*.a debian/*.debhelper debian/files debian/*.log @@ -17,6 +18,7 @@ debian/*.substvars debian/*/ /deploy/qt-*.tar.gz /deploy/Qt-* +/symbols # ignore ctags /tags diff --git a/build.sh b/build.sh index ab6e3b48..7d3428d9 100755 --- a/build.sh +++ b/build.sh @@ -48,6 +48,10 @@ until [ -z "$1" ]; do esac done +if [[ $OSTYPE = linux* ]]; then + cd src/breakpad && ./configure && make && cd ../.. +fi + cd src/qt && ./preconfig.sh --jobs $COMPILE_JOBS --qt-config "$QT_CFG" && cd ../.. src/qt/bin/qmake make -j$COMPILE_JOBS diff --git a/src/main.cpp b/src/main.cpp index a66acc7e..8ca481d1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,6 +32,10 @@ #include "env.h" #include "phantom.h" +#ifdef Q_OS_LINUX +#include "client/linux/handler/exception_handler.h" +#endif + #include #if QT_VERSION != QT_VERSION_CHECK(4, 8, 0) @@ -40,6 +44,10 @@ int main(int argc, char** argv, const char** envp) { +#ifdef Q_OS_LINUX + google_breakpad::ExceptionHandler eh("/tmp", NULL, Utils::exceptionHandler, NULL, true); +#endif + // Registering an alternative Message Handler qInstallMsgHandler(Utils::messageHandler); diff --git a/src/phantomjs.pro b/src/phantomjs.pro index a2685ace..b9188543 100644 --- a/src/phantomjs.pro +++ b/src/phantomjs.pro @@ -58,6 +58,11 @@ include(gif/gif.pri) include(mongoose/mongoose.pri) include(linenoise/linenoise.pri) +linux* { + INCLUDEPATH += $$PWD/breakpad/src + LIBS += $$PWD/breakpad/src/client/linux/libbreakpad_client.a +} + win32: RC_FILE = phantomjs_win.rc os2: RC_FILE = phantomjs_os2.rc diff --git a/src/qt/configure b/src/qt/configure index ad733594..e563cf04 100755 --- a/src/qt/configure +++ b/src/qt/configure @@ -7645,8 +7645,8 @@ else QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SVG" fi -if [ "$CFG_WEBKIT" != "no" ]; then - CFG_WEBKIT="$canBuildWebKit" +if [ "$canBuildWebKit" == "no" ]; then + CFG_WEBKIT="no" fi if [ "$CFG_WEBKIT" != "no" ]; then diff --git a/src/qt/src/3rdparty/webkit/Source/JavaScriptCore/JavaScriptCore.pro b/src/qt/src/3rdparty/webkit/Source/JavaScriptCore/JavaScriptCore.pro index a1091795..8b2146f7 100644 --- a/src/qt/src/3rdparty/webkit/Source/JavaScriptCore/JavaScriptCore.pro +++ b/src/qt/src/3rdparty/webkit/Source/JavaScriptCore/JavaScriptCore.pro @@ -22,7 +22,7 @@ contains(QT_CONFIG, embedded):CONFIG += embedded contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols unix:contains(QT_CONFIG, reduce_relocations):CONFIG += bsymbolic_functions -CONFIG(QTDIR_build) { +!CONFIG(webkit-debug):CONFIG(QTDIR_build) { # Remove the following 2 lines if you want debug information in JavaScriptCore CONFIG -= separate_debug_info CONFIG += no_debug_info diff --git a/src/utils.cpp b/src/utils.cpp index f9efadc9..cf5c6166 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -67,6 +67,15 @@ void Utils::messageHandler(QtMsgType type, const char *msg) } } +bool Utils::exceptionHandler(const char* dump_path, const char* minidump_id, void* context, bool succeeded) +{ + fprintf(stderr, "PhantomJS has crashed. Please file a bug report at " \ + "https://code.google.com/p/phantomjs/issues/entry and " \ + "attach the crash dump file: %s/%s.dmp\n", + dump_path, minidump_id); + return succeeded; +} + QVariant Utils::coffee2js(const QString &script) { return CSConverter::instance()->convert(script); diff --git a/src/utils.h b/src/utils.h index c195b992..cbc993ef 100644 --- a/src/utils.h +++ b/src/utils.h @@ -49,6 +49,7 @@ class Utils public: static void showUsage(); static void messageHandler(QtMsgType type, const char *msg); + static bool exceptionHandler(const char* dump_path, const char* minidump_id, void* context, bool succeeded); static QVariant coffee2js(const QString &script); static bool injectJsInFrame(const QString &jsFilePath, const QString &libraryPath, QWebFrame *targetFrame, const bool startingScript = false); static bool injectJsInFrame(const QString &jsFilePath, const Encoding &jsFileEnc, const QString &libraryPath, QWebFrame *targetFrame, const bool startingScript = false); @@ -57,6 +58,7 @@ public: static bool loadJSForDebug(const QString &jsFilePath, const Encoding &jsFileEnc, const QString &libraryPath, QWebFrame *targetFrame, const bool autorun = false); static bool loadJSForDebug(const QString &jsFilePath, const QString &libraryPath, QWebFrame *targetFrame, const bool autorun = false); static void cleanupFromDebug(); + private: static QString findScript(const QString &jsFilePath, const QString& libraryPath); static QString jsFromScriptFile(const QString& scriptPath, const Encoding& enc); diff --git a/tools/crash-report.sh b/tools/crash-report.sh new file mode 100755 index 00000000..be8abec6 --- /dev/null +++ b/tools/crash-report.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +`dirname $0`/../src/breakpad/src/processor/minidump_stackwalk $1 `dirname $0`/../symbols diff --git a/tools/dump-symbols.sh b/tools/dump-symbols.sh new file mode 100755 index 00000000..e053d67f --- /dev/null +++ b/tools/dump-symbols.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Generates debugging symbols for breakpad. qt and phantomjs must have +# been compiled in debug mode. So do: +# +# $ make distclean && cd src/qt && make clean && cd ../.. +# $ ./build.sh --qt-config "-debug -webkit-debug" +# $ tools/dump-symbols.sh +# +# To display the crash report: +# +# $ tools/crash-report.sh /tmp/5e2cc287-96c8-7a1b-59c79999-00fa22a2.dmp + +rm -r symbols/* + +files="" +files+="bin/phantomjs " +files+="src/qt/lib/libQtCore.so.4.8.0 " +files+="src/qt/lib/libQtWebKit.so.4.9.0 " +files+="src/qt/lib/libQtGui.so.4.8.0 " +files+="src/qt/lib/libQtNetwork.so.4.8.0" + +for file in $files; do + name=`basename $file` + src/breakpad/src/tools/linux/dump_syms/dump_syms $file > $name.sym + dir=symbols/$name/`head -n1 $name.sym | cut -d ' ' -f 4` + mkdir -p $dir + mv $name.sym $dir +done