diff options
-rw-r--r-- | llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h | 6 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp | 22 |
2 files changed, 18 insertions, 10 deletions
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h index 458278e4282..9909def1072 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h @@ -72,7 +72,8 @@ public: /// Parse a unit header from \p debug_info starting at \p offset_ptr. bool extract(DWARFContext &Context, const DWARFDataExtractor &debug_info, uint32_t *offset_ptr, DWARFSectionKind Kind = DW_SECT_INFO, - const DWARFUnitIndex *Index = nullptr); + const DWARFUnitIndex *Index = nullptr, + const DWARFUnitIndex::Entry *Entry = nullptr); uint32_t getOffset() const { return Offset; } const dwarf::FormParams &getFormParams() const { return FormParams; } uint16_t getVersion() const { return FormParams.Version; } @@ -108,7 +109,8 @@ const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context, /// .debug_info and .debug_types, or from .debug_info.dwo and .debug_types.dwo. class DWARFUnitVector final : public SmallVector<std::unique_ptr<DWARFUnit>, 1> { std::function<std::unique_ptr<DWARFUnit>(uint32_t, DWARFSectionKind, - const DWARFSection *)> + const DWARFSection *, + const DWARFUnitIndex::Entry *)> Parser; int NumInfoUnits = -1; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index 1caaa249bef..48900e4b7a2 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -66,9 +66,11 @@ void DWARFUnitVector::addUnitsImpl( DWARFDataExtractor Data(Obj, Section, LE, 0); // Lazy initialization of Parser, now that we have all section info. if (!Parser) { - Parser = [=, &Context, &Obj, &Section, &SOS, &LS]( - uint32_t Offset, DWARFSectionKind SectionKind, - const DWARFSection *CurSection) -> std::unique_ptr<DWARFUnit> { + Parser = [=, &Context, &Obj, &Section, &SOS, + &LS](uint32_t Offset, DWARFSectionKind SectionKind, + const DWARFSection *CurSection, + const DWARFUnitIndex::Entry *IndexEntry) + -> std::unique_ptr<DWARFUnit> { const DWARFSection &InfoSection = CurSection ? *CurSection : Section; DWARFDataExtractor Data(Obj, InfoSection, LE, 0); if (!Data.isValidOffset(Offset)) @@ -77,7 +79,8 @@ void DWARFUnitVector::addUnitsImpl( if (IsDWO) Index = &getDWARFUnitIndex(Context, SectionKind); DWARFUnitHeader Header; - if (!Header.extract(Context, Data, &Offset, SectionKind, Index)) + if (!Header.extract(Context, Data, &Offset, SectionKind, Index, + IndexEntry)) return nullptr; std::unique_ptr<DWARFUnit> U; if (Header.isTypeUnit()) @@ -106,7 +109,7 @@ void DWARFUnitVector::addUnitsImpl( ++I; continue; } - auto U = Parser(Offset, SectionKind, &Section); + auto U = Parser(Offset, SectionKind, &Section, nullptr); // If parsing failed, we're done with this section. if (!U) break; @@ -156,7 +159,7 @@ DWARFUnitVector::getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) { if (!Parser) return nullptr; - auto U = Parser(Offset, DW_SECT_INFO, nullptr); + auto U = Parser(Offset, DW_SECT_INFO, nullptr, &E); if (!U) U = nullptr; @@ -233,9 +236,12 @@ bool DWARFUnitHeader::extract(DWARFContext &Context, const DWARFDataExtractor &debug_info, uint32_t *offset_ptr, DWARFSectionKind SectionKind, - const DWARFUnitIndex *Index) { + const DWARFUnitIndex *Index, + const DWARFUnitIndex::Entry *Entry) { Offset = *offset_ptr; - IndexEntry = Index ? Index->getFromOffset(*offset_ptr) : nullptr; + IndexEntry = Entry; + if (!IndexEntry && Index) + IndexEntry = Index->getFromOffset(*offset_ptr); Length = debug_info.getU32(offset_ptr); // FIXME: Support DWARF64. unsigned SizeOfLength = 4; |