File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed
include/llvm/DebugInfo/DWARF Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -460,6 +460,11 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
460
460
// / Returns the Offset of the DIE within the containing CU or TU.
461
461
std::optional<uint64_t > getDIEUnitOffset () const ;
462
462
463
+ // / Returns the Entry corresponding to the parent of the DIE represented by
464
+ // / `this` Entry. If the parent DIE is not indexed by this table, or if this
465
+ // / table does not track parents through IDX_parent, an error is returned.
466
+ Expected<DWARFDebugNames::Entry> getParentDIEEntry () const ;
467
+
463
468
// / Return the Abbreviation that can be used to interpret the raw values of
464
469
// / this Accelerator Entry.
465
470
const Abbrev &getAbbrev () const { return *Abbr; }
@@ -609,6 +614,13 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
609
614
610
615
Expected<Entry> getEntry (uint64_t *Offset) const ;
611
616
617
+ // Returns the Entry at the relative `Offset` from the start of the Entry
618
+ // pool.
619
+ Expected<Entry> getEntryAtRelativeOffset (uint64_t Offset) const {
620
+ auto OffsetFromSection = Offset + this ->EntriesBase ;
621
+ return getEntry (&OffsetFromSection);
622
+ }
623
+
612
624
// / Look up all entries in this Name Index matching \c Key.
613
625
iterator_range<ValueIterator> equal_range (StringRef Key) const ;
614
626
Original file line number Diff line number Diff line change @@ -650,6 +650,16 @@ std::optional<uint64_t> DWARFDebugNames::Entry::getLocalTUIndex() const {
650
650
return std::nullopt;
651
651
}
652
652
653
+ Expected<DWARFDebugNames::Entry>
654
+ DWARFDebugNames::Entry::getParentDIEEntry () const {
655
+ // The offset of the accelerator table entry for the parent.
656
+ std::optional<DWARFFormValue> ParentEntryOff = lookup (dwarf::DW_IDX_parent);
657
+ if (!ParentEntryOff)
658
+ return createStringError (errc::illegal_byte_sequence,
659
+ " Incorrectly terminated entry list." );
660
+ return NameIdx->getEntryAtRelativeOffset (ParentEntryOff->getRawUValue ());
661
+ }
662
+
653
663
void DWARFDebugNames::Entry::dump (ScopedPrinter &W) const {
654
664
W.startLine () << formatv (" Abbrev: {0:x}\n " , Abbr->Code );
655
665
W.startLine () << formatv (" Tag: {0}\n " , Abbr->Tag );
You can’t perform that action at this time.
0 commit comments