Skip to content

[LLDB][NativePDB] Find functions by basename #152295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 12, 2025

Conversation

Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Aug 6, 2025

This adds the ability for functions to be matched by their basename.

Before, the globals were searched for the name. This works if the full name is available but fails for basenames.
PDB only includes the full names of functions, so we need to cache all basenames. This is (again) very similar to SymbolFilePDB. There are two main differences:

  • We can't just access the parent of a function to determine that it's a member function - we need to check the type of the function, and its "this type".
  • SymbolFilePDB saved the full method name in the map. However, when searching for methods, only the basename is passed, so the function never found any methods.

Fixes #51933.

@Nerixyz Nerixyz requested a review from JDevlieghere as a code owner August 6, 2025 11:50
@llvmbot llvmbot added the lldb label Aug 6, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 6, 2025

@llvm/pr-subscribers-lldb

Author: nerix (Nerixyz)

Changes

This adds the ability for functions to be matched by their basename.

Before, the globals were searched for the name. This works if the full name is available but fails for basenames.
PDB only includes the full names of functions, so we need to cache all basenames. This is (again) very similar to SymbolFilePDB. There are two main differences:

  • We can't just access the parent of a function to determine that it's a member function - we need to check the type of the function, and its "this type".
  • SymbolFilePDB saved the full method name in the map. However, when searching for methods, only the basename is passed, so the function never found any methods.

Fixes #51933.


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

3 Files Affected:

  • (modified) lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp (+130-19)
  • (modified) lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h (+9)
  • (modified) lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp (+34)
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index dcea33dd9f854..04a3b9b7b87a2 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -39,6 +39,7 @@
 #include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h"
 #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
+#include "llvm/DebugInfo/PDB/Native/PublicsStream.h"
 #include "llvm/DebugInfo/PDB/Native/SymbolStream.h"
 #include "llvm/DebugInfo/PDB/Native/TpiStream.h"
 #include "llvm/DebugInfo/PDB/PDB.h"
@@ -1641,6 +1642,94 @@ void SymbolFileNativePDB::DumpClangAST(Stream &s, llvm::StringRef filter) {
   clang->GetNativePDBParser()->Dump(s, filter);
 }
 
