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
This commit is contained in:
ted.mielczarek 2010-04-29 18:02:42 +00:00
parent f2dfb88b2a
commit 131c0c6a83
6 changed files with 54 additions and 17 deletions

View file

@ -33,6 +33,9 @@
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 */; };
8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; };
D2A5DD301188633800081F03 /* breakpad_nlist_64.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C53690ECCE3FD009BE4BA /* breakpad_nlist_64.cc */; };
D2A5DD401188640400081F03 /* breakpad_nlist_64.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C53690ECCE3FD009BE4BA /* breakpad_nlist_64.cc */; };
D2A5DD411188642E00081F03 /* breakpad_nlist_64.cc in Sources */ = {isa = PBXBuildFile; fileRef = F92C53690ECCE3FD009BE4BA /* breakpad_nlist_64.cc */; };
F91AF5D00FD60393009D8BE2 /* BreakpadFramework_Test.mm in Sources */ = {isa = PBXBuildFile; fileRef = F91AF5CF0FD60393009D8BE2 /* BreakpadFramework_Test.mm */; };
F91AF6210FD60784009D8BE2 /* Breakpad.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Breakpad.framework */; };
F9286B3A0F7EB25800A4DCC8 /* InspectorMain.mm in Sources */ = {isa = PBXBuildFile; fileRef = F9286B390F7EB25800A4DCC8 /* InspectorMain.mm */; };
@ -199,49 +202,49 @@
isa = PBXContainerItemProxy;
containerPortal = F95BB87C101F949F00AA053B /* crash_report.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 8DD76FA10486AA7600D96B5E /* crash_report */;
remoteGlobalIDString = 8DD76FA10486AA7600D96B5E;
remoteInfo = crash_report;
};
F95BB891101F94AC00AA053B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F95BB889101F94AC00AA053B /* dump_syms.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 8DD76FA10486AA7600D96B5E /* dump_syms */;
remoteGlobalIDString = 8DD76FA10486AA7600D96B5E;
remoteInfo = dump_syms;
};
F95BB89E101F94C000AA053B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F95BB894101F94C000AA053B /* symupload.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 8DD76FA10486AA7600D96B5E /* symupload */;
remoteGlobalIDString = 8DD76FA10486AA7600D96B5E;
remoteInfo = symupload;
};
F95BB8A0101F94C000AA053B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F95BB894101F94C000AA053B /* symupload.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 9BD835FB0B0544950055103E /* minidump_upload */;
remoteGlobalIDString = 9BD835FB0B0544950055103E;
remoteInfo = minidump_upload;
};
F95BB8B2101F94D300AA053B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F95BB889101F94AC00AA053B /* dump_syms.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 8DD76F960486AA7600D96B5E /* dump_syms */;
remoteGlobalIDString = 8DD76F960486AA7600D96B5E;
remoteInfo = dump_syms;
};
F95BB8B4101F94D300AA053B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F95BB894101F94C000AA053B /* symupload.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 8DD76F960486AA7600D96B5E /* symupload */;
remoteGlobalIDString = 8DD76F960486AA7600D96B5E;
remoteInfo = symupload;
};
F95BB8B6101F94D300AA053B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F95BB87C101F949F00AA053B /* crash_report.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 8DD76F960486AA7600D96B5E /* crash_report */;
remoteGlobalIDString = 8DD76F960486AA7600D96B5E;
remoteInfo = crash_report;
};
F9C44E190EF0790F003AEBAA /* PBXContainerItemProxy */ = {
@ -1045,6 +1048,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D2A5DD301188633800081F03 /* breakpad_nlist_64.cc in Sources */,
F92C563F0ECD10CA009BE4BA /* convert_UTF.c in Sources */,
F92C56400ECD10CA009BE4BA /* dynamic_images.cc in Sources */,
F92C56410ECD10CA009BE4BA /* file_id.cc in Sources */,
@ -1074,6 +1078,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D2A5DD401188640400081F03 /* breakpad_nlist_64.cc in Sources */,
F93803CD0F8083B7004D428B /* dynamic_images.cc in Sources */,
F93803CE0F8083B7004D428B /* exception_handler.cc in Sources */,
F93803CF0F8083B7004D428B /* minidump_generator.cc in Sources */,
@ -1104,6 +1109,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D2A5DD411188642E00081F03 /* breakpad_nlist_64.cc in Sources */,
F93DE3350F82C66B00608B94 /* dynamic_images.cc in Sources */,
F93DE3360F82C66B00608B94 /* exception_handler.cc in Sources */,
F93DE3370F82C66B00608B94 /* minidump_generator.cc in Sources */,
@ -1314,7 +1320,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH_PRE_XCODE_3_1 = "$(NATIVE_ARCH)";
ONLY_ACTIVE_ARCH_PRE_XCODE_3_1 = "$(NATIVE_ARCH_ACTUAL)";
PREBINDING = NO;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
};

View file

@ -36,7 +36,6 @@
#include <mach-o/loader.h>
#include <sys/sysctl.h>
#include <sys/resource.h>
#include <mach/mach_vm.h>
#include <CoreFoundation/CoreFoundation.h>
@ -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<const breakpad_mach_segment_command *>(cmd);

View file

