From a0a0de39a8b25bea9ae18d98c4eb4c052c1a9864 Mon Sep 17 00:00:00 2001 From: nealsid Date: Tue, 21 Apr 2009 08:29:46 +0000 Subject: [PATCH] Patch from Jeremy Moskovich to build with 10.5 SDK correctly. Also removed externals directory. A=jeremy R=nealsid git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@328 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/client/mac/Framework/Breakpad.mm | 12 ++++++------ src/client/mac/handler/minidump_generator.cc | 14 ++++++-------- src/client/mac/handler/minidump_generator.h | 12 ++++++++++++ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/client/mac/Framework/Breakpad.mm b/src/client/mac/Framework/Breakpad.mm index 9de0a94b..65678807 100644 --- a/src/client/mac/Framework/Breakpad.mm +++ b/src/client/mac/Framework/Breakpad.mm @@ -39,20 +39,20 @@ #define DEBUGLOG if (gDebugLog) fprintf #define IGNORE_DEBUGGER "BREAKPAD_IGNORE_DEBUGGER" -#import "client/mac/Framework/Breakpad.h" -#import "client/mac/crash_generation/Inspector.h" -#import "client/mac/Framework/OnDemandServer.h" -#import "client/mac/handler/protected_memory_allocator.h" #import "common/mac/MachIPC.h" #import "common/mac/SimpleStringDictionary.h" +#import "client/mac/crash_generation/Inspector.h" +#import "client/mac/handler/exception_handler.h" +#import "client/mac/Framework/Breakpad.h" +#import "client/mac/Framework/OnDemandServer.h" +#import "client/mac/handler/protected_memory_allocator.h" + #import #import #import -#import "exception_handler.h" -#import "string_utilities.h" using google_breakpad::KeyValueEntry; using google_breakpad::SimpleStringDictionary; diff --git a/src/client/mac/handler/minidump_generator.cc b/src/client/mac/handler/minidump_generator.cc index 75c32ebc..b3091d4d 100644 --- a/src/client/mac/handler/minidump_generator.cc +++ b/src/client/mac/handler/minidump_generator.cc @@ -418,9 +418,9 @@ bool MinidumpGenerator::WriteStack(breakpad_thread_state_data_t state, reinterpret_cast(state); #if TARGET_CPU_X86_64 - mach_vm_address_t start_addr = machine_state->__rsp; + mach_vm_address_t start_addr = REGISTER_FROM_THREADSTATE(machine_state, rsp); #else - mach_vm_address_t start_addr = machine_state->esp; + mach_vm_address_t start_addr = REGISTER_FROM_THREADSTATE(machine_state, esp); #endif return WriteStackFromStartAddress(start_addr, stack_location); } @@ -431,9 +431,9 @@ MinidumpGenerator::CurrentPCForStack(breakpad_thread_state_data_t state) { reinterpret_cast(state); #if TARGET_CPU_X86_64 - return machine_state->__rip; + return REGISTER_FROM_THREADSTATE(machine_state, rip); #else - return machine_state->eip; + return REGISTER_FROM_THREADSTATE(machine_state, eip); #endif } @@ -449,10 +449,9 @@ bool MinidumpGenerator::WriteContext(breakpad_thread_state_data_t state, *register_location = context.location(); MinidumpContext *context_ptr = context.get(); +#define AddReg(a) context_ptr->a = REGISTER_FROM_THREADSTATE(machine_state, a) #if TARGET_CPU_X86 context_ptr->context_flags = MD_CONTEXT_X86; - -#define AddReg(a) context_ptr->a = machine_state->a AddReg(eax); AddReg(ebx); AddReg(ecx); @@ -472,8 +471,6 @@ bool MinidumpGenerator::WriteContext(breakpad_thread_state_data_t state, AddReg(eip); #else - -#define AddReg(a) context_ptr->a = machine_state->__ ## a context_ptr->context_flags = MD_CONTEXT_AMD64; AddReg(rax); AddReg(rbx); @@ -501,6 +498,7 @@ bool MinidumpGenerator::WriteContext(breakpad_thread_state_data_t state, AddReg(fs); AddReg(gs); #endif +#undef AddReg(a) return true; } diff --git a/src/client/mac/handler/minidump_generator.h b/src/client/mac/handler/minidump_generator.h index 0d3424c3..6a06ed66 100644 --- a/src/client/mac/handler/minidump_generator.h +++ b/src/client/mac/handler/minidump_generator.h @@ -66,6 +66,18 @@ typedef ppc_thread_state_t breakpad_thread_state_t; typedef MDRawContextPPC MinidumpContext; #endif +// Use the REGISTER_FROM_THREADSTATE to access a register name from the +// breakpad_thread_state_t structure. +#if __DARWIN_UNIX03 || !TARGET_CPU_X86 || TARGET_CPU_X86_64 +// In The 10.5 SDK Headers Apple prepended __ to the variable names in the +// i386_thread_state_t structure. There's no good way to tell what version of +// the SDK we're compiling against so we just toggle on the same preprocessor +// symbol Apple's headers use. +#define REGISTER_FROM_THREADSTATE(a, b) ((a)->__ ## b) +#else +#define REGISTER_FROM_THREADSTATE(a, b) (a->b) +#endif + // Creates a minidump file of the current process. If there is exception data, // use SetExceptionInformation() to add this to the minidump. The minidump // file is generated by the Write() function.