aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-09-28 16:15:01 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-09-28 16:15:01 +0200
commite3c605a796b6f09c6b38a206fd110992ff5d1e4c (patch)
tree5de62ffd772d0010944d19c67c8e92d1d98a59fb /src/main.cpp
parentbreakpad: Use system breakpad by default (diff)
downloadsmolbote-e3c605a796b6f09c6b38a206fd110992ff5d1e4c.tar.xz
breakpad: try to write session on crash
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f3ddeb9..e7fdcee 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,22 +22,34 @@
#endif
#ifdef BreakpadEnabled
+#ifdef Q_OS_LINUX
#include <client/linux/handler/exception_handler.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());
+
+ if(auto *app = static_cast<Browser *>(context); app != nullptr) {
+ auto session = app->session();
+ QJsonDocument doc(session);
+ QFile sessionFile(QString("%1.json").arg(QString::fromStdString(descriptor.path())));
+ if(sessionFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ sessionFile.write(qUtf8Printable(doc.toJson()));
+ sessionFile.flush();
+ sessionFile.close();
+ }
+ }
+
return succeeded;
}
+#endif // Q_OS_LINUX
#endif
int main(int argc, char **argv)
{
-#ifdef BreakpadEnabled
- google_breakpad::MinidumpDescriptor descriptor("/tmp");
- google_breakpad::ExceptionHandler eh(descriptor, NULL, dumpCallback, NULL, true, -1);
-#endif
-
// a beautiful hack to be able to write to stdout on Windows
#ifdef _WIN32
if(AttachConsole(ATTACH_PARENT_PROCESS)) {
@@ -116,6 +128,13 @@ int main(int argc, char **argv)
// set this, otherwise the webview becomes black when using a stylesheet
app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
+#ifdef BreakpadEnabled
+ google_breakpad::MinidumpDescriptor descriptor("/tmp");
+
+ // minidump descriptor, filter callback, minidump callback, callback_context, install handler, server_fd
+ google_breakpad::ExceptionHandler eh(descriptor, nullptr, dumpCallback, &app, true, -1);
+#endif
+
// translator
if(config->exists("browser.locale")) {
auto *translator = new QTranslator(&app);