mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-25 22:30:49 +08:00
Convert Crashpad to use ARC
See https://chromium.googlesource.com/chromium/src/+/main/docs/mac/arc.md for information about this conversion. Bug: chromium:1280726 Change-Id: I9ed10e9a255eb6b13035b05bcc587c4b6cb7b78e Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/4651106 Reviewed-by: Mark Mentovai <mmentovai@google.com> Commit-Queue: Mark Mentovai <mark@chromium.org> Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
87e1883047
commit
9e37dc46b6
2
DEPS
2
DEPS
@ -47,7 +47,7 @@ deps = {
|
||||
'9719c1e1e676814c456b55f5f070eabad6709d31',
|
||||
'crashpad/third_party/mini_chromium/mini_chromium':
|
||||
Var('chromium_git') + '/chromium/mini_chromium@' +
|
||||
'f0eebea8bd59215be300ffbe5e7883e85a6fdc0e',
|
||||
'e009af846ef4790a90d69fe13ed54df25b93fdef',
|
||||
'crashpad/third_party/libfuzzer/src':
|
||||
Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git@' +
|
||||
'fda403cf93ecb8792cb1d061564d89a6553ca020',
|
||||
|
@ -31,9 +31,8 @@ config("crashpad_is_in_fuchsia") {
|
||||
}
|
||||
|
||||
config("flock_always_supported_defines") {
|
||||
defines = [
|
||||
"CRASHPAD_FLOCK_ALWAYS_SUPPORTED=$crashpad_flock_always_supported",
|
||||
]
|
||||
defines =
|
||||
[ "CRASHPAD_FLOCK_ALWAYS_SUPPORTED=$crashpad_flock_always_supported" ]
|
||||
}
|
||||
|
||||
group("default_exe_manifest_win") {
|
||||
@ -52,16 +51,17 @@ config("crashpad_fuzzer_flags") {
|
||||
ldflags = [ "-fsanitize=address" ]
|
||||
}
|
||||
|
||||
if (crashpad_is_ios) {
|
||||
group("ios_enable_arc") {
|
||||
if (crashpad_is_apple) {
|
||||
group("apple_enable_arc") {
|
||||
if (crashpad_is_in_chromium) {
|
||||
public_configs = [ "//build/config/compiler:enable_arc" ]
|
||||
} else if (crashpad_is_standalone) {
|
||||
public_configs =
|
||||
[ "//third_party/mini_chromium/mini_chromium/build/config:ios_enable_arc" ]
|
||||
public_configs = [ "//third_party/mini_chromium/mini_chromium/build/config:apple_enable_arc" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (crashpad_is_ios) {
|
||||
group("ios_xctest") {
|
||||
if (crashpad_is_in_chromium) {
|
||||
public_configs = [ "//build/config/ios:xctest_config" ]
|
||||
|
@ -59,6 +59,7 @@ if (crashpad_is_external || crashpad_is_in_dart) {
|
||||
if (crashpad_is_in_chromium) {
|
||||
crashpad_is_mac = is_mac
|
||||
crashpad_is_ios = is_ios
|
||||
crashpad_is_apple = is_apple
|
||||
crashpad_is_win = is_win
|
||||
crashpad_is_linux = is_linux || is_chromeos
|
||||
crashpad_is_android = is_android
|
||||
@ -73,6 +74,7 @@ if (crashpad_is_in_chromium) {
|
||||
|
||||
crashpad_is_mac = mini_chromium_is_mac
|
||||
crashpad_is_ios = mini_chromium_is_ios
|
||||
crashpad_is_apple = mini_chromium_is_apple
|
||||
crashpad_is_win = mini_chromium_is_win
|
||||
crashpad_is_linux = mini_chromium_is_linux
|
||||
crashpad_is_android = mini_chromium_is_android
|
||||
|
@ -89,6 +89,10 @@ crashpad_static_library("client") {
|
||||
cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union
|
||||
}
|
||||
|
||||
if (crashpad_is_apple) {
|
||||
deps += [ "../build:apple_enable_arc" ]
|
||||
}
|
||||
|
||||
if (crashpad_is_ios) {
|
||||
deps += [
|
||||
"../handler:common",
|
||||
@ -127,7 +131,7 @@ static_library("common") {
|
||||
"simple_string_dictionary.h",
|
||||
]
|
||||
|
||||
if (crashpad_is_mac || crashpad_is_ios) {
|
||||
if (crashpad_is_apple) {
|
||||
sources += [ "crash_report_database_mac.mm" ]
|
||||
}
|
||||
if (crashpad_is_win) {
|
||||
@ -147,17 +151,19 @@ static_library("common") {
|
||||
]
|
||||
deps = [ "../util" ]
|
||||
configs += [ "../build:flock_always_supported_defines" ]
|
||||
|
||||
if (crashpad_is_apple) {
|
||||
deps += [ "../build:apple_enable_arc" ]
|
||||
}
|
||||
}
|
||||
|
||||
crashpad_executable("ring_buffer_annotation_load_test") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"ring_buffer_annotation_load_test_main.cc",
|
||||
]
|
||||
sources = [ "ring_buffer_annotation_load_test_main.cc" ]
|
||||
deps = [
|
||||
":client",
|
||||
"../tools:tool_support",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../tools:tool_support",
|
||||
]
|
||||
}
|
||||
|
||||
@ -212,6 +218,10 @@ source_set("client_test") {
|
||||
data_deps = [ "../handler:crashpad_handler" ]
|
||||
}
|
||||
|
||||
if (crashpad_is_apple) {
|
||||
deps += [ "../build:apple_enable_arc" ]
|
||||
}
|
||||
|
||||
if (crashpad_is_win) {
|
||||
data_deps += [
|
||||
"../handler:crashpad_handler_console",
|
||||
|
@ -49,6 +49,10 @@
|
||||
#include "util/ios/scoped_background_task.h"
|
||||
#endif // BUILDFLAG(IS_IOS)
|
||||
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
namespace {
|
||||
|
@ -27,6 +27,10 @@
|
||||
#include "testing/platform_test.h"
|
||||
#include "util/thread/thread.h"
|
||||
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
namespace {
|
||||
|
@ -54,6 +54,10 @@
|
||||
#include "client/annotation.h"
|
||||
#include "client/simulate_crash_ios.h"
|
||||
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
namespace {
|
||||
@ -65,7 +69,7 @@ struct objc_typeinfo {
|
||||
Class cls_unremapped;
|
||||
};
|
||||
struct objc_exception {
|
||||
id obj;
|
||||
id __unsafe_unretained obj;
|
||||
objc_typeinfo tinfo;
|
||||
};
|
||||
|
||||
@ -219,7 +223,7 @@ class ExceptionPreprocessorState {
|
||||
// preprocessor didn't catch anything, so pass the frames or just the context
|
||||
// to the exception_delegate.
|
||||
void FinalizeUncaughtNSException(id exception) {
|
||||
if (last_exception() == exception &&
|
||||
if (last_exception() == (__bridge void*)exception &&
|
||||
!last_handled_intermediate_dump_.empty() &&
|
||||
exception_delegate_->MoveIntermediateDumpAtPathToPending(
|
||||
last_handled_intermediate_dump_)) {
|
||||
@ -331,10 +335,10 @@ id ObjcExceptionPreprocessor(id exception) {
|
||||
// ignore it.
|
||||
ExceptionPreprocessorState* preprocessor_state =
|
||||
ExceptionPreprocessorState::Get();
|
||||
if (preprocessor_state->last_exception() == exception) {
|
||||
if (preprocessor_state->last_exception() == (__bridge void*)exception) {
|
||||
return preprocessor_state->MaybeCallNextPreprocessor(exception);
|
||||
}
|
||||
preprocessor_state->set_last_exception(exception);
|
||||
preprocessor_state->set_last_exception((__bridge void*)exception);
|
||||
|
||||
static bool seen_first_exception;
|
||||
|
||||
|
@ -19,6 +19,10 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "testing/platform_test.h"
|
||||
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
namespace {
|
||||
|
@ -17,7 +17,7 @@ import("../build/crashpad_buildconfig.gni")
|
||||
config("compat_config") {
|
||||
include_dirs = []
|
||||
|
||||
if (crashpad_is_mac || crashpad_is_ios) {
|
||||
if (crashpad_is_apple) {
|
||||
include_dirs += [ "mac" ]
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ config("compat_config") {
|
||||
}
|
||||
|
||||
template("compat_target") {
|
||||
if (crashpad_is_mac || crashpad_is_ios) {
|
||||
if (crashpad_is_apple) {
|
||||
# There are no sources to compile, which doesn’t mix will with a
|
||||
# static_library.
|
||||
group(target_name) {
|
||||
@ -64,7 +64,7 @@ template("compat_target") {
|
||||
compat_target("compat") {
|
||||
sources = []
|
||||
|
||||
if (crashpad_is_mac || crashpad_is_ios) {
|
||||
if (crashpad_is_apple) {
|
||||
sources += [
|
||||
"mac/Availability.h",
|
||||
"mac/AvailabilityVersions.h",
|
||||
|
@ -100,7 +100,7 @@ static_library("common") {
|
||||
"minidump_to_upload_parameters.cc",
|
||||
"minidump_to_upload_parameters.h",
|
||||
]
|
||||
if (crashpad_is_mac || crashpad_is_ios) {
|
||||
if (crashpad_is_apple) {
|
||||
sources += [
|
||||
"mac/file_limit_annotation.cc",
|
||||
"mac/file_limit_annotation.h",
|
||||
|
@ -566,7 +566,7 @@ if ((crashpad_is_linux || crashpad_is_android || crashpad_is_fuchsia) &&
|
||||
}
|
||||
}
|
||||
|
||||
if (crashpad_is_mac || crashpad_is_ios) {
|
||||
if (crashpad_is_apple) {
|
||||
crashpad_loadable_module("crashpad_snapshot_test_module_crashy_initializer") {
|
||||
testonly = true
|
||||
sources = [
|
||||
|
@ -61,12 +61,10 @@ static_library("test") {
|
||||
# TODO(crbug.com/812974): Remove !crashpad_is_fuchsia when Fuchsia is no
|
||||
# longer treated as a posix platform.
|
||||
if (crashpad_is_posix && !crashpad_is_fuchsia) {
|
||||
sources += [
|
||||
"scoped_set_thread_name_posix.cc",
|
||||
]
|
||||
sources += [ "scoped_set_thread_name_posix.cc" ]
|
||||
}
|
||||
|
||||
if (crashpad_is_mac || crashpad_is_ios) {
|
||||
if (crashpad_is_apple) {
|
||||
sources += [
|
||||
"mac/mach_errors.cc",
|
||||
"mac/mach_errors.h",
|
||||
@ -135,9 +133,9 @@ static_library("test") {
|
||||
data = [ "test_paths_test_data_root.txt" ]
|
||||
|
||||
deps = [
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../compat",
|
||||
"../third_party/googletest:googletest",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../util",
|
||||
]
|
||||
|
||||
@ -214,10 +212,10 @@ source_set("test_test") {
|
||||
|
||||
deps = [
|
||||
":test",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../compat",
|
||||
"../third_party/googletest:googlemock",
|
||||
"../third_party/googletest:googletest",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../util",
|
||||
]
|
||||
|
||||
@ -243,10 +241,10 @@ static_library("googlemock_main") {
|
||||
defines = [ "CRASHPAD_TEST_LAUNCHER_GOOGLEMOCK" ]
|
||||
deps = [
|
||||
":test",
|
||||
"../third_party/googletest:googlemock",
|
||||
"../third_party/googletest:googletest",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"$mini_chromium_source_parent:base_test_support",
|
||||
"../third_party/googletest:googlemock",
|
||||
"../third_party/googletest:googletest",
|
||||
]
|
||||
if (crashpad_is_android) {
|
||||
deps += [ "../util" ]
|
||||
@ -263,9 +261,9 @@ static_library("googletest_main") {
|
||||
defines = [ "CRASHPAD_TEST_LAUNCHER_GOOGLETEST" ]
|
||||
deps = [
|
||||
":test",
|
||||
"../third_party/googletest:googletest",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"$mini_chromium_source_parent:base_test_support",
|
||||
"../third_party/googletest:googletest",
|
||||
]
|
||||
if (crashpad_is_android) {
|
||||
deps += [ "../util" ]
|
||||
|
@ -40,7 +40,7 @@ source_set("google_test_runner") {
|
||||
configs += [ "../..:crashpad_config" ]
|
||||
deps = [
|
||||
"../$mini_chromium_source_parent:base",
|
||||
"../../build:ios_enable_arc",
|
||||
"../../build:apple_enable_arc",
|
||||
"../../build:ios_xctest",
|
||||
"../../test/ios:google_test_runner_shared_headers",
|
||||
]
|
||||
@ -57,7 +57,7 @@ source_set("google_test_setup") {
|
||||
deps = [
|
||||
":google_test_runner_shared_headers",
|
||||
"../$mini_chromium_source_parent:base",
|
||||
"../../build:ios_enable_arc",
|
||||
"../../build:apple_enable_arc",
|
||||
"../../third_party/googletest:googletest",
|
||||
]
|
||||
frameworks = [ "UIKit.framework" ]
|
||||
@ -72,7 +72,7 @@ source_set("xcuitests") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"../../build:ios_enable_arc",
|
||||
"../../build:apple_enable_arc",
|
||||
"../../build:ios_xctest",
|
||||
"../../client:common",
|
||||
"../../test/ios/host:app_shared_sources",
|
||||
|
@ -24,7 +24,7 @@ source_set("app_shared_sources") {
|
||||
testonly = true
|
||||
sources = [ "cptest_shared_object.h" ]
|
||||
configs += [ "../../..:crashpad_config" ]
|
||||
deps = [ "../../../build:ios_enable_arc" ]
|
||||
deps = [ "../../../build:apple_enable_arc" ]
|
||||
frameworks = [ "UIKit.framework" ]
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ static_library("app_host_sources") {
|
||||
configs += [ "../../..:crashpad_config" ]
|
||||
deps = [
|
||||
":app_shared_sources",
|
||||
"../../../build:ios_enable_arc",
|
||||
"../../../build:apple_enable_arc",
|
||||
"../../../client",
|
||||
"../../../snapshot",
|
||||
"../../../test",
|
||||
|
2
third_party/edo/BUILD.gn
vendored
2
third_party/edo/BUILD.gn
vendored
@ -139,6 +139,6 @@ if (crashpad_is_in_chromium) {
|
||||
]
|
||||
|
||||
public_configs = [ ":config" ]
|
||||
deps = [ "../../build:ios_enable_arc" ]
|
||||
deps = [ "../../build:apple_enable_arc" ]
|
||||
}
|
||||
}
|
||||
|
@ -36,8 +36,7 @@ crashpad_executable("dump_minidump_annotations") {
|
||||
]
|
||||
|
||||
if (crashpad_is_win) {
|
||||
cflags =
|
||||
[ "/wd4201" ] # nonstandard extension used : nameless struct/union
|
||||
cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,10 +46,10 @@ if (!crashpad_is_ios && !crashpad_is_fuchsia) {
|
||||
|
||||
deps = [
|
||||
":tool_support",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../build:default_exe_manifest_win",
|
||||
"../client",
|
||||
"../compat",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../util",
|
||||
]
|
||||
}
|
||||
@ -60,9 +59,9 @@ if (!crashpad_is_ios && !crashpad_is_fuchsia) {
|
||||
|
||||
deps = [
|
||||
":tool_support",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../build:default_exe_manifest_win",
|
||||
"../compat",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../util",
|
||||
"../util:net",
|
||||
]
|
||||
@ -73,8 +72,8 @@ crashpad_executable("base94_encoder") {
|
||||
sources = [ "base94_encoder.cc" ]
|
||||
deps = [
|
||||
":tool_support",
|
||||
"../build:default_exe_manifest_win",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../build:default_exe_manifest_win",
|
||||
"../util",
|
||||
]
|
||||
}
|
||||
@ -85,11 +84,11 @@ if (!crashpad_is_fuchsia && !crashpad_is_ios) {
|
||||
|
||||
deps = [
|
||||
":tool_support",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../build:default_exe_manifest_win",
|
||||
"../compat",
|
||||
"../minidump",
|
||||
"../snapshot",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../util",
|
||||
]
|
||||
|
||||
@ -119,9 +118,9 @@ if (crashpad_is_mac || crashpad_is_fuchsia) {
|
||||
|
||||
deps = [
|
||||
":tool_support",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../client",
|
||||
"../compat",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../util",
|
||||
]
|
||||
}
|
||||
@ -133,8 +132,8 @@ if (crashpad_is_mac) {
|
||||
|
||||
deps = [
|
||||
":tool_support",
|
||||
"../compat",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../compat",
|
||||
"../util",
|
||||
]
|
||||
}
|
||||
@ -154,8 +153,8 @@ if (crashpad_is_mac) {
|
||||
|
||||
deps = [
|
||||
":tool_support",
|
||||
"../compat",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../compat",
|
||||
"../util",
|
||||
]
|
||||
}
|
||||
@ -170,8 +169,9 @@ if (crashpad_is_mac) {
|
||||
|
||||
deps = [
|
||||
":tool_support",
|
||||
"../compat",
|
||||
"$mini_chromium_source_parent:base",
|
||||
"../build:apple_enable_arc",
|
||||
"../compat",
|
||||
"../util",
|
||||
]
|
||||
}
|
||||
|
@ -24,12 +24,16 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/apple/bridging.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "tools/tool_support.h"
|
||||
#include "util/mac/service_management.h"
|
||||
#include "util/stdlib/objc.h"
|
||||
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
namespace crashpad {
|
||||
namespace {
|
||||
|
||||
@ -158,13 +162,13 @@ int OnDemandServiceToolMain(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
NSMutableDictionary* mutable_job_dictionary =
|
||||
[[job_dictionary mutableCopy] autorelease];
|
||||
[job_dictionary mutableCopy];
|
||||
mutable_job_dictionary[@LAUNCH_JOBKEY_MACHSERVICES] = mach_services;
|
||||
job_dictionary = mutable_job_dictionary;
|
||||
}
|
||||
|
||||
CFDictionaryRef job_dictionary_cf =
|
||||
base::mac::NSToCFCast(job_dictionary);
|
||||
base::apple::NSToCFPtrCast(job_dictionary);
|
||||
if (!ServiceManagementSubmitJob(job_dictionary_cf)) {
|
||||
fprintf(stderr, "%s: failed to submit job\n", me.c_str());
|
||||
return EXIT_FAILURE;
|
||||
|
@ -19,7 +19,7 @@ if (crashpad_is_in_chromium) {
|
||||
import("//build/config/sanitizers/sanitizers.gni")
|
||||
}
|
||||
|
||||
if (crashpad_is_mac || crashpad_is_ios) {
|
||||
if (crashpad_is_apple) {
|
||||
if (crashpad_is_in_chromium || crashpad_is_in_fuchsia) {
|
||||
import("//build/config/sysroot.gni")
|
||||
} else {
|
||||
@ -317,7 +317,7 @@ crashpad_static_library("util") {
|
||||
}
|
||||
}
|
||||
|
||||
if (crashpad_is_mac || crashpad_is_ios) {
|
||||
if (crashpad_is_apple) {
|
||||
sources += [
|
||||
"mac/xattr.cc",
|
||||
"mac/xattr.h",
|
||||
@ -401,10 +401,10 @@ crashpad_static_library("util") {
|
||||
"ios/raw_logging.h",
|
||||
"ios/scoped_background_task.h",
|
||||
"ios/scoped_background_task.mm",
|
||||
"ios/scoped_vm_read.cc",
|
||||
"ios/scoped_vm_read.h",
|
||||
"ios/scoped_vm_map.cc",
|
||||
"ios/scoped_vm_map.h",
|
||||
"ios/scoped_vm_read.cc",
|
||||
"ios/scoped_vm_read.h",
|
||||
]
|
||||
}
|
||||
|
||||
@ -585,13 +585,12 @@ crashpad_static_library("util") {
|
||||
|
||||
configs = [ "../build:flock_always_supported_defines" ]
|
||||
|
||||
if (crashpad_is_mac || crashpad_is_ios) {
|
||||
if (crashpad_is_apple) {
|
||||
include_dirs += [ "$root_gen_dir" ]
|
||||
deps += [ ":mig_output" ]
|
||||
}
|
||||
|
||||
if (crashpad_is_ios) {
|
||||
deps += [ "../build:ios_enable_arc" ]
|
||||
deps += [
|
||||
":mig_output",
|
||||
"../build:apple_enable_arc",
|
||||
]
|
||||
}
|
||||
|
||||
if (crashpad_is_mac && !crashpad_is_in_fuchsia) {
|
||||
@ -652,6 +651,10 @@ crashpad_static_library("net") {
|
||||
"$mini_chromium_source_parent:base",
|
||||
]
|
||||
|
||||
if (crashpad_is_apple) {
|
||||
deps += [ "../build:apple_enable_arc" ]
|
||||
}
|
||||
|
||||
if (crashpad_is_mac && !crashpad_is_in_fuchsia) {
|
||||
sources += [ "net/http_transport_mac.mm" ]
|
||||
}
|
||||
@ -804,7 +807,7 @@ source_set("util_test") {
|
||||
sources += [ "posix/scoped_mmap_test.cc" ]
|
||||
}
|
||||
|
||||
if (crashpad_is_mac || crashpad_is_ios) {
|
||||
if (crashpad_is_apple) {
|
||||
sources += [
|
||||
"mac/xattr_test.cc",
|
||||
"mach/composite_mach_message_server_test.cc",
|
||||
@ -840,8 +843,8 @@ source_set("util_test") {
|
||||
sources += [
|
||||
"ios/ios_intermediate_dump_reader_test.cc",
|
||||
"ios/ios_intermediate_dump_writer_test.cc",
|
||||
"ios/scoped_vm_read_test.cc",
|
||||
"ios/scoped_vm_map_test.cc",
|
||||
"ios/scoped_vm_read_test.cc",
|
||||
]
|
||||
|
||||
sources -= [
|
||||
@ -919,6 +922,10 @@ source_set("util_test") {
|
||||
}
|
||||
}
|
||||
|
||||
if (crashpad_is_apple) {
|
||||
deps += [ "../build:apple_enable_arc" ]
|
||||
}
|
||||
|
||||
if (crashpad_is_mac) {
|
||||
frameworks = [ "Foundation.framework" ]
|
||||
}
|
||||
|
@ -27,6 +27,10 @@
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
std::string ReadStringSysctlByName(const char* name) {
|
||||
|
@ -16,12 +16,17 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#include "base/apple/bridging.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/mac/scoped_launch_data.h"
|
||||
#include "base/mac/scoped_cftyperef.h"
|
||||
#include "base/mac/scoped_launch_data.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
launch_data_t CFPropertyToLaunchData(CFPropertyListRef property_cf) {
|
||||
@ -34,7 +39,7 @@ launch_data_t CFPropertyToLaunchData(CFPropertyListRef property_cf) {
|
||||
CFTypeID type_id_cf = CFGetTypeID(property_cf);
|
||||
|
||||
if (type_id_cf == CFDictionaryGetTypeID()) {
|
||||
NSDictionary* dictionary_ns = base::mac::CFToNSCast(
|
||||
NSDictionary* dictionary_ns = base::apple::CFToNSPtrCast(
|
||||
base::mac::CFCastStrict<CFDictionaryRef>(property_cf));
|
||||
base::mac::ScopedLaunchData dictionary_launch(
|
||||
LaunchDataAlloc(LAUNCH_DATA_DICTIONARY));
|
||||
@ -45,7 +50,7 @@ launch_data_t CFPropertyToLaunchData(CFPropertyListRef property_cf) {
|
||||
}
|
||||
|
||||
CFPropertyListRef value_cf =
|
||||
implicit_cast<CFPropertyListRef>(dictionary_ns[key]);
|
||||
(__bridge CFPropertyListRef)dictionary_ns[key];
|
||||
launch_data_t value_launch = CFPropertyToLaunchData(value_cf);
|
||||
if (!value_launch) {
|
||||
return nullptr;
|
||||
@ -58,15 +63,14 @@ launch_data_t CFPropertyToLaunchData(CFPropertyListRef property_cf) {
|
||||
data_launch = dictionary_launch.release();
|
||||
|
||||
} else if (type_id_cf == CFArrayGetTypeID()) {
|
||||
NSArray* array_ns = base::mac::CFToNSCast(
|
||||
NSArray* array_ns = base::apple::CFToNSPtrCast(
|
||||
base::mac::CFCastStrict<CFArrayRef>(property_cf));
|
||||
base::mac::ScopedLaunchData array_launch(
|
||||
LaunchDataAlloc(LAUNCH_DATA_ARRAY));
|
||||
size_t index = 0;
|
||||
|
||||
for (id element_ns in array_ns) {
|
||||
CFPropertyListRef element_cf =
|
||||
implicit_cast<CFPropertyListRef>(element_ns);
|
||||
CFPropertyListRef element_cf = (__bridge CFPropertyListRef)element_ns;
|
||||
launch_data_t element_launch = CFPropertyToLaunchData(element_cf);
|
||||
if (!element_launch) {
|
||||
return nullptr;
|
||||
@ -79,7 +83,7 @@ launch_data_t CFPropertyToLaunchData(CFPropertyListRef property_cf) {
|
||||
|
||||
} else if (type_id_cf == CFNumberGetTypeID()) {
|
||||
CFNumberRef number_cf = base::mac::CFCastStrict<CFNumberRef>(property_cf);
|
||||
NSNumber* number_ns = base::mac::CFToNSCast(number_cf);
|
||||
NSNumber* number_ns = base::apple::CFToNSPtrCast(number_cf);
|
||||
switch (CFNumberGetType(number_cf)) {
|
||||
case kCFNumberSInt8Type:
|
||||
case kCFNumberSInt16Type:
|
||||
@ -113,7 +117,7 @@ launch_data_t CFPropertyToLaunchData(CFPropertyListRef property_cf) {
|
||||
data_launch = LaunchDataNewBool(CFBooleanGetValue(boolean_cf));
|
||||
|
||||
} else if (type_id_cf == CFStringGetTypeID()) {
|
||||
NSString* string_ns = base::mac::CFToNSCast(
|
||||
NSString* string_ns = base::apple::CFToNSPtrCast(
|
||||
base::mac::CFCastStrict<CFStringRef>(property_cf));
|
||||
|
||||
// -fileSystemRepresentation might be more correct than -UTF8String,
|
||||
@ -125,7 +129,7 @@ launch_data_t CFPropertyToLaunchData(CFPropertyListRef property_cf) {
|
||||
data_launch = LaunchDataNewString([string_ns UTF8String]);
|
||||
|
||||
} else if (type_id_cf == CFDataGetTypeID()) {
|
||||
NSData* data_ns = base::mac::CFToNSCast(
|
||||
NSData* data_ns = base::apple::CFToNSPtrCast(
|
||||
base::mac::CFCastStrict<CFDataRef>(property_cf));
|
||||
data_launch = LaunchDataNewOpaque([data_ns bytes], [data_ns length]);
|
||||
} else {
|
||||
|
@ -23,10 +23,15 @@
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
|
||||
#include "base/apple/bridging.h"
|
||||
#include "base/mac/scoped_launch_data.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "util/stdlib/objc.h"
|
||||
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
namespace {
|
||||
@ -60,7 +65,8 @@ TEST(Launchd, CFPropertyToLaunchData_Integer) {
|
||||
|
||||
for (size_t index = 0; index < std::size(integer_nses); ++index) {
|
||||
NSNumber* integer_ns = integer_nses[index];
|
||||
launch_data.reset(CFPropertyToLaunchData(integer_ns));
|
||||
launch_data.reset(
|
||||
CFPropertyToLaunchData(base::apple::NSToCFPtrCast(integer_ns)));
|
||||
ASSERT_TRUE(launch_data.get());
|
||||
ASSERT_EQ(LaunchDataGetType(launch_data.get()), LAUNCH_DATA_INTEGER);
|
||||
EXPECT_EQ(LaunchDataGetInteger(launch_data.get()),
|
||||
@ -90,7 +96,8 @@ TEST(Launchd, CFPropertyToLaunchData_FloatingPoint) {
|
||||
|
||||
for (size_t index = 0; index < std::size(double_nses); ++index) {
|
||||
NSNumber* double_ns = double_nses[index];
|
||||
launch_data.reset(CFPropertyToLaunchData(double_ns));
|
||||
launch_data.reset(
|
||||
CFPropertyToLaunchData(base::apple::NSToCFPtrCast(double_ns)));
|
||||
ASSERT_TRUE(launch_data.get());
|
||||
ASSERT_EQ(LaunchDataGetType(launch_data.get()), LAUNCH_DATA_REAL);
|
||||
double expected_double_value = [double_ns doubleValue];
|
||||
@ -109,17 +116,19 @@ TEST(Launchd, CFPropertyToLaunchData_Boolean) {
|
||||
@autoreleasepool {
|
||||
base::mac::ScopedLaunchData launch_data;
|
||||
|
||||
NSNumber* bool_nses[] = {
|
||||
@NO,
|
||||
@YES,
|
||||
// Use CFBooleanRefs here because calling NSToCFPtrCast on an NSNumber
|
||||
// boolean can fail. Casting an NSNumber expects a CFNumberRef as a result
|
||||
// but a cast boolean will end up as a CFBooleanRef.
|
||||
CFBooleanRef bools[] = {
|
||||
kCFBooleanFalse,
|
||||
kCFBooleanTrue,
|
||||
};
|
||||
|
||||
for (size_t index = 0; index < std::size(bool_nses); ++index) {
|
||||
NSNumber* bool_ns = bool_nses[index];
|
||||
launch_data.reset(CFPropertyToLaunchData(bool_ns));
|
||||
for (CFBooleanRef bool_cf : bools) {
|
||||
launch_data.reset(CFPropertyToLaunchData(bool_cf));
|
||||
ASSERT_TRUE(launch_data.get());
|
||||
ASSERT_EQ(LaunchDataGetType(launch_data.get()), LAUNCH_DATA_BOOL);
|
||||
if ([bool_ns boolValue]) {
|
||||
if (CFBooleanGetValue(bool_cf)) {
|
||||
EXPECT_TRUE(LaunchDataGetBool(launch_data.get()));
|
||||
} else {
|
||||
EXPECT_FALSE(LaunchDataGetBool(launch_data.get()));
|
||||
@ -140,7 +149,8 @@ TEST(Launchd, CFPropertyToLaunchData_String) {
|
||||
|
||||
for (size_t index = 0; index < std::size(string_nses); ++index) {
|
||||
NSString* string_ns = string_nses[index];
|
||||
launch_data.reset(CFPropertyToLaunchData(string_ns));
|
||||
launch_data.reset(
|
||||
CFPropertyToLaunchData(base::apple::NSToCFPtrCast(string_ns)));
|
||||
ASSERT_TRUE(launch_data.get());
|
||||
ASSERT_EQ(LaunchDataGetType(launch_data.get()), LAUNCH_DATA_STRING);
|
||||
EXPECT_STREQ([string_ns UTF8String],
|
||||
@ -156,7 +166,8 @@ TEST(Launchd, CFPropertyToLaunchData_Data) {
|
||||
static constexpr uint8_t data_c[] = {
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 9, 8, 7, 6, 5, 4, 3, 2};
|
||||
NSData* data_ns = [NSData dataWithBytes:data_c length:sizeof(data_c)];
|
||||
launch_data.reset(CFPropertyToLaunchData(data_ns));
|
||||
launch_data.reset(
|
||||
CFPropertyToLaunchData(base::apple::NSToCFPtrCast(data_ns)));
|
||||
ASSERT_TRUE(launch_data.get());
|
||||
ASSERT_EQ(LaunchDataGetType(launch_data.get()), LAUNCH_DATA_OPAQUE);
|
||||
EXPECT_EQ(LaunchDataGetOpaqueSize(launch_data.get()), sizeof(data_c));
|
||||
@ -174,7 +185,8 @@ TEST(Launchd, CFPropertyToLaunchData_Dictionary) {
|
||||
@"key" : @"value",
|
||||
};
|
||||
|
||||
launch_data.reset(CFPropertyToLaunchData(dictionary_ns));
|
||||
launch_data.reset(
|
||||
CFPropertyToLaunchData(base::apple::NSToCFPtrCast(dictionary_ns)));
|
||||
ASSERT_TRUE(launch_data.get());
|
||||
ASSERT_EQ(LaunchDataGetType(launch_data.get()), LAUNCH_DATA_DICTIONARY);
|
||||
EXPECT_EQ(LaunchDataDictGetCount(launch_data.get()), [dictionary_ns count]);
|
||||
@ -193,7 +205,8 @@ TEST(Launchd, CFPropertyToLaunchData_Array) {
|
||||
|
||||
NSArray* array_ns = @[ @"element_1", @"element_2", ];
|
||||
|
||||
launch_data.reset(CFPropertyToLaunchData(array_ns));
|
||||
launch_data.reset(
|
||||
CFPropertyToLaunchData(base::apple::NSToCFPtrCast(array_ns)));
|
||||
ASSERT_TRUE(launch_data.get());
|
||||
ASSERT_EQ(LaunchDataGetType(launch_data.get()), LAUNCH_DATA_ARRAY);
|
||||
EXPECT_EQ(LaunchDataArrayGetCount(launch_data.get()), [array_ns count]);
|
||||
@ -219,18 +232,20 @@ TEST(Launchd, CFPropertyToLaunchData_NSDate) {
|
||||
base::mac::ScopedLaunchData launch_data;
|
||||
|
||||
NSDate* date = [NSDate date];
|
||||
launch_data.reset(CFPropertyToLaunchData(date));
|
||||
launch_data.reset(CFPropertyToLaunchData(base::apple::NSToCFPtrCast(date)));
|
||||
EXPECT_FALSE(launch_data.get());
|
||||
|
||||
NSDictionary* date_dictionary = @{
|
||||
@"key" : @"value",
|
||||
@"date" : date,
|
||||
};
|
||||
launch_data.reset(CFPropertyToLaunchData(date_dictionary));
|
||||
launch_data.reset(
|
||||
CFPropertyToLaunchData(base::apple::NSToCFPtrCast(date_dictionary)));
|
||||
EXPECT_FALSE(launch_data.get());
|
||||
|
||||
NSArray* date_array = @[ @"string_1", date, @"string_2", ];
|
||||
launch_data.reset(CFPropertyToLaunchData(date_array));
|
||||
launch_data.reset(
|
||||
CFPropertyToLaunchData(base::apple::NSToCFPtrCast(date_array)));
|
||||
EXPECT_FALSE(launch_data.get());
|
||||
}
|
||||
}
|
||||
@ -249,7 +264,8 @@ TEST(Launchd, CFPropertyToLaunchData_RealWorldJobDictionary) {
|
||||
},
|
||||
};
|
||||
|
||||
launch_data.reset(CFPropertyToLaunchData(job_dictionary));
|
||||
launch_data.reset(
|
||||
CFPropertyToLaunchData(base::apple::NSToCFPtrCast(job_dictionary)));
|
||||
ASSERT_TRUE(launch_data.get());
|
||||
ASSERT_EQ(LaunchDataGetType(launch_data.get()), LAUNCH_DATA_DICTIONARY);
|
||||
EXPECT_EQ(LaunchDataDictGetCount(launch_data.get()), 4u);
|
||||
|
@ -19,10 +19,13 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
namespace {
|
||||
@ -33,8 +36,8 @@ namespace {
|
||||
// check for with ASSERT_NO_FATAL_FAILURE() or testing::Test::HasFatalFailure().
|
||||
void SwVers(NSString* argument, std::string* output) {
|
||||
@autoreleasepool {
|
||||
base::scoped_nsobject<NSPipe> pipe([[NSPipe alloc] init]);
|
||||
base::scoped_nsobject<NSTask> task([[NSTask alloc] init]);
|
||||
NSPipe* pipe = [[NSPipe alloc] init];
|
||||
NSTask* task = [[NSTask alloc] init];
|
||||
[task setStandardOutput:pipe];
|
||||
[task setLaunchPath:@"/usr/bin/sw_vers"];
|
||||
[task setArguments:@[ argument ]];
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/apple/bridging.h"
|
||||
#include "base/mac/scoped_cftyperef.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
@ -30,6 +30,10 @@
|
||||
#include "util/posix/process_info.h"
|
||||
#include "util/stdlib/objc.h"
|
||||
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
namespace crashpad {
|
||||
namespace test {
|
||||
namespace {
|
||||
@ -124,7 +128,7 @@ TEST(ServiceManagement, SubmitRemoveJob) {
|
||||
@[ @"/bin/sh", @"-c", shell_script_ns, ],
|
||||
};
|
||||
CFDictionaryRef job_dictionary_cf =
|
||||
base::mac::NSToCFCast(job_dictionary_ns);
|
||||
base::apple::NSToCFPtrCast(job_dictionary_ns);
|
||||
|
||||
// The job may be left over from a failed previous run.
|
||||
if (ServiceManagementIsJobLoaded(kJobLabel)) {
|
||||
|
@ -17,8 +17,8 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include "base/apple/bridging.h"
|
||||
#include "base/mac/foundation_util.h"
|
||||
#import "base/mac/scoped_nsobject.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "build/build_config.h"
|
||||
@ -28,12 +28,16 @@
|
||||
#include "util/misc/metrics.h"
|
||||
#include "util/net/http_body.h"
|
||||
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
// An implementation of NSInputStream that reads from a
|
||||
// crashpad::HTTPBodyStream.
|
||||
@interface CrashpadHTTPBodyStreamTransport : NSInputStream {
|
||||
@private
|
||||
NSStreamStatus _streamStatus;
|
||||
id<NSStreamDelegate> _delegate;
|
||||
id<NSStreamDelegate> __strong _delegate;
|
||||
crashpad::HTTPBodyStream* _bodyStream; // weak
|
||||
}
|
||||
- (instancetype)initWithBodyStream:(crashpad::HTTPBodyStream*)bodyStream;
|
||||
@ -154,12 +158,13 @@ NSString* UserAgentString() {
|
||||
// Expected to be CFNetwork.
|
||||
NSBundle* nsurl_bundle = [NSBundle bundleForClass:[NSURLRequest class]];
|
||||
NSString* bundle_name = base::mac::ObjCCast<NSString>([nsurl_bundle
|
||||
objectForInfoDictionaryKey:base::mac::CFToNSCast(kCFBundleNameKey)]);
|
||||
objectForInfoDictionaryKey:base::apple::CFToNSPtrCast(kCFBundleNameKey)]);
|
||||
if (bundle_name) {
|
||||
user_agent = AppendEscapedFormat(user_agent, @" %@", bundle_name);
|
||||
|
||||
NSString* bundle_version = base::mac::ObjCCast<NSString>([nsurl_bundle
|
||||
objectForInfoDictionaryKey:base::mac::CFToNSCast(kCFBundleVersionKey)]);
|
||||
NSString* bundle_version = base::mac::ObjCCast<NSString>(
|
||||
[nsurl_bundle objectForInfoDictionaryKey:base::apple::CFToNSPtrCast(
|
||||
kCFBundleVersionKey)]);
|
||||
if (bundle_version) {
|
||||
user_agent = AppendEscapedFormat(user_agent, @"/%@", bundle_version);
|
||||
}
|
||||
@ -240,10 +245,9 @@ bool HTTPTransportMac::ExecuteSynchronously(std::string* response_body) {
|
||||
forHTTPHeaderField:base::SysUTF8ToNSString(pair.first)];
|
||||
}
|
||||
|
||||
base::scoped_nsobject<NSInputStream> input_stream(
|
||||
[[CrashpadHTTPBodyStreamTransport alloc]
|
||||
initWithBodyStream:body_stream()]);
|
||||
[request setHTTPBodyStream:input_stream.get()];
|
||||
NSInputStream* input_stream = [[CrashpadHTTPBodyStreamTransport alloc]
|
||||
initWithBodyStream:body_stream()];
|
||||
[request setHTTPBodyStream:input_stream];
|
||||
|
||||
NSURLResponse* response = nil;
|
||||
NSError* error = nil;
|
||||
|
Loading…
x
Reference in New Issue
Block a user