DebugNamesDWARFIndex: Add type lookup suport
authorPavel Labath <labath@google.com>
Thu, 7 Jun 2018 12:26:18 +0000 (12:26 +0000)
committerPavel Labath <labath@google.com>
Thu, 7 Jun 2018 12:26:18 +0000 (12:26 +0000)
This implements just one of the GetTypes overloads. The other is not
testable from lldb-test so I'm leaving it unimplemented until I figure
out what to do with testing.

llvm-svn: 334190

lldb/lit/SymbolFile/DWARF/find-basic-type.cpp
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h

index db2aa9e..41b66c7 100644 (file)
 // RUN: lldb-test symbols --name=not_there --find=type %t | \
 // RUN:   FileCheck --check-prefix=EMPTY %s
 
+// RUN: clang %s -g -c -emit-llvm -o - --target=x86_64-pc-linux | \
+// RUN:   llc -accel-tables=Dwarf -filetype=obj -o %t.o
+// RUN: ld.lld %t.o -o %t
+// RUN: lldb-test symbols --name=foo --find=type %t | \
+// RUN:   FileCheck --check-prefix=NAME %s
+// RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
+// RUN:   FileCheck --check-prefix=CONTEXT %s
+// RUN: lldb-test symbols --name=not_there --find=type %t | \
+// RUN:   FileCheck --check-prefix=EMPTY %s
+
 // EMPTY: Found 0 types:
 // NAME: Found 4 types:
 // CONTEXT: Found 1 types:
index 5f20bc1..5d434e0 100644 (file)
@@ -98,6 +98,16 @@ void DebugNamesDWARFIndex::GetGlobalVariables(const RegularExpression &regex,
   }
 }
 
+void DebugNamesDWARFIndex::GetTypes(ConstString name, DIEArray &offsets) {
+  m_fallback.GetTypes(name, offsets);
+
+  for (const DebugNames::Entry &entry :
+       m_debug_names_up->equal_range(name.GetStringRef())) {
+    if (isType(entry.tag()))
+      Append(entry, offsets);
+  }
+}
+
 void DebugNamesDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
   m_fallback.GetNamespaces(name, offsets);
 
index bace531..9164045 100644 (file)
@@ -32,7 +32,7 @@ public:
   void GetObjCMethods(ConstString class_name, DIEArray &offsets) override {}
   void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
                             DIEArray &offsets) override {}
-  void GetTypes(ConstString name, DIEArray &offsets) override {}
+  void GetTypes(ConstString name, DIEArray &offsets) override;
   void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override {}
   void GetNamespaces(ConstString name, DIEArray &offsets) override;
   void GetFunctions(ConstString name, DWARFDebugInfo &info,