Use chromeos buildflags
This CL upstreams changes made in chromium to use buildflags:
https://chromium-review.googlesource.com/c/chromium/src/+/2494261
https://chromium-review.googlesource.com/c/chromium/src/+/2594831
and alters the buildflags in handler_main.cc to allow LaCrOS to use
/sbin/crash_reporter
Bug: chromium:1159628
Change-Id: I32d1e6083971eb245f26618fc81777ddf6fa9463
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2622766
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
GitOrigin-RevId: 2e066d2e56d096073f66d8979d6316d3a3cc9492
diff --git a/DEPS b/DEPS
index db8fd8d..11add5e 100644
--- a/DEPS
+++ b/DEPS
@@ -42,7 +42,7 @@
'7bde79cc274d06451bf65ae82c012a5d3e476b5a',
'crashpad/third_party/mini_chromium/mini_chromium':
Var('chromium_git') + '/chromium/mini_chromium@' +
- 'c748b289b825056985f3dd3b36dc86c766d787ad',
+ '12ea507eb719a54698e1429e91e84c65284805ab',
'crashpad/third_party/libfuzzer/src':
Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git@' +
'fda403cf93ecb8792cb1d061564d89a6553ca020',
diff --git a/client/BUILD.gn b/client/BUILD.gn
index 4a5f34a..0546383 100644
--- a/client/BUILD.gn
+++ b/client/BUILD.gn
@@ -88,7 +88,8 @@
"../util",
]
- deps = []
+ deps = [ "../third_party/mini_chromium:chromeos_buildflags" ]
+
if (crashpad_is_win) {
libs = [ "rpcrt4.lib" ]
diff --git a/client/crashpad_client.h b/client/crashpad_client.h
index 5d42139..b1327a4 100644
--- a/client/crashpad_client.h
+++ b/client/crashpad_client.h
@@ -25,6 +25,7 @@
#include "base/files/file_path.h"
#include "base/macros.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "util/file/file_io.h"
#include "util/misc/capture_context.h"
@@ -646,7 +647,7 @@
static void UseSystemDefaultHandler();
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
//! \brief Sets a timestamp on the signal handler to be passed on to
//! crashpad_handler and then eventually Chrome OS's crash_reporter.
//!
diff --git a/client/crashpad_client_linux.cc b/client/crashpad_client_linux.cc
index 8425d77..cf94e6b 100644
--- a/client/crashpad_client_linux.cc
+++ b/client/crashpad_client_linux.cc
@@ -28,6 +28,7 @@
#include "base/logging.h"
#include "base/strings/stringprintf.h"
+#include "build/chromeos_buildflags.h"
#include "client/client_argv_handling.h"
#include "third_party/lss/lss.h"
#include "util/file/file_io.h"
@@ -335,7 +336,7 @@
ExceptionHandlerProtocol::ClientInformation info = {};
info.exception_information_address =
FromPointerCast<VMAddress>(&GetExceptionInfo());
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
info.crash_loop_before_time = crash_loop_before_time_;
#endif
@@ -343,7 +344,7 @@
client.RequestCrashDump(info);
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
void SetCrashLoopBefore(uint64_t crash_loop_before_time) {
crash_loop_before_time_ = crash_loop_before_time;
}
@@ -357,7 +358,7 @@
ScopedFileHandle sock_to_handler_;
pid_t handler_pid_ = -1;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// An optional UNIX timestamp passed to us from Chrome.
// This will pass to crashpad_handler and then to Chrome OS crash_reporter.
// This should really be a time_t, but it's basically an opaque value (we
@@ -678,7 +679,7 @@
unhandled_signals_ = signals;
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
// static
void CrashpadClient::SetCrashLoopBefore(uint64_t crash_loop_before_time) {
auto request_crash_dump_handler = RequestCrashDumpHandler::Get();
diff --git a/handler/BUILD.gn b/handler/BUILD.gn
index c1b516a..1d5951e 100644
--- a/handler/BUILD.gn
+++ b/handler/BUILD.gn
@@ -75,6 +75,7 @@
deps = [
"../minidump",
"../snapshot",
+ "../third_party/mini_chromium:chromeos_buildflags",
"../tools:tool_support",
]
diff --git a/handler/handler_main.cc b/handler/handler_main.cc
index a3ba9bb..737ee4e 100644
--- a/handler/handler_main.cc
+++ b/handler/handler_main.cc
@@ -38,6 +38,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "client/crash_report_database.h"
#include "client/crashpad_client.h"
#include "client/crashpad_info.h"
@@ -56,7 +57,7 @@
#include "util/string/split_string.h"
#include "util/synchronization/semaphore.h"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
#include "handler/linux/cros_crash_report_exception_handler.h"
#endif
@@ -162,7 +163,7 @@
#endif // OS_LINUX || OS_CHROMEOS || OS_ANDROID
" --url=URL send crash reports to this Breakpad server URL,\n"
" only if uploads are enabled for the database\n"
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
" --use-cros-crash-reporter\n"
" pass crash reports to /sbin/crash_reporter\n"
" instead of storing them in the database\n"
@@ -173,7 +174,7 @@
" pass the --always_allow_feedback flag to\n"
" crash_reporter, thus skipping metrics consent\n"
" checks\n"
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
#if defined(OS_ANDROID)
" --write-minidump-to-log write minidump to log\n"
#endif // OS_ANDROID
@@ -212,11 +213,11 @@
bool periodic_tasks;
bool rate_limit;
bool upload_gzip;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
bool use_cros_crash_reporter = false;
base::FilePath minidump_dir_for_tests;
bool always_allow_feedback = false;
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
#if defined(ATTACHMENTS_SUPPORTED)
std::vector<base::FilePath> attachments;
#endif // ATTACHMENTS_SUPPORTED
@@ -506,7 +507,7 @@
void InitCrashpadLogging() {
logging::LoggingSettings settings;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH)
settings.logging_dest = logging::LOG_TO_FILE;
settings.log_file_path = "/var/log/chrome/chrome";
#elif defined(OS_WIN)
@@ -576,11 +577,11 @@
kOptionTraceParentWithException,
#endif
kOptionURL,
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
kOptionUseCrosCrashReporter,
kOptionMinidumpDirForTests,
kOptionAlwaysAllowFeedback,
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
#if defined(OS_ANDROID)
kOptionWriteMinidumpToLog,
#endif // OS_ANDROID
@@ -658,7 +659,7 @@
kOptionTraceParentWithException},
#endif // OS_LINUX || OS_CHROMEOS || OS_ANDROID
{"url", required_argument, nullptr, kOptionURL},
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
{"use-cros-crash-reporter",
no_argument,
nullptr,
@@ -671,7 +672,7 @@
no_argument,
nullptr,
kOptionAlwaysAllowFeedback},
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
#if defined(OS_ANDROID)
{"write-minidump-to-log", no_argument, nullptr, kOptionWriteMinidumpToLog},
#endif // OS_ANDROID
@@ -832,7 +833,7 @@
options.url = optarg;
break;
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
case kOptionUseCrosCrashReporter: {
options.use_cros_crash_reporter = true;
break;
@@ -846,7 +847,7 @@
options.always_allow_feedback = true;
break;
}
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
#if defined(OS_ANDROID)
case kOptionWriteMinidumpToLog: {
options.write_minidump_to_log = true;
@@ -992,7 +993,7 @@
std::unique_ptr<CrashReportExceptionHandler> exception_handler;
#endif
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
if (options.use_cros_crash_reporter) {
auto cros_handler = std::make_unique<CrosCrashReportExceptionHandler>(
database.get(),
@@ -1035,7 +1036,7 @@
false,
#endif // OS_LINUX
user_stream_sources);
-#endif // OS_CHROMEOS
+#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)
#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
if (options.exception_information_address) {
diff --git a/third_party/mini_chromium/BUILD.gn b/third_party/mini_chromium/BUILD.gn
index 3efd710..66de3c8 100644
--- a/third_party/mini_chromium/BUILD.gn
+++ b/third_party/mini_chromium/BUILD.gn
@@ -45,3 +45,16 @@
public_deps = [ "//third_party/mini_chromium/mini_chromium/build" ]
}
}
+
+group("chromeos_buildflags") {
+ if (crashpad_is_in_chromium) {
+ public_deps = [ "//build/chromeos_buildflags" ]
+ } else if (crashpad_is_standalone || crashpad_is_in_fuchsia) {
+ public_deps = [ "mini_chromium/build:chromeos_buildflags" ]
+ } else if (crashpad_is_external) {
+ public_deps = [ "../../../../mini_chromium/mini_chromium/build:chromeos_buildflags" ]
+ } else if (crashpad_is_in_dart) {
+ public_deps = [ "//third_party/mini_chromium/mini_chromium/build:chromeos_buildflags" ]
+ }
+}
+