Integrate Google Breakpad crash reporter. Linux only for now.

1.6
Jon Leighton 2012-06-05 20:22:12 +01:00
parent 0fa15e51c9
commit 8f7ee0ecd8
10 changed files with 65 additions and 3 deletions

2
.gitignore vendored
View File

@ -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

View File

@ -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

View File

@ -32,6 +32,10 @@
#include "env.h"
#include "phantom.h"
#ifdef Q_OS_LINUX
#include "client/linux/handler/exception_handler.h"
#endif
#include <QApplication>
#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);

View File

@ -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

4
src/qt/configure vendored
View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

3
tools/crash-report.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
`dirname $0`/../src/breakpad/src/processor/minidump_stackwalk $1 `dirname $0`/../symbols

29
tools/dump-symbols.sh Executable file
View File

@ -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