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
This commit is contained in:
ted.mielczarek@gmail.com 2013-03-06 20:14:34 +00:00
parent 7546209ddd
commit dc64e106e2
2 changed files with 29 additions and 5 deletions

View file

@ -116,6 +116,11 @@ class DumpSymbols {
// return false. // return false.
bool WriteSymbolFile(std::ostream &stream); 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: private:
// Used internally. // Used internally.
class DumperLineToModule; class DumperLineToModule;

View file

@ -53,6 +53,7 @@
#include "common/mac/arch_utilities.h" #include "common/mac/arch_utilities.h"
#include "common/mac/macho_reader.h" #include "common/mac/macho_reader.h"
#include "common/module.h" #include "common/module.h"
#include "common/scoped_ptr.h"
#include "common/stabs_reader.h" #include "common/stabs_reader.h"
#include "common/stabs_to_module.h" #include "common/stabs_to_module.h"
#include "common/symbol_data.h" #include "common/symbol_data.h"
@ -71,6 +72,7 @@ using google_breakpad::mach_o::Segment;
using google_breakpad::Module; using google_breakpad::Module;
using google_breakpad::StabsReader; using google_breakpad::StabsReader;
using google_breakpad::StabsToModule; using google_breakpad::StabsToModule;
using google_breakpad::scoped_ptr;
using std::make_pair; using std::make_pair;
using std::pair; using std::pair;
using std::string; using std::string;
@ -439,7 +441,7 @@ bool DumpSymbols::LoadCommandDumper::SymtabCommand(const ByteBuffer &entries,
return true; 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 // Select an object file, if SetArchitecture hasn't been called to set one
// explicitly. // explicitly.
if (!selected_object_file_) { if (!selected_object_file_) {
@ -490,8 +492,10 @@ bool DumpSymbols::WriteSymbolFile(std::ostream &stream) {
identifier += "0"; identifier += "0";
// Create a module to hold the debugging information. // Create a module to hold the debugging information.
Module module([module_name UTF8String], "mac", selected_arch_name, scoped_ptr<Module> module(new Module([module_name UTF8String],
identifier); "mac",
selected_arch_name,
identifier));
// Parse the selected object file. // Parse the selected object file.
mach_o::Reader::Reporter reporter(selected_object_name_); mach_o::Reader::Reporter reporter(selected_object_name_);
@ -504,11 +508,26 @@ bool DumpSymbols::WriteSymbolFile(std::ostream &stream) {
return false; return false;
// Walk its load commands, and deal with whatever is there. // 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)) if (!reader.WalkLoadCommands(&load_command_dumper))
return false; 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 } // namespace google_breakpad