aboutsummaryrefslogtreecommitdiff
path: root/src/tools/mac/crash_report/on_demand_symbol_supplier.mm
diff options
context:
space:
mode:
authordmaclach <dmaclach@4c0a9323-5329-0410-9bdc-e9ce6186880e>2007-09-15 00:33:09 +0000
committerdmaclach <dmaclach@4c0a9323-5329-0410-9bdc-e9ce6186880e>2007-09-15 00:33:09 +0000
commit99b36baa82b7ea8c744e2f66071d27837e897989 (patch)
tree198d22f4a041b57abd5bc9037ae7968036c0f7c1 /src/tools/mac/crash_report/on_demand_symbol_supplier.mm
parentIssue203 : reviewed by Waylonis (diff)
downloadbreakpad-99b36baa82b7ea8c744e2f66071d27837e897989.tar.xz
Adds the ability to designate a folder with sym files in it that will be used for symbol matching
to crash_report. git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@207 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/tools/mac/crash_report/on_demand_symbol_supplier.mm')
-rw-r--r--src/tools/mac/crash_report/on_demand_symbol_supplier.mm67
1 files changed, 66 insertions, 1 deletions
diff --git a/src/tools/mac/crash_report/on_demand_symbol_supplier.mm b/src/tools/mac/crash_report/on_demand_symbol_supplier.mm
index 5f3bee91..b8501955 100644
--- a/src/tools/mac/crash_report/on_demand_symbol_supplier.mm
+++ b/src/tools/mac/crash_report/on_demand_symbol_supplier.mm
@@ -47,8 +47,73 @@ using google_breakpad::PathnameStripper;
using google_breakpad::SymbolSupplier;
using google_breakpad::SystemInfo;
-OnDemandSymbolSupplier::OnDemandSymbolSupplier(const string &search_dir)
+OnDemandSymbolSupplier::OnDemandSymbolSupplier(const string &search_dir,
+ const string &symbol_search_dir)
: search_dir_(search_dir) {
+ NSFileManager *mgr = [NSFileManager defaultManager];
+ int length = symbol_search_dir.length();
+ if (length) {
+ // Load all sym files in symbol_search_dir into our module_file_map
+ // A symbol file always starts with a line like this:
+ // MODULE mac x86 BBF0A8F9BEADDD2048E6464001CA193F0 GoogleDesktopDaemon
+ // or
+ // MODULE mac ppc BBF0A8F9BEADDD2048E6464001CA193F0 GoogleDesktopDaemon
+ const char *symbolSearchStr = symbol_search_dir.c_str();
+ NSString *symbolSearchPath =
+ [mgr stringWithFileSystemRepresentation:symbolSearchStr
+ length:strlen(symbolSearchStr)];
+ NSDirectoryEnumerator *dirEnum = [mgr enumeratorAtPath:symbolSearchPath];
+ NSString *fileName;
+ NSCharacterSet *hexSet =
+ [NSCharacterSet characterSetWithCharactersInString:@"0123456789ABCDEF"];
+ NSCharacterSet *newlineSet =
+ [NSCharacterSet characterSetWithCharactersInString:@"\r\n"];
+ while ((fileName = [dirEnum nextObject])) {
+ // Check to see what type of file we have
+ NSDictionary *attrib = [dirEnum fileAttributes];
+ NSString *fileType = [attrib objectForKey:NSFileType];
+ if ([fileType isEqualToString:NSFileTypeDirectory]) {
+ // Skip subdirectories
+ [dirEnum skipDescendents];
+ } else {
+ NSString *filePath = [symbolSearchPath stringByAppendingPathComponent:fileName];
+ NSString *dataStr = [[[NSString alloc] initWithContentsOfFile:filePath] autorelease];
+ if (dataStr) {
+ // Check file to see if it is of appropriate type, and grab module
+ // name.
+ NSScanner *scanner = [NSScanner scannerWithString:dataStr];
+ BOOL goodScan = [scanner scanString:@"MODULE mac " intoString:nil];
+ if (goodScan) {
+ goodScan = ([scanner scanString:@"x86 " intoString:nil] ||
+ [scanner scanString:@"ppc " intoString:nil]);
+ if (goodScan) {
+ NSString *moduleID;
+ goodScan = [scanner scanCharactersFromSet:hexSet
+ intoString:&moduleID];
+ if (goodScan) {
+ // Module IDs are always 33 chars long
+ goodScan = [moduleID length] == 33;
+ if (goodScan) {
+ NSString *moduleName;
+ goodScan = [scanner scanUpToCharactersFromSet:newlineSet
+ intoString:&moduleName];
+ if (goodScan) {
+ goodScan = [moduleName length] > 0;
+ if (goodScan) {
+ const char *moduleNameStr = [moduleName UTF8String];
+ const char *filePathStr = [filePath fileSystemRepresentation];
+ // Map our file
+ module_file_map_[moduleNameStr] = filePathStr;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
SymbolSupplier::SymbolResult