crashpad: detect when crashpad handler is missing
This commit is contained in:
@@ -71,49 +71,62 @@ bool LinuxExceptionHandler(int, siginfo_t*, ucontext_t*)
|
|||||||
|
|
||||||
bool InitializeCrashpad()
|
bool InitializeCrashpad()
|
||||||
{
|
{
|
||||||
QString exe_dir = QCoreApplication::applicationDirPath();
|
QString handler_fn;
|
||||||
|
|
||||||
|
// Determine filename of handler from platform
|
||||||
#ifdef OS_WIN
|
#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
|
#else
|
||||||
// FIXME: On Linux, probably should put this in a subdir so that it doesn't conflict with
|
handler_fn = QStringLiteral("crashpad_handler");
|
||||||
// anything else in /usr/bin
|
|
||||||
base::FilePath handler(QSTRING_TO_BASE_STRING(QDir(exe_dir).filePath(QStringLiteral("crashpad_handler"))));
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
base::FilePath reports_dir = GenerateReportPathForCrashpad();
|
// Generate absolute path
|
||||||
|
QString handler_abs_path = QDir(QCoreApplication::applicationDirPath()).filePath(handler_fn);
|
||||||
|
|
||||||
base::FilePath metrics_dir(QSTRING_TO_BASE_STRING(QDir(OLIVE_NAMESPACE::FileFunctions::GetTempFilePath()).filePath(QStringLiteral("metrics"))));
|
bool status = false;
|
||||||
|
|
||||||
// Metadata that will be posted to the server with the crash report map
|
if (QFileInfo::exists(handler_abs_path)) {
|
||||||
std::map<std::string, std::string> annotations;
|
base::FilePath handler(QSTRING_TO_BASE_STRING(handler_fn));
|
||||||
|
|
||||||
// Disable crashpad rate limiting so that all crashes have dmp files
|
base::FilePath reports_dir = GenerateReportPathForCrashpad();
|
||||||
std::vector<std::string> arguments;
|
|
||||||
arguments.push_back("--no-rate-limit");
|
|
||||||
arguments.push_back("--no-upload-gzip");
|
|
||||||
|
|
||||||
// Initialize Crashpad database
|
base::FilePath metrics_dir(QSTRING_TO_BASE_STRING(QDir(OLIVE_NAMESPACE::FileFunctions::GetTempFilePath()).filePath(QStringLiteral("metrics"))));
|
||||||
std::unique_ptr<crashpad::CrashReportDatabase> database = crashpad::CrashReportDatabase::Initialize(reports_dir);
|
|
||||||
if (database == NULL) return false;
|
|
||||||
|
|
||||||
// Disable automated crash uploads
|
// Metadata that will be posted to the server with the crash report map
|
||||||
crashpad::Settings *settings = database->GetSettings();
|
std::map<std::string, std::string> annotations;
|
||||||
if (settings == NULL) return false;
|
|
||||||
settings->SetUploadsEnabled(false);
|
// Disable crashpad rate limiting so that all crashes have dmp files
|
||||||
|
std::vector<std::string> arguments;
|
||||||
|
arguments.push_back("--no-rate-limit");
|
||||||
|
arguments.push_back("--no-upload-gzip");
|
||||||
|
|
||||||
|
// Initialize Crashpad database
|
||||||
|
std::unique_ptr<crashpad::CrashReportDatabase> database = crashpad::CrashReportDatabase::Initialize(reports_dir);
|
||||||
|
if (database == NULL) return false;
|
||||||
|
|
||||||
|
// Disable automated crash uploads
|
||||||
|
crashpad::Settings *settings = database->GetSettings();
|
||||||
|
if (settings == NULL) return false;
|
||||||
|
settings->SetUploadsEnabled(false);
|
||||||
|
|
||||||
|
// Start crash handler
|
||||||
|
client = new crashpad::CrashpadClient();
|
||||||
|
status = client->StartHandler(handler, reports_dir, metrics_dir,
|
||||||
|
"https://olivevideoeditor.org/crashpad/report.php",
|
||||||
|
annotations, arguments, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
// Start crash handler
|
|
||||||
client = new crashpad::CrashpadClient();
|
|
||||||
bool 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
|
// Override Crashpad exception filter with our own
|
||||||
|
if (status) {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
SetUnhandledExceptionFilter(Win32ExceptionHandler);
|
SetUnhandledExceptionFilter(Win32ExceptionHandler);
|
||||||
#elif defined(OS_LINUX)
|
#elif defined(OS_LINUX)
|
||||||
crashpad::CrashpadClient::SetFirstChanceExceptionHandler(LinuxExceptionHandler);
|
crashpad::CrashpadClient::SetFirstChanceExceptionHandler(LinuxExceptionHandler);
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
qWarning() << "Failed to start Crashpad, automatic crash reporting will be disabled";
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user