From 10df0710774cad44404237f72e1c65088622d5db Mon Sep 17 00:00:00 2001 From: pajlada Date: Wed, 27 Jun 2018 23:06:37 +0000 Subject: [PATCH] Breakpad implementation (#535) * qBreakpad simple implementation * update chatterino.pro for linux * Add breakpad building script for linux --- .gitmodules | 3 +++ BUILDING_ON_WINDOWS.md | 5 +++++ chatterino.pro | 8 +++++++- lib/qBreakpad | 1 + src/main.cpp | 8 ++++++++ tools/build-breakpad-linux.sh | 14 ++++++++++++++ 6 files changed, 38 insertions(+), 1 deletion(-) create mode 160000 lib/qBreakpad create mode 100755 tools/build-breakpad-linux.sh diff --git a/.gitmodules b/.gitmodules index 3a7f6edb4..32042876c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -17,3 +17,6 @@ path = lib/websocketpp url = https://github.com/zaphoyd/websocketpp.git branch = develop +[submodule "lib/qBreakpad"] + path = lib/qBreakpad + url = https://github.com/jiakuan/qBreakpad.git diff --git a/BUILDING_ON_WINDOWS.md b/BUILDING_ON_WINDOWS.md index aa1b7746b..aaa8743c3 100644 --- a/BUILDING_ON_WINDOWS.md +++ b/BUILDING_ON_WINDOWS.md @@ -32,6 +32,11 @@ 2. Under Tools: - Select Qt Creator, and Qt Creator CDB Debugger Support +### Compile with Breakpad support (Optional) +1. Open up lib/qBreakpad/handler/handler.pro +2. Build it in whichever mode you wanna build Chatterino (Debug/Profile/Release) +3. Copy the newly built qBreakpad.lib to a folder you create: `lib/qBreakpad/build/handler` + # Windows (Using MSYS2, not recommended) Note: This guide is currently out of date and will not work as is. Note: This build will have some features missing from the build. diff --git a/chatterino.pro b/chatterino.pro index 247183cb6..489697723 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -17,6 +17,12 @@ DEFINES += QT_DEPRECATED_WARNINGS PRECOMPILED_HEADER = src/PrecompiledHeader.hpp CONFIG += precompile_header +useBreakpad { + LIBS += -L$$PWD/lib/qBreakpad/handler/build + include(lib/qBreakpad/qBreakpad.pri) + DEFINES += CHATTERINO_USE_BREAKPAD +} + # https://bugreports.qt.io/browse/QTBUG-27018 equals(QMAKE_CXX, "clang++")|equals(QMAKE_CXX, "g++") { TARGET = bin/chatterino @@ -444,4 +450,4 @@ win32-msvc* { linux { QMAKE_LFLAGS += -lrt -} +} \ No newline at end of file diff --git a/lib/qBreakpad b/lib/qBreakpad new file mode 160000 index 000000000..a4626c12e --- /dev/null +++ b/lib/qBreakpad @@ -0,0 +1 @@ +Subproject commit a4626c12e9ae6f02fc1ca7a4e399bd8307424103 diff --git a/src/main.cpp b/src/main.cpp index 2c81362a1..6848d702e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,6 +23,10 @@ #include #endif +#ifdef CHATTERINO_USE_BREAKPAD +#include +#endif + int runGui(QApplication &a, int argc, char *argv[]); void runNativeMessagingHost(); void installCustomPalette(); @@ -83,6 +87,10 @@ int runGui(QApplication &a, int argc, char *argv[]) app->construct(); +#ifdef CHATTERINO_USE_BREAKPAD + QBreakpadInstance.setDumpPath(app->paths->settingsFolderPath + "/Crashes"); +#endif + auto &pathMan = *app->paths; // Running file auto runningPath = pathMan.miscDirectory + "/running_" + pathMan.applicationFilePathHash; diff --git a/tools/build-breakpad-linux.sh b/tools/build-breakpad-linux.sh new file mode 100755 index 000000000..7d343ce6a --- /dev/null +++ b/tools/build-breakpad-linux.sh @@ -0,0 +1,14 @@ +#!/bin/bash +cd ../lib/qBreakpad + +echo "Updating qBreakpad's breakpad dependency version" +cd third_party/breakpad +git checkout 7b3afa9258e58a57ffbeb395d445811f92616ae9 +cd ../../ + +cd handler +mkdir build +cd build +qmake .. +echo "Building handler" +make -j8 && "Successfully built qBreakpad"