aboutsummaryrefslogtreecommitdiff
path: root/src/common/dwarf_cu_to_module.h
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/dwarf_cu_to_module.h
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/dwarf_cu_to_module.h')
-rw-r--r--src/common/dwarf_cu_to_module.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/common/dwarf_cu_to_module.h b/src/common/dwarf_cu_to_module.h
index 3e15b667..e71c3e77 100644
--- a/src/common/dwarf_cu_to_module.h
+++ b/src/common/dwarf_cu_to_module.h
@@ -89,6 +89,11 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler {
const uint8_t* contents,
uint64_t length);
+ void SetDebugRangeInfo(const uint8_t* contents, uint64_t size,
+ dwarf2reader::ByteReader* reader) {
+ range_list_reader_ = dwarf2reader::RangeListReader(contents, size, reader);
+ }
+
// Clear the section map for testing.
void ClearSectionMapForTest();
@@ -119,6 +124,9 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler {
// True if we are handling references between compilation units.
const bool handle_inter_cu_refs_;
+ // Reader for .debug_ranges section, which is global to the file.
+ dwarf2reader::RangeListReader range_list_reader_;
+
// Inter-compilation unit data used internally by the handlers.
scoped_ptr<FilePrivate> file_private_;
};
@@ -127,16 +135,23 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler {
// DwarfCUToModule.
class RangesHandler {
public:
- RangesHandler() { }
+ RangesHandler() : reader_(nullptr) { }
virtual ~RangesHandler() { }
// Called when finishing a function to populate the function's ranges.
- // The ranges' entries are read starting from offset in the .debug_ranges
- // section, base_address holds the base PC the range list values are
- // offsets off. Return false if the rangelist falls out of the
- // .debug_ranges section.
+ // base_address holds the base PC the range list values are offsets
+ // off. Return false if the rangelist falls out of the relevant section.
virtual bool ReadRanges(uint64_t offset, Module::Address base_address,
vector<Module::Range>* ranges) = 0;
+
+ // Read ranges from this buffer and interpret them according to attr. Called
+ // upon seeing a DW_AT_ranges or DW_AT_rngslist attribute.
+ void SetRangesReader(dwarf2reader::RangeListReader* reader) {
+ reader_ = reader;
+ }
+
+ protected:
+ dwarf2reader::RangeListReader* reader_;
};
// An abstract base class for handlers that handle DWARF line data