mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-02 20:26:59 +01: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:
parent
8fc6aced6c
commit
c38d62b233
19
BUILD.gn
19
BUILD.gn
@ -903,6 +903,7 @@ static_library("libcef_static") {
|
||||
"//third_party/blink/public:blink",
|
||||
"//third_party/brotli:dec",
|
||||
"//third_party/cld_3/src/src:cld_3",
|
||||
"//third_party/crashpad/crashpad/handler",
|
||||
"//third_party/hunspell",
|
||||
"//third_party/leveldatabase",
|
||||
"//third_party/libxml:libxml",
|
||||
@ -975,6 +976,8 @@ static_library("libcef_static") {
|
||||
"libcef/browser/osr/browser_platform_delegate_osr_linux.h",
|
||||
"libcef/browser/printing/print_dialog_linux.cc",
|
||||
"libcef/browser/printing/print_dialog_linux.h",
|
||||
"libcef/common/util_linux.h",
|
||||
"libcef/common/util_linux.cc",
|
||||
]
|
||||
|
||||
if (ozone_platform_x11) {
|
||||
@ -1017,26 +1020,10 @@ static_library("libcef_static") {
|
||||
]
|
||||
}
|
||||
|
||||
if (is_win || is_mac) {
|
||||
deps += [ "//third_party/crashpad/crashpad/handler" ]
|
||||
}
|
||||
|
||||
if (ozone_platform_x11) {
|
||||
deps += [ "//ui/events/devices/x11" ]
|
||||
}
|
||||
|
||||
if (is_posix && !is_mac) {
|
||||
sources += [
|
||||
"libcef/common/cef_crash_report_utils.cc",
|
||||
"libcef/common/cef_crash_report_utils.h",
|
||||
]
|
||||
|
||||
deps += [
|
||||
"//components/crash/core/app",
|
||||
"//components/crash/content/browser",
|
||||
]
|
||||
}
|
||||
|
||||
if (v8_use_external_startup_data && use_v8_context_snapshot) {
|
||||
deps += [ "//tools/v8_context_snapshot" ]
|
||||
}
|
||||
|
@ -143,17 +143,14 @@
|
||||
#include "ui/base/ui_base_switches.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
#include "base/debug/leak_annotations.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "components/crash/content/browser/crash_handler_host_linux.h"
|
||||
#include "components/crash/core/app/breakpad_linux.h"
|
||||
#include "content/public/common/content_descriptors.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
#include "net/ssl/client_cert_store_mac.h"
|
||||
#include "services/video_capture/public/mojom/constants.mojom.h"
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
#include "components/crash/core/app/crash_switches.h"
|
||||
#include "components/crash/core/app/crashpad.h"
|
||||
#include "content/public/common/content_descriptors.h"
|
||||
#include "libcef/common/crash_reporting.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
@ -409,59 +406,13 @@ class CefQuotaPermissionContext : public content::QuotaPermissionContext {
|
||||
};
|
||||
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
|
||||
const std::string& process_type) {
|
||||
base::FilePath dumps_path;
|
||||
base::PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path);
|
||||
{
|
||||
ANNOTATE_SCOPED_MEMORY_LEAK;
|
||||
// Uploads will only occur if a non-empty crash URL is specified in
|
||||
// AlloyMainDelegate::InitCrashReporter.
|
||||
breakpad::CrashHandlerHostLinux* crash_handler =
|
||||
new breakpad::CrashHandlerHostLinux(process_type, dumps_path,
|
||||
true /* upload */);
|
||||
crash_handler->StartUploaderThread();
|
||||
return crash_handler;
|
||||
}
|
||||
}
|
||||
|
||||
int GetCrashSignalFD(const base::CommandLine& command_line) {
|
||||
if (!breakpad::IsCrashReporterEnabled())
|
||||
int GetCrashSignalFD() {
|
||||
if (!crash_reporting::Enabled())
|
||||
return -1;
|
||||
|
||||
// Extensions have the same process type as renderers.
|
||||
if (command_line.HasSwitch(extensions::switches::kExtensionProcess)) {
|
||||
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr;
|
||||
if (!crash_handler)
|
||||
crash_handler = CreateCrashHandlerHost("extension");
|
||||
return crash_handler->GetDeathSignalSocket();
|
||||
}
|
||||
|
||||
std::string process_type =
|
||||
command_line.GetSwitchValueASCII(switches::kProcessType);
|
||||
|
||||
if (process_type == switches::kRendererProcess) {
|
||||
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr;
|
||||
if (!crash_handler)
|
||||
crash_handler = CreateCrashHandlerHost(process_type);
|
||||
return crash_handler->GetDeathSignalSocket();
|
||||
}
|
||||
|
||||
if (process_type == switches::kPpapiPluginProcess) {
|
||||
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr;
|
||||
if (!crash_handler)
|
||||
crash_handler = CreateCrashHandlerHost(process_type);
|
||||
return crash_handler->GetDeathSignalSocket();
|
||||
}
|
||||
|
||||
if (process_type == switches::kGpuProcess) {
|
||||
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr;
|
||||
if (!crash_handler)
|
||||
crash_handler = CreateCrashHandlerHost(process_type);
|
||||
return crash_handler->GetDeathSignalSocket();
|
||||
}
|
||||
|
||||
return -1;
|
||||
int fd;
|
||||
pid_t pid;
|
||||
return crash_reporter::GetHandlerSocket(&fd, &pid) ? fd : -1;
|
||||
}
|
||||
#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
|
||||
@ -797,7 +748,7 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
if (process_type == switches::kZygoteProcess) {
|
||||
if (browser_cmd->HasSwitch(switches::kBrowserSubprocessPath)) {
|
||||
// Force use of the sub-process executable path for the zygote process.
|
||||
@ -815,7 +766,17 @@ void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
|
||||
base::size(kSwitchNames));
|
||||
}
|
||||
#endif // BUILDFLAG(IS_LINUX)
|
||||
|
||||
if (crash_reporting::Enabled()) {
|
||||
int fd;
|
||||
pid_t pid;
|
||||
if (crash_reporter::GetHandlerSocket(&fd, &pid)) {
|
||||
command_line->AppendSwitchASCII(
|
||||
crash_reporter::switches::kCrashpadHandlerPid,
|
||||
base::NumberToString(pid));
|
||||
}
|
||||
}
|
||||
#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
|
||||
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
|
||||
if (app.get()) {
|
||||
@ -1132,17 +1093,17 @@ AlloyContentBrowserClient::WillCreateURLLoaderRequestInterceptors(
|
||||
return interceptors;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
void AlloyContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
|
||||
const base::CommandLine& command_line,
|
||||
int child_process_id,
|
||||
content::PosixFileDescriptorInfo* mappings) {
|
||||
int crash_signal_fd = GetCrashSignalFD(command_line);
|
||||
int crash_signal_fd = GetCrashSignalFD();
|
||||
if (crash_signal_fd >= 0) {
|
||||
mappings->Share(kCrashDumpSignal, crash_signal_fd);
|
||||
}
|
||||
}
|
||||
#endif // BUILDFLAG(IS_LINUX)
|
||||
#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
|
||||
void AlloyContentBrowserClient::ExposeInterfacesToRenderer(
|
||||
service_manager::BinderRegistry* registry,
|
||||
|
@ -137,7 +137,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
|
||||
const scoped_refptr<network::SharedURLLoaderFactory>&
|
||||
network_loader_factory) override;
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
void GetAdditionalMappedFilesForChildProcess(
|
||||
const base::CommandLine& command_line,
|
||||
int child_process_id,
|
||||
|
@ -21,12 +21,14 @@
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "components/crash/core/app/crash_switches.h"
|
||||
#include "content/app/content_main_runner_impl.h"
|
||||
#include "content/browser/scheduler/browser_task_executor.h"
|
||||
#include "content/public/app/content_main.h"
|
||||
#include "content/public/app/content_main_runner.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "third_party/crashpad/crashpad/handler/handler_main.h"
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include <Objbase.h>
|
||||
@ -35,11 +37,6 @@
|
||||
#include "sandbox/win/src/sandbox_types.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
|
||||
#include "components/crash/core/app/crash_switches.h"
|
||||
#include "third_party/crashpad/crashpad/handler/handler_main.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
enum class RuntimeType {
|
||||
@ -65,16 +62,14 @@ std::unique_ptr<CefMainRunnerDelegate> MakeDelegate(
|
||||
}
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
|
||||
|
||||
// Based on components/crash/core/app/run_as_crashpad_handler_win.cc
|
||||
// Remove the "--type=crashpad-handler" command-line flag that will otherwise
|
||||
// confuse the crashpad handler.
|
||||
// Chrome uses an embedded crashpad handler on Windows only and imports this
|
||||
// function via the existing "run_as_crashpad_handler" target defined in
|
||||
// components/crash/core/app/BUILD.gn. CEF uses an embedded handler on both
|
||||
// Windows and macOS so we define the function here instead of using the
|
||||
// existing target (because we can't use that target on macOS).
|
||||
// components/crash/core/app/BUILD.gn. CEF uses an embedded handler on all
|
||||
// platforms so we define the function here instead of using the existing
|
||||
// target (because we can't use that target on macOS).
|
||||
int RunAsCrashpadHandler(const base::CommandLine& command_line) {
|
||||
base::CommandLine::StringVector argv = command_line.argv();
|
||||
const base::CommandLine::StringType process_type =
|
||||
@ -88,8 +83,8 @@ int RunAsCrashpadHandler(const base::CommandLine& command_line) {
|
||||
}),
|
||||
argv.end());
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
// HandlerMain on macOS uses the system version of getopt_long which expects
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
// HandlerMain on POSIX uses the system version of getopt_long which expects
|
||||
// the first argument to be the program name.
|
||||
argv.insert(argv.begin(), command_line.GetProgram().value());
|
||||
#endif
|
||||
@ -111,8 +106,6 @@ int RunAsCrashpadHandler(const base::CommandLine& command_line) {
|
||||
argv_as_utf8.get(), nullptr);
|
||||
}
|
||||
|
||||
#endif // BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
|
||||
|
||||
} // namespace
|
||||
|
||||
// Used to run the UI on a separate thread.
|
||||
@ -327,13 +320,11 @@ int CefMainRunner::RunAsHelperProcess(const CefMainArgs& args,
|
||||
|
||||
int result;
|
||||
|
||||
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
|
||||
if (process_type == crash_reporter::switches::kCrashpadHandler) {
|
||||
result = RunAsCrashpadHandler(command_line);
|
||||
main_delegate->AfterExecuteProcess();
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Execute the secondary process.
|
||||
content::ContentMainParams main_params(
|
||||
|
@ -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_
|
@ -135,98 +135,8 @@ index e2d53ac83dde0..6ac76e407a748 100644
|
||||
// Sets the kNumSwitches key and the set of keys named using kSwitchFormat based
|
||||
// on the given |command_line|.
|
||||
void SetCrashKeysFromCommandLine(const base::CommandLine& command_line);
|
||||
diff --git components/crash/core/app/breakpad_linux.cc components/crash/core/app/breakpad_linux.cc
|
||||
index 823e49a234e3d..3f0f95a330bf4 100644
|
||||
--- components/crash/core/app/breakpad_linux.cc
|
||||
+++ components/crash/core/app/breakpad_linux.cc
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "base/base_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/debug/dump_without_crashing.h"
|
||||
+#include "base/debug/leak_annotations.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/linux_util.h"
|
||||
@@ -721,7 +722,7 @@ bool CrashDone(const MinidumpDescriptor& minidump,
|
||||
info.process_type_length = 7;
|
||||
info.distro = base::g_linux_distro;
|
||||
info.distro_length = my_strlen(base::g_linux_distro);
|
||||
- info.upload = upload;
|
||||
+ info.upload = upload && g_upload_url;
|
||||
info.process_start_time = g_process_start_time;
|
||||
info.oom_size = base::g_oom_size;
|
||||
info.pid = g_pid;
|
||||
@@ -1735,10 +1736,27 @@ void HandleCrashDump(const BreakpadInfo& info) {
|
||||
GetCrashReporterClient()->GetProductNameAndVersion(&product_name, &version);
|
||||
|
||||
writer.AddBoundary();
|
||||
- writer.AddPairString("prod", product_name);
|
||||
+ writer.AddPairString("product", product_name);
|
||||
+ writer.AddBoundary();
|
||||
+ writer.AddPairString("version", version);
|
||||
writer.AddBoundary();
|
||||
- writer.AddPairString("ver", version);
|
||||
+
|
||||
+#if defined(ARCH_CPU_ARM_FAMILY)
|
||||
+#if defined(ARCH_CPU_32_BITS)
|
||||
+ const char* platform = "linuxarm";
|
||||
+#elif defined(ARCH_CPU_64_BITS)
|
||||
+ const char* platform = "linuxarm64";
|
||||
+#endif
|
||||
+#else
|
||||
+#if defined(ARCH_CPU_32_BITS)
|
||||
+ const char* platform = "linux32";
|
||||
+#elif defined(ARCH_CPU_64_BITS)
|
||||
+ const char* platform = "linux64";
|
||||
+#endif
|
||||
+#endif // defined(ARCH_CPU_ARM_FAMILY)
|
||||
+ writer.AddPairString("platform", platform);
|
||||
writer.AddBoundary();
|
||||
+
|
||||
if (info.pid > 0) {
|
||||
char pid_value_buf[kUint64StringSize];
|
||||
uint64_t pid_value_len = my_uint64_len(info.pid);
|
||||
@@ -1855,6 +1873,9 @@ void HandleCrashDump(const BreakpadInfo& info) {
|
||||
crash_reporter::internal::TransitionalCrashKeyStorage;
|
||||
CrashKeyStorage::Iterator crash_key_iterator(*info.crash_keys);
|
||||
const CrashKeyStorage::Entry* entry;
|
||||
+
|
||||
+ crash_reporter::CrashReporterClient::ParameterMap parameters;
|
||||
+
|
||||
while ((entry = crash_key_iterator.Next())) {
|
||||
size_t key_size, value_size;
|
||||
// Check for malformed messages.
|
||||
@@ -1865,7 +1886,13 @@ void HandleCrashDump(const BreakpadInfo& info) {
|
||||
? CrashKeyStorage::value_size - 1
|
||||
: my_strlen(entry->value);
|
||||
|
||||
- writer.AddPairData(entry->key, key_size, entry->value, value_size);
|
||||
+ parameters.insert(std::make_pair(std::string{entry->key, key_size}, std::string{entry->value, value_size}));
|
||||
+ }
|
||||
+ if (!parameters.empty())
|
||||
+ parameters = GetCrashReporterClient()->FilterParameters(parameters);
|
||||
+
|
||||
+ for (const auto& param : parameters) {
|
||||
+ writer.AddPairData(param.first.data(), param.first.size(), param.second.data(), param.second.size());
|
||||
writer.AddBoundary();
|
||||
writer.Flush();
|
||||
}
|
||||
diff --git components/crash/core/app/breakpad_linux.h components/crash/core/app/breakpad_linux.h
|
||||
index 2f0d4c555506a..c537846b21568 100644
|
||||
--- components/crash/core/app/breakpad_linux.h
|
||||
+++ components/crash/core/app/breakpad_linux.h
|
||||
@@ -20,6 +20,9 @@ extern void InitCrashReporter(const std::string& process_type);
|
||||
// Sets the product/distribution channel crash key.
|
||||
void SetChannelCrashKey(const std::string& channel);
|
||||
|
||||
+// Set the crash server URL.
|
||||
+void SetCrashServerURL(const std::string& url);
|
||||
+
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
extern void InitCrashKeysForTesting();
|
||||
|
||||
diff --git components/crash/core/app/crash_reporter_client.cc components/crash/core/app/crash_reporter_client.cc
|
||||
index 82b7f241e2618..d3cd5524bb253 100644
|
||||
index 82b7f241e2618..525f1efe5aa6a 100644
|
||||
--- components/crash/core/app/crash_reporter_client.cc
|
||||
+++ components/crash/core/app/crash_reporter_client.cc
|
||||
@@ -89,7 +89,7 @@ bool CrashReporterClient::GetShouldDumpLargerDumps() {
|
||||
@ -283,23 +193,18 @@ index 82b7f241e2618..d3cd5524bb253 100644
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
unsigned int CrashReporterClient::GetCrashDumpPercentage() {
|
||||
return 100;
|
||||
@@ -203,9 +227,11 @@ bool CrashReporterClient::ShouldMonitorCrashHandlerExpensively() {
|
||||
@@ -203,9 +227,4 @@ bool CrashReporterClient::ShouldMonitorCrashHandlerExpensively() {
|
||||
return false;
|
||||
}
|
||||
|
||||
-bool CrashReporterClient::EnableBreakpadForProcess(
|
||||
- const std::string& process_type) {
|
||||
- return false;
|
||||
+#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
+CrashReporterClient::ParameterMap
|
||||
+CrashReporterClient::FilterParameters(const ParameterMap& parameters) {
|
||||
+ return parameters;
|
||||
}
|
||||
+#endif
|
||||
|
||||
-}
|
||||
-
|
||||
} // namespace crash_reporter
|
||||
diff --git components/crash/core/app/crash_reporter_client.h components/crash/core/app/crash_reporter_client.h
|
||||
index 24e53fa62c2c4..68011566b5723 100644
|
||||
index 24e53fa62c2c4..ffc72f79d67b0 100644
|
||||
--- components/crash/core/app/crash_reporter_client.h
|
||||
+++ components/crash/core/app/crash_reporter_client.h
|
||||
@@ -5,7 +5,9 @@
|
||||
@ -337,7 +242,7 @@ index 24e53fa62c2c4..68011566b5723 100644
|
||||
#endif
|
||||
|
||||
// The location where minidump files should be written. Returns true if
|
||||
@@ -206,6 +210,27 @@ class CrashReporterClient {
|
||||
@@ -206,6 +210,20 @@ class CrashReporterClient {
|
||||
|
||||
// Returns true if breakpad should run in the given process type.
|
||||
virtual bool EnableBreakpadForProcess(const std::string& process_type);
|
||||
@ -354,13 +259,6 @@ index 24e53fa62c2c4..68011566b5723 100644
|
||||
+ // Returns true if forwarding of crashes to the system crash reporter is
|
||||
+ // enabled for the browser process.
|
||||
+ virtual bool EnableBrowserCrashForwarding();
|
||||
+#endif
|
||||
+
|
||||
+#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
||||
+ // Provides an oportunity to modify the parameters that will be sent with a
|
||||
+ // crash upload.
|
||||
+ using ParameterMap = std::map<std::string, std::string>;
|
||||
+ virtual ParameterMap FilterParameters(const ParameterMap& parameters);
|
||||
+#endif
|
||||
};
|
||||
|
||||
@ -379,6 +277,79 @@ index 6da6be46cee4a..5e3067c081867 100644
|
||||
crashpad::CrashpadInfo::GetCrashpadInfo()
|
||||
->set_system_crash_reporter_forwarding(crashpad::TriState::kDisabled);
|
||||
}
|
||||
diff --git components/crash/core/app/crashpad_linux.cc components/crash/core/app/crashpad_linux.cc
|
||||
index dc2b18b322350..be84c0d0d1d7a 100644
|
||||
--- components/crash/core/app/crashpad_linux.cc
|
||||
+++ components/crash/core/app/crashpad_linux.cc
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "components/crash/core/app/crash_reporter_client.h"
|
||||
#include "components/crash/core/app/crash_switches.h"
|
||||
#include "content/public/common/content_descriptors.h"
|
||||
+#include "content/public/common/content_paths.h"
|
||||
#include "sandbox/linux/services/namespace_sandbox.h"
|
||||
#include "third_party/crashpad/crashpad/client/crashpad_client.h"
|
||||
#include "third_party/crashpad/crashpad/client/crashpad_info.h"
|
||||
@@ -117,11 +118,10 @@ bool PlatformCrashpadInitialization(
|
||||
crash_reporter_client->GetCrashDumpLocation(database_path);
|
||||
crash_reporter_client->GetCrashMetricsLocation(&metrics_path);
|
||||
|
||||
+ // Use the same main (default) or subprocess helper exe.
|
||||
base::FilePath handler_path;
|
||||
- if (!base::PathService::Get(base::DIR_EXE, &handler_path)) {
|
||||
- return false;
|
||||
- }
|
||||
- handler_path = handler_path.Append("chrome_crashpad_handler");
|
||||
+ base::PathService::Get(content::CHILD_PROCESS_EXE, &handler_path);
|
||||
+ DCHECK(!handler_path.empty());
|
||||
|
||||
// When --use-cros-crash-reporter is set (below), the handler passes dumps
|
||||
// to ChromeOS's /sbin/crash_reporter which in turn passes the dump to
|
||||
@@ -138,8 +138,8 @@ bool PlatformCrashpadInitialization(
|
||||
&product_version, &channel);
|
||||
|
||||
std::map<std::string, std::string> annotations;
|
||||
- annotations["prod"] = product_name;
|
||||
- annotations["ver"] = product_version;
|
||||
+ annotations["product"] = product_name;
|
||||
+ annotations["version"] = product_version;
|
||||
|
||||
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
|
||||
// Empty means stable.
|
||||
@@ -156,7 +156,20 @@ bool PlatformCrashpadInitialization(
|
||||
annotations["channel"] = channel;
|
||||
}
|
||||
|
||||
- annotations["plat"] = std::string("Linux");
|
||||
+#if defined(ARCH_CPU_ARM_FAMILY)
|
||||
+#if defined(ARCH_CPU_32_BITS)
|
||||
+ const char* platform = "linuxarm";
|
||||
+#elif defined(ARCH_CPU_64_BITS)
|
||||
+ const char* platform = "linuxarm64";
|
||||
+#endif
|
||||
+#else
|
||||
+#if defined(ARCH_CPU_32_BITS)
|
||||
+ const char* platform = "linux32";
|
||||
+#elif defined(ARCH_CPU_64_BITS)
|
||||
+ const char* platform = "linux64";
|
||||
+#endif
|
||||
+#endif // defined(ARCH_CPU_ARM_FAMILY)
|
||||
+ annotations["platform"] = platform;
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
// "build_time_millis" is used on LaCros chrome to determine when to stop
|
||||
@@ -201,6 +214,12 @@ bool PlatformCrashpadInitialization(
|
||||
}
|
||||
#endif
|
||||
|
||||
+ // Since we're using the same main or subprocess helper exe we must specify
|
||||
+ // the process type.
|
||||
+ arguments.push_back(std::string("--type=") + switches::kCrashpadHandler);
|
||||
+
|
||||
+ crash_reporter_client->GetCrashOptionalArguments(&arguments);
|
||||
+
|
||||
bool result =
|
||||
client.StartHandler(handler_path, *database_path, metrics_path, url,
|
||||
annotations, arguments, false, false);
|
||||
diff --git components/crash/core/app/crashpad_mac.mm components/crash/core/app/crashpad_mac.mm
|
||||
index dc041c43371fd..1d060ae55c586 100644
|
||||
--- components/crash/core/app/crashpad_mac.mm
|
||||
|
Loading…
x
Reference in New Issue
Block a user