diff --git a/lib/DebugInfo/DWARF/DWARFUnit.cpp b/lib/DebugInfo/DWARF/DWARFUnit.cpp index 7f0ee660cd0..e5cba5e50b3 100644 --- a/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -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 -parseRngListTableHeader(DWARFDataExtractor &DA, uint64_t Offset, +template +static Expected +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( + 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( + RangesDA, RangeSectionBase, Header.getFormat())) DWO->RngListTable = TableOrError.get(); else WithColor::error() << "parsing a range list table: " diff --git a/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s b/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s index ac94c6c73af..f8395818734 100644 --- a/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s +++ b/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s @@ -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 diff --git a/test/DebugInfo/X86/dwarfdump-rnglists.s b/test/DebugInfo/X86/dwarfdump-rnglists.s index 3b07c0351ae..7886374c4d6 100644 --- a/test/DebugInfo/X86/dwarfdump-rnglists.s +++ b/test/DebugInfo/X86/dwarfdump-rnglists.s @@ -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