summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h38
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h22
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h23
3 files changed, 37 insertions, 46 deletions
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h
index 57fb1f1da90..f36f470980b 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h
@@ -31,13 +31,14 @@ class DWARFDebugInfoEntry {
/// Offset within the .debug_info of the start of this entry.
uint32_t Offset;
- /// How many to add to "this" to get the sibling.
- uint32_t SiblingIdx;
+ /// The integer depth of this DIE within the compile unit DIEs where the
+ /// compile/type unit DIE has a depth of zero.
+ uint32_t Depth;
const DWARFAbbreviationDeclaration *AbbrevDecl;
public:
DWARFDebugInfoEntry()
- : Offset(0), SiblingIdx(0), AbbrevDecl(nullptr) {}
+ : Offset(0), Depth(0), AbbrevDecl(nullptr) {}
/// Extracts a debug info entry, which is a child of a given unit,
/// starting at a given offset. If DIE can't be extracted, returns false and
@@ -45,33 +46,16 @@ public:
bool extractFast(const DWARFUnit &U, uint32_t *OffsetPtr);
/// High performance extraction should use this call.
bool extractFast(const DWARFUnit &U, uint32_t *OffsetPtr,
- const DataExtractor &DebugInfoData, uint32_t UEndOffset);
+ const DataExtractor &DebugInfoData,
+ uint32_t UEndOffset,
+ uint32_t Depth);
uint32_t getOffset() const { return Offset; }
- bool hasChildren() const { return AbbrevDecl && AbbrevDecl->hasChildren(); }
-
- // We know we are kept in a vector of contiguous entries, so we know
- // our sibling will be some index after "this".
- const DWARFDebugInfoEntry *getSibling() const {
- return SiblingIdx > 0 ? this + SiblingIdx : nullptr;
- }
-
- // We know we are kept in a vector of contiguous entries, so we know
- // we don't need to store our child pointer, if we have a child it will
- // be the next entry in the list...
- const DWARFDebugInfoEntry *getFirstChild() const {
- return hasChildren() ? this + 1 : nullptr;
+ uint32_t getDepth() const { return Depth; }
+ dwarf::Tag getTag() const {
+ return AbbrevDecl ? AbbrevDecl->getTag() : dwarf::DW_TAG_null;
}
-
- void setSibling(const DWARFDebugInfoEntry *Sibling) {
- if (Sibling) {
- // We know we are kept in a vector of contiguous entries, so we know
- // our sibling will be some index after "this".
- SiblingIdx = Sibling - this;
- } else
- SiblingIdx = 0;
- }
-
+ bool hasChildren() const { return AbbrevDecl && AbbrevDecl->hasChildren(); }
const DWARFAbbreviationDeclaration *getAbbreviationDeclarationPtr() const {
return AbbrevDecl;
}
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
index 857cabab0df..f33758de6a5 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
@@ -40,6 +40,9 @@ public:
bool isValid() const { return U && Die; }
explicit operator bool() const { return isValid(); }
+ bool operator ==(const DWARFDie &RHS) const {
+ return Die == RHS.Die && U == RHS.U;
+ }
const DWARFDebugInfoEntry *getDebugInfoEntry() const { return Die; }
DWARFUnit *getDwarfUnit() const { return U; }
@@ -82,23 +85,26 @@ public:
/// Returns true if DIE represents a subprogram or an inlined subroutine.
bool isSubroutineDIE() const;
-
- /// Get the silbing of this DIE object.
+ /// Get the parent of this DIE object.
+ ///
+ /// \returns a valid DWARFDie instance if this object has a parent or an
+ /// invalid DWARFDie instance if it doesn't.
+ DWARFDie getParent() const;
+
+ /// Get the sibling of this DIE object.
///
/// \returns a valid DWARFDie instance if this object has a sibling or an
/// invalid DWARFDie instance if it doesn't.
- DWARFDie getSibling() const {
- assert(isValid() && "must check validity prior to calling");
- return DWARFDie(U, Die->getSibling());
- }
+ DWARFDie getSibling() const;
/// Get the first child of this DIE object.
///
/// \returns a valid DWARFDie instance if this object has children or an
/// invalid DWARFDie instance if it doesn't.
DWARFDie getFirstChild() const {
- assert(isValid() && "must check validity prior to calling");
- return DWARFDie(U, Die->getFirstChild());
+ if (isValid() && Die->hasChildren())
+ return DWARFDie(U, Die + 1);
+ return DWARFDie();
}
/// Dump the DIE and all of its attributes to the supplied stream.
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
index 0f4a6f0438d..78bbe098b2d 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
@@ -140,6 +140,12 @@ class DWARFUnit {
const DWARFUnitIndex::Entry *IndexEntry;
+ uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) {
+ auto First = DieArray.data();
+ assert(Die >= First && Die < First + DieArray.size());
+ return Die - First;
+ }
+
protected:
virtual bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr);
/// Size in bytes of the unit header.
@@ -251,19 +257,18 @@ public:
/// method on a DIE that isn't accessible by following
/// children/sibling links starting from this unit's getUnitDIE().
uint32_t getDIEIndex(const DWARFDie &D) {
- auto DIE = D.getDebugInfoEntry();
- assert(!DieArray.empty() && DIE >= &DieArray[0] &&
- DIE < &DieArray[0] + DieArray.size());
- return DIE - &DieArray[0];
+ return getDIEIndex(D.getDebugInfoEntry());
}
/// \brief Return the DIE object at the given index.
DWARFDie getDIEAtIndex(unsigned Index) {
- if (Index < DieArray.size())
- return DWARFDie(this, &DieArray[Index]);
- return DWARFDie();
+ assert(Index < DieArray.size());
+ return DWARFDie(this, &DieArray[Index]);
}
+ DWARFDie getParent(const DWARFDebugInfoEntry *Die);
+ DWARFDie getSibling(const DWARFDebugInfoEntry *Die);
+
/// \brief Return the DIE object for a given offset inside the
/// unit's DIE vector.
///
@@ -298,10 +303,6 @@ private:
/// extractDIEsToVector - Appends all parsed DIEs to a vector.
void extractDIEsToVector(bool AppendCUDie, bool AppendNonCUDIEs,
std::vector<DWARFDebugInfoEntry> &DIEs) const;
- /// setDIERelations - We read in all of the DIE entries into our flat list
- /// of DIE entries and now we need to go back through all of them and set the
- /// parent, sibling and child pointers for quick DIE navigation.
- void setDIERelations();
/// clearDIEs - Clear parsed DIEs to keep memory usage low.
void clearDIEs(bool KeepCUDie);
OpenPOWER on IntegriCloud