aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2013-03-06 20:14:34 +0000
committerted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2013-03-06 20:14:34 +0000
commitdc64e106e22d8c83b016b33300ffd3e4fbf19cb3 (patch)
treedfd1b8192d4d35127b20fead9835c1744f5df407 /src
parentMake OOP mac crashreporting exit after writing dump (diff)
downloadbreakpad-dc64e106e22d8c83b016b33300ffd3e4fbf19cb3.tar.xz
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
Diffstat (limited to 'src')
-rw-r--r--src/common/mac/dump_syms.h5
-rw-r--r--src/common/mac/dump_syms.mm29
2 files changed, 29 insertions, 5 deletions
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> 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