Go to the documentation of this file.
9 #ifndef LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
10 #define LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
37 class DWARFAbbreviationDeclarationSet;
39 class DWARFDebugAbbrev;
41 class DWARFDebugRangeList;
42 class DWARFLocationTable;
98 assert((!DWOId || *DWOId ==
Id) &&
"setting DWOId to a different value");
106 return UnitType == dwarf::DW_UT_type ||
UnitType == dwarf::DW_UT_split_type;
129 int NumInfoUnits = -1;
164 return NumInfoUnits == -1 ?
size() : NumInfoUnits;
219 std::unique_ptr<DWARFLocationTable> LocTable;
238 std::vector<DWARFDebugInfoEntry> DieArray;
243 std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap;
247 std::map<uint64_t, std::pair<uint64_t, DWARFDie>> VariableDieMap;
253 std::shared_ptr<DWARFUnit> DWO;
256 auto First = DieArray.data();
311 return StringOffsetSection;
321 AddrOffsetSection = AOS;
322 AddrOffsetSectionBase =
Base;
326 return AddrOffsetSectionBase;
337 RangeSectionBase =
Base;
341 return LocSectionBase;
366 return StringOffsetsTableContribution;
370 assert(StringOffsetsTableContribution);
371 return StringOffsetsTableContribution->getDwarfOffsetByteSize();
375 assert(StringOffsetsTableContribution);
376 return StringOffsetsTableContribution->Base;
385 case dwarf::DW_UT_compile:
386 return Tag == dwarf::DW_TAG_compile_unit;
387 case dwarf::DW_UT_type:
388 return Tag == dwarf::DW_TAG_type_unit;
389 case dwarf::DW_UT_partial:
390 return Tag == dwarf::DW_TAG_partial_unit;
391 case dwarf::DW_UT_skeleton:
392 return Tag == dwarf::DW_TAG_skeleton_unit;
393 case dwarf::DW_UT_split_compile:
394 case dwarf::DW_UT_split_type:
403 extractDIEsIfNeeded(ExtractUnitDIEOnly);
404 if (DieArray.empty())
406 return DWARFDie(
this, &DieArray[0]);
412 return DWO->getUnitDIE(ExtractUnitDIEOnly);
418 extractDIEsIfNeeded(
true);
465 extractDIEsIfNeeded(
false);
466 return DieArray.size();
476 return getDIEIndex(
D.getDebugInfoEntry());
496 extractDIEsIfNeeded(
false);
501 if (It != DieArray.end() && It->getOffset() == Offset)
508 if (
const auto *Contrib = IndexEntry->getContribution(DW_SECT_LINE))
509 return Contrib->Offset;
514 extractDIEsIfNeeded(
false);
524 size_t getDebugInfoSize()
const {
531 void extractDIEsIfNeeded(
bool CUDieOnly);
534 void extractDIEsToVector(
bool AppendCUDie,
bool AppendNonCUDIEs,
535 std::vector<DWARFDebugInfoEntry> &DIEs)
const;
538 void clearDIEs(
bool KeepCUDie);
546 return !U->isTypeUnit();
551 #endif // LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
const DWARFAbbreviationDeclarationSet * getAbbreviations() const
Expected< DWARFAddressRangesVector > findRnglistFromIndex(uint32_t Index)
Return a vector of address ranges retrieved from an encoded range list whose offset is found via a ta...
DWARFDie getFirstChild(const DWARFDebugInfoEntry *Die)
This is an optimization pass for GlobalISel generic memory operations.
StringRef getStringSection() const
Optional< uint64_t > getRnglistOffset(uint32_t Index)
Return a rangelist's offset based on an index.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
DataExtractor getStringExtractor() const
An abstract base class for various kinds of location tables (.debug_loc, .debug_loclists,...
void addUnitsForSection(DWARFContext &C, const DWARFSection &Section, DWARFSectionKind SectionKind)
Read units from a .debug_info or .debug_types section.
void addUnitsForDWOSection(DWARFContext &C, const DWARFSection &DWOSection, DWARFSectionKind SectionKind, bool Lazy=false)
Read units from a .debug_info.dwo or .debug_types.dwo section.
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
Expected< StrOffsetsContributionDescriptor > validateContributionSize(DWARFDataExtractor &DA)
Determine whether a contribution to the string offsets table is consistent with the relevant section ...
A structured debug information entry.
Tagged union holding either a T or a Error.
uint8_t getVersion() const
const DWARFUnitVector & getUnitVector() const
Return the DWARFUnitVector containing this unit.
DWARFDebugInfoEntry - A DIE with only the minimum required data.
const dwarf::FormParams & getFormParams() const
uint64_t getLength() const
unsigned getNumTypesUnits() const
Returns number of units from all .debug_types[.dwo] sections.
uint64_t Size
The contribution size not including the header.
bool isUnitType(uint8_t UnitType)
Optional< object::SectionedAddress > getAddrOffsetSectionItem(uint32_t Index) const
uint64_t getAbbrOffset() const
uint8_t getUnitType() const
Optional< uint64_t > getLoclistOffset(uint32_t Index)
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
dwarf::DwarfFormat getFormat() const
unsigned getNumDIEs()
Returns the number of DIEs in the unit.
Optional< uint64_t > getDWOId()
unsigned getNumInfoUnits() const
Returns number of units from all .debug_info[.dwo] sections.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Expected< Optional< StrOffsetsContributionDescriptor > > determineStringOffsetsTableContribution(DWARFDataExtractor &DA)
Find the unit's contribution to the string offsets table and determine its length and form.
(vector float) vec_cmpeq(*A, *B) C
Represents base address of the CU.
DWARFSectionKind
The enum of section identifiers to be used in internal interfaces.
into llvm powi allowing the code generator to produce balanced multiplication trees First
DWARFDie getVariableForAddress(uint64_t Address)
Returns variable DIE for the address provided.
This class implements an extremely fast bulk output stream that can only output to a stream.
void setSkeletonUnit(DWARFUnit *SU)
virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts)=0
uint32_t getLineTableOffset() const
const DWARFSection & getLineSection() const
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
void updateAddressDieMap(DWARFDie Die)
Recursively update address to Die map.
DWARFDie getParent(const DWARFDebugInfoEntry *Die)
void setDWOId(uint64_t NewID)
DWARFDie getSubroutineForAddress(uint64_t Address)
Returns subprogram DIE with address range encompassing the provided address.
typename UnitVector::iterator iterator
DWARFDataExtractor getDebugInfoExtractor() const
static bool isMatchingUnitTypeAndTag(uint8_t UnitType, dwarf::Tag Tag)
Expected< DWARFAddressRangesVector > collectAddressRanges()
const Optional< StrOffsetsContributionDescriptor > & getStringOffsetsTableContribution() const
Expected< DWARFLocationExpressionsVector > findLoclistFromOffset(uint64_t Offset)
DWARFUnit * getLinkedUnit()
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
uint32_t getDIEIndex(const DWARFDie &D)
Return the index of a DIE inside the unit's DIE vector.
uint8_t getUnitLengthFieldByteSize(DwarfFormat Format)
Get the byte size of the unit length field depending on the DWARF format.
DWARFDie getSibling(const DWARFDebugInfoEntry *Die)
uint8_t getDwarfStringOffsetsByteSize() const
DWARFUnit(DWARFContext &Context, const DWARFSection &Section, const DWARFUnitHeader &Header, const DWARFDebugAbbrev *DA, const DWARFSection *RS, const DWARFSection *LocSection, StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, const DWARFSection &LS, bool LE, bool IsDWO, const DWARFUnitVector &UnitVector)
UnitType
Constants for unit types in DWARF v5.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
uint8_t getRefAddrByteSize() const
const DWARFSection & getStringOffsetSection() const
dwarf::DwarfFormat getFormat() const
uint64_t getNextUnitOffset() const
DWARFDie getDIEAtIndex(unsigned Index)
Return the DIE object at the given index.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
DWARFUnit * getUnitForIndexEntry(const DWARFUnitIndex::Entry &E)
const char * getCompilationDir()
uint64_t getLocSectionBase() const
DWARFUnit * addUnit(std::unique_ptr< DWARFUnit > Unit)
Add an existing DWARFUnit to this UnitVector.
StringRef - Represent a constant reference to a string, i.e.
DWARFContext & getContext() const
decltype(make_filter_range(std::declval< iterator_range >(), isCompileUnit)) compile_unit_range
DWARFUnit * getUnitForOffset(uint64_t Offset) const
uint8_t getDwarfOffsetByteSize() const
die_iterator_range dies()
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
Optional< uint64_t > getAddrOffsetSectionBase() const
Expected< uint64_t > getStringOffsetSectionItem(uint32_t Index) const
DWARFDie getNonSkeletonUnitDIE(bool ExtractUnitDIEOnly=true)
Expected< DWARFAddressRangesVector > findRnglistFromOffset(uint64_t Offset)
Return a vector of address ranges resulting from a (possibly encoded) range list starting at a given ...
Error extractRangeList(uint64_t RangeListOffset, DWARFDebugRangeList &RangeList) const
Extract the range list referenced by this compile unit from the .debug_ranges section.
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
uint8_t getAddressByteSize() const
DWARFDie getLastChild(const DWARFDebugInfoEntry *Die)
SectionKind - This is a simple POD value that classifies the properties of a section.
StrOffsetsContributionDescriptor()=default
void setRangesSection(const DWARFSection *RS, uint64_t Base)
uint32_t getHeaderSize() const
Size in bytes of the parsed unit header.
DWARFDie getPreviousSibling(const DWARFDebugInfoEntry *Die)
Error tryExtractDIEsIfNeeded(bool CUDieOnly)
Lightweight error class with error context and mandatory checking.
void finishedInfoUnits()
Indicate that parsing .debug_info[.dwo] is done, and remaining units will be from ....
uint64_t getOffset() const
uint8_t getDwarfOffsetByteSize() const
void getInlinedChainForAddress(uint64_t Address, SmallVectorImpl< DWARFDie > &InlinedChain)
getInlinedChainForAddress - fetches inlined chain for a given address.
const DWARFSection & getInfoSection() const
uint64_t getAbbreviationsOffset() const
llvm::Optional< object::SectionedAddress > getBaseAddress()
typename SuperClass::iterator iterator
A range adaptor for a pair of iterators.
bool isCompileUnit(const std::unique_ptr< DWARFUnit > &U)
void setAddrOffsetSection(const DWARFSection *AOS, uint64_t Base)
const DWARFUnitIndex & getDWARFUnitIndex(DWARFContext &Context, DWARFSectionKind Kind)
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
DWARFDie getDIEForOffset(uint64_t Offset)
Return the DIE object for a given offset inside the unit's DIE vector.
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
const DWARFLocationTable & getLocationTable()
StrOffsetsContributionDescriptor(uint64_t Base, uint64_t Size, uint8_t Version, dwarf::DwarfFormat Format)
Expected< Optional< StrOffsetsContributionDescriptor > > determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA)
Find the unit's contribution to the string offsets table and determine its length and form.
const DWARFUnitHeader & getHeader() const
uint64_t getStringOffsetsBase() const
void updateVariableDieMap(DWARFDie Die)
Recursively update address to variable Die map.
uint16_t getVersion() const
Container for dump options that control which debug information will be dumped.
Describe a collection of units.
unsigned getNumUnits() const
Returns number of all units held by this instance.