mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Linux: Migrate from breakpad to crashpad (see issue #3249)
Renderer process crashes are currently only reported with `--no-sandbox`.
This commit is contained in:
@@ -52,6 +52,8 @@
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
#include "libcef/common/util_mac.h"
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
#include "libcef/common/util_linux.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
@@ -94,8 +96,7 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
command_line->GetSwitchValueASCII(switches::kProcessType);
|
||||
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
// Read the crash configuration file. Platforms using Breakpad also add a
|
||||
// command-line switch. On Windows this is done from chrome_elf.
|
||||
// Read the crash configuration file. On Windows this is done from chrome_elf.
|
||||
crash_reporting::BasicStartupComplete(command_line);
|
||||
#endif
|
||||
|
||||
@@ -355,6 +356,8 @@ void AlloyMainDelegate::PreSandboxStartup() {
|
||||
// Only override these paths when executing the main process.
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
util_mac::PreSandboxStartup();
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
util_linux::PreSandboxStartup();
|
||||
#endif
|
||||
|
||||
resource_util::OverrideDefaultDownloadDir();
|
||||
|
@@ -24,6 +24,12 @@
|
||||
#include "third_party/blink/public/common/switches.h"
|
||||
#include "ui/base/ui_base_switches.h"
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
#include "libcef/common/util_mac.h"
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
#include "libcef/common/util_linux.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
#include "libcef/common/util_mac.h"
|
||||
#endif
|
||||
@@ -58,8 +64,7 @@ bool ChromeMainDelegateCef::BasicStartupComplete(int* exit_code) {
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
// Read the crash configuration file. Platforms using Breakpad also add a
|
||||
// command-line switch. On Windows this is done from chrome_elf.
|
||||
// Read the crash configuration file. On Windows this is done from chrome_elf.
|
||||
crash_reporting::BasicStartupComplete(command_line);
|
||||
#endif
|
||||
|
||||
@@ -143,11 +148,13 @@ void ChromeMainDelegateCef::PreSandboxStartup() {
|
||||
const std::string& process_type =
|
||||
command_line->GetSwitchValueASCII(switches::kProcessType);
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
if (process_type.empty()) {
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
util_mac::PreSandboxStartup();
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
util_linux::PreSandboxStartup();
|
||||
#endif
|
||||
}
|
||||
#endif // BUILDFLAG(IS_MAC)
|
||||
|
||||
// Since this may be configured via CefSettings we override the value on
|
||||
// all platforms. We can't use the default implementation on macOS because
|
||||
|
@@ -615,22 +615,6 @@ void CefCrashReporterClient::GetProductNameAndVersion(std::string* product_name,
|
||||
*version = product_version_;
|
||||
}
|
||||
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
|
||||
base::FilePath CefCrashReporterClient::GetReporterLogFilename() {
|
||||
return base::FilePath(FILE_PATH_LITERAL("uploads.log"));
|
||||
}
|
||||
|
||||
bool CefCrashReporterClient::EnableBreakpadForProcess(
|
||||
const std::string& process_type) {
|
||||
return process_type == switches::kRendererProcess ||
|
||||
process_type == switches::kPpapiPluginProcess ||
|
||||
process_type == switches::kZygoteProcess ||
|
||||
process_type == switches::kGpuProcess;
|
||||
}
|
||||
|
||||
#endif // !BUILDFLAG(IS_MAC)
|
||||
|
||||
bool CefCrashReporterClient::GetCrashDumpLocation(base::FilePath* crash_dir) {
|
||||
// By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
|
||||
// location to write breakpad crash dumps can be set.
|
||||
@@ -654,21 +638,11 @@ bool CefCrashReporterClient::GetCollectStatsInSample() {
|
||||
return true;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
|
||||
bool CefCrashReporterClient::ReportingIsEnforcedByPolicy(
|
||||
bool* crashpad_enabled) {
|
||||
*crashpad_enabled = true;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
bool CefCrashReporterClient::IsRunningUnattended() {
|
||||
// Crash upload will only be enabled with Breakpad on Linux if this method
|
||||
// returns false.
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string CefCrashReporterClient::GetUploadUrl() {
|
||||
return server_url_;
|
||||
@@ -721,13 +695,6 @@ bool CefCrashReporterClient::EnableBrowserCrashForwarding() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
CefCrashReporterClient::ParameterMap CefCrashReporterClient::FilterParameters(
|
||||
const ParameterMap& parameters) {
|
||||
return crash_report_utils::FilterParameters(parameters);
|
||||
}
|
||||
#endif
|
||||
|
||||
// The new Crashpad Annotation API requires that annotations be declared using
|
||||
// static storage. We work around this limitation by defining a fixed amount of
|
||||
// storage for each key size and later substituting the actual key name during
|
||||
|
@@ -57,23 +57,13 @@ class CefCrashReporterClient : public crash_reporter::CrashReporterClient {
|
||||
void GetProductNameAndVersion(std::string* product_name,
|
||||
std::string* version,
|
||||
std::string* channel) override;
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
base::FilePath GetReporterLogFilename() override;
|
||||
bool EnableBreakpadForProcess(const std::string& process_type) override;
|
||||
#endif
|
||||
bool GetCrashDumpLocation(base::FilePath* crash_dir) override;
|
||||
#endif // BUILDFLAG(IS_POSIX)
|
||||
|
||||
// All of these methods must return true to enable crash report upload.
|
||||
bool GetCollectStatsConsent() override;
|
||||
bool GetCollectStatsInSample() override;
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
|
||||
bool ReportingIsEnforcedByPolicy(bool* crashpad_enabled) override;
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
bool IsRunningUnattended() override;
|
||||
#endif
|
||||
|
||||
std::string GetUploadUrl() override;
|
||||
void GetCrashOptionalArguments(std::vector<std::string>* arguments) override;
|
||||
@@ -87,10 +77,6 @@ class CefCrashReporterClient : public crash_reporter::CrashReporterClient {
|
||||
bool EnableBrowserCrashForwarding() override;
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
ParameterMap FilterParameters(const ParameterMap& parameters) override;
|
||||
#endif
|
||||
|
||||
// Set or clear a crash key value.
|
||||
bool SetCrashKeyValue(const base::StringPiece& key,
|
||||
const base::StringPiece& value);
|
||||
|
@@ -22,21 +22,16 @@
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "components/crash/core/app/crashpad.h"
|
||||
#include "components/crash/core/common/crash_keys.h"
|
||||
#include "content/public/common/content_paths.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
#include "base/lazy_instance.h"
|
||||
#include "components/crash/core/app/crashpad.h"
|
||||
#include "libcef/common/crash_reporter_client.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
#include "components/crash/core/app/breakpad_linux.h"
|
||||
#include "v8/include/v8-wasm-trap-handler-posix.h"
|
||||
#endif
|
||||
|
||||
namespace crash_reporting {
|
||||
|
||||
namespace {
|
||||
@@ -131,11 +126,10 @@ void InitCrashReporter(const base::CommandLine& command_line,
|
||||
|
||||
g_crash_reporting_enabled = true;
|
||||
#else // !BUILDFLAG(IS_MAC)
|
||||
|
||||
if (process_type != switches::kZygoteProcess) {
|
||||
// Crash reporting for subprocesses created using the zygote will be
|
||||
// initialized in ZygoteForked.
|
||||
breakpad::InitCrashReporter(process_type);
|
||||
crash_reporter::InitializeCrashpad(process_type.empty(), process_type);
|
||||
|
||||
g_crash_reporting_enabled = true;
|
||||
}
|
||||
@@ -196,10 +190,8 @@ void BasicStartupComplete(base::CommandLine* command_line) {
|
||||
CefCrashReporterClient* crash_client = g_crash_reporter_client.Pointer();
|
||||
if (crash_client->ReadCrashConfigFile()) {
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
// Breakpad requires this switch.
|
||||
command_line->AppendSwitch(switches::kEnableCrashReporter);
|
||||
|
||||
breakpad::SetFirstChanceExceptionHandler(v8::TryHandleWebAssemblyTrapPosix);
|
||||
// Crashpad requires this switch on Linux.
|
||||
command_line->AppendSwitch(switches::kEnableCrashpad);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -232,8 +224,8 @@ void ZygoteForked(base::CommandLine* command_line,
|
||||
const std::string& process_type) {
|
||||
CefCrashReporterClient* crash_client = g_crash_reporter_client.Pointer();
|
||||
if (crash_client->HasCrashConfigFile()) {
|
||||
// Breakpad requires this switch.
|
||||
command_line->AppendSwitch(switches::kEnableCrashReporter);
|
||||
// Crashpad requires this switch on Linux.
|
||||
command_line->AppendSwitch(switches::kEnableCrashpad);
|
||||
}
|
||||
|
||||
InitCrashReporter(*command_line, process_type);
|
||||
|
34
libcef/common/util_linux.cc
Normal file
34
libcef/common/util_linux.cc
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2022 The Chromium Embedded Framework Authors. Portions copyright
|
||||
// 2011 The Chromium Authors. All rights reserved. Use of this source code is
|
||||
// governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/common/util_linux.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/path_service.h"
|
||||
#include "content/public/common/content_paths.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
|
||||
namespace util_linux {
|
||||
|
||||
namespace {
|
||||
|
||||
void OverrideChildProcessPath() {
|
||||
base::FilePath child_process_path =
|
||||
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
|
||||
switches::kBrowserSubprocessPath);
|
||||
if (child_process_path.empty())
|
||||
return;
|
||||
|
||||
// Used by ChildProcessHost::GetChildPath and PlatformCrashpadInitialization.
|
||||
base::PathService::Override(content::CHILD_PROCESS_EXE, child_process_path);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void PreSandboxStartup() {
|
||||
OverrideChildProcessPath();
|
||||
}
|
||||
|
||||
} // namespace util_linux
|
16
libcef/common/util_linux.h
Normal file
16
libcef/common/util_linux.h
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright 2022 The Chromium Embedded Framework Authors. Portions copyright
|
||||
// 2011 The Chromium Authors. All rights reserved. Use of this source code is
|
||||
// governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_COMMON_UTIL_LINUX_H_
|
||||
#define CEF_LIBCEF_COMMON_UTIL_LINUX_H_
|
||||
#pragma once
|
||||
|
||||
namespace util_linux {
|
||||
|
||||
// Called from MainDelegate::PreSandboxStartup for the main process.
|
||||
void PreSandboxStartup();
|
||||
|
||||
} // namespace util_linux
|
||||
|
||||
#endif // CEF_LIBCEF_COMMON_UTIL_LINUX_H_
|
Reference in New Issue
Block a user