feat: support crashpad on linux (#29719)

This commit is contained in:
Jeremy Rose 2021-07-19 10:11:10 -07:00 committed by GitHub
parent 612361c4da
commit c9ba0d02d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 547 additions and 455 deletions

View file

@ -58,7 +58,8 @@
#endif
#if !defined(MAS_BUILD)
#include "components/crash/core/app/crashpad.h" // nogncheck
#include "components/crash/core/app/crash_switches.h" // nogncheck
#include "components/crash/core/app/crashpad.h" // nogncheck
#include "components/crash/core/common/crash_key.h"
#include "components/crash/core/common/crash_keys.h"
#include "shell/app/electron_crash_reporter_client.h"
@ -369,9 +370,19 @@ void ElectronMainDelegate::PreSandboxStartup() {
#endif
#if defined(OS_LINUX)
// Zygote needs to call InitCrashReporter() in RunZygote().
if (process_type != ::switches::kZygoteProcess && !process_type.empty()) {
ElectronCrashReporterClient::Create();
breakpad::InitCrashReporter(process_type);
if (crash_reporter::IsCrashpadEnabled()) {
if (command_line->HasSwitch(
crash_reporter::switches::kCrashpadHandlerPid)) {
crash_reporter::InitializeCrashpad(false, process_type);
crash_reporter::SetFirstChanceExceptionHandler(
v8::TryHandleWebAssemblyTrapPosix);
}
} else {
breakpad::InitCrashReporter(process_type);
}
}
#endif
@ -466,7 +477,16 @@ void ElectronMainDelegate::ZygoteForked() {
base::CommandLine::ForCurrentProcess();
std::string process_type =
command_line->GetSwitchValueASCII(::switches::kProcessType);
breakpad::InitCrashReporter(process_type);
if (crash_reporter::IsCrashpadEnabled()) {
if (command_line->HasSwitch(
crash_reporter::switches::kCrashpadHandlerPid)) {
crash_reporter::InitializeCrashpad(false, process_type);
crash_reporter::SetFirstChanceExceptionHandler(
v8::TryHandleWebAssemblyTrapPosix);
}
} else {
breakpad::InitCrashReporter(process_type);
}
// Reset the command line for the newly spawned process.
crash_keys::SetCrashKeysFromCommandLine(*command_line);