aboutsummaryrefslogtreecommitdiff
path: root/src/common/mac/dump_syms.cc
diff options
context:
space:
mode:
authorSterling Augustine <saugustine@google.com>2020-09-26 16:48:02 -0700
committerSterling Augustine <saugustine@google.com>2020-09-28 17:56:12 +0000
commit2b936b06c12657b684f6c7276d6ae5a24cb48ab5 (patch)
treed07a176763db1e44bbbde2c572c33f26ebae8ddc /src/common/mac/dump_syms.cc
parentChange JSON serialization error check. (diff)
downloadbreakpad-2b936b06c12657b684f6c7276d6ae5a24cb48ab5.tar.xz
Refactor rangelist handling to prepare for dwarf5 .debug_rngslist
Dwarf5 introduces a new .debug_rngslist section, to take the place of the Dwarf4 .debug_ranges. However, the dwarf version is CU-based, and not file-based, so there can be both sections, and which section the CU needs isn't known until the dwarf parser encounters either DW_AT_ranges (dwarf 4 and lower) or DW_AT_rnglists_base (dwarf 5). This change refactors the code around range lists and range list readers to defer the decision of what section to parse until the relevant attribute is found. It moves the range list section reader from the range-list handler itself (which doesn't know which section it will use) to the CU context, and then lets the handler know when it encounters DW_AT_ranges. I will add a reader for the new dwarf5 section, along with the code to interpret the new section, and its forms and such in a subsequent patch. Change-Id: Ie92e4c9daa3f0acb98d7ef74f6b9c2065db849b1 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2433684 Reviewed-by: Mark Mentovai <mark@chromium.org>
Diffstat (limited to 'src/common/mac/dump_syms.cc')
-rw-r--r--src/common/mac/dump_syms.cc24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/common/mac/dump_syms.cc b/src/common/mac/dump_syms.cc
index 24bcd653..9ee6e006 100644
--- a/src/common/mac/dump_syms.cc
+++ b/src/common/mac/dump_syms.cc
@@ -311,23 +311,14 @@ string DumpSymbols::Identifier() {
class DumpSymbols::DumperRangesHandler:
public DwarfCUToModule::RangesHandler {
public:
- DumperRangesHandler(const uint8_t* buffer, uint64_t size,
- dwarf2reader::ByteReader* reader)
- : buffer_(buffer), size_(size), reader_(reader) { }
+ DumperRangesHandler() { }
bool ReadRanges(uint64_t offset, Module::Address base_address,
vector<Module::Range>* ranges) {
DwarfRangeListHandler handler(base_address, ranges);
- dwarf2reader::RangeListReader rangelist_reader(buffer_, size_, reader_,
- &handler);
- return rangelist_reader.ReadRangeList(offset);
+ return reader_->ReadRangeList(offset, &handler);
}
-
- private:
- const uint8_t* buffer_;
- uint64_t size_;
- dwarf2reader::ByteReader* reader_;
};
// A line-to-module loader that accepts line number info parsed by
@@ -457,17 +448,18 @@ void DumpSymbols::ReadDwarf(google_breakpad::Module* module,
DumperLineToModule line_to_module(&byte_reader);
// Optional .debug_ranges reader
- scoped_ptr<DumperRangesHandler> ranges_handler;
dwarf2reader::SectionMap::const_iterator ranges_entry =
file_context.section_map().find("__debug_ranges");
if (ranges_entry != file_context.section_map().end()) {
const std::pair<const uint8_t*, uint64_t>& ranges_section =
ranges_entry->second;
- ranges_handler.reset(
- new DumperRangesHandler(ranges_section.first, ranges_section.second,
- &byte_reader));
+ file_context.SetDebugRangeInfo(ranges_section.first,
+ ranges_section.second,
+ &byte_reader);
}
+ DumperRangesHandler ranges_handler;
+
// Walk the __debug_info section, one compilation unit at a time.
uint64_t debug_info_length = debug_info_section.second;
for (uint64_t offset = 0; offset < debug_info_length;) {
@@ -476,7 +468,7 @@ void DumpSymbols::ReadDwarf(google_breakpad::Module* module,
DwarfCUToModule::WarningReporter reporter(selected_object_name_,
offset);
DwarfCUToModule root_handler(&file_context, &line_to_module,
- ranges_handler.get(), &reporter);
+ &ranges_handler, &reporter);
// Make a Dwarf2Handler that drives our DIEHandler.
dwarf2reader::DIEDispatcher die_dispatcher(&root_handler);
// Make a DWARF parser for the compilation unit at OFFSET.