crashpad: detect when crashpad handler is missing

This commit is contained in:
itsmattkc
2020-09-24 23:56:58 +10:00
parent 3855da2335
commit 654370425d
+19 -6
View File
@@ -71,16 +71,23 @@ bool LinuxExceptionHandler(int, siginfo_t*, ucontext_t*)
bool InitializeCrashpad()
{
QString exe_dir = QCoreApplication::applicationDirPath();
QString handler_fn;
// Determine filename of handler from platform
#ifdef OS_WIN
base::FilePath handler(QSTRING_TO_BASE_STRING(QDir(exe_dir).filePath(QStringLiteral("crashpad_handler.exe"))));
handler_fn = QStringLiteral("crashpad_handler.exe");
#else
// FIXME: On Linux, probably should put this in a subdir so that it doesn't conflict with
// anything else in /usr/bin
base::FilePath handler(QSTRING_TO_BASE_STRING(QDir(exe_dir).filePath(QStringLiteral("crashpad_handler"))));
handler_fn = QStringLiteral("crashpad_handler");
#endif
// Generate absolute path
QString handler_abs_path = QDir(QCoreApplication::applicationDirPath()).filePath(handler_fn);
bool status = false;
if (QFileInfo::exists(handler_abs_path)) {
base::FilePath handler(QSTRING_TO_BASE_STRING(handler_fn));
base::FilePath reports_dir = GenerateReportPathForCrashpad();
base::FilePath metrics_dir(QSTRING_TO_BASE_STRING(QDir(OLIVE_NAMESPACE::FileFunctions::GetTempFilePath()).filePath(QStringLiteral("metrics"))));
@@ -104,16 +111,22 @@ bool InitializeCrashpad()
// Start crash handler
client = new crashpad::CrashpadClient();
bool status = client->StartHandler(handler, reports_dir, metrics_dir,
status = client->StartHandler(handler, reports_dir, metrics_dir,
"https://olivevideoeditor.org/crashpad/report.php",
annotations, arguments, true, true);
}
// Override Crashpad exception filter with our own
if (status) {
#if defined(OS_WIN)
SetUnhandledExceptionFilter(Win32ExceptionHandler);
#elif defined(OS_LINUX)
crashpad::CrashpadClient::SetFirstChanceExceptionHandler(LinuxExceptionHandler);
#endif
} else {
qWarning() << "Failed to start Crashpad, automatic crash reporting will be disabled";
}
return status;
}