diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/mac/Breakpad.xcodeproj/project.pbxproj | 11 | ||||
-rw-r--r-- | src/client/mac/handler/dynamic_images.cc | 62 |
2 files changed, 68 insertions, 5 deletions
diff --git a/src/client/mac/Breakpad.xcodeproj/project.pbxproj b/src/client/mac/Breakpad.xcodeproj/project.pbxproj index 83a3f3c7..2dcbc134 100644 --- a/src/client/mac/Breakpad.xcodeproj/project.pbxproj +++ b/src/client/mac/Breakpad.xcodeproj/project.pbxproj @@ -38,6 +38,10 @@ 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 */; }; + 4DBE49A6134A4F200072546A /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DBE4769134A4F080072546A /* CoreServices.framework */; }; + 4DBE49A7134A4F280072546A /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DBE4769134A4F080072546A /* CoreServices.framework */; }; + 4DBE49A8134A4F380072546A /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DBE4769134A4F080072546A /* CoreServices.framework */; }; + 4DBE49A9134A4F460072546A /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DBE4769134A4F080072546A /* CoreServices.framework */; }; 8B3101C611F0CD9F00FCF3E4 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; }; 8B3101C711F0CD9F00FCF3E4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; }; 8B3101CA11F0CDB000FCF3E4 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; }; @@ -544,6 +548,7 @@ 3329D4EC0FA16D820007BBC5 /* Breakpad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Breakpad.xib; path = sender/Breakpad.xib; sourceTree = "<group>"; }; 33880C7F0F9E097100817F82 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = sender/English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 4084699C0F5D9CF900FDCA37 /* crash_report_sender.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = crash_report_sender.icns; path = sender/crash_report_sender.icns; sourceTree = "<group>"; }; + 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; }; 8B3101E911F0CDE300FCF3E4 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; 8B31022211F0CE1000FCF3E4 /* GTMGarbageCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GTMGarbageCollection.h; path = ../../common/mac/GTMGarbageCollection.h; sourceTree = SOURCE_ROOT; }; @@ -692,6 +697,7 @@ files = ( D246418412BAA4BA005170D0 /* Foundation.framework in Frameworks */, D246419C12BAA65F005170D0 /* libcrypto.dylib in Frameworks */, + 4DBE49A6134A4F200072546A /* CoreServices.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -709,6 +715,7 @@ D2F9A53F121383A1002747C1 /* Foundation.framework in Frameworks */, D2F9A540121383A1002747C1 /* libcrypto.dylib in Frameworks */, D2F9A541121383A1002747C1 /* libgtest.a in Frameworks */, + 4DBE49A9134A4F460072546A /* CoreServices.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -748,6 +755,7 @@ 8B31029411F0D54300FCF3E4 /* Foundation.framework in Frameworks */, 8B4BDABE12012CEF009C7060 /* libcrypto.dylib in Frameworks */, D23F4B3312A7E17700686C8D /* libgtest.a in Frameworks */, + 4DBE49A7134A4F280072546A /* CoreServices.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -765,6 +773,7 @@ 8B3102E611F0D74C00FCF3E4 /* Foundation.framework in Frameworks */, 8B4BDAC512012D05009C7060 /* libcrypto.dylib in Frameworks */, D2F9A44412131F84002747C1 /* libgtest.a in Frameworks */, + 4DBE49A8134A4F380072546A /* CoreServices.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -840,6 +849,7 @@ 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */, 0867D6A5FE840307C02AAC07 /* AppKit.framework */, 0867D69BFE84028FC02AAC07 /* Foundation.framework */, + 4DBE4769134A4F080072546A /* CoreServices.framework */, ); name = Frameworks; sourceTree = "<group>"; @@ -1337,6 +1347,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "Breakpad" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( English, diff --git a/src/client/mac/handler/dynamic_images.cc b/src/client/mac/handler/dynamic_images.cc index 035afe7e..c6499e68 100644 --- a/src/client/mac/handler/dynamic_images.cc +++ b/src/client/mac/handler/dynamic_images.cc @@ -36,15 +36,37 @@ extern "C" { // needed to compile on Leopard } #include "breakpad_nlist_64.h" +#include <AvailabilityMacros.h> #include <assert.h> +#include <CoreServices/CoreServices.h> #include <dlfcn.h> #include <mach/mach_vm.h> +#include <mach/task_info.h> #include <sys/sysctl.h> #include <algorithm> #include <string> #include <vector> +#ifndef MAC_OS_X_VERSION_10_6 +#define MAC_OS_X_VERSION_10_6 1060 +#endif + +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 + +// Fallback declarations for TASK_DYLD_INFO and friends, introduced in +// <mach/task_info.h> in the Mac OS X 10.6 SDK. +#define TASK_DYLD_INFO 17 +struct task_dyld_info { + mach_vm_address_t all_image_info_addr; + mach_vm_size_t all_image_info_size; +}; +typedef struct task_dyld_info task_dyld_info_data_t; +typedef struct task_dyld_info *task_dyld_info_t; +#define TASK_DYLD_INFO_COUNT (sizeof(task_dyld_info_data_t) / sizeof(natural_t)) + +#endif + namespace google_breakpad { using std::string; @@ -336,13 +358,43 @@ static uint64_t LookupSymbol(const char* symbol_name, return list.n_value; } +static SInt32 GetOSVersionInternal() { + SInt32 os_version = 0; + Gestalt(gestaltSystemVersion, &os_version); + return os_version; +} + +static SInt32 GetOSVersion() { + static SInt32 os_version = GetOSVersionInternal(); + return os_version; +} + +static bool IsSnowLeopardOrLater() { +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + return true; +#else + return GetOSVersion() >= 0x1060; +#endif +} + uint64_t DynamicImages::GetDyldAllImageInfosPointer() { - const char *imageSymbolName = "_dyld_all_image_infos"; - const char *dyldPath = "/usr/lib/dyld"; + if (IsSnowLeopardOrLater()) { + task_dyld_info_data_t task_dyld_info; + mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT; + if (task_info(task_, TASK_DYLD_INFO, (task_info_t)&task_dyld_info, + &count) != KERN_SUCCESS) { + return NULL; + } - if (Is64Bit()) - return LookupSymbol<MachO64>(imageSymbolName, dyldPath, cpu_type_); - return LookupSymbol<MachO32>(imageSymbolName, dyldPath, cpu_type_); + return (uint64_t)task_dyld_info.all_image_info_addr; + } else { + const char *imageSymbolName = "_dyld_all_image_infos"; + const char *dyldPath = "/usr/lib/dyld"; + + if (Is64Bit()) + return LookupSymbol<MachO64>(imageSymbolName, dyldPath, cpu_type_); + return LookupSymbol<MachO32>(imageSymbolName, dyldPath, cpu_type_); + } } //============================================================================== |