summaryrefslogtreecommitdiffstats
path: root/lldb/lit/SymbolFile
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2018-06-07 10:04:44 +0000
committerPavel Labath <labath@google.com>2018-06-07 10:04:44 +0000
commite1d18758eb71bc8b17dbd95acccb61934095ef63 (patch)
tree2d1ca963b98d1d3622a1c143bd93a1c76a222228 /lldb/lit/SymbolFile
parent90083d3088ae859289a4277540dbf28b576fd59f (diff)
downloadbcm5719-llvm-e1d18758eb71bc8b17dbd95acccb61934095ef63.tar.gz
bcm5719-llvm-e1d18758eb71bc8b17dbd95acccb61934095ef63.zip
DebugNamesDWARFIndex: Add ability to lookup variables
Summary: This patch adds the ability to lookup variables to the DWARF v5 index class. During review we discovered an inconsistency between how the existing two indexes handle looking up qualified names of the variables: - manual index would return a value if the input string exactly matched the demangled name of some variable. - apple index ignored the context and returned any variable with the same base name. So, this patch also rectifies that situation: - it removes all context handling from the index classes. The GetGlobalVariables functions now just take a base name. For manual index, this meant we can stop putting demangled names into the variable index (this matches the behavior for functions). - context extraction is put into SymbolFileDWARF, so that it is common to all indexes. - additional filtering based on the context is also done in SymbolFileDWARF. This is done via a simple substring search, which is not ideal, but it matches what we are doing for functions (cf. Module::LookupInfo::Prune). Reviewers: clayborg, JDevlieghere Subscribers: aprantl, lldb-commits Differential Revision: https://reviews.llvm.org/D47781 llvm-svn: 334181
Diffstat (limited to 'lldb/lit/SymbolFile')
-rw-r--r--lldb/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp14
-rw-r--r--lldb/lit/SymbolFile/DWARF/find-basic-variable.cpp12
-rw-r--r--lldb/lit/SymbolFile/DWARF/find-qualified-variable.cpp15
3 files changed, 41 insertions, 0 deletions
diff --git a/lldb/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp b/lldb/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp
new file mode 100644
index 00000000000..c7cb3f27f6d
--- /dev/null
+++ b/lldb/lit/SymbolFile/DWARF/dwarf5-index-is-used.cpp
@@ -0,0 +1,14 @@
+// Test that we use the DWARF v5 name indexes.
+
+// REQUIRES: lld
+
+// 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 %t | FileCheck %s
+
+// CHECK: Name Index
+// CHECK: String: 0x{{.*}} "_start"
+// CHECK: Tag: DW_TAG_subprogram
+
+extern "C" void _start() {}
diff --git a/lldb/lit/SymbolFile/DWARF/find-basic-variable.cpp b/lldb/lit/SymbolFile/DWARF/find-basic-variable.cpp
index 5b677097df2..3ec14ea06ef 100644
--- a/lldb/lit/SymbolFile/DWARF/find-basic-variable.cpp
+++ b/lldb/lit/SymbolFile/DWARF/find-basic-variable.cpp
@@ -20,6 +20,18 @@
// RUN: FileCheck --check-prefix=REGEX %s
// RUN: lldb-test symbols --name=not_there --find=variable %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=variable --context=context %t | \
+// RUN: FileCheck --check-prefix=CONTEXT %s
+// RUN: lldb-test symbols --name=foo --find=variable %t | \
+// RUN: FileCheck --check-prefix=NAME %s
+// RUN: lldb-test symbols --regex --name=foo --find=variable %t | \
+// RUN: FileCheck --check-prefix=REGEX %s
+// RUN: lldb-test symbols --name=not_there --find=variable %t | \
+// RUN: FileCheck --check-prefix=EMPTY %s
// EMPTY: Found 0 variables:
// NAME: Found 4 variables:
diff --git a/lldb/lit/SymbolFile/DWARF/find-qualified-variable.cpp b/lldb/lit/SymbolFile/DWARF/find-qualified-variable.cpp
new file mode 100644
index 00000000000..ca1b3184fbe
--- /dev/null
+++ b/lldb/lit/SymbolFile/DWARF/find-qualified-variable.cpp
@@ -0,0 +1,15 @@
+// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
+// RUN: lldb-test symbols --name=A::foo --find=variable %t | FileCheck %s
+
+// CHECK: Found 1 variables:
+
+struct A {
+ static int foo;
+};
+int A::foo;
+// NAME-DAG: name = "foo", {{.*}} decl = find-qualified-variable.cpp:[[@LINE-1]]
+
+struct B {
+ static int foo;
+};
+int B::foo;
OpenPOWER on IntegriCloud