/// 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; }
/// .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;
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))
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())
++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;
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;
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;