diff options
Diffstat (limited to 'src/common/mac')
-rw-r--r-- | src/common/mac/dump_syms.h | 15 | ||||
-rw-r--r-- | src/common/mac/dump_syms.mm | 36 |
2 files changed, 33 insertions, 18 deletions
diff --git a/src/common/mac/dump_syms.h b/src/common/mac/dump_syms.h index 0e2f464d..af12b778 100644 --- a/src/common/mac/dump_syms.h +++ b/src/common/mac/dump_syms.h @@ -47,13 +47,15 @@ #include "common/byte_cursor.h" #include "common/mac/macho_reader.h" #include "common/module.h" +#include "common/symbol_data.h" namespace google_breakpad { class DumpSymbols { public: - DumpSymbols() - : input_pathname_(), + explicit DumpSymbols(SymbolData symbol_data) + : symbol_data_(symbol_data), + input_pathname_(), object_filename_(), contents_(), selected_object_file_(), @@ -110,9 +112,9 @@ class DumpSymbols { } // Read the selected object file's debugging information, and write it out to - // |stream|. Write the CFI section if |cfi| is true. Return true on success; - // if an error occurs, report it and return false. - bool WriteSymbolFile(std::ostream &stream, bool cfi); + // |stream|. Return true on success; if an error occurs, report it and + // return false. + bool WriteSymbolFile(std::ostream &stream); private: // Used internally. @@ -139,6 +141,9 @@ class DumpSymbols { const mach_o::Section §ion, bool eh_frame) const; + // The selection of what type of symbol data to read/write. + const SymbolData symbol_data_; + // The name of the file or bundle whose symbols this will dump. // This is the path given to Read, for use in error messages. NSString *input_pathname_; diff --git a/src/common/mac/dump_syms.mm b/src/common/mac/dump_syms.mm index e26b05ea..f1aab426 100644 --- a/src/common/mac/dump_syms.mm +++ b/src/common/mac/dump_syms.mm @@ -55,6 +55,7 @@ #include "common/module.h" #include "common/stabs_reader.h" #include "common/stabs_to_module.h" +#include "common/symbol_data.h" #ifndef CPU_TYPE_ARM #define CPU_TYPE_ARM (static_cast<cpu_type_t>(12)) @@ -370,8 +371,12 @@ class DumpSymbols::LoadCommandDumper: // file, and adding data to MODULE. LoadCommandDumper(const DumpSymbols &dumper, google_breakpad::Module *module, - const mach_o::Reader &reader) - : dumper_(dumper), module_(module), reader_(reader) { } + const mach_o::Reader &reader, + SymbolData symbol_data) + : dumper_(dumper), + module_(module), + reader_(reader), + symbol_data_(symbol_data) { } bool SegmentCommand(const mach_o::Segment &segment); bool SymtabCommand(const ByteBuffer &entries, const ByteBuffer &strings); @@ -380,6 +385,7 @@ class DumpSymbols::LoadCommandDumper: const DumpSymbols &dumper_; google_breakpad::Module *module_; // WEAK const mach_o::Reader &reader_; + const SymbolData symbol_data_; }; bool DumpSymbols::LoadCommandDumper::SegmentCommand(const Segment &segment) { @@ -387,7 +393,7 @@ bool DumpSymbols::LoadCommandDumper::SegmentCommand(const Segment &segment) { if (!reader_.MapSegmentSections(segment, §ion_map)) return false; - if (segment.name == "__TEXT") { + if (segment.name == "__TEXT" && symbol_data_ != NO_CFI) { module_->SetLoadAddress(segment.vmaddr); mach_o::SectionMap::const_iterator eh_frame = section_map.find("__eh_frame"); @@ -399,13 +405,17 @@ bool DumpSymbols::LoadCommandDumper::SegmentCommand(const Segment &segment) { } if (segment.name == "__DWARF") { - if (!dumper_.ReadDwarf(module_, reader_, section_map)) - return false; - mach_o::SectionMap::const_iterator debug_frame - = section_map.find("__debug_frame"); - if (debug_frame != section_map.end()) { - // If there is a problem reading this, don't treat it as a fatal error. - dumper_.ReadCFI(module_, reader_, debug_frame->second, false); + if (symbol_data_ != ONLY_CFI) { + if (!dumper_.ReadDwarf(module_, reader_, section_map)) + return false; + } + if (symbol_data_ != NO_CFI) { + mach_o::SectionMap::const_iterator debug_frame + = section_map.find("__debug_frame"); + if (debug_frame != section_map.end()) { + // If there is a problem reading this, don't treat it as a fatal error. + dumper_.ReadCFI(module_, reader_, debug_frame->second, false); + } } } @@ -429,7 +439,7 @@ bool DumpSymbols::LoadCommandDumper::SymtabCommand(const ByteBuffer &entries, return true; } -bool DumpSymbols::WriteSymbolFile(std::ostream &stream, bool cfi) { +bool DumpSymbols::WriteSymbolFile(std::ostream &stream) { // Select an object file, if SetArchitecture hasn't been called to set one // explicitly. if (!selected_object_file_) { @@ -494,11 +504,11 @@ bool DumpSymbols::WriteSymbolFile(std::ostream &stream, bool cfi) { return false; // Walk its load commands, and deal with whatever is there. - LoadCommandDumper load_command_dumper(*this, &module, reader); + LoadCommandDumper load_command_dumper(*this, &module, reader, symbol_data_); if (!reader.WalkLoadCommands(&load_command_dumper)) return false; - return module.Write(stream, cfi); + return module.Write(stream, symbol_data_); } } // namespace google_breakpad |