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.
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;

View file

@ -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> 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