From 6fbc102794fe6318b56d1f6b0b7cbc53aee95855 Mon Sep 17 00:00:00 2001 From: "mark@chromium.org" Date: Tue, 21 Feb 2012 21:24:43 +0000 Subject: Funnel all bootstrap_register calls through a routine that doesn't care that it's deprecated. Apple marked bootstrap_register as deprecated on 10.5 but it's actually still needed on that OS release. There isn't a way to get the functionality Breakpad needs from it without calling it until 10.6. Review URL: https://breakpad.appspot.com/350001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@921 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/client/mac/Breakpad.xcodeproj/project.pbxproj | 16 +++++++ src/client/mac/Framework/OnDemandServer.mm | 15 ++++--- src/client/mac/crash_generation/Inspector.mm | 7 +-- src/common/mac/MachIPC.mm | 8 ++-- src/common/mac/bootstrap_compat.cc | 42 ++++++++++++++++++ src/common/mac/bootstrap_compat.h | 54 +++++++++++++++++++++++ 6 files changed, 130 insertions(+), 12 deletions(-) create mode 100644 src/common/mac/bootstrap_compat.cc create mode 100644 src/common/mac/bootstrap_compat.h (limited to 'src') diff --git a/src/client/mac/Breakpad.xcodeproj/project.pbxproj b/src/client/mac/Breakpad.xcodeproj/project.pbxproj index 6cc78027..3082a061 100644 --- a/src/client/mac/Breakpad.xcodeproj/project.pbxproj +++ b/src/client/mac/Breakpad.xcodeproj/project.pbxproj @@ -43,6 +43,12 @@ 3329D4ED0FA16D820007BBC5 /* Breakpad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3329D4EC0FA16D820007BBC5 /* Breakpad.xib */; }; 33880C800F9E097100817F82 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 33880C7E0F9E097100817F82 /* InfoPlist.strings */; }; 4084699D0F5D9CF900FDCA37 /* crash_report_sender.icns in Resources */ = {isa = PBXBuildFile; fileRef = 4084699C0F5D9CF900FDCA37 /* crash_report_sender.icns */; }; + 4D61A25F14F43CFC002D5862 /* bootstrap_compat.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D61A25D14F43CFC002D5862 /* bootstrap_compat.cc */; }; + 4D61A26B14F43D3C002D5862 /* bootstrap_compat.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D61A25D14F43CFC002D5862 /* bootstrap_compat.cc */; }; + 4D61A26C14F43D42002D5862 /* bootstrap_compat.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D61A25D14F43CFC002D5862 /* bootstrap_compat.cc */; }; + 4D61A26D14F43D43002D5862 /* bootstrap_compat.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D61A25D14F43CFC002D5862 /* bootstrap_compat.cc */; }; + 4D61A26E14F43D45002D5862 /* bootstrap_compat.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D61A25D14F43CFC002D5862 /* bootstrap_compat.cc */; }; + 4D61A26F14F43D48002D5862 /* bootstrap_compat.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D61A25D14F43CFC002D5862 /* bootstrap_compat.cc */; }; 4D72CA0E13DFAD5C006CABE3 /* md5.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D72CA0D13DFAD5C006CABE3 /* md5.cc */; }; 4D72CA2513DFAE1C006CABE3 /* md5.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D72CA0D13DFAD5C006CABE3 /* md5.cc */; }; 4D72CA2F13DFAE65006CABE3 /* md5.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D72CA0D13DFAD5C006CABE3 /* md5.cc */; }; @@ -558,6 +564,8 @@ 3329D4EC0FA16D820007BBC5 /* Breakpad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Breakpad.xib; path = sender/Breakpad.xib; sourceTree = ""; }; 33880C7F0F9E097100817F82 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = sender/English.lproj/InfoPlist.strings; sourceTree = ""; }; 4084699C0F5D9CF900FDCA37 /* crash_report_sender.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = crash_report_sender.icns; path = sender/crash_report_sender.icns; sourceTree = ""; }; + 4D61A25D14F43CFC002D5862 /* bootstrap_compat.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bootstrap_compat.cc; path = ../../common/mac/bootstrap_compat.cc; sourceTree = SOURCE_ROOT; }; + 4D61A25E14F43CFC002D5862 /* bootstrap_compat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bootstrap_compat.h; path = ../../common/mac/bootstrap_compat.h; sourceTree = SOURCE_ROOT; }; 4D72CA0D13DFAD5C006CABE3 /* md5.cc */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = md5.cc; path = ../../common/md5.cc; sourceTree = SOURCE_ROOT; }; 4DBE4769134A4F080072546A /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; 8B31007011F0CD3C00FCF3E4 /* GTMDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GTMDefines.h; path = ../../common/mac/GTMDefines.h; sourceTree = SOURCE_ROOT; }; @@ -943,6 +951,8 @@ F92C53770ECCE635009BE4BA /* HTTPMultipartUpload.m */, F92C53780ECCE635009BE4BA /* MachIPC.h */, F92C53790ECCE635009BE4BA /* MachIPC.mm */, + 4D61A25D14F43CFC002D5862 /* bootstrap_compat.cc */, + 4D61A25E14F43CFC002D5862 /* bootstrap_compat.h */, F92C537A0ECCE635009BE4BA /* macho_id.cc */, F92C537B0ECCE635009BE4BA /* macho_id.h */, F92C537C0ECCE635009BE4BA /* macho_utilities.cc */, @@ -1679,6 +1689,7 @@ D24641A012BAA67F005170D0 /* macho_walker.cc in Sources */, D24641AF12BAA82D005170D0 /* macho_utilities.cc in Sources */, 4D72CA2513DFAE1C006CABE3 /* md5.cc in Sources */, + 4D61A26C14F43D42002D5862 /* bootstrap_compat.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1717,6 +1728,7 @@ D24641EE12BAC6FB005170D0 /* pathname_stripper.cc in Sources */, D24641EF12BAC6FB005170D0 /* basic_code_modules.cc in Sources */, 4D72CA3913DFAE92006CABE3 /* md5.cc in Sources */, + 4D61A26F14F43D48002D5862 /* bootstrap_compat.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1727,6 +1739,7 @@ F92C53B80ECCE7B3009BE4BA /* Inspector.mm in Sources */, F9286B3A0F7EB25800A4DCC8 /* InspectorMain.mm in Sources */, 163201E31443029300C4DBF5 /* ConfigFile.mm in Sources */, + 4D61A26B14F43D3C002D5862 /* bootstrap_compat.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1748,6 +1761,7 @@ F92C56480ECD10CA009BE4BA /* SimpleStringDictionary.mm in Sources */, F92C56490ECD10CA009BE4BA /* string_utilities.cc in Sources */, F92C564A0ECD10CA009BE4BA /* string_conversion.cc in Sources */, + 4D61A25F14F43CFC002D5862 /* bootstrap_compat.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1787,6 +1801,7 @@ F93803D70F8083B7004D428B /* string_utilities.cc in Sources */, D23F4B2E12A7E13200686C8D /* minidump_generator_test.cc in Sources */, 4D72CA2F13DFAE65006CABE3 /* md5.cc in Sources */, + 4D61A26D14F43D43002D5862 /* bootstrap_compat.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1827,6 +1842,7 @@ D2F9A3D51212F87C002747C1 /* exception_handler_test.cc in Sources */, D244540B12439BA0009BBCE0 /* memory_unittest.cc in Sources */, 4D72CA3813DFAE91006CABE3 /* md5.cc in Sources */, + 4D61A26E14F43D45002D5862 /* bootstrap_compat.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/client/mac/Framework/OnDemandServer.mm b/src/client/mac/Framework/OnDemandServer.mm index cfbc6629..4e779c89 100644 --- a/src/client/mac/Framework/OnDemandServer.mm +++ b/src/client/mac/Framework/OnDemandServer.mm @@ -28,7 +28,9 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #import "OnDemandServer.h" + #import "Breakpad.h" +#include "common/mac/bootstrap_compat.h" #if DEBUG #define PRINT_MACH_RESULT(result_, message_) \ @@ -100,9 +102,10 @@ kern_return_t OnDemandServer::Initialize(const char *server_command, // in the subset by registering it under a known name. The inspector will // recover this port and set it as its own bootstrap port in Inspector.mm // Inspector::ResetBootstrapPort. - kr = bootstrap_register(bootstrap_subset_port, - const_cast(BREAKPAD_BOOTSTRAP_PARENT_PORT), - bootstrap_port); + kr = breakpad::BootstrapRegister( + bootstrap_subset_port, + const_cast(BREAKPAD_BOOTSTRAP_PARENT_PORT), + bootstrap_port); if (kr != BOOTSTRAP_SUCCESS) { PRINT_BOOTSTRAP_RESULT(kr, "bootstrap_register(): "); return kr; @@ -169,9 +172,9 @@ void OnDemandServer::Unregister() { if (server_port_ != MACH_PORT_NULL) { // unregister the service - kern_return_t kr = bootstrap_register(server_port_, - service_name_, - MACH_PORT_NULL); + kern_return_t kr = breakpad::BootstrapRegister(server_port_, + service_name_, + MACH_PORT_NULL); if (kr != KERN_SUCCESS) { PRINT_MACH_RESULT(kr, "Breakpad UNREGISTER : bootstrap_register() : "); diff --git a/src/client/mac/crash_generation/Inspector.mm b/src/client/mac/crash_generation/Inspector.mm index 2a2c08db..ea5d19a6 100644 --- a/src/client/mac/crash_generation/Inspector.mm +++ b/src/client/mac/crash_generation/Inspector.mm @@ -43,6 +43,7 @@ #import "common/mac/SimpleStringDictionary.h" #import "common/mac/MachIPC.h" +#include "common/mac/bootstrap_compat.h" #import "GTMDefines.h" @@ -174,9 +175,9 @@ kern_return_t Inspector::ServiceCheckOut(const char *receive_port_name) { } // Unregister the service associated with the receive port. - kr = bootstrap_register(bootstrap_subset_port_, - (char*)receive_port_name, - MACH_PORT_NULL); + kr = breakpad::BootstrapRegister(bootstrap_subset_port_, + (char*)receive_port_name, + MACH_PORT_NULL); if (kr != KERN_SUCCESS) { PRINT_MACH_RESULT(kr, "Inspector: UNREGISTERING: bootstrap_register()"); diff --git a/src/common/mac/MachIPC.mm b/src/common/mac/MachIPC.mm index 4f58c02d..dc9773f7 100644 --- a/src/common/mac/MachIPC.mm +++ b/src/common/mac/MachIPC.mm @@ -32,6 +32,7 @@ #import #import "MachIPC.h" +#include "common/mac/bootstrap_compat.h" namespace google_breakpad { //============================================================================== @@ -187,9 +188,10 @@ ReceivePort::ReceivePort(const char *receive_port_name) { if (init_result_ != KERN_SUCCESS) return; - init_result_ = bootstrap_register(bootstrap_port, - const_cast(receive_port_name), - port_); + init_result_ = breakpad::BootstrapRegister( + bootstrap_port, + const_cast(receive_port_name), + port_); } //============================================================================== diff --git a/src/common/mac/bootstrap_compat.cc b/src/common/mac/bootstrap_compat.cc new file mode 100644 index 00000000..d875d95b --- /dev/null +++ b/src/common/mac/bootstrap_compat.cc @@ -0,0 +1,42 @@ +// Copyright (c) 2012, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "common/mac/bootstrap_compat.h" + +namespace breakpad { + +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +kern_return_t BootstrapRegister(mach_port_t bp, + name_t service_name, + mach_port_t sp) { + return bootstrap_register(bp, service_name, sp); +} +#pragma GCC diagnostic warning "-Wdeprecated-declarations" + +} // namesapce breakpad diff --git a/src/common/mac/bootstrap_compat.h b/src/common/mac/bootstrap_compat.h new file mode 100644 index 00000000..8ca7357c --- /dev/null +++ b/src/common/mac/bootstrap_compat.h @@ -0,0 +1,54 @@ +// Copyright (c) 2012, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef COMMON_MAC_BOOTSTRAP_COMPAT_H_ +#define COMMON_MAC_BOOTSTRAP_COMPAT_H_ + +#include + +namespace breakpad { + +// Wrapper for bootstrap_register to avoid deprecation warnings. +// +// In 10.6, it's possible to call bootstrap_check_in as the one-stop-shop for +// handling what bootstrap_register is used for. In 10.5, bootstrap_check_in +// can't check in a service whose name has not yet been registered, despite +// bootstrap_register being marked as deprecated in that OS release. Breakpad +// needs to register new service names, and in 10.5, calling +// bootstrap_register is the only way to achieve that. Attempts to call +// bootstrap_check_in for a new service name on 10.5 will result in +// BOOTSTRAP_UNKNOWN_SERVICE being returned rather than registration of the +// new service name. +kern_return_t BootstrapRegister(mach_port_t bp, + name_t service_name, + mach_port_t sp); + +} // namespace breakpad + +#endif // COMMON_MAC_BOOTSTRAP_COMPAT_H_ -- cgit v1.2.1