mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-03-25 11:38:42 +00:00
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>
This commit is contained in:
@@ -1569,10 +1569,11 @@ void LineInfo::ReadLines() {
|
||||
}
|
||||
|
||||
RangeListReader::RangeListReader(const uint8_t* buffer, uint64_t size,
|
||||
ByteReader* reader, RangeListHandler* handler)
|
||||
: buffer_(buffer), size_(size), reader_(reader), handler_(handler) { }
|
||||
ByteReader* reader)
|
||||
: buffer_(buffer), size_(size), reader_(reader) { }
|
||||
|
||||
bool RangeListReader::ReadRangeList(uint64_t offset) {
|
||||
bool RangeListReader::ReadRangeList(uint64_t offset,
|
||||
RangeListHandler* handler) {
|
||||
const uint64_t max_address =
|
||||
(reader_->AddressSize() == 4) ? 0xffffffffUL
|
||||
: 0xffffffffffffffffULL;
|
||||
@@ -1589,12 +1590,12 @@ bool RangeListReader::ReadRangeList(uint64_t offset) {
|
||||
reader_->ReadAddress(buffer_ + offset + reader_->AddressSize());
|
||||
|
||||
if (start_address == max_address) { // Base address selection
|
||||
handler_->SetBaseAddress(end_address);
|
||||
handler->SetBaseAddress(end_address);
|
||||
} else if (start_address == 0 && end_address == 0) { // End-of-list
|
||||
handler_->Finish();
|
||||
handler->Finish();
|
||||
list_end = true;
|
||||
} else { // Add a range entry
|
||||
handler_->AddRange(start_address, end_address);
|
||||
handler->AddRange(start_address, end_address);
|
||||
}
|
||||
|
||||
offset += entry_size;
|
||||
|
||||
@@ -243,16 +243,14 @@ class RangeListHandler {
|
||||
|
||||
class RangeListReader {
|
||||
public:
|
||||
RangeListReader(const uint8_t* buffer, uint64_t size, ByteReader* reader,
|
||||
RangeListHandler* handler);
|
||||
RangeListReader(const uint8_t* buffer, uint64_t size, ByteReader* reader);
|
||||
|
||||
bool ReadRangeList(uint64_t offset);
|
||||
bool ReadRangeList(uint64_t offset, RangeListHandler* handler);
|
||||
|
||||
private:
|
||||
const uint8_t* buffer_;
|
||||
uint64_t size_;
|
||||
ByteReader* reader_;
|
||||
RangeListHandler* handler_;
|
||||
};
|
||||
|
||||
// This class is the main interface between the reader and the
|
||||
|
||||
Reference in New Issue
Block a user