diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-12-08 12:41:18 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-12-08 12:41:18 +0100 |
commit | a118a7b6de720906e383d52aee056fbe55eb680d (patch) | |
tree | 4eb528ae7f994fd7f0d4163e27862bc86d40905c /src/main.cpp | |
parent | Configuration: parse command line after parsing config file (diff) | |
download | smolbote-a118a7b6de720906e383d52aee056fbe55eb680d.tar.xz |
Split crash handler code off main
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 40 |
1 files changed, 3 insertions, 37 deletions
diff --git a/src/main.cpp b/src/main.cpp index 2a0d355..e718722 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,6 +13,7 @@ #include "session/session.h" #include "session/sessiondialog.h" #include "util.h" +#include "crashhandler.h" #include "version.h" #include <QFile> #include <QLibraryInfo> @@ -34,41 +35,6 @@ #error "You have enabled Breakpad integration, but Breakpad was not found." #endif -#ifdef CONFIG_USEBREAKPAD - -struct BreakpadContext { - char *handler = nullptr; -}; - -#ifdef Q_OS_LINUX -#include <client/linux/handler/exception_handler.h> -#include <unistd.h> - -// bool filter_callback (void*) -// --> true: continue processing and write a minidump - -static bool dumpCallback(const google_breakpad::MinidumpDescriptor &descriptor, void *context, bool succeeded) -{ - printf("Dump path: %s\n", descriptor.path()); - - auto *ctx = static_cast<BreakpadContext *>(context); - if(ctx != nullptr) { - if(ctx->handler != nullptr) { - // fork and run 'handler master:commit path.dmp' - pid_t pid = fork(); - if(pid == 0) { - char buffer[256]; - snprintf(buffer, 256, "%s %s %s", ctx->handler, poi_Build, descriptor.path()); - execlp("/bin/sh", "/bin/sh", "-c", buffer, (char *)nullptr); - } - } - } - - return succeeded; -} -#endif // Q_OS_LINUX -#endif // CONFIG_USEBREAKPAD - int main(int argc, char **argv) { // a beautiful hack to be able to write to stdout on Windows @@ -140,7 +106,7 @@ int main(int argc, char **argv) const std::string crashpath = config->value<std::string>("browser.crash.path").value_or("/tmp"); assert(!crashpath.empty()); - BreakpadContext ctx; + CrashHandler::BreakpadContext ctx; google_breakpad::MinidumpDescriptor descriptor(crashpath.c_str()); const auto crashHandler = config->value<std::string>("browser.crash.handler"); @@ -152,7 +118,7 @@ int main(int argc, char **argv) } // minidump descriptor, filter callback, minidump callback, callback_context, install handler, server_fd - google_breakpad::ExceptionHandler eh(descriptor, nullptr, dumpCallback, &ctx, true, -1); + google_breakpad::ExceptionHandler eh(descriptor, nullptr, CrashHandler::dumpCallback, &ctx, true, -1); #ifdef QT_DEBUG qDebug("Installed breakpad exception handler (path=%s)", crashpath.c_str()); |