diff options
author | Sterling Augustine <saugustine@google.com> | 2020-09-26 16:48:02 -0700 |
---|---|---|
committer | Sterling Augustine <saugustine@google.com> | 2020-09-28 17:56:12 +0000 |
commit | 2b936b06c12657b684f6c7276d6ae5a24cb48ab5 (patch) | |
tree | d07a176763db1e44bbbde2c572c33f26ebae8ddc /src/common/dwarf_cu_to_module.cc | |
parent | Change JSON serialization error check. (diff) | |
download | breakpad-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/dwarf_cu_to_module.cc')
-rw-r--r-- | src/common/dwarf_cu_to_module.cc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/common/dwarf_cu_to_module.cc b/src/common/dwarf_cu_to_module.cc index a5bc7d6c..589f8bb2 100644 --- a/src/common/dwarf_cu_to_module.cc +++ b/src/common/dwarf_cu_to_module.cc @@ -134,6 +134,7 @@ DwarfCUToModule::FileContext::FileContext(const string& filename, : filename_(filename), module_(module), handle_inter_cu_refs_(handle_inter_cu_refs), + range_list_reader_(nullptr, 0, nullptr), file_private_(new FilePrivate()) { } @@ -193,7 +194,7 @@ struct DwarfCUToModule::CUContext { // For printing error messages. WarningReporter* reporter; - // For reading ranges from the .debug_ranges section + // For handling ranges, however they may be specified. RangesHandler* ranges_handler; // The source language of this compilation unit. @@ -206,6 +207,9 @@ struct DwarfCUToModule::CUContext { uint64_t high_pc; uint64_t ranges; + // For reading dwarf4 ranges. + scoped_ptr<dwarf2reader::RangeListReader> range_list_reader_; + // The functions defined in this compilation unit. We accumulate // them here during parsing. Then, in DwarfCUToModule::Finish, we // assign them lines and add them to file_context->module. @@ -512,6 +516,15 @@ void DwarfCUToModule::FuncHandler::ProcessAttributeUnsigned( break; case dwarf2reader::DW_AT_ranges: ranges_ = data; + if (cu_context_->ranges_handler) { + cu_context_->ranges_handler->SetRangesReader( + &cu_context_->file_context->range_list_reader_); + } else { + cu_context_->reporter->MissingRanges(); + // The rest of the code will fall back to low-pc, which is better than + // nothing. + ranges_ = 0; + } break; default: |