Drop 10.5 support.

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/575823002
This commit is contained in:
Mark Mentovai 2014-09-16 11:55:55 -04:00
parent e49510ab7c
commit 850ec0657d
13 changed files with 6 additions and 334 deletions

View File

@ -23,7 +23,6 @@
'mac/mach-o/getsect.cc',
'mac/mach-o/getsect.h',
'mac/mach-o/loader.h',
'mac/servers/bootstrap.h',
'non_mac/mach/mach.h',
'non_win/dbghelp.h',
'non_win/minwinbase.h',

View File

@ -17,12 +17,6 @@
#include_next <AvailabilityMacros.h>
// 10.6 SDK
#ifndef MAC_OS_X_VERSION_10_6
#define MAC_OS_X_VERSION_10_6 1060
#endif
// 10.7 SDK
#ifndef MAC_OS_X_VERSION_10_7

View File

@ -61,16 +61,6 @@
// <mach/i386/thread_status.h>
// 10.6 SDK
#ifndef x86_AVX_STATE32
#define x86_AVX_STATE32 16
#endif
#ifndef x86_AVX_STATE64
#define x86_AVX_STATE64 17
#endif
// 10.8 SDK
#ifndef x86_AVX_STATE

View File

@ -1,28 +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_SERVERS_BOOTSTRAP_H_
#define CRASHPAD_COMPAT_MAC_SERVERS_BOOTSTRAP_H_
#include_next <servers/bootstrap.h>
// <servers/bootstrap.h>
// 10.6 SDK
#ifndef BOOTSTRAP_NO_CHILDREN
#define BOOTSTRAP_NO_CHILDREN 1106
#endif
#endif // CRASHPAD_COMPAT_MAC_SERVERS_BOOTSTRAP_H_

View File

