1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

DebugInfo: Templatize rnglist header parsing to setup for reuse with loclist header parsing

This commit is contained in:
David Blaikie 2019-11-15 15:48:31 -08:00
parent 659e34e367
commit e2c9856a21
3 changed files with 12 additions and 11 deletions

View File

@ -317,8 +317,9 @@ bool DWARFUnitHeader::extract(DWARFContext &Context,
// Parse the rangelist table header, including the optional array of offsets
// following it (DWARF v5 and later).
static Expected<DWARFDebugRnglistTable>
parseRngListTableHeader(DWARFDataExtractor &DA, uint64_t Offset,
template<typename ListTableType>
static Expected<ListTableType>
parseListTableHeader(DWARFDataExtractor &DA, uint64_t Offset,
DwarfFormat Format) {
// We are expected to be called with Offset 0 or pointing just past the table
// header. Correct Offset in the latter case so that it points to the start
@ -326,12 +327,12 @@ parseRngListTableHeader(DWARFDataExtractor &DA, uint64_t Offset,
if (Offset > 0) {
uint64_t HeaderSize = DWARFListTableHeader::getHeaderSize(Format);
if (Offset < HeaderSize)
return createStringError(errc::invalid_argument, "Did not detect a valid"
" range list table with base = 0x%" PRIx64 "\n",
return createStringError(errc::invalid_argument, "did not detect a valid"
" list table with base = 0x%" PRIx64 "\n",
Offset);
Offset -= HeaderSize;
}
llvm::DWARFDebugRnglistTable Table;
ListTableType Table;
if (Error E = Table.extractHeaderAndOffsets(DA, &Offset))
return std::move(E);
return Table;
@ -483,8 +484,8 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
// extracted lazily.
DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
isLittleEndian, 0);
auto TableOrError = parseRngListTableHeader(RangesDA, RangeSectionBase,
Header.getFormat());
auto TableOrError = parseListTableHeader<DWARFDebugRnglistTable>(
RangesDA, RangeSectionBase, Header.getFormat());
if (!TableOrError)
return createStringError(errc::invalid_argument,
"parsing a range list table: " +
@ -539,8 +540,8 @@ bool DWARFUnit::parseDWO() {
DWO->setRangesSection(&Context.getDWARFObj().getRnglistsDWOSection(), 0);
DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
isLittleEndian, 0);
if (auto TableOrError = parseRngListTableHeader(RangesDA, RangeSectionBase,
Header.getFormat()))
if (auto TableOrError = parseListTableHeader<DWARFDebugRnglistTable>(
RangesDA, RangeSectionBase, Header.getFormat()))
DWO->RngListTable = TableOrError.get();
else
WithColor::error() << "parsing a range list table: "

View File

@ -206,6 +206,6 @@ Range1_end:
# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000011
# CHECK-NEXT: [0x0000002a, 0x00000034))
#ERR: error: parsing a range list table: Did not detect a valid range list table with base = 0x8
#ERR: error: parsing a range list table: did not detect a valid list table with base = 0x8
#ERR: error: decoding address ranges: missing or invalid range list table
#ERR: error: decoding address ranges: invalid range list offset 0xfa0

View File

@ -202,6 +202,6 @@ Range1_end:
# CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000009
# CHECK-NEXT: [0x0000002a, 0x00000034))
#ERR: error: parsing a range list table: Did not detect a valid range list table with base = 0x8
#ERR: error: parsing a range list table: did not detect a valid list table with base = 0x8
#ERR: error: decoding address ranges: missing or invalid range list table
#ERR: error: decoding address ranges: invalid range list offset 0xfa0