Commit c5a20e34 authored by Vlad Tsyrklevich's avatar Vlad Tsyrklevich Committed by Commit Bot

Refactor crashpad_handler binary on macOS

In order to define custom UserStreamDataSources, we need a
chromium-built crashpad_handler binary. This change refactors the
crashpad_handler executable to be built within chromium as
chrome_crashpad_handler and moved into it's final destination under the
original 'crashpad_handler' name.

Bug: 912286
Change-Id: I0f52028ae4c149823b30747589e2dd94225694c6
Reviewed-on: https://chromium-review.googlesource.com/c/1449330Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Reviewed-by: default avatarPavel Feldman <pfeldman@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629394}
parent 77920d98
......@@ -842,23 +842,36 @@ if (is_win) {
}
}
if (using_sanitizer) {
bundle_data("chrome_framework_helpers_asan_runtime") {
# crashpad_handler requires the ASan runtime at its @executable_path.
sources = [
"$root_out_dir/libclang_rt.asan_osx_dynamic.dylib",
]
outputs = [
"{{bundle_contents_dir}}/Helpers/{{source_file_part}}",
]
public_deps = [
"//build/config/sanitizers:copy_asan_runtime",
]
}
}
bundle_data("chrome_framework_helpers") {
sources = [
"$root_out_dir/crashpad_handler",
"$root_out_dir/chrome_crashpad_handler",
]
outputs = [
"{{bundle_contents_dir}}/Helpers/{{source_file_part}}",
"{{bundle_contents_dir}}/Helpers/crashpad_handler",
]
public_deps = [
"//third_party/crashpad/crashpad/handler:crashpad_handler",
"//components/crash/content/app:chrome_crashpad_handler",
]
if (using_sanitizer) {
# crashpad_handler requires the ASan runtime at its @executable_path.
sources += [ "$root_out_dir/libclang_rt.asan_osx_dynamic.dylib" ]
public_deps += [ "//build/config/sanitizers:copy_asan_runtime" ]
public_deps += [ ":chrome_framework_helpers_asan_runtime" ]
}
}
......@@ -1334,7 +1347,7 @@ if (is_win) {
"$root_out_dir/AlertNotificationService.xpc/Contents/MacOS/AlertNotificationService",
"$root_out_dir/$chrome_helper_name.app/Contents/MacOS/$chrome_helper_name",
"$root_out_dir/$chrome_product_full_name.app/Contents/MacOS/$chrome_product_full_name",
"$root_out_dir/crashpad_handler",
"$root_out_dir/$chrome_framework_name.framework/Versions/$chrome_framework_version/Helpers/crashpad_handler",
"$root_out_dir/libswiftshader_libEGL.dylib",
"$root_out_dir/libswiftshader_libGLESv2.dylib",
]
......@@ -1365,8 +1378,8 @@ if (is_win) {
":chrome_framework",
":chrome_helper_app",
"//chrome/browser/ui/cocoa/notifications:alert_notification_xpc_service",
"//components/crash/content/app:chrome_crashpad_handler",
"//third_party/breakpad:dump_syms",
"//third_party/crashpad/crashpad/handler:crashpad_handler",
"//third_party/swiftshader/src/OpenGL/libEGL:swiftshader_libEGL",
"//third_party/swiftshader/src/OpenGL/libGLESv2:swiftshader_libGLESv2",
]
......@@ -1405,7 +1418,7 @@ if (is_win) {
":chrome_framework",
":chrome_helper_app",
"//chrome/browser/ui/cocoa/notifications:alert_notification_xpc_service",
"//third_party/crashpad/crashpad/handler:crashpad_handler",
"//components/crash/content/app:chrome_crashpad_handler",
"//third_party/swiftshader/src/OpenGL/libEGL:swiftshader_libEGL",
"//third_party/swiftshader/src/OpenGL/libGLESv2:swiftshader_libGLESv2",
]
......
......@@ -189,6 +189,42 @@ if (is_win) {
}
}
if (is_mac) {
# We build a chromium-specific crashpad_handler executable so that we can
# define custom UserStreamDataSources. This executable is renamed to
# 'crashpad_handler' in output bundles.
executable("chrome_crashpad_handler") {
sources = [
"chrome_crashpad_handler.cc",
]
deps = [
"//third_party/crashpad/crashpad/handler:handler",
]
if (is_component_build) {
ldflags = [
# The handler is in
# Chromium.app/Contents/Versions/X/Chromium Framework.framework/Versions/A/Helpers/
# so set rpath up to the base.
"-rpath",
"@loader_path/../../../../../../../..",
# The handler is also in
# Content Shell.app/Contents/Frameworks/Content Shell Framework.framework/Versions/C/Helpers/
# so set the rpath for that too.
"-rpath",
"@loader_path/../../../../../../..",
# The handler can also be executed in an unbundled framework at
# Chromium Framework.framework/Versions/A/Helpers/
"-rpath",
"@loader_path/../../../..",
]
}
}
}
# 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") {
......
// Copyright 2019 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 "third_party/crashpad/crashpad/handler/handler_main.h"
int main(int argc, char* argv[]) {
return crashpad::HandlerMain(argc, argv, nullptr);
}
......@@ -658,13 +658,13 @@ if (is_mac) {
bundle_data("content_shell_framework_helpers") {
testonly = true
sources = [
"$root_out_dir/crashpad_handler",
"$root_out_dir/chrome_crashpad_handler",
]
outputs = [
"{{bundle_contents_dir}}/Helpers/{{source_file_part}}",
"{{bundle_contents_dir}}/Helpers/crashpad_handler",
]
public_deps = [
"//third_party/crashpad/crashpad/handler:crashpad_handler",
"//components/crash/content/app:chrome_crashpad_handler",
]
}
......
......@@ -601,27 +601,51 @@ test("headless_unittests") {
}
if (is_mac) {
copy("mac_helpers") {
copy("mac_helpers_crashpad_handler") {
sources = [
"$root_out_dir/crashpad_handler",
"$root_out_dir/chrome_crashpad_handler",
]
deps = [
"//base",
"//third_party/crashpad/crashpad/handler:crashpad_handler",
"//components/crash/content/app:chrome_crashpad_handler",
]
if (is_component_build) {
sources += [ "$root_out_dir/libbase.dylib" ]
outputs = [
"$root_out_dir/Helpers/crashpad_handler",
]
}
if (is_component_build) {
copy("mac_helpers_libraries") {
sources = [
"$root_out_dir/libbase.dylib",
]
deps = [
"//base",
]
outputs = [
"$root_out_dir/Helpers/{{source_file_part}}",
]
if (use_custom_libcxx) {
sources += [ "$root_out_dir/libc++.dylib" ]
deps += [ "//buildtools/third_party/libc++:libc++" ]
}
}
}
outputs = [
"$root_out_dir/Helpers/{{source_file_part}}",
group("mac_helpers") {
data = [
"$root_out_dir/Helpers",
]
deps = [
":mac_helpers_crashpad_handler",
]
if (is_component_build) {
deps += [ ":mac_helpers_libraries" ]
}
}
}
......
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