[all-commits] [llvm/llvm-project] cc0acd: [DWARFDataExtractor] Add a "truncating" constructor
Pavel Labath via All-commits
all-commits at lists.llvm.org
Tue Apr 21 07:52:44 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: cc0acda782858ad8d48a38e024a1987d12249721
https://github.com/llvm/llvm-project/commit/cc0acda782858ad8d48a38e024a1987d12249721
Author: Pavel Labath <pavel at labath.sk>
Date: 2020-04-21 (Tue, 21 Apr 2020)
Changed paths:
M llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
M llvm/unittests/DebugInfo/DWARF/DWARFDataExtractorTest.cpp
Log Message:
-----------
[DWARFDataExtractor] Add a "truncating" constructor
Summary:
This constructor allows us to create a new DWARFDataExtractor which will
only present a subrange of an entire debug section. Since debug sections
typically consist of multiple contributions, it is expected that one
will create a new data extractor for each contribution in order to
avoid unexpectedly running off into the next one.
This is very useful for unifying the flows for detecting parse errors.
Without it, the code needs to consider two very different scenarios:
1. If there is another contribution after the current one, the
DataExtractor functions will just start reading from there. This is
detectable by comparing the current offset against the known
end-of-contribution offset.
2. If this is the last contribution, the data extractor will just start
returning zeroes (or other default values). This situation can *not*
be detected by checking the parsing offset, as this will not be
advanced in case of errors.
Using a truncated data extractor simplifies the code (and reduces
cognitive load) by making these two cases behave identically -- a
running off the end of a contribution will _always_ produce an EOF error
(if one uses error-aware parsing methods) or return default values.
Reviewers: dblaikie, probinson, jhenderson, ikudrin
Subscribers: aprantl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D77556
More information about the All-commits
mailing list