aboutsummaryrefslogtreecommitdiff
path: root/src/common/mac
diff options
context:
space:
mode:
authorted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2013-03-06 15:32:53 +0000
committerted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2013-03-06 15:32:53 +0000
commit983903ee0aef76f7a277ce09de6b12164eba8a32 (patch)
tree2156b673c7b77dc1cd056ce730d0995fb0f90f41 /src/common/mac
parentMinor Android fixup for symbol dumping code (diff)
downloadbreakpad-983903ee0aef76f7a277ce09de6b12164eba8a32.tar.xz
Allow reading just CFI data when reading symbols
R=thestig at https://breakpad.appspot.com/517002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1124 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/mac')
-rw-r--r--src/common/mac/dump_syms.h15
-rw-r--r--src/common/mac/dump_syms.mm36
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 &section,
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, &section_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