Commit 0656f2cb authored by Vlad Tsyrklevich's avatar Vlad Tsyrklevich Committed by Commit Bot

Refactor Android to use chrome_crashpad_handler

Instead of using crashpad's crashpad_handler, refactor Android to use
our own custom chrome_crashpad_handler (also used by macOS) and have it
also pass through the CrashpadHandlerMain entry point so that it picks
up any custom crashpad hooks we want to install.

CQ-DEPEND=CL:1707405

Bug: 973167
Change-Id: Id6d91a35ce12e547b4a7c92d07f869c96afae797
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1708838Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682364}
parent 2c4bcb68
......@@ -199,13 +199,13 @@ template("chrome_public_common_apk_or_module_tmpl") {
if (!_is_monochrome && !_is_trichrome) {
deps += [
"//chrome/android:chrome_public_v8_assets",
"//third_party/crashpad/crashpad/handler:crashpad_handler_named_as_so",
"//components/crash/content/app:chrome_crashpad_handler_named_as_so",
"//third_party/icu:icu_assets",
]
if (!defined(loadable_modules)) {
loadable_modules = []
}
loadable_modules += [ "$root_out_dir/libcrashpad_handler.so" ]
loadable_modules += [ "$root_out_dir/libchrome_crashpad_handler.so" ]
}
if (_enable_multidex) {
......
......@@ -25,7 +25,7 @@ CHROME_SPECIFIC = BuildFileMatchRegex(
r'lib/.*/libchrome\.\d{4}\.\d{2,3}\.so', # libchrome placeholders
r'lib/.*/libchromium_android_linker\.so',
r'lib/.*/libchromeview\.so', # placeholder library
r'lib/.*/libcrashpad_handler\.so',
r'lib/.*/libchrome_crashpad_handler\.so',
r'lib/.*/crazy\.libchrome\.so',
r'lib/.*/crazy\.libchrome\.align',
r'lib/.*/gdbserver',
......
......@@ -663,10 +663,10 @@ if (is_android) {
"//base:base_java",
"//chromecast/android:libcast_shell_android",
"//chromecast/browser/android:cast_shell_java",
"//third_party/crashpad/crashpad/handler:crashpad_handler_named_as_so",
"//components/crash/content/app:chrome_crashpad_handler_named_as_so",
]
loadable_modules = [ "$root_out_dir/libcrashpad_handler.so" ]
loadable_modules = [ "$root_out_dir/libchrome_crashpad_handler.so" ]
command_line_flags_file = "castshell-command-line"
enable_multidex = true
......
......@@ -213,7 +213,7 @@ if (is_win) {
}
}
if (is_mac) {
if (is_mac || is_android) {
# We build a chromium-specific crashpad_handler executable so that we can
# define custom UserStreamDataSources.
executable("chrome_crashpad_handler") {
......@@ -222,15 +222,11 @@ if (is_mac) {
]
deps = [
"//components/gwp_asan/buildflags",
"//third_party/crashpad/crashpad/handler:handler",
":crashpad_handler_main",
"//third_party/crashpad/crashpad/handler",
]
if (enable_gwp_asan) {
deps += [ "//components/gwp_asan/crash_handler" ]
}
if (is_component_build) {
if (is_mac && is_component_build) {
ldflags = [
# The handler is in
# Chromium.app/Contents/Versions/X/Chromium Framework.framework/Versions/A/Helpers/
......@@ -257,6 +253,26 @@ if (is_mac) {
}
}
if (is_android) {
# There is not any normal way to package native executables in an Android APK.
# It is normal to package native code as a loadable module but Android's APK
# installer will ignore files not named like a shared object, so give the
# handler executable an acceptable name.
copy("chrome_crashpad_handler_named_as_so") {
deps = [
":chrome_crashpad_handler",
]
sources = [
"$root_out_dir/chrome_crashpad_handler",
]
outputs = [
"$root_out_dir/libchrome_crashpad_handler.so",
]
}
}
# This source set provides the functionality required for tests, which on Windows
# link the export thunks directly into the test binary.
source_set("test_support") {
......
......@@ -2,22 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "components/gwp_asan/buildflags/buildflags.h"
#include "third_party/crashpad/crashpad/handler/handler_main.h"
#include "third_party/crashpad/crashpad/handler/user_stream_data_source.h"
#if BUILDFLAG(ENABLE_GWP_ASAN)
#include "components/gwp_asan/crash_handler/crash_handler.h"
#endif
// Forward declare this for macOS (it's only defined by crashpad on Android.)
extern "C" int CrashpadHandlerMain(int argc, char* argv[]);
int main(int argc, char* argv[]) {
crashpad::UserStreamDataSources user_stream_data_sources;
#if BUILDFLAG(ENABLE_GWP_ASAN)
user_stream_data_sources.push_back(
std::make_unique<gwp_asan::UserStreamDataSource>());
#endif
return crashpad::HandlerMain(argc, argv, &user_stream_data_sources);
return CrashpadHandlerMain(argc, argv);
}
......@@ -397,7 +397,7 @@ bool GetHandlerPath(base::FilePath* exe_dir, base::FilePath* handler_path) {
if (!base::PathService::Get(base::DIR_MODULE, exe_dir)) {
return false;
}
*handler_path = exe_dir->Append("libcrashpad_handler.so");
*handler_path = exe_dir->Append("libchrome_crashpad_handler.so");
return true;
}
......
......@@ -170,12 +170,12 @@ android_apk("content_shell_apk") {
"//base:base_java",
"//base:base_java_test_support",
"//components/crash/android:java",
"//components/crash/content/app:chrome_crashpad_handler_named_as_so",
"//content/public/android:content_java",
"//content/public/test/android:android_test_message_pump_support_java",
"//media/capture/video/android:capture_java",
"//net/android:net_java",
"//services/shape_detection:shape_detection_java",
"//third_party/crashpad/crashpad/handler:crashpad_handler_named_as_so",
"//third_party/mesa_headers",
"//ui/android:ui_java",
]
......@@ -183,7 +183,7 @@ android_apk("content_shell_apk") {
android_manifest = content_shell_manifest
android_manifest_dep = ":content_shell_manifest"
shared_libraries = [ ":libcontent_shell_content_view" ]
loadable_modules = [ "$root_out_dir/libcrashpad_handler.so" ]
loadable_modules = [ "$root_out_dir/libchrome_crashpad_handler.so" ]
command_line_flags_file = "content-shell-command-line"
}
......
......@@ -19,9 +19,9 @@ This doc outlines some tricks / gotchas / features of how we ship native code in
dump is requested (e.g. after a crash), a Crashpad handler process is started
to produce a dump.
* Chrome and ChromeModern (Android J through M):
* libcrashpad_handler.so is a standalone executable containing all of the
crash dumping code. It is stored compressed and extracted automatically by
the system, allowing it to be directly executed to produce a crash dump.
* libchrome_crashpad_handler.so is a standalone executable containing all of
the crash dumping code. It is stored compressed and extracted automatically
by the system, allowing it to be directly executed to produce a crash dump.
* Monochrome (N through P) and SystemWebView (L through P):
* All of the Crashpad code is linked into the package's main native library
(e.g. libmonochrome.so). When a dump is requested, /system/bin/app_process
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment