Skip to content

Commit 1b12766

Browse files
Jaroslav Sevciklabath
authored andcommitted
[lldb/DWARF] Only match mangled name in full-name function lookup (with accelerators)
Summary: In the spirit of https://reviews.llvm.org/D70846, we only return functions with matching mangled name from Apple/DebugNamesDWARFIndex::GetFunction if eFunctionNameTypeFull is requested. This speeds up lookup in the presence of large amount of class methods of the same name (a typical examples would be constructors of templates with many instantiations or overloaded operators). Reviewers: labath Reviewed By: labath Subscribers: aprantl, arphaman, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D73191
1 parent fba7574 commit 1b12766

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void DWARFIndex::ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
3939
if (!SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die))
4040
return;
4141

42-
// In case of a full match, we just insert everything we find.
43-
if (name_type_mask & eFunctionNameTypeFull) {
42+
// In case of a full match, we insert functions with a matching mangled name.
43+
if (name_type_mask & eFunctionNameTypeFull && die.GetMangledName() == name) {
4444
dies.push_back(die);
4545
return;
4646
}

lldb/test/Shell/SymbolFile/DWARF/find-basic-function.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
// RUN: FileCheck --check-prefix=FULL %s
1111
// RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \
1212
// RUN: FileCheck --check-prefix=FULL-MANGLED %s
13+
// RUN: lldb-test symbols --name=_ZN3bar3baz3fooEv --find=function --function-flags=full %t | \
14+
// RUN: FileCheck --check-prefix=FULL-MANGLED-NAMESPACE %s
15+
// RUN: lldb-test symbols --name=_ZN4sbar3fooEi --find=function --function-flags=full %t | \
16+
// RUN: FileCheck --check-prefix=FULL-MANGLED-METHOD %s
1317
// RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \
1418
// RUN: FileCheck --check-prefix=CONTEXT %s
1519
// RUN: lldb-test symbols --name=not_there --find=function %t | \
@@ -21,9 +25,13 @@
2125
// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
2226
// RUN: FileCheck --check-prefix=METHOD %s
2327
// RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \
24-
// RUN: FileCheck --check-prefix=FULL-INDEXED %s
28+
// RUN: FileCheck --check-prefix=FULL %s
2529
// RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \
2630
// RUN: FileCheck --check-prefix=FULL-MANGLED %s
31+
// RUN: lldb-test symbols --name=_ZN3bar3baz3fooEv --find=function --function-flags=full %t | \
32+
// RUN: FileCheck --check-prefix=FULL-MANGLED-NAMESPACE %s
33+
// RUN: lldb-test symbols --name=_ZN4sbar3fooEi --find=function --function-flags=full %t | \
34+
// RUN: FileCheck --check-prefix=FULL-MANGLED-METHOD %s
2735
// RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \
2836
// RUN: FileCheck --check-prefix=CONTEXT %s
2937
// RUN: lldb-test symbols --name=not_there --find=function %t | \
@@ -37,9 +45,13 @@
3745
// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
3846
// RUN: FileCheck --check-prefix=METHOD %s
3947
// RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \
40-
// RUN: FileCheck --check-prefix=FULL-INDEXED %s
48+
// RUN: FileCheck --check-prefix=FULL %s
4149
// RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \
4250
// RUN: FileCheck --check-prefix=FULL-MANGLED %s
51+
// RUN: lldb-test symbols --name=_ZN3bar3baz3fooEv --find=function --function-flags=full %t | \
52+
// RUN: FileCheck --check-prefix=FULL-MANGLED-NAMESPACE %s
53+
// RUN: lldb-test symbols --name=_ZN4sbar3fooEi --find=function --function-flags=full %t | \
54+
// RUN: FileCheck --check-prefix=FULL-MANGLED-METHOD %s
4355
// RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \
4456
// RUN: FileCheck --check-prefix=CONTEXT %s
4557
// RUN: lldb-test symbols --name=not_there --find=function %t | \
@@ -58,20 +70,17 @@
5870
// METHOD-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
5971
// METHOD-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv"
6072

61-
// FULL-INDEXED: Found 7 functions:
62-
// FULL-INDEXED-DAG: name = "foo()", mangled = "_Z3foov"
63-
// FULL-INDEXED-DAG: name = "foo(int)", mangled = "_Z3fooi"
64-
// FULL-INDEXED-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
65-
// FULL-INDEXED-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv"
66-
// FULL-INDEXED-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv"
67-
// FULL-INDEXED-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
68-
// FULL-INDEXED-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv"
69-
7073
// FULL: Found 0 functions:
7174

7275
// FULL-MANGLED: Found 1 functions:
7376
// FULL-MANGLED-DAG: name = "foo(int)", mangled = "_Z3fooi"
7477

78+
// FULL-MANGLED-NAMESPACE: Found 1 functions:
79+
// FULL-MANGLED-NAMESPACE-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv"
80+
81+
// FULL-MANGLED-METHOD: Found 1 functions:
82+
// FULL-MANGLED-METHOD-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
83+
7584
// CONTEXT: Found 1 functions:
7685
// CONTEXT-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
7786

0 commit comments

Comments
 (0)