[llvm] r229179 - DWARFUnit: Add a couple of helpers to access the DIE array.

Frederic Riss friss at apple.com
Fri Feb 13 15:18:25 PST 2015


Author: friss
Date: Fri Feb 13 17:18:24 2015
New Revision: 229179

URL: http://llvm.org/viewvc/llvm-project?rev=229179&view=rev
Log:
DWARFUnit: Add a couple of helpers to access the DIE array.

To be used in dsymutil (or any other client that wants to take
advantage of the fact that DIEs are stored in a vector).

Modified:
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h?rev=229179&r1=229178&r2=229179&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h Fri Feb 13 17:18:24 2015
@@ -233,6 +233,26 @@ public:
     return DIE - &DieArray[0];
   }
 
+  /// \brief Return the DIE object at the given index.
+  const DWARFDebugInfoEntryMinimal *getDIEAtIndex(unsigned Index) const {
+    assert(Index < DieArray.size());
+    return &DieArray[Index];
+  }
+
+  /// \brief Return the DIE object for a given offset inside the
+  /// unit's DIE vector.
+  ///
+  /// The unit needs to have his DIEs extracted for this method to work.
+  const DWARFDebugInfoEntryMinimal *getDIEForOffset(uint32_t Offset) const {
+    assert(!DieArray.empty());
+    auto it = std::lower_bound(
+        DieArray.begin(), DieArray.end(), Offset,
+        [=](const DWARFDebugInfoEntryMinimal &LHS, uint32_t Offset) {
+          return LHS.getOffset() < Offset;
+        });
+    return it == DieArray.end() ? nullptr : &*it;
+  }
+
 private:
   /// Size in bytes of the .debug_info data associated with this compile unit.
   size_t getDebugInfoSize() const { return Length + 4 - getHeaderSize(); }





More information about the llvm-commits mailing list