diff options
Diffstat (limited to 'src/tools/mac')
-rw-r--r-- | src/tools/mac/crash_report/on_demand_symbol_supplier.h | 44 | ||||
-rw-r--r-- | src/tools/mac/crash_report/on_demand_symbol_supplier.mm | 94 | ||||
-rw-r--r-- | src/tools/mac/dump_syms/dump_syms_tool.cc | 4 | ||||
-rw-r--r-- | src/tools/mac/dump_syms/macho_dump.cc | 32 |
4 files changed, 87 insertions, 87 deletions
diff --git a/src/tools/mac/crash_report/on_demand_symbol_supplier.h b/src/tools/mac/crash_report/on_demand_symbol_supplier.h index 3fbe108e..69b41405 100644 --- a/src/tools/mac/crash_report/on_demand_symbol_supplier.h +++ b/src/tools/mac/crash_report/on_demand_symbol_supplier.h @@ -47,30 +47,30 @@ class OnDemandSymbolSupplier : public SymbolSupplier { public: // |search_dir| is the directory to search for alternative symbols with // the same name as the module in the minidump - OnDemandSymbolSupplier(const string &search_dir, - const string &symbol_search_dir); + OnDemandSymbolSupplier(const string& search_dir, + const string& symbol_search_dir); virtual ~OnDemandSymbolSupplier() {} // Returns the path to the symbol file for the given module. - virtual SymbolResult GetSymbolFile(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file); + virtual SymbolResult GetSymbolFile(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file); // Returns the path to the symbol file for the given module. - virtual SymbolResult GetSymbolFile(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - string *symbol_data); + virtual SymbolResult GetSymbolFile(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + string* symbol_data); // Allocates data buffer on heap, and takes the ownership of // the data buffer. - virtual SymbolResult GetCStringSymbolData(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - char **symbol_data, - size_t *symbol_data_size); + virtual SymbolResult GetCStringSymbolData(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + char** symbol_data, + size_t* symbol_data_size); // Delete the data buffer allocated for module in GetCStringSymbolData(). - virtual void FreeSymbolData(const CodeModule *module); + virtual void FreeSymbolData(const CodeModule* module); protected: // Search directory @@ -82,28 +82,28 @@ class OnDemandSymbolSupplier : public SymbolSupplier { map<string, string> module_file_map_; // Map of allocated data buffers, keyed by module->code_file(). - map<string, char *> memory_buffers_; + map<string, char*> memory_buffers_; // Return the name for |module| This will be the value used as the key // to the |module_file_map_|. - string GetNameForModule(const CodeModule *module); + string GetNameForModule(const CodeModule* module); // Find the module on local system. If the module resides in a different // location than the full path in the minidump, this will be the location // used. - string GetLocalModulePath(const CodeModule *module); + string GetLocalModulePath(const CodeModule* module); // Return the full path for |module|. - string GetModulePath(const CodeModule *module); + string GetModulePath(const CodeModule* module); // Return the path to the symbol file for |module|. If an empty string is // returned, then |module| doesn't have a symbol file. - string GetModuleSymbolFile(const CodeModule *module); + string GetModuleSymbolFile(const CodeModule* module); // Generate the breakpad symbol file for |module|. Return true if successful. // File is generated in /tmp. - bool GenerateSymbolFile(const CodeModule *module, - const SystemInfo *system_info); + bool GenerateSymbolFile(const CodeModule* module, + const SystemInfo* system_info); }; } // namespace google_breakpad 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 1955d266..cfcecee8 100644 --- a/src/tools/mac/crash_report/on_demand_symbol_supplier.mm +++ b/src/tools/mac/crash_report/on_demand_symbol_supplier.mm @@ -51,10 +51,10 @@ using google_breakpad::PathnameStripper; using google_breakpad::SymbolSupplier; using google_breakpad::SystemInfo; -OnDemandSymbolSupplier::OnDemandSymbolSupplier(const string &search_dir, - const string &symbol_search_dir) +OnDemandSymbolSupplier::OnDemandSymbolSupplier(const string& search_dir, + const string& symbol_search_dir) : search_dir_(search_dir) { - NSFileManager *mgr = [NSFileManager defaultManager]; + NSFileManager* mgr = [NSFileManager defaultManager]; size_t length = symbol_search_dir.length(); if (length) { // Load all sym files in symbol_search_dir into our module_file_map @@ -62,51 +62,51 @@ OnDemandSymbolSupplier::OnDemandSymbolSupplier(const string &search_dir, // MODULE mac x86 BBF0A8F9BEADDD2048E6464001CA193F0 GoogleDesktopDaemon // or // MODULE mac ppc BBF0A8F9BEADDD2048E6464001CA193F0 GoogleDesktopDaemon - const char *symbolSearchStr = symbol_search_dir.c_str(); - NSString *symbolSearchPath = + 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 = + NSDirectoryEnumerator* dirEnum = [mgr enumeratorAtPath:symbolSearchPath]; + NSString* fileName; + NSCharacterSet* hexSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789ABCDEF"]; - NSCharacterSet *newlineSet = + 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]; + 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 stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL]; + NSString* filePath = [symbolSearchPath stringByAppendingPathComponent:fileName]; + NSString* dataStr = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL]; if (dataStr) { // Check file to see if it is of appropriate type, and grab module // name. - NSScanner *scanner = [NSScanner scannerWithString:dataStr]; + NSScanner* scanner = [NSScanner scannerWithString:dataStr]; BOOL goodScan = [scanner scanString:@"MODULE mac " intoString:nil]; if (goodScan) { goodScan = ([scanner scanString:@"x86 " intoString:nil] || [scanner scanString:@"x86_64 " intoString:nil] || [scanner scanString:@"ppc " intoString:nil]); if (goodScan) { - NSString *moduleID; + 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; + 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]; + const char* moduleNameStr = [moduleName UTF8String]; + const char* filePathStr = [filePath fileSystemRepresentation]; // Map our file module_file_map_[moduleNameStr] = filePathStr; } @@ -122,9 +122,9 @@ OnDemandSymbolSupplier::OnDemandSymbolSupplier(const string &search_dir, } SymbolSupplier::SymbolResult -OnDemandSymbolSupplier::GetSymbolFile(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file) { +OnDemandSymbolSupplier::GetSymbolFile(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file) { string path(GetModuleSymbolFile(module)); if (path.empty()) { @@ -142,10 +142,10 @@ OnDemandSymbolSupplier::GetSymbolFile(const CodeModule *module, } SymbolSupplier::SymbolResult -OnDemandSymbolSupplier::GetSymbolFile(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - string *symbol_data) { +OnDemandSymbolSupplier::GetSymbolFile(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + string* symbol_data) { SymbolSupplier::SymbolResult s = GetSymbolFile(module, system_info, symbol_file); @@ -162,11 +162,11 @@ OnDemandSymbolSupplier::GetSymbolFile(const CodeModule *module, } SymbolSupplier::SymbolResult -OnDemandSymbolSupplier::GetCStringSymbolData(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - char **symbol_data, - size_t *symbol_data_size) { +OnDemandSymbolSupplier::GetCStringSymbolData(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + char** symbol_data, + size_t* symbol_data_size) { std::string symbol_data_string; SymbolSupplier::SymbolResult result = GetSymbolFile(module, system_info, @@ -186,21 +186,21 @@ OnDemandSymbolSupplier::GetCStringSymbolData(const CodeModule *module, return result; } -void OnDemandSymbolSupplier::FreeSymbolData(const CodeModule *module) { - map<string, char *>::iterator it = memory_buffers_.find(module->code_file()); +void OnDemandSymbolSupplier::FreeSymbolData(const CodeModule* module) { + map<string, char*>::iterator it = memory_buffers_.find(module->code_file()); if (it != memory_buffers_.end()) { delete [] it->second; memory_buffers_.erase(it); } } -string OnDemandSymbolSupplier::GetLocalModulePath(const CodeModule *module) { - NSFileManager *mgr = [NSFileManager defaultManager]; - const char *moduleStr = module->code_file().c_str(); - NSString *modulePath = +string OnDemandSymbolSupplier::GetLocalModulePath(const CodeModule* module) { + NSFileManager* mgr = [NSFileManager defaultManager]; + const char* moduleStr = module->code_file().c_str(); + NSString* modulePath = [mgr stringWithFileSystemRepresentation:moduleStr length:strlen(moduleStr)]; - const char *searchStr = search_dir_.c_str(); - NSString *searchDir = + const char* searchStr = search_dir_.c_str(); + NSString* searchDir = [mgr stringWithFileSystemRepresentation:searchStr length:strlen(searchStr)]; if ([mgr fileExistsAtPath:modulePath]) @@ -209,9 +209,9 @@ string OnDemandSymbolSupplier::GetLocalModulePath(const CodeModule *module) { // If the module is not found, try to start appending the components to the // search string and stop if a file (not dir) is found or all components // have been appended - NSArray *pathComponents = [modulePath componentsSeparatedByString:@"/"]; + NSArray* pathComponents = [modulePath componentsSeparatedByString:@"/"]; size_t count = [pathComponents count]; - NSMutableString *path = [NSMutableString string]; + NSMutableString* path = [NSMutableString string]; for (size_t i = 0; i < count; ++i) { [path setString:searchDir]; @@ -230,22 +230,22 @@ string OnDemandSymbolSupplier::GetLocalModulePath(const CodeModule *module) { return ""; } -string OnDemandSymbolSupplier::GetModulePath(const CodeModule *module) { +string OnDemandSymbolSupplier::GetModulePath(const CodeModule* module) { return module->code_file(); } -string OnDemandSymbolSupplier::GetNameForModule(const CodeModule *module) { +string OnDemandSymbolSupplier::GetNameForModule(const CodeModule* module) { return PathnameStripper::File(module->code_file()); } -string OnDemandSymbolSupplier::GetModuleSymbolFile(const CodeModule *module) { +string OnDemandSymbolSupplier::GetModuleSymbolFile(const CodeModule* module) { string name(GetNameForModule(module)); map<string, string>::iterator result = module_file_map_.find(name); return (result == module_file_map_.end()) ? "" : (*result).second; } -static float GetFileModificationTime(const char *path) { +static float GetFileModificationTime(const char* path) { float result = 0; struct stat file_stat; if (stat(path, &file_stat) == 0) @@ -255,12 +255,12 @@ static float GetFileModificationTime(const char *path) { return result; } -bool OnDemandSymbolSupplier::GenerateSymbolFile(const CodeModule *module, - const SystemInfo *system_info) { +bool OnDemandSymbolSupplier::GenerateSymbolFile(const CodeModule* module, + const SystemInfo* system_info) { bool result = true; string name = GetNameForModule(module); string module_path = GetLocalModulePath(module); - NSString *symbol_path = [NSString stringWithFormat:@"/tmp/%s.%s.sym", + NSString* symbol_path = [NSString stringWithFormat:@"/tmp/%s.%s.sym", name.c_str(), system_info->cpu.c_str()]; if (module_path.empty()) diff --git a/src/tools/mac/dump_syms/dump_syms_tool.cc b/src/tools/mac/dump_syms/dump_syms_tool.cc index 6f68457b..8d73f0bd 100644 --- a/src/tools/mac/dump_syms/dump_syms_tool.cc +++ b/src/tools/mac/dump_syms/dump_syms_tool.cc @@ -106,7 +106,7 @@ static void CopyCFIDataBetweenModules(Module* to_module, } } -static bool Start(const Options &options) { +static bool Start(const Options& options) { SymbolData symbol_data = options.cfi ? ALL_SYMBOL_DATA : NO_CFI; DumpSymbols dump_symbols(symbol_data, options.handle_inter_cu_refs); @@ -210,7 +210,7 @@ static void SetupOptions(int argc, const char *argv[], Options *options) { extern int optind; signed char ch; - while ((ch = getopt(argc, (char * const *)argv, "ia:g:chr?")) != -1) { + while ((ch = getopt(argc, (char * const*)argv, "ia:g:chr?")) != -1) { switch (ch) { case 'i': options->header_only = true; diff --git a/src/tools/mac/dump_syms/macho_dump.cc b/src/tools/mac/dump_syms/macho_dump.cc index 6e784ca7..34f82ab1 100644 --- a/src/tools/mac/dump_syms/macho_dump.cc +++ b/src/tools/mac/dump_syms/macho_dump.cc @@ -60,7 +60,7 @@ namespace mach_o = google_breakpad::mach_o; string program_name; -int check_syscall(int result, const char *operation, const char *filename) { +int check_syscall(int result, const char* operation, const char* filename) { if (result < 0) { fprintf(stderr, "%s: %s '%s': %s\n", program_name.c_str(), operation, @@ -73,7 +73,7 @@ int check_syscall(int result, const char *operation, const char *filename) { class DumpSection: public mach_o::Reader::SectionHandler { public: DumpSection() : index_(0) { } - bool HandleSection(const mach_o::Section §ion) { + bool HandleSection(const mach_o::Section& section) { printf(" section %d '%s' in segment '%s'\n" " address: 0x%llx\n" " alignment: 1 << %d B\n" @@ -92,13 +92,13 @@ class DumpSection: public mach_o::Reader::SectionHandler { class DumpCommand: public mach_o::Reader::LoadCommandHandler { public: - DumpCommand(mach_o::Reader *reader) : reader_(reader), index_(0) { } + DumpCommand(mach_o::Reader* reader) : reader_(reader), index_(0) { } bool UnknownCommand(mach_o::LoadCommandType type, - const ByteBuffer &contents) { + const ByteBuffer& contents) { printf(" load command %d: %d", index_++, type); return true; } - bool SegmentCommand(const mach_o::Segment &segment) { + bool SegmentCommand(const mach_o::Segment& segment) { printf(" load command %d: %s-bit segment '%s'\n" " address: 0x%llx\n" " memory size: 0x%llx\n" @@ -115,24 +115,24 @@ class DumpCommand: public mach_o::Reader::LoadCommandHandler { return reader_->WalkSegmentSections(segment, &dump_section); } private: - mach_o::Reader *reader_; + mach_o::Reader* reader_; int index_; }; -void DumpFile(const char *filename) { +void DumpFile(const char* filename) { int fd = check_syscall(open(filename, O_RDONLY), "opening", filename); struct stat attributes; check_syscall(fstat(fd, &attributes), "getting file attributes for", filename); - void *mapping = mmap(NULL, attributes.st_size, PROT_READ, + void* mapping = mmap(NULL, attributes.st_size, PROT_READ, MAP_PRIVATE, fd, 0); close(fd); - check_syscall(mapping == (void *)-1 ? -1 : 0, + check_syscall(mapping == (void*)-1 ? -1 : 0, "mapping contents of", filename); mach_o::FatReader::Reporter fat_reporter(filename); mach_o::FatReader fat_reader(&fat_reporter); - if (!fat_reader.Read(reinterpret_cast<uint8_t *>(mapping), + if (!fat_reader.Read(reinterpret_cast<uint8_t*>(mapping), attributes.st_size)) { exit(1); } @@ -140,14 +140,14 @@ void DumpFile(const char *filename) { size_t object_files_size; const SuperFatArch* super_fat_object_files = fat_reader.object_files(&object_files_size); - struct fat_arch *object_files; + struct fat_arch* object_files; if (!super_fat_object_files->ConvertToFatArch(object_files)) { exit(1); } printf(" object file count: %ld\n", object_files_size); for (size_t i = 0; i < object_files_size; i++) { - const struct fat_arch &file = object_files[i]; - const NXArchInfo *fat_arch_info = + const struct fat_arch& file = object_files[i]; + const NXArchInfo* fat_arch_info = google_breakpad::BreakpadGetArchInfoFromCpuType( file.cputype, file.cpusubtype); printf("\n object file %ld:\n" @@ -162,7 +162,7 @@ void DumpFile(const char *filename) { name << filename; if (object_files_size > 1) name << ", object file #" << i; - ByteBuffer file_contents(reinterpret_cast<uint8_t *>(mapping) + ByteBuffer file_contents(reinterpret_cast<uint8_t*>(mapping) + file.offset, file.size); mach_o::Reader::Reporter reporter(name.str()); mach_o::Reader reader(&reporter); @@ -170,7 +170,7 @@ void DumpFile(const char *filename) { exit(1); } - const NXArchInfo *macho_arch_info = + const NXArchInfo* macho_arch_info = NXGetArchInfoFromCpuType(reader.cpu_type(), reader.cpu_subtype()); printf(" Mach-O header:\n" @@ -190,7 +190,7 @@ void DumpFile(const char *filename) { } // namespace -int main(int argc, char **argv) { +int main(int argc, char** argv) { program_name = google_breakpad::BaseName(argv[0]); if (argc == 1) { fprintf(stderr, "Usage: %s FILE ...\n" |