[Lldb-commits] [lldb] [LLDB][NativePDB] Find functions by basename (PR #152295)

via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 8 13:12:54 PDT 2025


================
@@ -6,24 +6,52 @@
 
 // RUN: lldb-test symbols --find=function --name=main --function-flags=full %t.exe \
 // RUN:     | FileCheck %s --check-prefix=FIND-MAIN
+// RUN: lldb-test symbols --find=function --name=main --function-flags=method %t.exe \
+// RUN:     | FileCheck %s --check-prefix=FIND-NO-FUNCTION
+// RUN: lldb-test symbols --find=function --name=main --function-flags=base %t.exe \
+// RUN:     | FileCheck %s --check-prefix=FIND-MAIN
 
 // RUN: lldb-test symbols --find=function --name=static_fn --function-flags=full %t.exe \
 // RUN:     | FileCheck %s --check-prefix=FIND-STATIC
+// RUN: lldb-test symbols --find=function --name=static_fn --function-flags=method %t.exe \
+// RUN:     | FileCheck %s --check-prefix=FIND-NO-FUNCTION
+// RUN: lldb-test symbols --find=function --name=static_fn --function-flags=base %t.exe \
+// RUN:     | FileCheck %s --check-prefix=FIND-STATIC
 
 // RUN: lldb-test symbols --find=function --name=varargs_fn --function-flags=full %t.exe \
 // RUN:     | FileCheck %s --check-prefix=FIND-VAR
+// RUN: lldb-test symbols --find=function --name=varargs_fn --function-flags=method %t.exe \
+// RUN:     | FileCheck %s --check-prefix=FIND-NO-FUNCTION
+// RUN: lldb-test symbols --find=function --name=varargs_fn --function-flags=base %t.exe \
+// RUN:     | FileCheck %s --check-prefix=FIND-VAR
 
 // RUN: lldb-test symbols --find=function --name=Struct::simple_method --function-flags=full %t.exe \
 // RUN:     | FileCheck %s --check-prefix=FIND-SIMPLE
+// RUN: lldb-test symbols --find=function --name=Struct::simple_method --function-flags=method %t.exe \
+// RUN:     | FileCheck %s --check-prefix=FIND-SIMPLE
+// RUN: lldb-test symbols --find=function --name=Struct::simple_method --function-flags=base %t.exe \
+// RUN:     | FileCheck %s --check-prefix=FIND-SIMPLE
 
 // RUN: lldb-test symbols --find=function --name=Struct::virtual_method --function-flags=full %t.exe \
 // RUN:     | FileCheck %s --check-prefix=FIND-VIRTUAL
+// RUN: lldb-test symbols --find=function --name=Struct::virtual_method --function-flags=method %t.exe \
+// RUN:     | FileCheck %s --check-prefix=FIND-VIRTUAL
+// RUN: lldb-test symbols --find=function --name=Struct::virtual_method --function-flags=base %t.exe \
+// RUN:     | FileCheck %s --check-prefix=FIND-VIRTUAL
 
 // RUN: lldb-test symbols --find=function --name=Struct::static_method --function-flags=full %t.exe \
 // RUN:     | FileCheck %s --check-prefix=FIND-STATIC-METHOD
+// RUN: lldb-test symbols --find=function --name=Struct::static_method --function-flags=method %t.exe \
+// RUN:     | FileCheck %s --check-prefix=FIND-NO-FUNCTION
+// RUN: lldb-test symbols --find=function --name=Struct::static_method --function-flags=base %t.exe \
+// RUN:     | FileCheck %s --check-prefix=FIND-STATIC-METHOD
 
 // RUN: lldb-test symbols --find=function --name=Struct::overloaded_method --function-flags=full %t.exe \
 // RUN:     | FileCheck %s --check-prefix=FIND-OVERLOAD
+// RUN: lldb-test symbols --find=function --name=Struct::overloaded_method --function-flags=method %t.exe \
+// RUN:     | FileCheck %s --check-prefix=FIND-OVERLOAD-METHOD
+// RUN: lldb-test symbols --find=function --name=Struct::overloaded_method --function-flags=base %t.exe \
+// RUN:     | FileCheck %s --check-prefix=FIND-OVERLOAD
----------------
Nerixyz wrote:

I added them. `--function-flags=method` will only match the basename of methods (the invocation might look a bit confusing). This is consistent with DWARF:

<details><summary>NativePDB</summary>

```console
> &'f:\dev\llvm-project\build\bin\lldb-test.exe' symbols --find=function --name=Struct::overloaded_method --function-flags=method 'F:\Dev\llvm-project\build\tools\lldb\test\Shell\SymbolFile\NativePDB\Output\find-functions.cpp.tmp.exe'
Module: F:\Dev\llvm-project\build\tools\lldb\test\Shell\SymbolFile\NativePDB\Output\find-functions.cpp.tmp.exe
Found 4 functions:
0x0000001f9e98e988: SymbolContextList
  CompileUnit: id = {0x00000000}, file = "F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp", language = "c++"
     Function: id = {0x5d000001}, name = "Class::overloaded_method", decl_context = {}, range = find-functions.cpp.tmp.exe[0x0000000140001200-0x000000014000121b)
     FuncType: id = {0x000101b4}, byte-size = 0, compiler_type = "_Bool (int)"
  CompileUnit: id = {0x00000000}, file = "F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp", language = "c++"
     Function: id = {0x67000001}, name = "Class::overloaded_method", decl_context = {}, range = find-functions.cpp.tmp.exe[0x0000000140001220-0x000000014000122b)
     FuncType: id = {0x000101a4}, byte-size = 0, compiler_type = "_Bool (void)"
  CompileUnit: id = {0x00000000}, file = "F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp", language = "c++"
     Function: id = {0x4c800001}, name = "Struct::overloaded_method", decl_context = {}, range = find-functions.cpp.tmp.exe[0x00000001400011a0-0x00000001400011d9)
     FuncType: id = {0x000100e4}, byte-size = 0, compiler_type = "int (void)"
  CompileUnit: id = {0x00000000}, file = "F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp", language = "c++"
     Function: id = {0x6f400001}, name = "Struct::overloaded_method", decl_context = {}, range = find-functions.cpp.tmp.exe[0x0000000140001230-0x0000000140001246)
     FuncType: id = {0x00010114}, byte-size = 0, compiler_type = "int (char)"
```
</details> 
<details><summary>DWARF</summary>

```console
> &'f:\dev\llvm-project\build\bin\lldb-test.exe' symbols --find=function --name=Struct::overloaded_method --function-flags=method a.exe
Module: a.exe
Found 6 functions:
0x0000003203f8e5d8: SymbolContextList
       Module: file = "a.exe", arch = "x86_64"
  CompileUnit: id = {0x00000000}, file = "F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp", language = "c++14"
     Function: id = {0x0000028f}, name = "int Struct::overloaded_method(void)", mangled = "?overloaded_method at Struct@@QEAAHXZ", decl_context = {ClassOrStruct(Struct)}, range = a.exe[0x0000000140001150-0x0000000140001189)
     FuncType: id = {0x0000028f}, byte-size = 0, decl = F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp:69, compiler_type = "int (void)"
       Module: file = "a.exe", arch = "x86_64"
  CompileUnit: id = {0x00000000}, file = "F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp", language = "c++14"
     Function: id = {0x000002b3}, name = "int Class::overloaded_method(bool)", mangled = "?overloaded_method at Class@@SAH_N at Z", decl_context = {ClassOrStruct(Class)}, range = a.exe[0x0000000140001190-0x00000001400011ae)
     FuncType: id = {0x000002b3}, byte-size = 0, decl = F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp:90, compiler_type = "int (_Bool)"
       Module: file = "a.exe", arch = "x86_64"
  CompileUnit: id = {0x00000000}, file = "F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp", language = "c++14"
     Function: id = {0x000002d5}, name = "bool Class::overloaded_method(int)", mangled = "?overloaded_method at Class@@QEAA_NH at Z", decl_context = {ClassOrStruct(Class)}, range = a.exe[0x00000001400011b0-0x00000001400011cb)
     FuncType: id = {0x000002d5}, byte-size = 0, decl = F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp:87, compiler_type = "_Bool (int)"
       Module: file = "a.exe", arch = "x86_64"
  CompileUnit: id = {0x00000000}, file = "F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp", language = "c++14"
     Function: id = {0x00000307}, name = "bool Class::overloaded_method(void)", mangled = "?overloaded_method at Class@@QEAA_NXZ", decl_context = {ClassOrStruct(Class)}, range = a.exe[0x00000001400011d0-0x00000001400011db)
     FuncType: id = {0x00000307}, byte-size = 0, decl = F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp:84, compiler_type = "_Bool (void)"
       Module: file = "a.exe", arch = "x86_64"
  CompileUnit: id = {0x00000000}, file = "F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp", language = "c++14"
     Function: id = {0x0000032b}, name = "int Struct::overloaded_method(char)", mangled = "?overloaded_method at Struct@@MEAAHD at Z", decl_context = {ClassOrStruct(Struct)}, range = a.exe[0x00000001400011e0-0x00000001400011f6)
     FuncType: id = {0x0000032b}, byte-size = 0, decl = F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp:73, compiler_type = "int (char)"
       Module: file = "a.exe", arch = "x86_64"
  CompileUnit: id = {0x00000000}, file = "F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp", language = "c++14"
     Function: id = {0x0000035d}, name = "int Struct::overloaded_method(char, int, ...)", mangled = "?overloaded_method at Struct@@CAHDHZZ", decl_context = {ClassOrStruct(Struct)}, range = a.exe[0x0000000140001200-0x0000000140001210)
     FuncType: id = {0x0000035d}, byte-size = 0, decl = F:\Dev\llvm-project\lldb\test\Shell\SymbolFile\NativePDB\find-functions.cpp:77, compiler_type = "int (char, int, ...)"
```
</details> 

I'm not sure if it's correct that DWARF returns static functions here.

https://github.com/llvm/llvm-project/pull/152295


More information about the lldb-commits mailing list