From dc64e106e22d8c83b016b33300ffd3e4fbf19cb3 Mon Sep 17 00:00:00 2001 From: "ted.mielczarek@gmail.com" Date: Wed, 6 Mar 2013 20:14:34 +0000 Subject: Provide a ReadSymbolData API for Mac dump_syms R=mark at https://breakpad.appspot.com/522002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1128 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/mac/dump_syms.h | 5 +++++ src/common/mac/dump_syms.mm | 29 ++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/common/mac/dump_syms.h b/src/common/mac/dump_syms.h index af12b778..f7d391fc 100644 --- a/src/common/mac/dump_syms.h +++ b/src/common/mac/dump_syms.h @@ -116,6 +116,11 @@ class DumpSymbols { // return false. bool WriteSymbolFile(std::ostream &stream); + // As above, but simply return the debugging information in module + // instead of writing it to a stream. The caller owns the resulting + // module object and must delete it when finished. + bool ReadSymbolData(Module** module); + private: // Used internally. class DumperLineToModule; diff --git a/src/common/mac/dump_syms.mm b/src/common/mac/dump_syms.mm index f1aab426..cd19f721 100644 --- a/src/common/mac/dump_syms.mm +++ b/src/common/mac/dump_syms.mm @@ -53,6 +53,7 @@ #include "common/mac/arch_utilities.h" #include "common/mac/macho_reader.h" #include "common/module.h" +#include "common/scoped_ptr.h" #include "common/stabs_reader.h" #include "common/stabs_to_module.h" #include "common/symbol_data.h" @@ -71,6 +72,7 @@ using google_breakpad::mach_o::Segment; using google_breakpad::Module; using google_breakpad::StabsReader; using google_breakpad::StabsToModule; +using google_breakpad::scoped_ptr; using std::make_pair; using std::pair; using std::string; @@ -439,7 +441,7 @@ bool DumpSymbols::LoadCommandDumper::SymtabCommand(const ByteBuffer &entries, return true; } -bool DumpSymbols::WriteSymbolFile(std::ostream &stream) { +bool DumpSymbols::ReadSymbolData(Module** out_module) { // Select an object file, if SetArchitecture hasn't been called to set one // explicitly. if (!selected_object_file_) { @@ -490,8 +492,10 @@ bool DumpSymbols::WriteSymbolFile(std::ostream &stream) { identifier += "0"; // Create a module to hold the debugging information. - Module module([module_name UTF8String], "mac", selected_arch_name, - identifier); + scoped_ptr module(new Module([module_name UTF8String], + "mac", + selected_arch_name, + identifier)); // Parse the selected object file. mach_o::Reader::Reporter reporter(selected_object_name_); @@ -504,11 +508,26 @@ bool DumpSymbols::WriteSymbolFile(std::ostream &stream) { return false; // Walk its load commands, and deal with whatever is there. - LoadCommandDumper load_command_dumper(*this, &module, reader, symbol_data_); + LoadCommandDumper load_command_dumper(*this, module.get(), reader, + symbol_data_); if (!reader.WalkLoadCommands(&load_command_dumper)) return false; - return module.Write(stream, symbol_data_); + *out_module = module.release(); + + return true; +} + +bool DumpSymbols::WriteSymbolFile(std::ostream &stream) { + Module* module = NULL; + + if (ReadSymbolData(&module) && module) { + bool res = module->Write(stream, symbol_data_); + delete module; + return res; + } + + return false; } } // namespace google_breakpad -- cgit v1.2.1