10 #ifndef LLVM_LIB_DEBUGINFO_DWARFUNIT_H
11 #define LLVM_LIB_DEBUGINFO_DWARFUNIT_H
62 template<
typename UnitType>
73 auto *CU = std::upper_bound(
75 [](
uint32_t LHS,
const std::unique_ptr<UnitType> &RHS) {
76 return LHS < RHS->getNextUnitOffset();
78 if (CU != this->
end())
87 bool IsDWO)
override {
93 while (Data.isValidOffset(Offset)) {
94 auto U = llvm::make_unique<UnitType>(
Context,
Section, DA, RS, SS, SOS,
95 AOS,
LS,
LE, IsDWO, *
this,
96 Index.getFromOffset(Offset));
97 if (!U->extract(Data, &Offset))
100 Offset = this->
back()->getNextUnitOffset();
130 std::vector<DWARFDebugInfoEntry> DieArray;
136 std::unique_ptr<DWARFContext> DWOContext;
140 DWARFUnit *getUnit()
const {
return DWOU; }
142 std::unique_ptr<DWOHolder> DWO;
147 auto First = DieArray.data();
148 assert(Die >= First && Die < First + DieArray.size());
172 AddrOffsetSection = AOS;
173 AddrOffsetSectionBase = Base;
177 RangeSectionBase = Base;
225 BaseAddr = base_addr;
229 extractDIEsIfNeeded(ExtractUnitDIEOnly);
230 if (DieArray.empty())
232 return DWARFDie(
this, &DieArray[0]);
252 extractDIEsIfNeeded(
false);
253 return DieArray.size();
268 assert(Index < DieArray.size());
269 return DWARFDie(
this, &DieArray[Index]);
280 extractDIEsIfNeeded(
false);
281 assert(!DieArray.empty());
282 auto it = std::lower_bound(
283 DieArray.begin(), DieArray.end(), Offset,
285 return LHS.getOffset() < Offset;
287 if (it == DieArray.end())
295 return Contrib->Offset;
300 extractDIEsIfNeeded(
false);
306 size_t getDebugInfoSize()
const {
return Length + 4 -
getHeaderSize(); }
310 size_t extractDIEsIfNeeded(
bool CUDieOnly);
312 void extractDIEsToVector(
bool AppendCUDie,
bool AppendNonCUDIEs,
313 std::vector<DWARFDebugInfoEntry> &DIEs)
const;
315 void clearDIEs(
bool KeepCUDie);
324 DWARFDie getSubprogramForAddress(uint64_t
Address);
void push_back(const T &Elt)
uint8_t getDwarfOffsetByteSize() const
bool getAddrOffsetSectionItem(uint32_t Index, uint64_t &Result) const
void setBaseAddress(uint64_t base_addr)
uint64_t getBaseAddress() const
std::vector< std::pair< uint64_t, uint64_t > > DWARFAddressRangesVector
DWARFAddressRangesVector - represents a set of absolute address ranges.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
StringRef getStringOffsetSection() const
virtual uint32_t getHeaderSize() const
Size in bytes of the unit header.
This class is the base class for all object file types.
uint32_t getNextUnitOffset() const
const DWARFDebugInfoEntry * getDebugInfoEntry() const
uint8_t getRefAddrByteSize() const
UnitVector::iterator iterator
virtual bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr)
const DWARFAbbreviationDeclarationSet * getAbbreviations() const
uint32_t getLength() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
static GCRegistry::Add< StatepointGC > D("statepoint-example","an example strategy for statepoint")
DWARFDie getSibling(const DWARFDebugInfoEntry *Die)
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.
llvm::SmallVectorImpl< std::unique_ptr< UnitType > > UnitVector
DWARFDie getParent(const DWARFDebugInfoEntry *Die)
uint16_t getVersion() const
~DWARFUnitSectionBase()=default
void collectAddressRanges(DWARFAddressRangesVector &CURanges)
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...
DWARFUnit(DWARFContext &Context, const DWARFSection &Section, const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, StringRef SOS, StringRef AOS, StringRef LS, bool LE, bool IsDWO, const DWARFUnitSectionBase &UnitSection, const DWARFUnitIndex::Entry *IndexEntry=nullptr)
die_iterator_range dies()
void parseDWO(DWARFContext &C, const DWARFSection &DWOSection, DWARFUnitIndex *Index=nullptr)
Utility class that carries the DWARF compile/type unit and the debug info entry in an object...
StringRef getStringSection() const
void setRangesSection(StringRef RS, uint32_t Base)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
const DWARFUnitSectionBase & getUnitSection() const
getUnitSection - Return the DWARFUnitSection containing this unit.
StringRef getLineSection() const
uint32_t getDIEIndex(const DWARFDie &D)
Return the index of a DIE inside the unit's DIE vector.
const char * getCompilationDir()
const DWARFUnitIndex & getDWARFUnitIndex(DWARFContext &Context, DWARFSectionKind Kind)
const RelocAddrMap * getRelocMap() const
DataExtractor getStringExtractor() const
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
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.
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
bool extractRangeList(uint32_t RangeListOffset, DWARFDebugRangeList &RangeList) const
extractRangeList - extracts the range list referenced by this compile unit from .debug_ranges section...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
A range adaptor for a pair of iterators.
bool extract(DataExtractor debug_info, uint32_t *offset_ptr)
DWARFContext & getContext() const
DataExtractor getDebugInfoExtractor() const
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
DWARFDie getDIEAtIndex(unsigned Index)
Return the DIE object at the given index.
const SectionContribution * getOffset(DWARFSectionKind Sec) const
void getInlinedChainForAddress(uint64_t Address, SmallVectorImpl< DWARFDie > &InlinedChain)
getInlinedChainForAddress - fetches inlined chain for a given address.
Optional< uint64_t > getDWOId()
bool getStringOffsetSectionItem(uint32_t Index, uint32_t &Result) const
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.
DWARFDebugInfoEntry - A DIE with only the minimum required data.
virtual void parseImpl(DWARFContext &Context, const DWARFSection &Section, const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, StringRef SOS, StringRef AOS, StringRef LS, bool isLittleEndian, bool isDWO)=0
void parse(DWARFContext &C, const DWARFSection &Section)
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
llvm::iterator_range< typename UnitVector::iterator > iterator_range
void setAddrOffsetSection(StringRef AOS, uint32_t Base)