9#ifndef LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
10#define LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
71 std::optional<uint64_t> DWOId;
97 return FormParams.getDwarfOffsetByteSize();
101 std::optional<uint64_t>
getDWOId()
const {
return DWOId; }
103 assert((!DWOId || *DWOId == Id) &&
"setting DWOId to a different value");
111 return UnitType == dwarf::DW_UT_type || UnitType == dwarf::DW_UT_split_type;
123 DWARFSectionKind Kind);
134 int NumInfoUnits = -1;
175 return NumInfoUnits == -1 ?
size() : NumInfoUnits;
230 std::unique_ptr<DWARFLocationTable> LocTable;
237 std::optional<uint64_t> AddrOffsetSectionBase;
244 std::optional<StrOffsetsContributionDescriptor>
245 StringOffsetsTableContribution;
248 std::optional<object::SectionedAddress> BaseAddr;
250 std::vector<DWARFDebugInfoEntry> DieArray;
255 std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap;
259 std::map<uint64_t, std::pair<uint64_t, DWARFDie>> VariableDieMap;
262 using die_iterator_range =
265 std::shared_ptr<DWARFUnit> DWO;
277 auto First = DieArray.data();
284 assert(Index < DieArray.size());
285 return &DieArray[Index];
330 return Header.getFormParams();
336 return Header.getDwarfOffsetByteSize();
349 return StringOffsetSection;
359 AddrOffsetSection = AOS;
360 AddrOffsetSectionBase =
Base;
364 return AddrOffsetSectionBase;
369 if (std::optional<uint64_t> AddrOffsetSectionBase =
377 void updateAddressDieMap(
DWARFDie Die);
380 void updateVariableDieMap(
DWARFDie Die);
384 RangeSectionBase =
Base;
388 return LocSectionBase;
391 std::optional<object::SectionedAddress>
392 getAddrOffsetSectionItem(
uint32_t Index)
const;
411 const std::optional<StrOffsetsContributionDescriptor> &
413 extractDIEsIfNeeded(
true );
414 return StringOffsetsTableContribution;
418 assert(StringOffsetsTableContribution);
419 return StringOffsetsTableContribution->getDwarfOffsetByteSize();
423 assert(StringOffsetsTableContribution);
424 return StringOffsetsTableContribution->Base;
433 case dwarf::DW_UT_compile:
434 return Tag == dwarf::DW_TAG_compile_unit;
435 case dwarf::DW_UT_type:
436 return Tag == dwarf::DW_TAG_type_unit;
437 case dwarf::DW_UT_partial:
438 return Tag == dwarf::DW_TAG_partial_unit;
439 case dwarf::DW_UT_skeleton:
440 return Tag == dwarf::DW_TAG_skeleton_unit;
441 case dwarf::DW_UT_split_compile:
442 case dwarf::DW_UT_split_type:
448 std::optional<object::SectionedAddress> getBaseAddress();
451 extractDIEsIfNeeded(ExtractUnitDIEOnly);
452 if (DieArray.empty())
454 return DWARFDie(
this, &DieArray[0]);
459 parseDWO(DWOAlternativeLocation);
460 return DWO ? DWO->getUnitDIE(ExtractUnitDIEOnly)
461 : getUnitDIE(ExtractUnitDIEOnly);
464 const char *getCompilationDir();
466 extractDIEsIfNeeded(
true);
483 std::optional<uint64_t> getRnglistOffset(
uint32_t Index);
485 std::optional<uint64_t> getLoclistOffset(
uint32_t Index);
513 extractDIEsIfNeeded(
false);
514 return DieArray.size();
542 return DWARFDie(
this, &DieArray[*DieIdx]);
550 extractDIEsIfNeeded(
false);
555 if (It != DieArray.end() && It->getOffset() ==
Offset)
556 return It - DieArray.begin();
561 if (
auto IndexEntry = Header.getIndexEntry())
562 if (
const auto *Contrib = IndexEntry->getContribution(DW_SECT_LINE))
563 return Contrib->getOffset32();
568 extractDIEsIfNeeded(
false);
578 size_t getDebugInfoSize()
const {
579 return Header.getLength() + Header.getUnitLengthFieldByteSize() -
585 void extractDIEsIfNeeded(
bool CUDieOnly);
588 void extractDIEsToVector(
bool AppendCUDie,
bool AppendNonCUDIEs,
589 std::vector<DWARFDebugInfoEntry> &DIEs)
const;
592 void clearDIEs(
bool KeepCUDie);
599 bool parseDWO(
StringRef AlternativeLocation = {});
603 return !U->isTypeUnit();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static const Function * getParent(const Value *V)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseSet and SmallDenseSet classes.
This file contains constants used for implementing Dwarf debug support.
static LLVM_PACKED_END size_t getHeaderSize(uint16_t Version)
This file defines the SmallVector class.
A structured debug information entry.
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
DWARFDebugInfoEntry - A DIE with only the minimum required data.
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
An abstract base class for various kinds of location tables (.debug_loc, .debug_loclists,...
Describe a collection of units.
SmallVectorImpl< std::unique_ptr< DWARFUnit > > UnitVector
LLVM_ABI DWARFUnit * addUnit(std::unique_ptr< DWARFUnit > Unit)
Add an existing DWARFUnit to this UnitVector.
unsigned getNumInfoUnits() const
Returns number of units from all .debug_info[.dwo] sections.
void finishedInfoUnits()
Indicate that parsing .debug_info[.dwo] is done, and remaining units will be from ....
llvm::iterator_range< UnitVector::iterator > iterator_range
unsigned getNumTypesUnits() const
Returns number of units from all .debug_types[.dwo] sections.
LLVM_ABI DWARFUnit * getUnitForIndexEntry(const DWARFUnitIndex::Entry &E, DWARFSectionKind Sec, const DWARFSection *Section=nullptr)
Returns the Unit from the .debug_info or .debug_types section by the index entry.
unsigned getNumUnits() const
Returns number of all units held by this instance.
LLVM_ABI void addUnitsForSection(DWARFContext &C, const DWARFSection &Section, DWARFSectionKind SectionKind)
Read units from a .debug_info or .debug_types section.
LLVM_ABI DWARFUnit * getUnitForOffset(uint64_t Offset) const
UnitVector::iterator iterator
LLVM_ABI void addUnitsForDWOSection(DWARFContext &C, const DWARFSection &DWOSection, DWARFSectionKind SectionKind, bool Lazy=false)
Read units from a .debug_info.dwo or .debug_types.dwo section.
decltype(make_filter_range(std::declval< iterator_range >(), isCompileUnit)) compile_unit_range
const DWARFDebugInfoEntry * getDebugInfoEntry(unsigned Index) const
Return DWARFDebugInfoEntry for the specified index Index.
std::optional< uint64_t > getDWOId()
uint32_t getHeaderSize() const
Size in bytes of the parsed unit header.
const DWARFLocationTable & getLocationTable()
unsigned getNumDIEs()
Returns the number of DIEs in the unit.
const dwarf::FormParams & getFormParams() const
DWARFDie getNonSkeletonUnitDIE(bool ExtractUnitDIEOnly=true, StringRef DWOAlternativeLocation={})
uint8_t getUnitType() const
uint64_t getLength() const
uint8_t getRefAddrByteSize() const
DataExtractor getStringExtractor() const
Error tryExtractDIEsIfNeeded(bool CUDieOnly)
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
DWARFContext & getContext() const
uint8_t getAddressByteSize() const
void setSkeletonUnit(DWARFUnit *SU)
std::optional< uint64_t > getAddrOffsetSectionBase() const
const DWARFSection & getInfoSection() const
void setAddrOffsetSection(const DWARFSection *AOS, uint64_t Base)
void setDWOId(uint64_t NewID)
uint64_t getLocSectionBase() const
void setRangesSection(const DWARFSection *RS, uint64_t Base)
uint8_t getDwarfStringOffsetsByteSize() const
const DWARFUnitHeader & getHeader() const
DWARFDie getDIEForOffset(uint64_t Offset)
Return the DIE object for a given offset Offset inside the unit's DIE vector.
uint32_t getDIEIndex(const DWARFDie &D) const
Return the index of a DIE inside the unit's DIE vector.
uint32_t getLineTableOffset() const
uint64_t getStringOffsetsBase() const
dwarf::DwarfFormat getFormat() 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)
std::optional< uint32_t > getDIEIndexForOffset(uint64_t Offset)
Return the DIE index for a given offset Offset inside the unit's DIE vector.
uint64_t getAbbreviationsOffset() const
uint16_t getVersion() const
std::optional< uint64_t > getIndexedAddressOffset(uint64_t Index)
Returns offset to the indexed address value inside .debug_addr section.
uint64_t getAbbrOffset() const
uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) const
Return the index of a Die entry inside the unit's DIE vector.
die_iterator_range dies()
bool isLittleEndian() const
virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts)=0
const DWARFUnitVector & getUnitVector() const
Return the DWARFUnitVector containing this unit.
const DWARFSection & getStringOffsetSection() const
const DWARFSection & getLineSection() const
StringRef getStringSection() const
uint8_t getDwarfOffsetByteSize() const
static bool isMatchingUnitTypeAndTag(uint8_t UnitType, dwarf::Tag Tag)
uint64_t getNextUnitOffset() const
const std::optional< StrOffsetsContributionDescriptor > & getStringOffsetsTableContribution()
DWARFUnit * getLinkedUnit()
DWARFDie getDIEAtIndex(unsigned Index)
Return the DIE object at the given index Index.
uint64_t getOffset() const
Implements a dense probed hash-table based set.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
SectionKind - This is a simple POD value that classifies the properties of a section.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
typename SuperClass::iterator iterator
StringRef - Represent a constant reference to a string, i.e.
Stores all information related to a compile unit, be it in its original instance of the object file o...
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
@ C
The default llvm calling convention, compatible with C.
uint8_t getUnitLengthFieldByteSize(DwarfFormat Format)
Get the byte size of the unit length field depending on the DWARF format.
bool isUnitType(uint8_t UnitType)
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI const DWARFUnitIndex & getDWARFUnitIndex(DWARFContext &Context, DWARFSectionKind Kind)
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
DWARFSectionKind
The enum of section identifiers to be used in internal interfaces.
FunctionAddr VTableAddr uintptr_t uintptr_t Version
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...
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
bool isCompileUnit(const std::unique_ptr< DWARFUnit > &U)
Container for dump options that control which debug information will be dumped.
LLVM_ABI Expected< StrOffsetsContributionDescriptor > validateContributionSize(DWARFDataExtractor &DA)
Determine whether a contribution to the string offsets table is consistent with the relevant section ...
dwarf::DwarfFormat getFormat() const
uint8_t getVersion() const
uint64_t Size
The contribution size not including the header.
StrOffsetsContributionDescriptor()=default
dwarf::FormParams FormParams
Format and version.
uint8_t getDwarfOffsetByteSize() const
StrOffsetsContributionDescriptor(uint64_t Base, uint64_t Size, uint8_t Version, dwarf::DwarfFormat Format)