@ -240,8 +240,7 @@ void ProcessReader::InitializeThreads() {
mach_msg_type_number_t thread_state_count =
Is64Bit() ? x86_THREAD_STATE64_COUNT : x86_THREAD_STATE32_COUNT;
// TODO(mark): Use the AVX variants instead of the FLOAT variants? Theyre
// supported on 10.6 and later.
// TODO(mark): Use the AVX variants instead of the FLOAT variants?
const thread_state_flavor_t kFloatStateFlavor =
Is64Bit() ? x86_FLOAT_STATE64 : x86_FLOAT_STATE32;
mach_msg_type_number_t float_state_count =
@ -354,8 +353,6 @@ void ProcessReader::InitializeModules() {
initialized_modules_ = true;
// This API only works on Mac OS X 10.6 and higher. On Mac OS X 10.5, find the
// “_dyld_all_image_infos” symbol in the loaded LC_LOAD_DYLINKER (dyld).
task_dyld_info_data_t dyld_info;
mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT;
kern_return_t kr = task_info(

View File

@ -105,7 +105,6 @@ TEST(ProcessTypes, DyldImagesSelf) {
EXPECT_EQ(self_image_infos->processDetachedFromSharedRegion,
proctype_image_infos.processDetachedFromSharedRegion);
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
if (proctype_image_infos.version >= 2) {
EXPECT_EQ(self_image_infos->libSystemInitialized,
proctype_image_infos.libSystemInitialized);
@ -139,7 +138,6 @@ TEST(ProcessTypes, DyldImagesSelf) {
EXPECT_EQ(static_cast<uint64_t>(self_image_infos->systemOrderFlag),
proctype_image_infos.systemOrderFlag);
}
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (proctype_image_infos.version >= 8) {
EXPECT_EQ(static_cast<uint64_t>(self_image_infos->uuidArrayCount),

View File

@ -1,88 +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.
#include "util/mach/bootstrap.h"
#include <AvailabilityMacros.h>
#include <servers/bootstrap.h>
#include "base/basictypes.h"
#include "base/mac/scoped_mach_port.h"
#include "util/mac/mac_util.h"
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_5
namespace {
// Wraps bootstrap_register to avoid the deprecation warning. It needs to be
// used on 10.5.
kern_return_t BootstrapRegister(mach_port_t bp,
name_t service_name,
mach_port_t sp) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
return bootstrap_register(bp, service_name, sp);
#pragma GCC diagnostic pop
}
} // namespace
#endif
namespace crashpad {
kern_return_t BootstrapCheckIn(mach_port_t bp,
const std::string& service_name,
mach_port_t* service_port) {
// bootstrap_check_in (until the 10.6 SDK) and bootstrap_register (all SDKs)
// are declared with a char* argument, but they dont actually modify the char
// data, so this is safe.
char* service_name_mutable = const_cast<char*>(service_name.c_str());
kern_return_t kr = bootstrap_check_in(bp, service_name_mutable, service_port);
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_5
if (kr == BOOTSTRAP_UNKNOWN_SERVICE && MacOSXMinorVersion() <= 5) {
// This code path should only be entered on 10.5 or earlier.
mach_port_t local_service_port;
kr = mach_port_allocate(
mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &local_service_port);
if (kr != KERN_SUCCESS) {
return kr;
}
base::mac::ScopedMachReceiveRight service_port_receive_right_owner(
local_service_port);
kr = mach_port_insert_right(mach_task_self(),
local_service_port,
local_service_port,
MACH_MSG_TYPE_MAKE_SEND);
if (kr != KERN_SUCCESS) {
return kr;
}
base::mac::ScopedMachSendRight service_port_send_right_owner(
local_service_port);
kr = BootstrapRegister(bp, service_name_mutable, local_service_port);
if (kr != BOOTSTRAP_SUCCESS) {
return kr;
}
ignore_result(service_port_receive_right_owner.release());
*service_port = local_service_port;
}
#endif
return kr;
}
} // namespace crashpad

View File

@ -1,46 +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_UTIL_MACH_BOOTSTRAP_H_
#define CRASHPAD_UTIL_MACH_BOOTSTRAP_H_
#include <mach/mach.h>
#include <string>
namespace crashpad {
//! \brief Calls `bootstrap_check_in()` to check in with the bootstrap server.
//!
//! \param[in] bp The bootstrap server to check in with.
//! \param[in] service_name The name of the service to check in.
//! \param[out] service_port The receive right for the checked-in service.
//!
//! \return `BOOTSTRAP_SUCCESS` on success, with \a service_port set
//! appropriately. Otherwise, any error that might be returned by
//! `bootstrap_check_in()`.
//!
//! This function is a wrapper around `bootstrap_check_in()`, checking in with
//! the bootstrap server at \a bp. It exists primarily for compatibility with
//! Mac OS X 10.5, where it is not possible to call `bootstrap_check_in()` for a
//! \a service_name that has not already been registered with the bootstrap
//! server using `bootstrap_register()`. `bootstrap_register()` was deprecated
//! in Mac OS X 10.5.
kern_return_t BootstrapCheckIn(mach_port_t bp,
const std::string& service_name,
mach_port_t* service_port);
} // namespace crashpad
#endif // CRASHPAD_UTIL_MACH_MACH_MESSAGE_SERVER_H_

View File

@ -1,135 +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.
#include "util/mach/bootstrap.h"
#include <mach/mach.h>
#include <servers/bootstrap.h>
#include <string.h>
#include <algorithm>
#include <string>
#include "base/basictypes.h"
#include "base/mac/scoped_mach_port.h"
#include "base/rand_util.h"
#include "gtest/gtest.h"
#include "util/mach/mach_extensions.h"
#include "util/test/mac/mach_errors.h"
namespace {
using namespace crashpad;
using namespace crashpad::test;
using namespace testing;
TEST(Bootstrap, BootstrapCheckIn) {
std::string service_name = "com.googlecode.crashpad.test.bootstrap.";
for (int index = 0; index < 16; ++index) {
service_name.append(1, base::RandInt('A', 'Z'));
}
// The service shouldnt be registered in the bootstrap namespace yet.
mach_port_t client_port = MACH_PORT_NULL;
kern_return_t kr =
bootstrap_look_up(bootstrap_port, service_name.c_str(), &client_port);
ASSERT_EQ(BOOTSTRAP_UNKNOWN_SERVICE, kr)
<< BootstrapErrorMessage(kr, "bootstrap_look_up");
// Check in, getting a receive right.
mach_port_t server_port;
kr = BootstrapCheckIn(bootstrap_port, service_name.c_str(), &server_port);
ASSERT_EQ(BOOTSTRAP_SUCCESS, kr)
<< BootstrapErrorMessage(kr, "bootstrap_check_in");
ASSERT_NE(kMachPortNull, server_port);
base::mac::ScopedMachReceiveRight server_port_owner(server_port);
// A subsequent checkin attempt should fail.
mach_port_t fail_port = MACH_PORT_NULL;
kr = BootstrapCheckIn(bootstrap_port, service_name.c_str(), &fail_port);
EXPECT_EQ(BOOTSTRAP_SERVICE_ACTIVE, kr);
EXPECT_EQ(kMachPortNull, fail_port);
// Look up the service, getting a send right.
kr = bootstrap_look_up(bootstrap_port, service_name.c_str(), &client_port);
ASSERT_EQ(BOOTSTRAP_SUCCESS, kr)
<< BootstrapErrorMessage(kr, "bootstrap_look_up");
base::mac::ScopedMachSendRight client_port_owner(client_port);
EXPECT_NE(kMachPortNull, client_port);
// Have the “client” send a message to the “server”.
struct SendMessage {
mach_msg_header_t header;
char data[64];
};
SendMessage send_message = {};
send_message.header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0);
send_message.header.msgh_size = sizeof(send_message);
send_message.header.msgh_remote_port = client_port;
const char kMessageData[] = "Mach messaging is not a big truck";
const size_t message_data_size =
std::min(sizeof(kMessageData), sizeof(send_message.data));
memcpy(send_message.data, kMessageData, message_data_size);
// The receive operation happens in this same thread after the send, so use a
// non-blocking send (MACH_SEND_TIMEOUT with MACH_MSG_TIMEOUT_NONE). This is a
// small and simple message and the destination ports queue should be empty
// so a non-blocking send should be successful.
kr = mach_msg(&send_message.header,
MACH_SEND_MSG | MACH_SEND_TIMEOUT,
send_message.header.msgh_size,
0,
MACH_PORT_NULL,
MACH_MSG_TIMEOUT_NONE,
MACH_PORT_NULL);
ASSERT_EQ(MACH_MSG_SUCCESS, kr) << MachErrorMessage(kr, "mach_msg");
struct ReceiveMessage : public SendMessage {
mach_msg_trailer_t trailer;
};
ReceiveMessage receive_message;
memset(&receive_message, 0xa5, sizeof(receive_message));
kr = mach_msg(&receive_message.header,
MACH_RCV_MSG | MACH_RCV_TIMEOUT,
0,
sizeof(receive_message),
server_port,
MACH_MSG_TIMEOUT_NONE,
MACH_PORT_NULL);
ASSERT_EQ(MACH_MSG_SUCCESS, kr) << MachErrorMessage(kr, "mach_msg");
EXPECT_EQ(sizeof(send_message), receive_message.header.msgh_size);
EXPECT_EQ(0, memcmp(receive_message.data, kMessageData, message_data_size));
// Make sure that the bootstrap servers mapping disappears if the service
// does.
server_port_owner.reset();
server_port = MACH_PORT_NULL;
// With the server port gone, the client port should have become a dead name.
mach_port_type_t client_port_type;
kr = mach_port_type(mach_task_self(), client_port, &client_port_type);
ASSERT_EQ(KERN_SUCCESS, kr) << MachErrorMessage(kr, "mach_port_type");
EXPECT_EQ(MACH_PORT_TYPE_DEAD_NAME, client_port_type);
client_port_owner.reset();
client_port = MACH_PORT_NULL;
kr = bootstrap_look_up(bootstrap_port, service_name.c_str(), &client_port);
ASSERT_EQ(BOOTSTRAP_UNKNOWN_SERVICE, kr)
<< BootstrapErrorMessage(kr, "bootstrap_look_up");
}
} // namespace

View File

@ -41,14 +41,6 @@ exception_mask_t ExcMaskAll() {
// See 10.6.8 xnu-1504.15.3/osfmk/mach/exception_types.h. 10.7 uses the same
// definition as 10.6. See 10.7.5 xnu-1699.32.7/osfmk/mach/exception_types.h
//
// The 10.5 SDK actually defined EXC_MASK_ALL as including EXC_MASK_CRASH.
// Later SDKs removed EXC_MASK_CRASH from EXC_MASK_ALL, but placed it into a
// new constant, EXC_MASK_VALID. For consistent behavior, dont include
// EXC_MASK_CRASH in the 10.5 EXC_MASK_ALL. Consumers that want EXC_MASK_ALL
// along with EXC_MASK_CRASH must use ExcMaskAll() | EXC_MASK_CRASH
// explicitly. 10.5 otherwise behaves identically to 10.6. See 10.5.8
// xnu-1228.15.4/osfmk/mach/exception_types.h.
const exception_mask_t kExcMaskAll_10_6 =
EXC_MASK_BAD_ACCESS | EXC_MASK_BAD_INSTRUCTION | EXC_MASK_ARITHMETIC |
EXC_MASK_EMULATION | EXC_MASK_SOFTWARE | EXC_MASK_BREAKPOINT |

View File

@ -77,6 +77,8 @@ mach_port_t MachThreadSelf();
//! appropriate for the system at run time.
//!
//! \note `EXC_MASK_ALL` does not include the value of `EXC_MASK_CRASH`.
//! Consumers that want `EXC_MASK_ALL` along with `EXC_MASK_CRASH` must use
//! ExcMaskAll() | `EXC_MASK_CRASH` explicitly.
exception_mask_t ExcMaskAll();
} // namespace crashpad

View File

@ -26,7 +26,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/rand_util.h"
#include "gtest/gtest.h"
#include "util/mach/bootstrap.h"
#include "util/mach/mach_extensions.h"
#include "util/misc/scoped_forbid_return.h"
#include "util/test/errors.h"
@ -98,8 +97,9 @@ void MachMultiprocess::PreFork() {
}
mach_port_t local_port;
kern_return_t kr =
BootstrapCheckIn(bootstrap_port, info_->service_name, &local_port);
kern_return_t kr = bootstrap_check_in(bootstrap_port,
info_->service_name.c_str(),
&local_port);
ASSERT_EQ(BOOTSTRAP_SUCCESS, kr)
<< BootstrapErrorMessage(kr, "bootstrap_check_in");
info_->local_port.reset(local_port);

View File

@ -59,8 +59,6 @@
'mac/process_types/loader.proctype',
'mac/process_types/nlist.proctype',
'mac/process_types/traits.h',
'mach/bootstrap.cc',
'mach/bootstrap.h',
'mach/exc_client_variants.cc',
'mach/exc_client_variants.h',
'mach/exc_server_variants.cc',
@ -196,7 +194,6 @@
'mac/process_reader_test.cc',
'mac/process_types_test.cc',
'mac/service_management_test.mm',
'mach/bootstrap_test.cc',
'mach/exc_client_variants_test.cc',
'mach/exc_server_variants_test.cc',
'mach/mach_extensions_test.cc',