1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*
* This file is part of smolbote. It's copyrighted by the contributors recorded
* in the version control history of the file, available from its original
* location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
*
* SPDX-License-Identifier: GPL-3.0
*/
#include "crashhandler.h"
#include "version.h"
#include <QByteArray>
#include <client/linux/handler/exception_handler.h>
#include <unistd.h>
// bool filter_callback (void*)
// --> true: continue processing and write a minidump
static bool minidumpCb(const google_breakpad::MinidumpDescriptor &descriptor, void *context, bool succeeded)
{
printf("Dump path: %s\n", descriptor.path());
auto *ctx = static_cast<CrashHandler::Context *>(context);
if(ctx != nullptr) {
if(!ctx->handler.empty()) {
// fork and run 'handler master:commit path.dmp'
pid_t pid = fork();
if(pid == 0) {
// pathname program argument ... nullptr
execlp(ctx->handler.c_str(),
ctx->handler.c_str(), "--crashd", ctx->dumppath.c_str(), "-c", descriptor.path(), poi_Version,
(char *)nullptr);
}
}
}
return succeeded;
}
bool CrashHandler::install_handler(CrashHandler::Context &ctx)
{
if(ctx.dumppath.empty())
return false;
// Disable Chromium's crash handler so breakpad can capture crashes instead.
// This has to be done before QtWebEngine gets initialized.
const auto chromiumFlags = qgetenv("QTWEBENGINE_CHROMIUM_FLAGS");
if(!chromiumFlags.contains("disable-in-process-stack-traces")) {
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", chromiumFlags + " --disable-in-process-stack-traces");
}
google_breakpad::MinidumpDescriptor descriptor(ctx.dumppath.c_str());
// minidump descriptor, filter callback, minidump callback, callback_context, install handler, server_fd
new google_breakpad::ExceptionHandler(descriptor, nullptr, minidumpCb, &ctx, true, -1);
return true;
}
|