@ -56,6 +56,8 @@
#if TARGET_CPU_X86
# define BREAKPAD_MACHINE_THREAD_STATE i386_THREAD_STATE
#elif TARGET_CPU_X86_64
# define BREAKPAD_MACHINE_THREAD_STATE x86_THREAD_STATE64
#else
# define BREAKPAD_MACHINE_THREAD_STATE MACHINE_THREAD_STATE
#endif

View file

@ -71,7 +71,9 @@ int MachoWalker::ValidateCPUType(int cpu_type) {
#if __ppc__
cpu_type = CPU_TYPE_POWERPC;
#elif __i386__
cpu_type = CPU_TYPE_X86;
cpu_type = CPU_TYPE_X86;
#elif __x86_64__
cpu_type = CPU_TYPE_X86_64;
#else
#error Unknown architecture -- are you on a PDP-11?
#endif

View file

@ -55,10 +55,10 @@ std::string ConvertToString(CFStringRef str) {
unsigned int IntegerValueAtIndex(string &str, unsigned int idx) {
string digits("0123456789"), temp;
unsigned int start = 0;
unsigned int end;
unsigned int found = 0;
unsigned int result = 0;
size_t start = 0;
size_t end;
size_t found = 0;
size_t result = 0;
for (; found <= idx; ++found) {
end = str.find_first_not_of(digits, start);

View file

@ -43,6 +43,8 @@
9BE650B50B52FE3000611104 /* macho_id.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9BE650AF0B52FE3000611104 /* macho_id.h */; };
9BE650B60B52FE3000611104 /* macho_walker.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9BE650B00B52FE3000611104 /* macho_walker.cc */; };
9BE650B70B52FE3000611104 /* macho_walker.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9BE650B10B52FE3000611104 /* macho_walker.h */; };
D2A5DD4D1188651100081F03 /* cfi_frame_info.cc in Sources */ = {isa = PBXBuildFile; fileRef = D2A5DD4C1188651100081F03 /* cfi_frame_info.cc */; };
D2A5DD631188658B00081F03 /* tokenize.cc in Sources */ = {isa = PBXBuildFile; fileRef = D2A5DD621188658B00081F03 /* tokenize.cc */; };
F9C7ECE50E8ABCA600E953AD /* bytereader.cc in Sources */ = {isa = PBXBuildFile; fileRef = F9C7ECE20E8ABCA600E953AD /* bytereader.cc */; };
F9C7ECE60E8ABCA600E953AD /* dwarf2reader.cc in Sources */ = {isa = PBXBuildFile; fileRef = F9C7ECE30E8ABCA600E953AD /* dwarf2reader.cc */; };
F9C7ECE70E8ABCA600E953AD /* functioninfo.cc in Sources */ = {isa = PBXBuildFile; fileRef = F9C7ECE40E8ABCA600E953AD /* functioninfo.cc */; };
@ -131,6 +133,8 @@
9BE650AF0B52FE3000611104 /* macho_id.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = macho_id.h; path = ../../../common/mac/macho_id.h; sourceTree = SOURCE_ROOT; };
9BE650B00B52FE3000611104 /* macho_walker.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = macho_walker.cc; path = ../../../common/mac/macho_walker.cc; sourceTree = SOURCE_ROOT; };
9BE650B10B52FE3000611104 /* macho_walker.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = macho_walker.h; path = ../../../common/mac/macho_walker.h; sourceTree = SOURCE_ROOT; };
D2A5DD4C1188651100081F03 /* cfi_frame_info.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cfi_frame_info.cc; path = ../../../processor/cfi_frame_info.cc; sourceTree = SOURCE_ROOT; };
D2A5DD621188658B00081F03 /* tokenize.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tokenize.cc; path = ../../../processor/tokenize.cc; sourceTree = SOURCE_ROOT; };
F9C7ECE20E8ABCA600E953AD /* bytereader.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bytereader.cc; path = ../../../common/dwarf/bytereader.cc; sourceTree = SOURCE_ROOT; };
F9C7ECE30E8ABCA600E953AD /* dwarf2reader.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dwarf2reader.cc; path = ../../../common/dwarf/dwarf2reader.cc; sourceTree = SOURCE_ROOT; };
F9C7ECE40E8ABCA600E953AD /* functioninfo.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = functioninfo.cc; path = ../../../common/dwarf/functioninfo.cc; sourceTree = SOURCE_ROOT; };
@ -241,6 +245,8 @@
9BDF17280B1B8B0200F8391B /* processor */ = {
isa = PBXGroup;
children = (
D2A5DD621188658B00081F03 /* tokenize.cc */,
D2A5DD4C1188651100081F03 /* cfi_frame_info.cc */,
F9F0706510FBC02D0037B88B /* stackwalker_arm.cc */,
F9F0706610FBC02D0037B88B /* stackwalker_arm.h */,
9B3904980B2E52FD0059FABE /* basic_source_line_resolver.cc */,
@ -358,6 +364,8 @@
F9C7ECE60E8ABCA600E953AD /* dwarf2reader.cc in Sources */,
F9C7ECE70E8ABCA600E953AD /* functioninfo.cc in Sources */,
F9F0706710FBC02D0037B88B /* stackwalker_arm.cc in Sources */,
D2A5DD4D1188651100081F03 /* cfi_frame_info.cc in Sources */,
D2A5DD631188658B00081F03 /* tokenize.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};