[Lldb-commits] [lldb] r334516 - DebugNamesDWARFIndex: Implement DWARFDeclContext variant of GetTypes method

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 12 09:50:01 PDT 2018


Author: labath
Date: Tue Jun 12 09:50:01 2018
New Revision: 334516

URL: http://llvm.org/viewvc/llvm-project?rev=334516&view=rev
Log:
DebugNamesDWARFIndex: Implement DWARFDeclContext variant of GetTypes method

This method is used to find complete definitions of a type when one
parses a compile unit with only forward declaration available.

Since it is only accessed from DWARFASTParserClang, it was not
possible/easy to trigger this codepath from lldb-test. Therefore, I
adapt add a debug-names variant to an existing dotest test to cover this
scenario.

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/lang/c/forward/TestForwardDeclaration.py
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h

Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/c/forward/TestForwardDeclaration.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/forward/TestForwardDeclaration.py?rev=334516&r1=334515&r2=334516&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/forward/TestForwardDeclaration.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/forward/TestForwardDeclaration.py Tue Jun 12 09:50:01 2018
@@ -7,6 +7,7 @@ import os
 import time
 import lldb
 from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
 import lldbsuite.test.lldbutil as lldbutil
 
 
@@ -14,9 +15,9 @@ class ForwardDeclarationTestCase(TestBas
 
     mydir = TestBase.compute_mydir(__file__)
 
-    def test_and_run_command(self):
+    def do_test(self, dictionary=None):
         """Display *bar_ptr when stopped on a function with forward declaration of struct bar."""
-        self.build()
+        self.build(dictionary=dictionary)
         exe = self.getBuildArtifact("a.out")
         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
@@ -53,3 +54,15 @@ class ForwardDeclarationTestCase(TestBas
                 '(bar)',
                 '(int) a = 1',
                 '(int) b = 2'])
+
+    def test(self):
+        self.do_test()
+
+    @no_debug_info_test
+    @skipIfDarwin
+    @skipIf(compiler=no_match("clang"))
+    @skipIf(compiler_version=["<", "7.0"])
+    def test_debug_names(self):
+        """Test that we are able to find complete types when using DWARF v5
+        accelerator tables"""
+        self.do_test(dict(CFLAGS_EXTRAS="-mllvm -accel-tables=Dwarf"))

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp?rev=334516&r1=334515&r2=334516&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp Tue Jun 12 09:50:01 2018
@@ -9,6 +9,7 @@
 
 #include "Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDeclContext.h"
 #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h"
 #include "lldb/Utility/RegularExpression.h"
 #include "lldb/Utility/Stream.h"
@@ -154,6 +155,17 @@ void DebugNamesDWARFIndex::GetTypes(Cons
       Append(entry, offsets);
   }
 }
+
+void DebugNamesDWARFIndex::GetTypes(const DWARFDeclContext &context,
+                                    DIEArray &offsets) {
+  m_fallback.GetTypes(context, offsets);
+
+  for (const DebugNames::Entry &entry :
+       m_debug_names_up->equal_range(context[0].name)) {
+    if (entry.tag() == context[0].tag)
+      Append(entry, offsets);
+  }
+}
 
 void DebugNamesDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
   m_fallback.GetNamespaces(name, offsets);

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h?rev=334516&r1=334515&r2=334516&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h Tue Jun 12 09:50:01 2018
@@ -33,7 +33,7 @@ public:
   void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
                             DIEArray &offsets) override {}
   void GetTypes(ConstString name, DIEArray &offsets) override;
-  void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override {}
+  void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override;
   void GetNamespaces(ConstString name, DIEArray &offsets) override;
   void GetFunctions(ConstString name, DWARFDebugInfo &info,
                     const CompilerDeclContext &parent_decl_ctx,




More information about the lldb-commits mailing list