10 #ifndef LLVM_LIB_DEBUGINFO_DWARFUNIT_H
11 #define LLVM_LIB_DEBUGINFO_DWARFUNIT_H
53 template<
typename UnitType>
57 struct UnitOffsetComparator {
58 bool operator()(uint32_t LHS,
59 const std::unique_ptr<UnitType> &RHS)
const {
60 return LHS < RHS->getNextUnitOffset();
69 SmallVector<std::unique_ptr<UnitType>, 1>(std::
move(DUS)), Parsed(DUS.Parsed) {}
76 auto *CU = std::upper_bound(this->
begin(), this->
end(), Offset,
77 UnitOffsetComparator());
78 if (CU != this->
end())
91 while (
Data.isValidOffset(Offset)) {
92 auto U = llvm::make_unique<UnitType>(Context,
Section, DA, RS,
SS, SOS,
94 if (!U->extract(
Data, &Offset))
97 Offset = this->
back()->getNextUnitOffset();
110 uint32_t RangeSectionBase;
114 uint32_t AddrOffsetSectionBase;
125 std::vector<DWARFDebugInfoEntryMinimal> DieArray;
129 std::unique_ptr<DWARFContext> DWOContext;
133 DWARFUnit *getUnit()
const {
return DWOU; }
135 std::unique_ptr<DWOHolder> DWO;
155 AddrOffsetSection = AOS;
156 AddrOffsetSectionBase = Base;
160 RangeSectionBase = Base;
195 BaseAddr = base_addr;
199 extractDIEsIfNeeded(ExtractUnitDIEOnly);
200 return DieArray.empty() ?
nullptr : &DieArray[0];
219 extractDIEsIfNeeded(
false);
220 return DieArray.size();
230 assert(!DieArray.empty() && DIE >= &DieArray[0] &&
231 DIE < &DieArray[0] + DieArray.size());
232 return DIE - &DieArray[0];
237 assert(Index < DieArray.size());
238 return &DieArray[Index];
246 assert(!DieArray.empty());
247 auto it = std::lower_bound(
248 DieArray.begin(), DieArray.end(), Offset,
250 return LHS.getOffset() < Offset;
252 return it == DieArray.end() ?
nullptr : &*it;
257 size_t getDebugInfoSize()
const {
return Length + 4 -
getHeaderSize(); }
261 size_t extractDIEsIfNeeded(
bool CUDieOnly);
263 void extractDIEsToVector(
bool AppendCUDie,
bool AppendNonCUDIEs,
264 std::vector<DWARFDebugInfoEntryMinimal> &DIEs)
const;
268 void setDIERelations();
270 void clearDIEs(
bool KeepCUDie);
279 const DWARFDebugInfoEntryMinimal *getSubprogramForAddress(uint64_t
Address);
void push_back(const T &Elt)
void setBaseAddress(uint64_t base_addr)
static It2 move(It1 I, It1 E, It2 Dest)
Use move-assignment to move the range [I, E) onto the objects starting with "Dest".
uint64_t getBaseAddress() const
std::vector< std::pair< uint64_t, uint64_t > > DWARFAddressRangesVector
DWARFAddressRangesVector - represents a set of absolute address ranges.
void collectAddressRanges(DWARFAddressRangesVector &CURanges)
StringRef getStringOffsetSection() const
virtual uint32_t getHeaderSize() const
Size in bytes of the unit header.
DWARFUnit(DWARFContext &Context, const DWARFSection &Section, const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, StringRef SOS, StringRef AOS, bool LE, const DWARFUnitSectionBase &UnitSection)
This class is the base class for all object file types.
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
UnitVector::iterator iterator
bool getStringOffsetSectionItem(uint32_t Index, uint32_t &Result) const
const DWARFAbbreviationDeclarationSet * getAbbreviations() const
uint32_t getLength() const
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.
llvm::SmallVectorImpl< std::unique_ptr< UnitType > > UnitVector
const DWARFDebugInfoEntryMinimal * getDIEAtIndex(unsigned Index) const
Return the DIE object at the given index.
DWARFDebugInfoEntryInlinedChain getInlinedChainForAddress(uint64_t Address)
getInlinedChainForAddress - fetches inlined chain for a given address.
void parse(DWARFContext &C, const DWARFSection &Section)
uint16_t getVersion() const
~DWARFUnitSectionBase()=default
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...
DWARFDebugInfoEntryMinimal - A DIE with only the minimum required data.
StringRef getStringSection() const
void setRangesSection(StringRef RS, uint32_t Base)
DIE - A structured debug information entry.
const DWARFUnitSectionBase & getUnitSection() const
getUnitSection - Return the DWARFUnitSection containing this unit.
DWARFUnitSection(DWARFUnitSection &&DUS)
uint32_t getDIEIndex(const DWARFDebugInfoEntryMinimal *DIE)
Return the index of a DIE inside the unit's DIE vector.
const RelocAddrMap * getRelocMap() const
virtual void parseImpl(DWARFContext &Context, const DWARFSection &Section, const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, StringRef SOS, StringRef AOS, bool isLittleEndian)=0
DataExtractor getStringExtractor() const
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.
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
A range adaptor for a pair of iterators.
const DWARFDebugInfoEntryMinimal * getDIEForOffset(uint32_t Offset) const
Return the DIE object for a given offset inside the unit's DIE vector.
void parseDWO(DWARFContext &C, const DWARFSection &DWOSection)
bool getAddrOffsetSectionItem(uint32_t Index, uint64_t &Result) const
DWARFContext & getContext() const
DataExtractor getDebugInfoExtractor() const
virtual bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr)
uint32_t getOffset() const
uint8_t getAddressByteSize() const
Base class for all DWARFUnitSection classes.
This class implements an extremely fast bulk output stream that can only output to a stream...
const DWARFDebugInfoEntryMinimal * getUnitDIE(bool ExtractUnitDIEOnly=true)
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)
DWARFDebugInfoEntryInlinedChain - represents a chain of inlined_subroutine DIEs, (possibly ending wit...