+void SymbolFileNativePDB::CacheFunctionNames() {
+  if (!m_func_full_names.IsEmpty())
+    return;
+
+  // (segment, code offset) -> gid
+  std::map<std::pair<uint16_t, uint32_t>, uint32_t> addr_ids;
+
+  // First, find all function references in the globals table.
+  for (const uint32_t gid : m_index->globals().getGlobalsTable()) {
+    CVSymbol ref_sym = m_index->symrecords().readRecord(gid);
+    auto kind = ref_sym.kind();
+    if (kind != S_PROCREF && kind != S_LPROCREF)
+      continue;
+
+    ProcRefSym ref =
+        llvm::cantFail(SymbolDeserializer::deserializeAs<ProcRefSym>(ref_sym));
+    if (ref.Name.empty())
+      continue;
+
+    // Find the function this is referencing
+    CompilandIndexItem &cci =
+        m_index->compilands().GetOrCreateCompiland(ref.modi());
+    auto iter = cci.m_debug_stream.getSymbolArray().at(ref.SymOffset);
+    if (iter == cci.m_debug_stream.getSymbolArray().end())
+      continue;
+    kind = iter->kind();
+    if (kind != S_GPROC32 && kind != S_LPROC32)
+      continue;
+
+    ProcSym proc =
+        llvm::cantFail(SymbolDeserializer::deserializeAs<ProcSym>(*iter));
+    if ((proc.Flags & ProcSymFlags::IsUnreachable) != ProcSymFlags::None)
+      continue;
+    if (proc.Name.empty())
+      continue;
+
+    // The function/procedure symbol only contains the demangled name.
+    // The mangled names are in the publics table. Save the address of this
+    // function to lookup the mangled name later.
+    addr_ids.emplace(std::make_pair(proc.Segment, proc.CodeOffset), gid);
+
+    llvm::StringRef basename = MSVCUndecoratedNameParser::DropScope(proc.Name);
+    if (basename.empty())
+      basename = proc.Name;
+
+    m_func_base_names.Append(ConstString(basename), gid);
+    m_func_full_names.Append(ConstString(proc.Name), gid);
+
+    // To see if this is a member function, check the type
+    auto type = m_index->tpi().getType(proc.FunctionType);
+    if (type.kind() == LF_MFUNCTION) {
+      MemberFunctionRecord mfr;
+      llvm::cantFail(
+          TypeDeserializer::deserializeAs<MemberFunctionRecord>(type, mfr));
+      if (!mfr.getThisType().isNoneType())
+        m_func_method_names.Append(ConstString(basename), gid);
+    }
+  }
+
+  // The publics stream contains all mangled function names and their address.
+  for (auto pid : m_index->publics().getPublicsTable()) {
+    PdbGlobalSymId global{pid, true};
+    CVSymbol sym = m_index->ReadSymbolRecord(global);
+    auto kind = sym.kind();
+    if (kind != S_PUB32)
+      continue;
+    PublicSym32 pub =
+        llvm::cantFail(SymbolDeserializer::deserializeAs<PublicSym32>(sym));
+    // We only care about mangled names - if the name isn't mangled, it's
+    // already in the full name map
+    if (!Mangled::IsMangledName(pub.Name))
+      continue;
+
+    // Check if this symbol is for one of our functions
+    auto it = addr_ids.find({pub.Segment, pub.Offset});
+    if (it != addr_ids.end())
+      m_func_full_names.Append(ConstString(pub.Name), it->second);
+  }
+
+  // Sort them before value searching is working properly
+  m_func_full_names.Sort();
+  m_func_full_names.SizeToFit();
+  m_func_method_names.Sort();
+  m_func_method_names.SizeToFit();
+  m_func_base_names.Sort();
+  m_func_base_names.SizeToFit();
+}
+
 void SymbolFileNativePDB::FindGlobalVariables(
     ConstString name, const CompilerDeclContext &parent_decl_ctx,
     uint32_t max_matches, VariableList &variables) {
@@ -1677,34 +1766,56 @@ void SymbolFileNativePDB::FindFunctions(
   if (name_type_mask & eFunctionNameTypeFull)
     name = lookup_info.GetName();
 
-  // For now we only support lookup by method name or full name.
   if (!(name_type_mask & eFunctionNameTypeFull ||
+        name_type_mask & eFunctionNameTypeBase ||
         name_type_mask & eFunctionNameTypeMethod))
     return;
+  CacheFunctionNames();
 
-  using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
+  std::set<uint32_t> resolved_ids; // avoid duplicate lookups
+  auto resolve_from = [&](UniqueCStringMap<uint32_t> &Names) {
+    std::vector<uint32_t> ids;
+    if (!Names.GetValues(name, ids))
+      return;
 
-  std::vector<SymbolAndOffset> matches = m_index->globals().findRecordsByName(
-      name.GetStringRef(), m_index->symrecords());
-  for (const SymbolAndOffset &match : matches) {
-    if (match.second.kind() != S_PROCREF && match.second.kind() != S_LPROCREF)
-      continue;
-    ProcRefSym proc(match.second.kind());
-    cantFail(SymbolDeserializer::deserializeAs<ProcRefSym>(match.second, proc));
+    for (uint32_t id : ids) {
+      if (resolved_ids.find(id) != resolved_ids.end())
+        continue;
 
-    if (!IsValidRecord(proc))
-      continue;
+      PdbGlobalSymId global{id, false};
+      if (parent_decl_ctx.IsValid() &&
+          GetDeclContextContainingUID(toOpaqueUid(global)) != parent_decl_ctx)
+        continue;
 
-    CompilandIndexItem &cci =
-        m_index->compilands().GetOrCreateCompiland(proc.modi());
-    SymbolContext sc;
+      CVSymbol sym = m_index->ReadSymbolRecord(global);
+      auto kind = sym.kind();
+      lldbassert(kind == S_PROCREF || kind == S_LPROCREF);
 
-    sc.comp_unit = GetOrCreateCompileUnit(cci).get();
-    PdbCompilandSymId func_id(proc.modi(), proc.SymOffset);
-    sc.function = GetOrCreateFunction(func_id, *sc.comp_unit).get();
+      ProcRefSym proc =
+          cantFail(SymbolDeserializer::deserializeAs<ProcRefSym>(sym));
 
-    sc_list.Append(sc);
-  }
+      if (!IsValidRecord(proc))
+        continue;
+
+      CompilandIndexItem &cci =
+          m_index->compilands().GetOrCreateCompiland(proc.modi());
+      SymbolContext sc;
+
+      sc.comp_unit = GetOrCreateCompileUnit(cci).get();
+      PdbCompilandSymId func_id(proc.modi(), proc.SymOffset);
+      sc.function = GetOrCreateFunction(func_id, *sc.comp_unit).get();
+
+      sc_list.Append(sc);
+      resolved_ids.insert(id);
+    }
+  };
+
+  if (name_type_mask & eFunctionNameTypeFull)
+    resolve_from(m_func_full_names);
+  if (name_type_mask & eFunctionNameTypeBase)
+    resolve_from(m_func_base_names);
+  if (name_type_mask & eFunctionNameTypeMethod)
+    resolve_from(m_func_method_names);
 }
 
 void SymbolFileNativePDB::FindFunctions(const RegularExpression &regex,
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
index eda375d4cebe7..e505f3f522fb7 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
@@ -260,6 +260,8 @@ class SymbolFileNativePDB : public SymbolFileCommon {
 
   std::vector<CompilerContext> GetContextForType(llvm::codeview::TypeIndex ti);
 
+  void CacheFunctionNames();
+
   llvm::BumpPtrAllocator m_allocator;
 
   lldb::addr_t m_obj_load_address = 0;
@@ -282,6 +284,13 @@ class SymbolFileNativePDB : public SymbolFileCommon {
       m_parent_types;
 
   lldb_private::UniqueCStringMap<uint32_t> m_type_base_names;
+
+  /// Global ID -> mangled name/full function name
+  lldb_private::UniqueCStringMap<uint32_t> m_func_full_names;
+  /// Global ID -> basename
+  lldb_private::UniqueCStringMap<uint32_t> m_func_base_names;
+  /// Global ID -> method basename
+  lldb_private::UniqueCStringMap<uint32_t> m_func_method_names;
 };
 
 } // namespace npdb
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp b/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp
index 5ebef61bdbfef..9bea463199829 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp
+++ b/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp
@@ -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
 
 struct Struct {
   int simple_method() {
@@ -69,6 +97,8 @@ int main(int argc, char **argv) {
 // FIND-MAIN:      Function: id = {{.*}}, name = "main"
 // FIND-MAIN-NEXT: FuncType: id = {{.*}}, compiler_type = "int (int, char **)"
 
+// FIND-NO-FUNCTION: Found 0 functions
+
 // FIND-STATIC:      Function: id = {{.*}}, name = "{{.*}}static_fn{{.*}}"
 // FIND-STATIC-NEXT: FuncType: id = {{.*}}, compiler_type = "int (void)"
 
@@ -88,3 +118,7 @@ int main(int argc, char **argv) {
 // FIND-OVERLOAD: FuncType: id = {{.*}}, compiler_type = "int (void)"
 // FIND-OVERLOAD: FuncType: id = {{.*}}, compiler_type = "int (char)"
 // FIND-OVERLOAD: FuncType: id = {{.*}}, compiler_type = "int (char, int, ...)"
+
+// FIND-OVERLOAD-METHOD: Function: id = {{.*}}, name = "{{.*}}Struct::overloaded_method{{.*}}"
+// FIND-OVERLOAD-METHOD: FuncType: id = {{.*}}, compiler_type = "int (void)"
+// FIND-OVERLOAD-METHOD: FuncType: id = {{.*}}, compiler_type = "int (char)"

// 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests on 2 different classes/namespaces with the same function basename?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

NativePDB
> &'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)"
DWARF
> &'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@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@Class@@SAH_N@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@Class@@QEAA_NH@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@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@Struct@@MEAAHD@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@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, ...)"

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not sure if dwarf plugin is correct to return static functions (need someone to verify this). Other than that, it looks good to me.

@JDevlieghere JDevlieghere merged commit 7e2cc72 into llvm:main Aug 12, 2025
9 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 12, 2025

LLVM Buildbot has detected a new failure on builder lldb-x86_64-debian running on lldb-x86_64-debian while building lldb at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/28713

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-shell :: SymbolFile/DWARF/x86/debug-types-address-ranges.s (1686 of 3143)
PASS: lldb-shell :: SymbolFile/DWARF/dwo-relative-path.s (1687 of 3143)
PASS: lldb-shell :: ScriptInterpreter/Python/fail_breakpoint_oneline.test (1688 of 3143)
PASS: lldb-shell :: SymbolFile/NativePDB/tag-types.cpp (1689 of 3143)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dir-separator-windows.s (1690 of 3143)
PASS: lldb-shell :: ObjectFile/ELF/PT_LOAD-overlap-PT_TLS.yaml (1691 of 3143)
PASS: lldb-shell :: SymbolFile/DWARF/x86/dir-separator-no-comp-dir-relative-name.s (1692 of 3143)
PASS: lldb-shell :: SymbolFile/Breakpad/stack-cfi-arm.yaml (1693 of 3143)
PASS: lldb-shell :: Target/target-label.test (1694 of 3143)
PASS: lldb-shell :: ObjectFile/ELF/PT_TLS-overlap-PT_LOAD.yaml (1695 of 3143)
FAIL: lldb-shell :: SymbolFile/NativePDB/find-functions.cpp (1696 of 3143)
******************** TEST 'lldb-shell :: SymbolFile/NativePDB/find-functions.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
/home/worker/2.0.1/lldb-x86_64-debian/build/bin/clang --driver-mode=cl --target=specify-a-target-or-use-a-_host-substitution --target=x86_64-windows-msvc -Od -Z7 -c /GR- /Fo/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.obj -- /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp # RUN: at line 4
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/clang --driver-mode=cl --target=specify-a-target-or-use-a-_host-substitution --target=x86_64-windows-msvc -Od -Z7 -c /GR- /Fo/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.obj -- /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp
/home/worker/2.0.1/lldb-x86_64-debian/build/bin/lld-link -debug:full -nodefaultlib -entry:main /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.obj -out:/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe -pdb:/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.pdb # RUN: at line 5
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/lld-link -debug:full -nodefaultlib -entry:main /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.obj -out:/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe -pdb:/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.pdb
/home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=main --function-flags=full /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe      | /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-MAIN # RUN: at line 7
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=main --function-flags=full /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-MAIN
/home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=main --function-flags=method /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe      | /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-NO-FUNCTION # RUN: at line 9
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=main --function-flags=method /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-NO-FUNCTION
/home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=main --function-flags=base /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe      | /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-MAIN # RUN: at line 11
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=main --function-flags=base /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-MAIN
/home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=static_fn --function-flags=full /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe      | /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-STATIC # RUN: at line 14
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=static_fn --function-flags=full /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-STATIC
/home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=static_fn --function-flags=method /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe      | /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-NO-FUNCTION # RUN: at line 16
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=static_fn --function-flags=method /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-NO-FUNCTION
/home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=static_fn --function-flags=base /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe      | /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-STATIC # RUN: at line 18
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=static_fn --function-flags=base /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-STATIC
/home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=varargs_fn --function-flags=full /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe      | /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-VAR # RUN: at line 21
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=varargs_fn --function-flags=full /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-VAR
/home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=varargs_fn --function-flags=method /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe      | /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-NO-FUNCTION # RUN: at line 23
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=varargs_fn --function-flags=method /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-NO-FUNCTION
/home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=varargs_fn --function-flags=base /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe      | /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-VAR # RUN: at line 25
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=varargs_fn --function-flags=base /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-VAR
/home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=Struct::simple_method --function-flags=full /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe      | /home/worker/2.0.1/lldb-x86_64-debian/build/bin/FileCheck /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp --check-prefix=FIND-SIMPLE # RUN: at line 28
+ /home/worker/2.0.1/lldb-x86_64-debian/build/bin/lldb-test symbols --find=function --name=Struct::simple_method --function-flags=full /home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/test/Shell/SymbolFile/NativePDB/Output/find-functions.cpp.tmp.exe

@JDevlieghere
Copy link
Member

Failures looks related to I'm going to revert to unblock the bot

/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp:144:24: error: FIND-OVERLOAD-FULL: expected string not found in input
// FIND-OVERLOAD-FULL: FuncType: id = {{.*}}, compiler_type = "int (char)"
                       ^
<stdin>:12:74: note: scanning from here
 FuncType: id = {0x000100e4}, byte-size = 0, compiler_type = "int (void)"
                                                                         ^

Input file: <stdin>
Check file: /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           .
           .
           .
           7:  CompileUnit: id = {0x00000000}, file = "/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp", language = "c++" 
           8:  Function: id = {0x70400001}, name = "Struct::overloaded_method", decl_context = {}, range = find-functions.cpp.tmp.exe[0x0000000140001204-0x000000014000121a) 
           9:  FuncType: id = {0x00010114}, byte-size = 0, compiler_type = "int (char)" 
          10:  CompileUnit: id = {0x00000000}, file = "/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp", language = "c++" 
          11:  Function: id = {0x4d800001}, name = "Struct::overloaded_method", decl_context = {}, range = find-functions.cpp.tmp.exe[0x0000000140001184-0x00000001400011bd) 
          12:  FuncType: id = {0x000100e4}, byte-size = 0, compiler_type = "int (void)" 
check:144                                                                              X error: no match found
          13:  
check:144     ~

>>>>>>

stdio-4.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LLDB failed to lookup method names in NativePDB plugin
6 participants