10 #ifndef LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
11 #define LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
38 class DWARFAbbreviationDeclarationSet;
40 class DWARFDebugAbbrev;
62 bool isLittleEndian,
bool isDWO) = 0;
69 template<
typename UnitType>
80 auto *CU = std::upper_bound(
82 [](
uint32_t LHS,
const std::unique_ptr<UnitType> &RHS) {
83 return LHS < RHS->getNextUnitOffset();
85 if (CU != this->
end())
100 while (
Data.isValidOffset(Offset)) {
101 auto U = llvm::make_unique<UnitType>(
Context,
Section, DA, RS, SS, SOS,
102 AOS,
LS,
LE, IsDWO, *
this,
103 Index.getFromOffset(Offset));
104 if (!U->extract(
Data, &Offset))
107 Offset = this->
back()->getNextUnitOffset();
124 uint64_t StringOffsetSectionBase = 0;
140 std::vector<DWARFDebugInfoEntry> DieArray;
145 std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap;
150 std::shared_ptr<DWARFUnit> DWO;
155 auto First = DieArray.data();
156 assert(Die >= First && Die < First + DieArray.size());
181 return StringOffsetSection;
185 AddrOffsetSection = AOS;
186 AddrOffsetSectionBase = Base;
194 RangeSectionBase = Base;
211 return StringOffsetSection.
Relocs;
242 return UnitType == dwarf::DW_UT_compile || UnitType == dwarf::DW_UT_type ||
243 UnitType == dwarf::DW_UT_partial ||
244 UnitType == dwarf::DW_UT_skeleton ||
245 UnitType == dwarf::DW_UT_split_compile ||
246 UnitType == dwarf::DW_UT_split_type;
256 case dwarf::DW_UT_compile:
257 case dwarf::DW_UT_partial:
259 case dwarf::DW_UT_skeleton:
260 case dwarf::DW_UT_split_compile:
262 case dwarf::DW_UT_type:
263 case dwarf::DW_UT_split_type:
272 BaseAddr = base_addr;
276 extractDIEsIfNeeded(ExtractUnitDIEOnly);
277 if (DieArray.empty())
279 return DWARFDie(
this, &DieArray[0]);
299 extractDIEsIfNeeded(
false);
300 return DieArray.size();
315 assert(Index < DieArray.size());
316 return DWARFDie(
this, &DieArray[Index]);
327 extractDIEsIfNeeded(
false);
328 assert(!DieArray.empty());
329 auto it = std::lower_bound(
330 DieArray.begin(), DieArray.end(), Offset,
332 return LHS.getOffset() < Offset;
334 if (it != DieArray.end() && it->getOffset() == Offset)
342 return Contrib->Offset;
347 extractDIEsIfNeeded(
false);
353 size_t getDebugInfoSize()
const {
return Length + 4 -
getHeaderSize(); }
357 size_t extractDIEsIfNeeded(
bool CUDieOnly);
360 void extractDIEsToVector(
bool AppendCUDie,
bool AppendNonCUDIEs,
361 std::vector<DWARFDebugInfoEntry> &DIEs)
const;
364 void clearDIEs(
bool KeepCUDie);
373 DWARFDie getSubroutineForAddress(uint64_t
Address);
378 #endif // LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
void getInlinedChainForAddress(uint64_t Address, SmallVectorImpl< DWARFDie > &InlinedChain)
getInlinedChainForAddress - fetches inlined chain for a given address.
void push_back(const T &Elt)
void parseDWO(DWARFContext &C, const DWARFSection &DWOSection, DWARFUnitIndex *Index=nullptr)
uint8_t getDwarfOffsetByteSize() const
const RelocAddrMap & getStringOffsetsRelocMap() const
void setBaseAddress(uint64_t base_addr)
uint8_t getUnitType() const
uint64_t getBaseAddress() const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
void collectAddressRanges(DWARFAddressRangesVector &CURanges)
bool getStringOffsetSectionItem(uint32_t Index, uint64_t &Result) const
virtual uint32_t getHeaderSize() const
Size in bytes of the unit header.
void setAddrOffsetSection(const DWARFSection *AOS, uint32_t Base)
DWARFDie getSibling(const DWARFDebugInfoEntry *Die)
bool extractRangeList(uint32_t RangeListOffset, DWARFDebugRangeList &RangeList) const
extractRangeList - extracts the range list referenced by this compile unit from .debug_ranges section...
uint32_t getNextUnitOffset() const
const DWARFDebugInfoEntry * getDebugInfoEntry() const
uint8_t getRefAddrByteSize() const
DWARFDataExtractor getDebugInfoExtractor() const
const DWARFAbbreviationDeclarationSet * getAbbreviations() const
uint32_t getLength() const
DWARFUnit(DWARFContext &Context, const DWARFSection &Section, const DWARFDebugAbbrev *DA, const DWARFSection *RS, StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, const DWARFSection &LS, bool LE, bool IsDWO, const DWARFUnitSectionBase &UnitSection, const DWARFUnitIndex::Entry *IndexEntry=nullptr)
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
const char * getCompilationDir()
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
UnitType * getUnitForOffset(uint32_t Offset) const override
Returns the Unit that contains the given section offset in the same section this Unit originated from...
unsigned getNumDIEs()
Returns the number of DIEs in the unit.
void parse(DWARFContext &C, const DWARFSection &Section)
uint16_t getVersion() const
~DWARFUnitSectionBase()=default
dwarf::DwarfFormat getFormat() const
virtual DWARFUnit * getUnitForOffset(uint32_t Offset) const =0
Returns the Unit that contains the given section offset in the same section this Unit originated from...
die_iterator_range dies()
Utility class that carries the DWARF compile/type unit and the debug info entry in an object...
StringRef getStringSection() const
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
const DWARFUnitSectionBase & getUnitSection() const
getUnitSection - Return the DWARFUnitSection containing this unit.
static uint32_t getDWARF5HeaderSize(uint8_t UnitType)
Return the number of bytes for the header of a unit of UnitType type.
const SectionContribution * getOffset(DWARFSectionKind Sec) const
DWARFDie getParent(const DWARFDebugInfoEntry *Die)
uint32_t getDIEIndex(const DWARFDie &D)
Return the index of a DIE inside the unit's DIE vector.
void setRangesSection(const DWARFSection *RS, uint32_t Base)
const DWARFUnitIndex & getDWARFUnitIndex(DWARFContext &Context, DWARFSectionKind Kind)
const RelocAddrMap * getRelocMap() const
UnitType
Constants for unit types in DWARF v5.
DataExtractor getStringExtractor() const
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
bool extract(DataExtractor debug_info, uint32_t *offset_ptr)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Concrete instance of DWARFUnitSection, specialized for one Unit type.
const DWARFFormParams & getFormParams() const
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
const DWARFSection & getLineSection() const
A range adaptor for a pair of iterators.
typename SuperClass::iterator iterator
llvm_unreachable("Unknown RegBank!")
bool getAddrOffsetSectionItem(uint32_t Index, uint64_t &Result) const
DWARFContext & getContext() const
static bool isValidUnitType(uint8_t UnitType)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
DWARFDie getDIEAtIndex(unsigned Index)
Return the DIE object at the given index.
virtual bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr)
Optional< uint64_t > getDWOId()
const DWARFSection & getStringOffsetSection() const
virtual void parseImpl(DWARFContext &Context, const DWARFSection &Section, const DWARFDebugAbbrev *DA, const DWARFSection *RS, StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, const DWARFSection &LS, bool isLittleEndian, bool isDWO)=0
void updateAddressDieMap(DWARFDie Die)
Recursively update address to Die map.
uint32_t getOffset() const
uint8_t getAddressByteSize() const
uint32_t getLineTableOffset() const
DWARFDie getDIEForOffset(uint32_t Offset)
Return the DIE object for a given offset inside the unit's DIE vector.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Base class for all DWARFUnitSection classes.
std::vector< DWARFAddressRange > DWARFAddressRangesVector
DWARFAddressRangesVector - represents a set of absolute address ranges.
DWARFDebugInfoEntry - A DIE with only the minimum required data.
StringRef - Represent a constant reference to a string, i.e.