mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
mac: Switch from <AvailabilityMacros.h> to <Availability.h>
The macOS 11.0 SDK, as of Xcode 12b6 12A8189n, has not updated <AvailabilityMacros.h> with a MAC_OS_X_VERSION_11_0 or MAC_OS_X_VERSION_10_16 constant. However, the <Availability.h> interface has been updated to provide both __MAC_11_0 and __MAC_10_16. <AvailabilityMacros.h>’s MAC_OS_X_VERSION_MAX_ALLOWED, which is supposed to identify the SDK version, is broken in the 11.0 SDK in that whenever the deployment target is set to 10.15 or earlier, the SDK will be mis-identified through this interface as 10.15. When using the <Availability.h> equivalent, __MAC_OS_X_VERSION_MAX_ALLOWED, the 11.0 SDK is identified as 10.16 (arguably it should be internally versioned as 11.0, but at least this interface allows it to be detected unambiguously.) It’s clear that the <AvailabilityMacros.h> interface provides no meaningful support for the macOS 11.0 SDK at all, but <Availability.h> does. <Availability.h> was introduced in the Mac OS X 10.5 SDK, so there is no relevant SDK version compatibility problem with this interface. Key differences between these interfaces for the purposes used by Crashpad: - <AvailabilityMacros.h> → <Availability.h> - MAC_OS_X_VERSION_MIN_REQUIRED (DT) → __MAC_OS_X_VERSION_MIN_REQUIRED - MAC_OS_X_VERSION_MAX_ALLOWED (SDK) → __MAC_OS_X_VERSION_MAX_ALLOWED - MAC_OS_X_VERSION_x_y → __MAC_x_y - <Availability.h> __MAC_OS_X_VERSION_* SDK/DT macros are only available when targeting macOS, while <AvailabilityMacros.h> MAC_OS_X_VERSION_* SDK/DT macros are available on all Apple platforms, which may be a source of confusion. (<Availability.h> __MAC_* macros do remain available on all Apple platforms.) This change was made mostly mechanically by: sed -i '' -Ee 's/<AvailabilityMacros.h>/<Availability.h>/g' \ $(git grep -E -l '<AvailabilityMacros.h>' | grep -v AvailabilityMacros.h) sed -i '' -Ee 's/(MAC_OS_X_VERSION_(MIN_REQUIRED|MAX_ALLOWED))/__\1/g' \ $(git grep -E -l 'MAC_OS_X_VERSION_(MIN_REQUIRED|MAX_ALLOWED)' | grep -v AvailabilityMacros.h) sed -i '' -Ee 's/(MAC_OS_X_VERSION_(10_[0-9]+))/__MAC_\2/g' \ $(git grep -E -l 'MAC_OS_X_VERSION_(10_[0-9]+)' | grep -v AvailabilityMacros.h) Bug: crashpad:347 Change-Id: Ibdcd7a6215a82f7060b7b67d98691f88454085fc Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2382421 Reviewed-by: Robert Sesek <rsesek@chromium.org> Commit-Queue: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
364fdd65a0
commit
bdf9471324
@ -57,7 +57,7 @@ template("compat_target") {
|
||||
# static_library.
|
||||
group(target_name) {
|
||||
forward_variables_from(invoker, "*")
|
||||
not_needed(["configs"])
|
||||
not_needed([ "configs" ])
|
||||
}
|
||||
} else {
|
||||
static_library(target_name) {
|
||||
@ -71,7 +71,8 @@ compat_target("compat") {
|
||||
|
||||
if (crashpad_is_mac || crashpad_is_ios) {
|
||||
sources += [
|
||||
"mac/AvailabilityMacros.h",
|
||||
"mac/Availability.h",
|
||||
"mac/AvailabilityVersions.h",
|
||||
"mac/kern/exc_resource.h",
|
||||
"mac/mach-o/loader.h",
|
||||
"mac/mach/i386/thread_state.h",
|
||||
|
@ -38,7 +38,8 @@
|
||||
'linux/signal.h',
|
||||
'linux/sys/ptrace.h',
|
||||
'linux/sys/user.h',
|
||||
'mac/AvailabilityMacros.h',
|
||||
'mac/Availability.h',
|
||||
'mac/AvailabilityVersions.h',
|
||||
'mac/kern/exc_resource.h',
|
||||
'mac/mach/i386/thread_state.h',
|
||||
'mac/mach/mach.h',
|
||||
|
28
compat/mac/Availability.h
Normal file
28
compat/mac/Availability.h
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright 2020 The Crashpad Authors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_COMPAT_MAC_AVAILABILITY_H_
|
||||
#define CRASHPAD_COMPAT_MAC_AVAILABILITY_H_
|
||||
|
||||
// Until the 10.15 SDK, the contents of <AvailabilityVersions.h> was in-line in
|
||||
// <Availability.h>, but since then, it was broken out into its own header.
|
||||
// This compat version of <Availability.h> allows these macros to always appear
|
||||
// to be provided by the new header, <AvailabilityVersions.h>, even when an
|
||||
// older SDK is in use.
|
||||
|
||||
#include_next <Availability.h>
|
||||
|
||||
#include <AvailabilityVersions.h>
|
||||
|
||||
#endif // CRASHPAD_COMPAT_MAC_AVAILABILITY_H_
|
@ -1,74 +0,0 @@
|
||||
// Copyright 2014 The Crashpad Authors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_COMPAT_MAC_AVAILABILITYMACROS_H_
|
||||
#define CRASHPAD_COMPAT_MAC_AVAILABILITYMACROS_H_
|
||||
|
||||
#include_next <AvailabilityMacros.h>
|
||||
|
||||
// 10.7 SDK
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_7
|
||||
#define MAC_OS_X_VERSION_10_7 1070
|
||||
#endif
|
||||
|
||||
// 10.8 SDK
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_8
|
||||
#define MAC_OS_X_VERSION_10_8 1080
|
||||
#endif
|
||||
|
||||
// 10.9 SDK
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_9
|
||||
#define MAC_OS_X_VERSION_10_9 1090
|
||||
#endif
|
||||
|
||||
// 10.10 SDK
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_10
|
||||
#define MAC_OS_X_VERSION_10_10 101000
|
||||
#endif
|
||||
|
||||
// 10.11 SDK
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_11
|
||||
#define MAC_OS_X_VERSION_10_11 101100
|
||||
#endif
|
||||
|
||||
// 10.12 SDK
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_12
|
||||
#define MAC_OS_X_VERSION_10_12 101200
|
||||
#endif
|
||||
|
||||
// 10.13 SDK
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_13
|
||||
#define MAC_OS_X_VERSION_10_13 101300
|
||||
#endif
|
||||
|
||||
// 10.14 SDK
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_14
|
||||
#define MAC_OS_X_VERSION_10_14 101400
|
||||
#endif
|
||||
|
||||
// 10.15 SDK
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_15
|
||||
#define MAC_OS_X_VERSION_10_15 101500
|
||||
#endif
|
||||
|
||||
#endif // CRASHPAD_COMPAT_MAC_AVAILABILITYMACROS_H_
|
86
compat/mac/AvailabilityVersions.h
Normal file
86
compat/mac/AvailabilityVersions.h
Normal file
@ -0,0 +1,86 @@
|
||||
// Copyright 2020 The Crashpad Authors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CRASHPAD_COMPAT_MAC_AVAILABILITYVERSIONS_H_
|
||||
#define CRASHPAD_COMPAT_MAC_AVAILABILITYVERSIONS_H_
|
||||
|
||||
#if __has_include_next(<AvailabilityVersions.h>)
|
||||
#include_next <AvailabilityVersions.h>
|
||||
#endif
|
||||
|
||||
// 10.7 SDK
|
||||
|
||||
#ifndef __MAC_10_7
|
||||
#define __MAC_10_7 1070
|
||||
#endif
|
||||
|
||||
// 10.8 SDK
|
||||
|
||||
#ifndef __MAC_10_8
|
||||
#define __MAC_10_8 1080
|
||||
#endif
|
||||
|
||||
// 10.9 SDK
|
||||
|
||||
#ifndef __MAC_10_9
|
||||
#define __MAC_10_9 1090
|
||||
#endif
|
||||
|
||||
// 10.10 SDK
|
||||
|
||||
#ifndef __MAC_10_10
|
||||
#define __MAC_10_10 101000
|
||||
#endif
|
||||
|
||||
// 10.11 SDK
|
||||
|
||||
#ifndef __MAC_10_11
|
||||
#define __MAC_10_11 101100
|
||||
#endif
|
||||
|
||||
// 10.12 SDK
|
||||
|
||||
#ifndef __MAC_10_12
|
||||
#define __MAC_10_12 101200
|
||||
#endif
|
||||
|
||||
// 10.13 SDK
|
||||
|
||||
#ifndef __MAC_10_13
|
||||
#define __MAC_10_13 101300
|
||||
#endif
|
||||
|
||||
// 10.14 SDK
|
||||
|
||||
#ifndef __MAC_10_14
|
||||
#define __MAC_10_14 101400
|
||||
#endif
|
||||
|
||||
// 10.15 SDK
|
||||
|
||||
#ifndef __MAC_10_15
|
||||
#define __MAC_10_15 101500
|
||||
#endif
|
||||
|
||||
// 11.0 SDK
|
||||
|
||||
#ifndef __MAC_10_16
|
||||
#define __MAC_10_16 101600
|
||||
#endif
|
||||
|
||||
#ifndef __MAC_11_0
|
||||
#define __MAC_11_0 110000
|
||||
#endif
|
||||
|
||||
#endif // CRASHPAD_COMPAT_MAC_AVAILABILITYVERSIONS_H_
|
@ -31,7 +31,7 @@
|
||||
#include "util/numeric/safe_assignment.h"
|
||||
|
||||
#if defined(OS_APPLE)
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <Availability.h>
|
||||
#elif defined(OS_ANDROID)
|
||||
#include <android/api-level.h>
|
||||
#endif
|
||||
@ -66,20 +66,19 @@ std::string BuildString(const SystemSnapshot* system_snapshot) {
|
||||
return machine_description;
|
||||
}
|
||||
|
||||
#if defined(OS_APPLE)
|
||||
// Converts the value of the MAC_OS_VERSION_MIN_REQUIRED or
|
||||
// MAC_OS_X_VERSION_MAX_ALLOWED macro from <AvailabilityMacros.h> to a number
|
||||
#if defined(OS_MAC)
|
||||
// Converts the value of the __MAC_OS_X_VERSION_MIN_REQUIRED or
|
||||
// __MAC_OS_X_VERSION_MAX_ALLOWED macro from <Availability.h> to a number
|
||||
// identifying the minor macOS version that it represents. For example, with an
|
||||
// argument of MAC_OS_X_VERSION_10_6, this function will return 6.
|
||||
// argument of __MAC_10_6, this function will return 6.
|
||||
int AvailabilityVersionToMacOSXMinorVersion(int availability) {
|
||||
// Through MAC_OS_X_VERSION_10_9, the minor version is the tens digit.
|
||||
// Through __MAC_10_9, the minor version is the tens digit.
|
||||
if (availability >= 1000 && availability <= 1099) {
|
||||
return (availability / 10) % 10;
|
||||
}
|
||||
|
||||
// After MAC_OS_X_VERSION_10_9, the older format was insufficient to represent
|
||||
// versions. Since then, the minor version is the thousands and hundreds
|
||||
// digits.
|
||||
// After __MAC_10_9, the older format was insufficient to represent versions.
|
||||
// Since then, the minor version is the thousands and hundreds digits.
|
||||
if (availability >= 100000 && availability <= 109999) {
|
||||
return (availability / 100) % 100;
|
||||
}
|
||||
@ -136,11 +135,11 @@ std::string MinidumpMiscInfoDebugBuildString() {
|
||||
PACKAGE_VERSION,
|
||||
kOS);
|
||||
|
||||
#if defined(OS_APPLE)
|
||||
#if defined(OS_MAC)
|
||||
debug_build_string += base::StringPrintf(
|
||||
",%d,%d",
|
||||
AvailabilityVersionToMacOSXMinorVersion(MAC_OS_X_VERSION_MIN_REQUIRED),
|
||||
AvailabilityVersionToMacOSXMinorVersion(MAC_OS_X_VERSION_MAX_ALLOWED));
|
||||
AvailabilityVersionToMacOSXMinorVersion(__MAC_OS_X_VERSION_MIN_REQUIRED),
|
||||
AvailabilityVersionToMacOSXMinorVersion(__MAC_OS_X_VERSION_MAX_ALLOWED));
|
||||
#elif defined(OS_ANDROID)
|
||||
debug_build_string += base::StringPrintf(",%d", __ANDROID_API__);
|
||||
#endif
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "snapshot/mac/mach_o_image_reader.h"
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <Availability.h>
|
||||
#include <dlfcn.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#include <mach-o/dyld_images.h>
|
||||
@ -606,7 +606,7 @@ TEST(MachOImageReader, Self_DyldImages) {
|
||||
ASSERT_NO_FATAL_FAILURE(ExpectSymbolTable(mach_header, &image_reader));
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7
|
||||
// If dyld is new enough to record UUIDs, check the UUID of any module that
|
||||
// it says has one. Note that dyld doesn’t record UUIDs of anything that
|
||||
// loaded out of the shared cache, but it should at least have a UUID for the
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "snapshot/mac/process_reader_mac.h"
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <Availability.h>
|
||||
#include <mach-o/loader.h>
|
||||
#include <mach/mach_vm.h>
|
||||
|
||||
@ -213,7 +213,7 @@ mach_vm_address_t ProcessReaderMac::DyldAllImageInfo(
|
||||
// This may look for the module that matches the executable path in the same
|
||||
// data set that vmmap uses.
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7
|
||||
// The task_dyld_info_data_t struct grew in 10.7, adding the format field.
|
||||
// Don’t check this field if it’s not present, which can happen when either
|
||||
// the SDK used at compile time or the kernel at run time are too old and
|
||||
|
@ -14,9 +14,9 @@
|
||||
|
||||
#include "snapshot/mac/process_reader_mac.h"
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <errno.h>
|
||||
#include <Availability.h>
|
||||
#include <OpenCL/opencl.h>
|
||||
#include <errno.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#include <mach-o/dyld_images.h>
|
||||
#include <mach/mach.h>
|
||||
@ -569,12 +569,12 @@ class ScopedOpenCLNoOpKernel {
|
||||
cl_int rv = clGetPlatformIDs(1, &platform_id, nullptr);
|
||||
ASSERT_EQ(rv, CL_SUCCESS) << "clGetPlatformIDs";
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10 && \
|
||||
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
|
||||
// cl_device_id is really available in OpenCL.framework back to 10.5, but in
|
||||
// the 10.10 SDK and later, OpenCL.framework includes <OpenGL/CGLDevice.h>,
|
||||
// which has its own cl_device_id that was introduced in 10.10. That
|
||||
// triggers erroneous availability warnings.
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_10 && \
|
||||
__MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_10
|
||||
// cl_device_id is really available in OpenCL.framework back to 10.5, but in
|
||||
// the 10.10 SDK and later, OpenCL.framework includes <OpenGL/CGLDevice.h>,
|
||||
// which has its own cl_device_id that was introduced in 10.10. That
|
||||
// triggers erroneous availability warnings.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||
#define DISABLED_WUNGUARDED_AVAILABILITY
|
||||
@ -640,7 +640,7 @@ class ScopedOpenCLNoOpKernel {
|
||||
// OpenCL kernels that run on the CPU do not result in cl_kernels images
|
||||
// appearing on that OS version.
|
||||
bool ExpectCLKernels() {
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_7
|
||||
return true;
|
||||
#else
|
||||
return MacOSXMinorVersion() >= 7;
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "snapshot/mac/process_types.h"
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <Availability.h>
|
||||
#include <mach/mach.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -68,7 +68,7 @@ TEST(ProcessTypes, DyldImagesSelf) {
|
||||
if (self_image_infos->version >= 2) {
|
||||
EXPECT_TRUE(self_image_infos->libSystemInitialized);
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7
|
||||
if (self_image_infos->version >= 9) {
|
||||
EXPECT_EQ(self_image_infos->dyldAllImageInfosAddress, self_image_infos);
|
||||
}
|
||||
@ -90,7 +90,7 @@ TEST(ProcessTypes, DyldImagesSelf) {
|
||||
|
||||
// This field is only present in the OS X 10.7 SDK (at build time) and kernel
|
||||
// (at run time).
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7
|
||||
if (MacOSXMinorVersion() >= 7) {
|
||||
#if !defined(ARCH_CPU_64_BITS)
|
||||
EXPECT_EQ(dyld_info.all_image_info_format, TASK_DYLD_ALL_IMAGE_INFO_32);
|
||||
@ -103,15 +103,15 @@ TEST(ProcessTypes, DyldImagesSelf) {
|
||||
ProcessReaderMac process_reader;
|
||||
ASSERT_TRUE(process_reader.Initialize(mach_task_self()));
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_15
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_15
|
||||
constexpr uint32_t kDyldAllImageInfosVersionInSDK = 16;
|
||||
#elif MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
|
||||
#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12
|
||||
constexpr uint32_t kDyldAllImageInfosVersionInSDK = 15;
|
||||
#elif MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
|
||||
#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_9
|
||||
constexpr uint32_t kDyldAllImageInfosVersionInSDK = 14;
|
||||
#elif MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7
|
||||
constexpr uint32_t kDyldAllImageInfosVersionInSDK = 12;
|
||||
#elif MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||
#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_6
|
||||
constexpr uint32_t kDyldAllImageInfosVersionInSDK = 7;
|
||||
#else
|
||||
constexpr uint32_t kDyldAllImageInfosVersionInSDK = 1;
|
||||
@ -126,11 +126,11 @@ TEST(ProcessTypes, DyldImagesSelf) {
|
||||
// test can only be performed if the run-time OS natively uses the same format
|
||||
// structure as the SDK.
|
||||
bool test_expected_size_for_version_matches_sdk_sizeof;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_12
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED == __MAC_10_12
|
||||
test_expected_size_for_version_matches_sdk_sizeof =
|
||||
mac_os_x_minor_version == 12;
|
||||
#elif MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_13 && \
|
||||
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_15
|
||||
#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_13 && \
|
||||
__MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_15
|
||||
test_expected_size_for_version_matches_sdk_sizeof =
|
||||
mac_os_x_minor_version >= 13 && mac_os_x_minor_version <= 14;
|
||||
#else
|
||||
@ -257,7 +257,7 @@ TEST(ProcessTypes, DyldImagesSelf) {
|
||||
EXPECT_EQ(proctype_image_infos.systemOrderFlag,
|
||||
implicit_cast<uint64_t>(self_image_infos->systemOrderFlag));
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7
|
||||
if (proctype_image_infos.version >= 8) {
|
||||
EXPECT_EQ(proctype_image_infos.uuidArrayCount,
|
||||
implicit_cast<uint64_t>(self_image_infos->uuidArrayCount));
|
||||
@ -299,7 +299,7 @@ TEST(ProcessTypes, DyldImagesSelf) {
|
||||
implicit_cast<uint64_t>(self_image_infos->sharedCacheSlide));
|
||||
}
|
||||
#endif
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_9
|
||||
if (proctype_image_infos.version >= 13) {
|
||||
EXPECT_EQ(memcmp(self_image_infos->sharedCacheUUID,
|
||||
proctype_image_infos.sharedCacheUUID,
|
||||
@ -307,7 +307,7 @@ TEST(ProcessTypes, DyldImagesSelf) {
|
||||
0);
|
||||
}
|
||||
#endif
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12
|
||||
if (proctype_image_infos.version >= 15) {
|
||||
EXPECT_EQ(proctype_image_infos.infoArrayChangeTimestamp,
|
||||
self_image_infos->infoArrayChangeTimestamp);
|
||||
@ -327,7 +327,7 @@ TEST(ProcessTypes, DyldImagesSelf) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12
|
||||
// As dyld_all_image_infos has evolved over time, new fields were added to the
|
||||
// reserved region. process_types::dyld_all_image_infos declares a recent
|
||||
// version of the structure, but an older SDK may declare an older version
|
||||
@ -352,7 +352,7 @@ TEST(ProcessTypes, DyldImagesSelf) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_13
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_13
|
||||
if (proctype_image_infos.version >= 15 && mac_os_x_minor_version >= 13) {
|
||||
EXPECT_EQ(proctype_image_infos.compact_dyld_image_info_addr,
|
||||
self_image_infos->compact_dyld_image_info_addr);
|
||||
@ -361,7 +361,7 @@ TEST(ProcessTypes, DyldImagesSelf) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_15
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_15
|
||||
if (proctype_image_infos.version >= 16) {
|
||||
EXPECT_EQ(proctype_image_infos.platform, self_image_infos->platform);
|
||||
}
|
||||
@ -399,7 +399,7 @@ TEST(ProcessTypes, DyldImagesSelf) {
|
||||
}
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7
|
||||
if (proctype_image_infos.version >= 8) {
|
||||
std::vector<process_types::dyld_uuid_info> proctype_uuid_info_vector(
|
||||
proctype_image_infos.uuidArrayCount);
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "snapshot/mac/system_snapshot_mac.h"
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <Availability.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
@ -364,7 +364,7 @@ bool SystemSnapshotMac::NXEnabled() const {
|
||||
// xnu-6153.11.26/bsd/kern/kern_sysctl.c (10.14.4 and 10.14.5 xnu source
|
||||
// are not yet available). In newer production kernels, NX is always
|
||||
// enabled. See 10.15.0 xnu-6153.11.26/osfmk/x86_64/pmap.c nx_enabled.
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_14
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_14
|
||||
const bool nx_always_enabled = true;
|
||||
#else // DT >= 10.14
|
||||
base::ScopedClearLastError reset_errno;
|
||||
|
@ -14,10 +14,10 @@
|
||||
|
||||
#include "test/mac/dyld.h"
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <Availability.h>
|
||||
#include <dlfcn.h>
|
||||
#include <mach/mach.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#include <mach/mach.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "base/logging.h"
|
||||
@ -25,7 +25,7 @@
|
||||
#include "test/scoped_module_handle.h"
|
||||
#include "util/numeric/safe_assignment.h"
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_13
|
||||
extern "C" {
|
||||
|
||||
// A non-public dyld API, declared in 10.12.4
|
||||
@ -41,14 +41,14 @@ namespace crashpad {
|
||||
namespace test {
|
||||
|
||||
const dyld_all_image_infos* DyldGetAllImageInfos() {
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_13
|
||||
// When building with the pre-10.13 SDK, the weak_import declaration above is
|
||||
// available and a symbol will be present in the SDK to link against. If the
|
||||
// old interface is also available at run time (running on pre-10.13), use it.
|
||||
if (_dyld_get_all_image_infos) {
|
||||
return _dyld_get_all_image_infos();
|
||||
}
|
||||
#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_13
|
||||
#elif __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_13
|
||||
// When building with the 10.13 SDK or later, but able to run on pre-10.13,
|
||||
// look for _dyld_get_all_image_infos in the same module that provides
|
||||
// _dyld_image_count. There’s no symbol in the SDK to link against, so this is
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "test/mac/mach_multiprocess.h"
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <Availability.h>
|
||||
#include <bsm/libbsm.h>
|
||||
|
||||
#include <memory>
|
||||
@ -150,7 +150,7 @@ void MachMultiprocess::MultiprocessParent() {
|
||||
// and other processes will be able to look it up and send messages to it,
|
||||
// these checks disambiguate genuine failures later on in the test from those
|
||||
// that would occur if an errant process sends a message to this service.
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8
|
||||
uid_t audit_auid;
|
||||
uid_t audit_euid;
|
||||
gid_t audit_egid;
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "util/mach/exc_server_variants.h"
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <Availability.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <algorithm>
|
||||
@ -682,7 +682,7 @@ kern_return_t ExcServerSuccessfulReturnValue(exception_type_t exception,
|
||||
exception_behavior_t behavior,
|
||||
bool set_thread_state) {
|
||||
if (exception == EXC_CRASH
|
||||
#if !defined(OS_IOS) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11
|
||||
#if !defined(OS_IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_11
|
||||
&& MacOSXMinorVersion() >= 11
|
||||
#endif
|
||||
) {
|
||||
|
@ -15,11 +15,10 @@
|
||||
#include "util/mach/exception_types.h"
|
||||
|
||||
#include <Availability.h>
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <libproc.h>
|
||||
#include <kern/exc_resource.h>
|
||||
#include <libproc.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "base/check_op.h"
|
||||
@ -29,7 +28,7 @@
|
||||
#include "util/mach/mach_extensions.h"
|
||||
#include "util/numeric/in_range_cast.h"
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_9
|
||||
|
||||
extern "C" {
|
||||
|
||||
@ -83,13 +82,13 @@ namespace {
|
||||
// present on OS X 10.9 and later. If it’s not available, sets errno to ENOSYS
|
||||
// and returns -1.
|
||||
int ProcGetWakemonParams(pid_t pid, int* rate_hz, int* flags) {
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_9
|
||||
// proc_get_wakemon_params() isn’t in the SDK. Look it up dynamically.
|
||||
static ProcGetWakemonParamsType proc_get_wakemon_params =
|
||||
GetProcGetWakemonParams();
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_9
|
||||
// proc_get_wakemon_params() is definitely available if the deployment target
|
||||
// is 10.9 or newer.
|
||||
if (!proc_get_wakemon_params) {
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "util/mach/mach_extensions.h"
|
||||
|
||||
#include <Availability.h>
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "base/mac/mach_logging.h"
|
||||
@ -50,7 +49,7 @@ exception_mask_t ExcMaskAll() {
|
||||
#error This code was not ported to iOS versions older than 7
|
||||
#endif
|
||||
|
||||
#if !defined(OS_IOS) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
|
||||
#if !defined(OS_IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_9
|
||||
const int mac_os_x_minor_version = MacOSXMinorVersion();
|
||||
#endif
|
||||
|
||||
@ -67,7 +66,7 @@ exception_mask_t ExcMaskAll() {
|
||||
EXC_MASK_MACH_SYSCALL |
|
||||
EXC_MASK_RPC_ALERT |
|
||||
EXC_MASK_MACHINE;
|
||||
#if !defined(OS_IOS) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
|
||||
#if !defined(OS_IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8
|
||||
if (mac_os_x_minor_version < 8) {
|
||||
return kExcMaskAll_10_6;
|
||||
}
|
||||
@ -77,7 +76,7 @@ exception_mask_t ExcMaskAll() {
|
||||
// xnu-2050.48.11/osfmk/mach/exception_types.h.
|
||||
constexpr exception_mask_t kExcMaskAll_10_8 =
|
||||
kExcMaskAll_10_6 | EXC_MASK_RESOURCE;
|
||||
#if !defined(OS_IOS) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
|
||||
#if !defined(OS_IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_9
|
||||
if (mac_os_x_minor_version < 9) {
|
||||
return kExcMaskAll_10_8;
|
||||
}
|
||||
@ -97,7 +96,7 @@ exception_mask_t ExcMaskValid() {
|
||||
#error This code was not ported to iOS versions older than 9
|
||||
#endif
|
||||
|
||||
#if !defined(OS_IOS) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11
|
||||
#if !defined(OS_IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_11
|
||||
if (MacOSXMinorVersion() < 11) {
|
||||
return kExcMaskValid_10_6;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "util/mach/mach_message.h"
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <Availability.h>
|
||||
|
||||
#include <limits>
|
||||
|
||||
@ -269,7 +269,7 @@ pid_t AuditPIDFromMachMessageTrailer(const mach_msg_trailer_t* trailer) {
|
||||
const mach_msg_audit_trailer_t* audit_trailer =
|
||||
reinterpret_cast<const mach_msg_audit_trailer_t*>(trailer);
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8
|
||||
pid_t audit_pid;
|
||||
audit_token_to_au32(audit_trailer->msgh_audit,
|
||||
nullptr,
|
||||
|
@ -15,10 +15,10 @@
|
||||
#ifndef CRASHPAD_UTIL_STDLIB_OBJC_H_
|
||||
#define CRASHPAD_UTIL_STDLIB_OBJC_H_
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <Availability.h>
|
||||
#include <objc/objc.h>
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_8
|
||||
|
||||
// In order for the @NO and @YES literals to work, NO and YES must be defined as
|
||||
// __objc_no and __objc_yes. See
|
||||
|
@ -14,9 +14,9 @@
|
||||
|
||||
#include "util/stdlib/strnlen.h"
|
||||
|
||||
#if defined(OS_MAC) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
|
||||
#if defined(OS_MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_7
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7
|
||||
// Redeclare a method only available on Mac OS X 10.7 and later to suppress a
|
||||
// -Wpartial-availability warning.
|
||||
extern "C" {
|
||||
@ -27,7 +27,7 @@ size_t strnlen(const char* string, size_t max_length);
|
||||
namespace crashpad {
|
||||
|
||||
size_t strnlen(const char* string, size_t max_length) {
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7
|
||||
if (::strnlen) {
|
||||
return ::strnlen(string, max_length);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "build/build_config.h"
|
||||
|
||||
#if defined(OS_MAC)
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <Availability.h>
|
||||
#endif
|
||||
|
||||
namespace crashpad {
|
||||
@ -38,7 +38,7 @@ namespace crashpad {
|
||||
//! and not all systems’ standard libraries provide an implementation.
|
||||
size_t strnlen(const char* string, size_t max_length);
|
||||
|
||||
#if !defined(OS_MAC) || MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
|
||||
#if !defined(OS_MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_7
|
||||
inline size_t strnlen(const char* string, size_t max_length) {
|
||||
return ::strnlen(string, max_length);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user