From d31c8b02925a1b20c09ee9ab771322353aea6267 Mon Sep 17 00:00:00 2001 From: waylonis Date: Tue, 23 Jan 2007 19:17:03 +0000 Subject: Changes to support patch #108: - Calculate unique file id for mach-o files - Add file id support to dump_syms and symupload tools - Fix return values of tools to indicate success or failure - Change dump_syms class to be Objective-C++ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@109 4c0a9323-5329-0410-9bdc-e9ce6186880e --- .../dump_syms/dump_syms.xcodeproj/project.pbxproj | 40 ++++++++++++++++++---- src/tools/mac/dump_syms/dump_syms_tool.m | 38 ++++++++++---------- 2 files changed, 54 insertions(+), 24 deletions(-) (limited to 'src/tools/mac/dump_syms') diff --git a/src/tools/mac/dump_syms/dump_syms.xcodeproj/project.pbxproj b/src/tools/mac/dump_syms/dump_syms.xcodeproj/project.pbxproj index b51a3f19..80f94097 100644 --- a/src/tools/mac/dump_syms/dump_syms.xcodeproj/project.pbxproj +++ b/src/tools/mac/dump_syms/dump_syms.xcodeproj/project.pbxproj @@ -7,10 +7,16 @@ objects = { /* Begin PBXBuildFile section */ - 8DD76F9A0486AA7600D96B5E /* dump_syms.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* dump_syms.m */; settings = {ATTRIBUTES = (); }; }; + 8DD76F9A0486AA7600D96B5E /* dump_syms.mm in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* dump_syms.mm */; settings = {ATTRIBUTES = (); }; }; 8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; }; 9BDF186F0B1BB43700F8391B /* dump_syms.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9BDF186D0B1BB43700F8391B /* dump_syms.h */; }; 9BDF18700B1BB43700F8391B /* dump_syms_tool.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BDF186E0B1BB43700F8391B /* dump_syms_tool.m */; }; + 9BE650470B52F6D800611104 /* file_id.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9BE650410B52F6D800611104 /* file_id.cc */; }; + 9BE650480B52F6D800611104 /* file_id.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9BE650420B52F6D800611104 /* file_id.h */; }; + 9BE650490B52F6D800611104 /* macho_id.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9BE650430B52F6D800611104 /* macho_id.cc */; }; + 9BE6504A0B52F6D800611104 /* macho_id.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9BE650440B52F6D800611104 /* macho_id.h */; }; + 9BE6504B0B52F6D800611104 /* macho_walker.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9BE650450B52F6D800611104 /* macho_walker.cc */; }; + 9BE6504C0B52F6D800611104 /* macho_walker.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9BE650460B52F6D800611104 /* macho_walker.h */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -21,17 +27,26 @@ dstSubfolderSpec = 0; files = ( 9BDF186F0B1BB43700F8391B /* dump_syms.h in CopyFiles */, + 9BE650480B52F6D800611104 /* file_id.h in CopyFiles */, + 9BE6504A0B52F6D800611104 /* macho_id.h in CopyFiles */, + 9BE6504C0B52F6D800611104 /* macho_walker.h in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 08FB7796FE84155DC02AAC07 /* dump_syms.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = dump_syms.m; path = ../../../common/mac/dump_syms.m; sourceTree = ""; }; + 08FB7796FE84155DC02AAC07 /* dump_syms.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = dump_syms.mm; path = ../../../common/mac/dump_syms.mm; sourceTree = ""; }; 08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 8DD76FA10486AA7600D96B5E /* dump_syms */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = dump_syms; sourceTree = BUILT_PRODUCTS_DIR; }; 9BDF186D0B1BB43700F8391B /* dump_syms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dump_syms.h; path = ../../../common/mac/dump_syms.h; sourceTree = ""; }; 9BDF186E0B1BB43700F8391B /* dump_syms_tool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = dump_syms_tool.m; sourceTree = ""; }; + 9BE650410B52F6D800611104 /* file_id.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = file_id.cc; path = ../../../common/mac/file_id.cc; sourceTree = SOURCE_ROOT; }; + 9BE650420B52F6D800611104 /* file_id.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = file_id.h; path = ../../../common/mac/file_id.h; sourceTree = SOURCE_ROOT; }; + 9BE650430B52F6D800611104 /* macho_id.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = macho_id.cc; path = ../../../common/mac/macho_id.cc; sourceTree = SOURCE_ROOT; }; + 9BE650440B52F6D800611104 /* macho_id.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = macho_id.h; path = ../../../common/mac/macho_id.h; sourceTree = SOURCE_ROOT; }; + 9BE650450B52F6D800611104 /* macho_walker.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = macho_walker.cc; path = ../../../common/mac/macho_walker.cc; sourceTree = SOURCE_ROOT; }; + 9BE650460B52F6D800611104 /* macho_walker.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = macho_walker.h; path = ../../../common/mac/macho_walker.h; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -49,8 +64,14 @@ 08FB7794FE84155DC02AAC07 /* dump_syms */ = { isa = PBXGroup; children = ( + 9BE650410B52F6D800611104 /* file_id.cc */, + 9BE650420B52F6D800611104 /* file_id.h */, + 9BE650430B52F6D800611104 /* macho_id.cc */, + 9BE650440B52F6D800611104 /* macho_id.h */, + 9BE650450B52F6D800611104 /* macho_walker.cc */, + 9BE650460B52F6D800611104 /* macho_walker.h */, 9BDF186D0B1BB43700F8391B /* dump_syms.h */, - 08FB7796FE84155DC02AAC07 /* dump_syms.m */, + 08FB7796FE84155DC02AAC07 /* dump_syms.mm */, 9BDF186E0B1BB43700F8391B /* dump_syms_tool.m */, 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */, 1AB674ADFE9D54B511CA2CBB /* Products */, @@ -115,8 +136,11 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8DD76F9A0486AA7600D96B5E /* dump_syms.m in Sources */, + 8DD76F9A0486AA7600D96B5E /* dump_syms.mm in Sources */, 9BDF18700B1BB43700F8391B /* dump_syms_tool.m in Sources */, + 9BE650470B52F6D800611104 /* file_id.cc in Sources */, + 9BE650490B52F6D800611104 /* macho_id.cc in Sources */, + 9BE6504B0B52F6D800611104 /* macho_walker.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -127,7 +151,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - GCC_C_LANGUAGE_STANDARD = c99; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_ENABLE_OBJC_EXCEPTIONS = YES; @@ -140,7 +164,9 @@ "$(inherited)", ); INSTALL_PATH = "$(HOME)/bin"; + OTHER_LDFLAGS = "-lcrypto"; PRODUCT_NAME = dump_syms; + WARNING_CFLAGS = "-Wall"; ZERO_LINK = NO; }; name = Debug; @@ -152,7 +178,7 @@ ppc, i386, ); - GCC_C_LANGUAGE_STANDARD = c99; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_MODEL_TUNING = G5; @@ -163,7 +189,9 @@ "$(inherited)", ); INSTALL_PATH = "$(HOME)/bin"; + OTHER_LDFLAGS = "-lcrypto"; PRODUCT_NAME = dump_syms; + WARNING_CFLAGS = "-Wall"; ZERO_LINK = NO; }; name = Release; diff --git a/src/tools/mac/dump_syms/dump_syms_tool.m b/src/tools/mac/dump_syms/dump_syms_tool.m index 60499a88..147989bf 100644 --- a/src/tools/mac/dump_syms/dump_syms_tool.m +++ b/src/tools/mac/dump_syms/dump_syms_tool.m @@ -46,21 +46,31 @@ typedef struct { static void Start(Options *options) { DumpSymbols *dump = [[DumpSymbols alloc] initWithContentsOfFile:options->srcPath]; + + if (!dump) { + fprintf(stderr, "%s is not a valid Mach-o file\n", + [options->srcPath fileSystemRepresentation]); + options->result = NO; + return; + } - [dump setArchitecture:options->arch]; - [dump setUUID:options->uuidStr]; + if (![dump setArchitecture:options->arch]) { + fprintf(stderr, "Architecture: %s not available in %s\n", + [options->arch UTF8String], + [options->srcPath fileSystemRepresentation]); + options->result = NO; + return; + } + options->result = [dump writeSymbolFile:@"-"]; } //============================================================================= static void Usage(int argc, const char *argv[]) { - fprintf(stderr, "Output airbag symbol file. If a UUID is not specified,\n" - "the program will try to locate one in the mach-o-file. If one is\n" - "not found, one will be created.\n"); - fprintf(stderr, "Usage: %s [-a ppc|i386|x86][-u uuid] \n", + fprintf(stderr, "Output an Airbag symbol file from a Mach-o file.\n"); + fprintf(stderr, "Usage: %s [-a ppc|i386|x86] \n", argv[0]); fprintf(stderr, "\t-a: Architecture type [default: native]\n"); - fprintf(stderr, "\t-u: Specify a UUID\n"); fprintf(stderr, "\t-h: Usage\n"); fprintf(stderr, "\t-?: Usage\n"); } @@ -97,9 +107,6 @@ static void SetupOptions(int argc, const char *argv[], Options *options) { exit(1); } break; - case 'u': - options->uuidStr = [NSString stringWithUTF8String:optarg]; - break; case '?': case 'h': Usage(argc, argv); @@ -107,14 +114,9 @@ static void SetupOptions(int argc, const char *argv[], Options *options) { break; } } - - if (!options->uuidStr) { - CFUUIDRef uuid = CFUUIDCreate(NULL); - options->uuidStr = (NSString *)CFUUIDCreateString(NULL, uuid); - } - + if ((argc - optind) != 1) { - fprintf(stderr, "%s: Missing executable\n", argv[0]); + fprintf(stderr, "Must specify Mach-o file\n"); Usage(argc, argv); exit(1); } @@ -135,5 +137,5 @@ int main (int argc, const char * argv[]) { [pool release]; - return options.result; + return !options.result; } -- cgit v1.2.1