10 #ifndef LLVM_DEBUGINFO_DWARF_DWARFUNIT_H 11 #define LLVM_DEBUGINFO_DWARF_DWARFUNIT_H 39 class DWARFAbbreviationDeclarationSet;
41 class DWARFDebugAbbrev;
53 uint64_t AbbrOffset = 0;
59 uint64_t TypeHash = 0;
89 assert((!DWOId || *DWOId == Id) &&
"setting DWOId to a different value");
97 return UnitType == dwarf::DW_UT_type || UnitType == dwarf::DW_UT_split_type;
125 bool isLittleEndian,
bool isDWO,
bool Lazy) = 0;
132 template<
typename UnitType>
136 std::function<std::unique_ptr<UnitType>(
uint32_t)> Parser;
144 auto *
CU = std::upper_bound(
146 [](
uint32_t LHS,
const std::unique_ptr<UnitType> &RHS) {
147 return LHS < RHS->getNextUnitOffset();
149 if (
CU != this->
end() && (*CU)->getOffset() <= Offset)
158 auto Offset = CUOff->Offset;
160 auto *
CU = std::upper_bound(
161 this->
begin(), this->
end(), CUOff->Offset,
162 [](
uint32_t LHS,
const std::unique_ptr<UnitType> &RHS) {
163 return LHS < RHS->getNextUnitOffset();
165 if (
CU != this->
end() && (*CU)->getOffset() <= Offset)
171 auto U = Parser(Offset);
175 auto *NewCU = U.get();
176 this->insert(
CU, std::move(U));
185 bool IsDWO,
bool Lazy)
override {
194 &
LS](
uint32_t Offset) -> std::unique_ptr<UnitType> {
200 auto U = llvm::make_unique<UnitType>(
201 Context,
Section, Header, DA, RS, SS, SOS, AOS,
LS,
LE, IsDWO,
211 if (
I != this->
end() && (*I)->getOffset() == Offset) {
215 auto U = Parser(Offset);
218 Offset = U->getNextUnitOffset();
219 I = std::next(this->insert(
I, std::move(U)));
241 : Base(Base), Size(Size), FormParams({
Version, 0, Format}) {}
283 std::vector<DWARFDebugInfoEntry> DieArray;
288 std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap;
293 std::shared_ptr<DWARFUnit> DWO;
296 auto First = DieArray.data();
297 assert(Die >= First && Die < First + DieArray.size());
349 return StringOffsetSection;
353 AddrOffsetSection = AOS;
354 AddrOffsetSectionBase = Base;
358 void updateAddressDieMap(
DWARFDie Die);
362 RangeSectionBase = Base;
366 bool getStringOffsetSectionItem(
uint32_t Index, uint64_t &Result)
const;
384 return StringOffsetsTableContribution;
388 assert(StringOffsetsTableContribution);
389 return StringOffsetsTableContribution->getDwarfOffsetByteSize();
393 assert(StringOffsetsTableContribution);
394 return StringOffsetsTableContribution->Base;
401 case dwarf::DW_UT_compile:
402 return Tag == dwarf::DW_TAG_compile_unit;
403 case dwarf::DW_UT_type:
404 return Tag == dwarf::DW_TAG_type_unit;
405 case dwarf::DW_UT_partial:
406 return Tag == dwarf::DW_TAG_partial_unit;
407 case dwarf::DW_UT_skeleton:
408 return Tag == dwarf::DW_TAG_skeleton_unit;
409 case dwarf::DW_UT_split_compile:
410 case dwarf::DW_UT_split_type:
423 case dwarf::DW_UT_compile:
424 case dwarf::DW_UT_partial:
426 case dwarf::DW_UT_skeleton:
427 case dwarf::DW_UT_split_compile:
429 case dwarf::DW_UT_type:
430 case dwarf::DW_UT_split_type:
439 extractDIEsIfNeeded(ExtractUnitDIEOnly);
440 if (DieArray.empty())
442 return DWARFDie(
this, &DieArray[0]);
445 const char *getCompilationDir();
447 extractDIEsIfNeeded(
true);
448 return getHeader().getDWOId();
466 return RngListTable->getOffsetEntry(Index);
480 void getInlinedChainForAddress(uint64_t Address,
489 extractDIEsIfNeeded(
false);
490 return DieArray.size();
505 assert(Index < DieArray.size());
506 return DWARFDie(
this, &DieArray[Index]);
520 extractDIEsIfNeeded(
false);
521 assert(!DieArray.empty());
523 DieArray.begin(), DieArray.end(), Offset,
525 return LHS.getOffset() < Offset;
527 if (it != DieArray.end() && it->getOffset() == Offset)
534 if (
const auto *Contrib = IndexEntry->getOffset(
DW_SECT_LINE))
535 return Contrib->Offset;
540 extractDIEsIfNeeded(
false);
546 size_t getDebugInfoSize()
const {
547 return Header.
getLength() + 4 - getHeaderSize();
552 size_t extractDIEsIfNeeded(
bool CUDieOnly);
555 void extractDIEsToVector(
bool AppendCUDie,
bool AppendNonCUDIEs,
556 std::vector<DWARFDebugInfoEntry> &DIEs)
const;
559 void clearDIEs(
bool KeepCUDie);
568 #endif // LLVM_DEBUGINFO_DWARF_DWARFUNIT_H
static bool isMatchingUnitTypeAndTag(uint8_t UnitType, dwarf::Tag Tag)
const_iterator end(StringRef path)
Get end iterator over path.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Compute iterated dominance frontiers using a linear time algorithm.
Represents a unit's contribution to the string offsets table.
bool isUnitType(uint8_t UnitType)
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
uint8_t getDwarfOffsetByteSize() const
void setAddrOffsetSection(const DWARFSection *AOS, uint32_t Base)
const Optional< StrOffsetsContributionDescriptor > & getStringOffsetsTableContribution() const
uint8_t getRefAddrByteSize() const
dwarf::DwarfFormat getFormat() const
uint8_t getDwarfStringOffsetsByteSize() const
UnitType * getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) override
const dwarf::FormParams & getFormParams() const
uint32_t getNextUnitOffset() const
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
const DWARFSection & getLineSection() const
Tagged union holding either a T or a Error.
const DWARFDebugInfoEntry * getDebugInfoEntry() const
uint8_t getAddressByteSize() const
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.
auto lower_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range))
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
void setDWOId(uint64_t NewID)
const DWARFSection & getStringOffsetSection() const
uint16_t getVersion() const
die_iterator_range dies()
Utility class that carries the DWARF compile/type unit and the debug info entry in an object...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Optional< uint64_t > getDWOId()
static uint32_t getDWARF5HeaderSize(uint8_t UnitType)
Return the number of bytes for the header of a unit of UnitType type.
StringRef getStringSection() const
uint32_t getDIEIndex(const DWARFDie &D)
Return the index of a DIE inside the unit's DIE vector.
DWARFContext & getContext() const
void setRangesSection(const DWARFSection *RS, uint32_t Base)
llvm::Expected< Value > parse(llvm::StringRef JSON)
Parses the provided JSON source, or returns a ParseError.
uint32_t getHeaderSize() const
Size in bytes of the parsed unit header.
const DWARFUnitIndex & getDWARFUnitIndex(DWARFContext &Context, DWARFSectionKind Kind)
StrOffsetsContributionDescriptor(uint64_t Base, uint64_t Size, uint8_t Version, dwarf::DwarfFormat Format)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
uint64_t getStringOffsetsBase() const
DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)
Represents base address of the CU.
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...
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
A range adaptor for a pair of iterators.
This file contains constants used for implementing Dwarf debug support.
typename SuperClass::iterator iterator
uint32_t getLength() const
static void clear(coro::Shape &Shape)
DataExtractor getStringExtractor() const
DWARFDie getDIEAtIndex(unsigned Index)
Return the DIE object at the given index.
uint8_t getVersion() const
const DWARFUnitSectionBase & getUnitSection() const
getUnitSection - Return the DWARFUnitSection containing this unit.
uint32_t getOffset() const
uint8_t getUnitType() 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.
const DWARFUnitHeader & getHeader() const
std::vector< DWARFAddressRange > DWARFAddressRangesVector
DWARFAddressRangesVector - represents a set of absolute address ranges.
DWARFDebugInfoEntry - A DIE with only the minimum required data.
Lightweight error class with error context and mandatory checking.
static const Function * getParent(const Value *V)
const SectionContribution * getOffset(DWARFSectionKind Sec) const
StringRef - Represent a constant reference to a string, i.e.
Optional< uint32_t > getRnglistOffset(uint32_t Index)
Return a rangelist's offset based on an index.
uint8_t getDwarfOffsetByteSize() const
uint32_t getLineTableOffset() const