feat: support crashpad on linux (#29719)
This commit is contained in:
parent
612361c4da
commit
c9ba0d02d7
13 changed files with 547 additions and 455 deletions
|
@ -44,6 +44,7 @@
|
|||
#include "base/guid.h"
|
||||
#include "components/crash/core/app/breakpad_linux.h"
|
||||
#include "components/crash/core/common/crash_keys.h"
|
||||
#include "components/upload_list/combining_upload_list.h"
|
||||
#include "v8/include/v8-wasm-trap-handler-posix.h"
|
||||
#include "v8/include/v8.h"
|
||||
#endif
|
||||
|
@ -150,16 +151,29 @@ void Start(const std::string& submit_url,
|
|||
? "node"
|
||||
: command_line->GetSwitchValueASCII(::switches::kProcessType);
|
||||
#if defined(OS_LINUX)
|
||||
::crash_keys::SetMetricsClientIdFromGUID(GetClientId());
|
||||
auto& global_crash_keys = GetGlobalCrashKeysMutable();
|
||||
for (const auto& pair : global_extra) {
|
||||
global_crash_keys[pair.first] = pair.second;
|
||||
if (::crash_reporter::IsCrashpadEnabled()) {
|
||||
for (const auto& pair : extra)
|
||||
electron::crash_keys::SetCrashKey(pair.first, pair.second);
|
||||
{
|
||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||
::crash_reporter::InitializeCrashpad(process_type.empty(), process_type);
|
||||
}
|
||||
if (ignore_system_crash_handler) {
|
||||
crashpad::CrashpadInfo::GetCrashpadInfo()
|
||||
->set_system_crash_reporter_forwarding(crashpad::TriState::kDisabled);
|
||||
}
|
||||
} else {
|
||||
::crash_keys::SetMetricsClientIdFromGUID(GetClientId());
|
||||
auto& global_crash_keys = GetGlobalCrashKeysMutable();
|
||||
for (const auto& pair : global_extra) {
|
||||
global_crash_keys[pair.first] = pair.second;
|
||||
}
|
||||
for (const auto& pair : extra)
|
||||
electron::crash_keys::SetCrashKey(pair.first, pair.second);
|
||||
for (const auto& pair : global_extra)
|
||||
electron::crash_keys::SetCrashKey(pair.first, pair.second);
|
||||
breakpad::InitCrashReporter(process_type);
|
||||
}
|
||||
for (const auto& pair : extra)
|
||||
electron::crash_keys::SetCrashKey(pair.first, pair.second);
|
||||
for (const auto& pair : global_extra)
|
||||
electron::crash_keys::SetCrashKey(pair.first, pair.second);
|
||||
breakpad::InitCrashReporter(process_type);
|
||||
#elif defined(OS_MAC)
|
||||
for (const auto& pair : extra)
|
||||
electron::crash_keys::SetCrashKey(pair.first, pair.second);
|
||||
|
@ -203,7 +217,20 @@ scoped_refptr<UploadList> CreateCrashUploadList() {
|
|||
base::PathService::Get(electron::DIR_CRASH_DUMPS, &crash_dir_path);
|
||||
base::FilePath upload_log_path =
|
||||
crash_dir_path.AppendASCII(CrashUploadList::kReporterLogFilename);
|
||||
return base::MakeRefCounted<TextLogUploadList>(upload_log_path);
|
||||
scoped_refptr<UploadList> result =
|
||||
base::MakeRefCounted<TextLogUploadList>(upload_log_path);
|
||||
if (crash_reporter::IsCrashpadEnabled()) {
|
||||
// Crashpad keeps the records of C++ crashes (segfaults, etc) in its
|
||||
// internal database. The JavaScript error reporter writes JS error upload
|
||||
// records to the older text format. Combine the two to present a complete
|
||||
// list to the user.
|
||||
// TODO(nornagon): what is "The JavaScript error reporter", and do we care
|
||||
// about it?
|
||||
std::vector<scoped_refptr<UploadList>> uploaders = {
|
||||
base::MakeRefCounted<CrashUploadListCrashpad>(), std::move(result)};
|
||||
result = base::MakeRefCounted<CombiningUploadList>(std::move(uploaders));
|
||||
}
|
||||
return result;
|
||||
#endif // defined(OS_MAC) || defined(OS_WIN)
|
||||
}
|
||||
|
||||
|
|
|
@ -298,6 +298,12 @@ breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
|
|||
}
|
||||
|
||||
int GetCrashSignalFD(const base::CommandLine& command_line) {
|
||||
if (crash_reporter::IsCrashpadEnabled()) {
|
||||
int fd;
|
||||
pid_t pid;
|
||||
return crash_reporter::GetHandlerSocket(&fd, &pid) ? fd : -1;
|
||||
}
|
||||
|
||||
// Extensions have the same process type as renderers.
|
||||
if (command_line.HasSwitch(extensions::switches::kExtensionProcess)) {
|
||||
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr;
|
||||
|
@ -526,20 +532,37 @@ void ElectronBrowserClient::AppendExtraCommandLineSwitches(
|
|||
|
||||
#if defined(OS_LINUX)
|
||||
bool enable_crash_reporter = false;
|
||||
enable_crash_reporter = breakpad::IsCrashReporterEnabled();
|
||||
if (crash_reporter::IsCrashpadEnabled()) {
|
||||
command_line->AppendSwitch(::switches::kEnableCrashpad);
|
||||
enable_crash_reporter = true;
|
||||
|
||||
int fd;
|
||||
pid_t pid;
|
||||
|
||||
if (crash_reporter::GetHandlerSocket(&fd, &pid)) {
|
||||
command_line->AppendSwitchASCII(
|
||||
crash_reporter::switches::kCrashpadHandlerPid,
|
||||
base::NumberToString(pid));
|
||||
}
|
||||
} else {
|
||||
enable_crash_reporter = breakpad::IsCrashReporterEnabled();
|
||||
}
|
||||
|
||||
if (enable_crash_reporter) {
|
||||
std::string switch_value =
|
||||
api::crash_reporter::GetClientId() + ",no_channel";
|
||||
command_line->AppendSwitchASCII(::switches::kEnableCrashReporter,
|
||||
switch_value);
|
||||
for (const auto& pair : api::crash_reporter::GetGlobalCrashKeys()) {
|
||||
if (!switch_value.empty())
|
||||
switch_value += ",";
|
||||
switch_value += pair.first;
|
||||
switch_value += "=";
|
||||
switch_value += pair.second;
|
||||
if (!crash_reporter::IsCrashpadEnabled()) {
|
||||
for (const auto& pair : api::crash_reporter::GetGlobalCrashKeys()) {
|
||||
if (!switch_value.empty())
|
||||
switch_value += ",";
|
||||
switch_value += pair.first;
|
||||
switch_value += "=";
|
||||
switch_value += pair.second;
|
||||
}
|
||||
command_line->AppendSwitchASCII(switches::kGlobalCrashKeys, switch_value);
|
||||
}
|
||||
command_line->AppendSwitchASCII(switches::kGlobalCrashKeys, switch_value);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue