aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/mac/Framework/Breakpad.mm10
-rw-r--r--src/client/mac/handler/minidump_generator.cc14
-rw-r--r--src/client/mac/handler/minidump_generator.h12
3 files changed, 23 insertions, 13 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 "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 "common/mac/MachIPC.h"
-#import "common/mac/SimpleStringDictionary.h"
#import <sys/stat.h>
#import <sys/sysctl.h>
#import <Foundation/Foundation.h>
-#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<breakpad_thread_state_t *>(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<breakpad_thread_state_t *>(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.