From 78a07bfa66e673ae766f8dfb7dd4f9bebba8fce6 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Wed, 21 Dec 2016 21:37:06 +0000 Subject: Add the ability for DWARFDie objects to get the parent DWARFDie. In order for the llvm DWARF parser to be used in LLDB we will need to be able to get the parent of a DIE. This patch adds that functionality by changing the DWARFDebugInfoEntry class to store a depth field instead of a sibling index. Using a depth field allows us to easily calculate the sibling and the parent without increasing the size of DWARFDebugInfoEntry. I tested llvm-dsymutil on a debug version of clang where this fully parses DWARF in over 1200 .o files to verify there was no serious regression in performance. Added a full suite of unit tests to test this functionality. Differential Revision: https://reviews.llvm.org/D27995 llvm-svn: 290274 --- llvm/lib/DebugInfo/DWARF/DWARFDie.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'llvm/lib/DebugInfo/DWARF/DWARFDie.cpp') diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp index 94777109e44..deec1633022 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -428,3 +428,14 @@ void DWARFDie::getInlinedChainForAddress( std::reverse(InlinedChain.begin(), InlinedChain.end()); } +DWARFDie DWARFDie::getParent() const { + if (isValid()) + return U->getParent(Die); + return DWARFDie(); +} + +DWARFDie DWARFDie::getSibling() const { + if (isValid()) + return U->getSibling(Die); + return DWARFDie(); +} -- cgit v1.2.3