Skip to content

Commit 19f947f

Browse files
committed
[lldb] Fix "exact match" debug_names type queries
.. in the global namespace The problem was the interaction of llvm#116989 with an optimization in GetTypesWithQuery. The optimization was only correct for non-exact matches, but that didn't matter before this PR due to the "second layer of defense". After that was removed, the query started returning more types than it should.
1 parent 89a0ee8 commit 19f947f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ void DebugNamesDWARFIndex::GetTypesWithQuery(
527527
ConstString name = query.GetTypeBasename();
528528
std::vector<lldb_private::CompilerContext> query_context =
529529
query.GetContextRef();
530-
if (query_context.size() <= 1)
530+
if (query_context.size() <= 1 && !query.GetExactMatch())
531531
return GetTypes(name, callback);
532532

533533
llvm::SmallVector<CompilerContext> parent_contexts =

lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-type.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// RUN: ld.lld %t.o -o %t
55
// RUN: lldb-test symbols --name=foo --find=type %t | \
66
// RUN: FileCheck --check-prefix=NAME %s
7+
// RUN: lldb-test symbols --name=::foo --find=type %t | \
8+
// RUN: FileCheck --check-prefix=EXACT %s
79
// RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
810
// RUN: FileCheck --check-prefix=CONTEXT %s
911
// RUN: lldb-test symbols --name=not_there --find=type %t | \
@@ -12,6 +14,8 @@
1214
// RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
1315
// RUN: lldb-test symbols --name=foo --find=type %t | \
1416
// RUN: FileCheck --check-prefix=NAME %s
17+
// RUN: lldb-test symbols --name=::foo --find=type %t | \
18+
// RUN: FileCheck --check-prefix=EXACT %s
1519
// RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
1620
// RUN: FileCheck --check-prefix=CONTEXT %s
1721
// RUN: lldb-test symbols --name=not_there --find=type %t | \
@@ -22,6 +26,8 @@
2226
// RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
2327
// RUN: lldb-test symbols --name=foo --find=type %t | \
2428
// RUN: FileCheck --check-prefix=NAME %s
29+
// RUN: lldb-test symbols --name=::foo --find=type %t | \
30+
// RUN: FileCheck --check-prefix=EXACT %s
2531
// RUN: lldb-test symbols --name=foo --context=context --find=type %t | \
2632
// RUN: FileCheck --check-prefix=CONTEXT %s
2733
// RUN: lldb-test symbols --name=not_there --find=type %t | \
@@ -31,9 +37,11 @@
3137

3238
// EMPTY: Found 0 types:
3339
// NAME: Found 4 types:
40+
// EXACT: Found 1 types:
3441
// CONTEXT: Found 1 types:
3542
struct foo { };
3643
// NAME-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-1]]
44+
// EXACT-DAG: name = "foo", {{.*}} decl = find-basic-type.cpp:[[@LINE-2]]
3745

3846
namespace bar {
3947
int context;

0 commit comments

Comments
 (0)