From 131c0c6a831cda65bee196062ebe460f09851b14 Mon Sep 17 00:00:00 2001 From: "ted.mielczarek" Date: Thu, 29 Apr 2010 18:02:42 +0000 Subject: issue 372 - fix Mac OS X minidump generation code to handle x86-64 properly. r=mark at http://breakpad.appspot.com/103001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@578 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/client/mac/handler/minidump_generator.cc | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/client/mac/handler') diff --git a/src/client/mac/handler/minidump_generator.cc b/src/client/mac/handler/minidump_generator.cc index f8dc8eaa..f6d0638c 100644 --- a/src/client/mac/handler/minidump_generator.cc +++ b/src/client/mac/handler/minidump_generator.cc @@ -36,7 +36,6 @@ #include #include #include -#include #include @@ -50,6 +49,12 @@ using MacStringUtils::IntegerValueAtIndex; namespace google_breakpad { +#if __LP64__ +#define LC_SEGMENT_ARCH LC_SEGMENT_64 +#else +#define LC_SEGMENT_ARCH LC_SEGMENT +#endif + // constructor when generating from within the crashed process MinidumpGenerator::MinidumpGenerator() : exception_type_(0), @@ -615,8 +620,10 @@ bool MinidumpGenerator::WriteSystemInfoStream( info_ptr->processor_architecture = MD_CPU_ARCHITECTURE_PPC; break; case CPU_TYPE_I386: - info_ptr->processor_architecture = MD_CPU_ARCHITECTURE_X86; + case CPU_TYPE_X86_64: + // hw.cputype is currently always I386 even on an x86-64 system #ifdef __i386__ + info_ptr->processor_architecture = MD_CPU_ARCHITECTURE_X86; // ebx is used for PIC code, so we need // to preserve it. #define cpuid(op,eax,ebx,ecx,edx) \ @@ -629,6 +636,18 @@ bool MinidumpGenerator::WriteSystemInfoStream( "=c" (ecx), \ "=d" (edx) \ : "0" (op)) +#elif defined(__x86_64__) + info_ptr->processor_architecture = MD_CPU_ARCHITECTURE_AMD64; +#define cpuid(op,eax,ebx,ecx,edx) \ + asm ("cpuid \n\t" \ + : "=a" (eax), \ + "=b" (ebx), \ + "=c" (ecx), \ + "=d" (edx) \ + : "0" (op)) +#endif + +#if defined(__i386__) || defined(__x86_64__) int unused, unused2; // get vendor id cpuid(0, unused, info_ptr->cpu.x86_cpu_info.vendor_id[0], @@ -659,7 +678,7 @@ bool MinidumpGenerator::WriteSystemInfoStream( ((info_ptr->cpu.x86_cpu_info.version_information & 0xFF00000) >> 20); } -#endif // __i386__ +#endif // __i386__ || __x86_64_ break; default: info_ptr->processor_architecture = MD_CPU_ARCHITECTURE_UNKNOWN; @@ -763,7 +782,7 @@ bool MinidumpGenerator::WriteModuleStream(unsigned int index, memset(module, 0, sizeof(MDRawModule)); for (unsigned int i = 0; cmd && (i < header->ncmds); i++) { - if (cmd->cmd == LC_SEGMENT) { + if (cmd->cmd == LC_SEGMENT_ARCH) { const breakpad_mach_segment_command *seg = reinterpret_cast(cmd); -- cgit v1.2.1