diff options
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.mm | 39 |
1 files changed, 25 insertions, 14 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 4123a27c..0f37686f 100644 --- a/src/tools/mac/crash_report/on_demand_symbol_supplier.mm +++ b/src/tools/mac/crash_report/on_demand_symbol_supplier.mm @@ -53,7 +53,7 @@ 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(); + size_t 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: @@ -149,7 +149,7 @@ OnDemandSymbolSupplier::GetSymbolFile(const CodeModule *module, if (s == FOUND) { - ifstream in(symbol_file->c_str()); + std::ifstream in(symbol_file->c_str()); getline(in, *symbol_data, std::string::traits_type::to_char_type( std::string::traits_type::eof())); in.close(); @@ -174,14 +174,14 @@ string OnDemandSymbolSupplier::GetLocalModulePath(const CodeModule *module) { // search string and stop if a file (not dir) is found or all components // have been appended NSArray *pathComponents = [modulePath componentsSeparatedByString:@"/"]; - int count = [pathComponents count]; + size_t count = [pathComponents count]; NSMutableString *path = [NSMutableString string]; - for (int i = 0; i < count; ++i) { + for (size_t i = 0; i < count; ++i) { [path setString:searchDir]; - for (int j = 0; j < i + 1; ++j) { - int idx = count - 1 - i + j; + for (size_t j = 0; j < i + 1; ++j) { + size_t idx = count - 1 - i + j; [path appendFormat:@"/%@", [pathComponents objectAtIndex:idx]]; } @@ -214,7 +214,7 @@ static float GetFileModificationTime(const char *path) { struct stat file_stat; if (stat(path, &file_stat) == 0) result = (float)file_stat.st_mtimespec.tv_sec + - (float)file_stat.st_mtimespec.tv_nsec / 1.0e9; + (float)file_stat.st_mtimespec.tv_nsec / 1.0e9f; return result; } @@ -236,7 +236,7 @@ bool OnDemandSymbolSupplier::GenerateSymbolFile(const CodeModule *module, if ([[NSFileManager defaultManager] fileExistsAtPath:symbol_path]) { // Check if the module file is newer than the saved symbols float cache_time = - GetFileModificationTime([symbol_path fileSystemRepresentation]); + GetFileModificationTime([symbol_path fileSystemRepresentation]); float module_time = GetFileModificationTime(module_path.c_str()); @@ -248,15 +248,26 @@ bool OnDemandSymbolSupplier::GenerateSymbolFile(const CodeModule *module, NSString *module_str = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:module_path.c_str() length:module_path.length()]; - DumpSymbols *dump = [[DumpSymbols alloc] initWithContentsOfFile:module_str]; - const char *archStr = system_info->cpu.c_str(); - if ([dump setArchitecture:[NSString stringWithUTF8String:archStr]]) { - [dump writeSymbolFile:symbol_path]; + DumpSymbols dump; + if (dump.Read(module_str)) { + if (dump.SetArchitecture(system_info->cpu)) { + FILE *file = fopen([symbol_path fileSystemRepresentation],"w"); + if (file) { + dump.WriteSymbolFile(file); + fclose(file); + } else { + printf("Unable to open %s (%d)\n", name.c_str(), errno); + result = false; + } + } else { + printf("Architecture %s not available for %s\n", + system_info->cpu.c_str(), name.c_str()); + result = false; + } } else { - printf("Architecture %s not available for %s\n", archStr, name.c_str()); + printf("Unable to open %s\n", [module_str UTF8String]); result = false; } - [dump release]; } // Add the mapping |