[Lldb-commits] [PATCH] D114467: [LLDB][NativePDB] Allow find functions by full names

Zequan Wu via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 23 12:31:46 PST 2021


zequanwu created this revision.
zequanwu added a reviewer: labath.
zequanwu requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

I don't see a reason why not to. If we allows lookup functions by full names,
I can change the test case in D113930 <https://reviews.llvm.org/D113930> to use `lldb-test symbols --find=function --name=full::name --function-flags=full ...`,
though the duplicate method decl prolem is still there for `lldb-test symbols --dump-ast`.
That's a seprate bug, we can fix it later.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114467

Files:
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp


Index: lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp
===================================================================
--- /dev/null
+++ lldb/test/Shell/SymbolFile/NativePDB/find-functions.cpp
@@ -0,0 +1,35 @@
+// clang-format off
+// REQUIRES: lld, x86
+
+// RUN: %clang_cl --target=x86_64-windows-msvc -Od -Z7 -c /Fo%t.obj -- %s
+// RUN: lld-link -debug:full -nodefaultlib -entry:main %t.obj -out:%t.exe -pdb:%t.pdb
+
+// 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=static_fn --function-flags=full %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
+
+static int static_fn() {
+  return 42;
+}
+
+int varargs_fn(int x, int y, ...) {
+  return x + y;
+}
+
+int main(int argc, char **argv) {
+  return static_fn() + varargs_fn(argc, argc);
+}
+
+// FIND-MAIN:      Function: id = {{.*}}, name = "main"
+// FIND-MAIN-NEXT: FuncType: id = {{.*}}, byte-size = 0, compiler_type = "int (int, char **)"
+
+// FIND-STATIC:      Function: id = {{.*}}, name = "static_fn"
+// FIND-STATIC-NEXT: FuncType: id = {{.*}}, byte-size = 0, compiler_type = "int (void)"
+
+// FIND-VAR:      Function: id = {{.*}}, name = "varargs_fn"
+// FIND-VAR-NEXT: FuncType: id = {{.*}}, byte-size = 0, compiler_type = "int (int, int, ...)"
Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -1182,8 +1182,9 @@
     FunctionNameType name_type_mask, bool include_inlines,
     SymbolContextList &sc_list) {
   std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
-  // For now we only support lookup by method name.
-  if (!(name_type_mask & eFunctionNameTypeMethod))
+  // For now we only support lookup by method name or full name.
+  if (!(name_type_mask & eFunctionNameTypeFull ||
+        name_type_mask & eFunctionNameTypeMethod))
     return;
 
   using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114467.389281.patch
Type: text/x-patch
Size: 2349 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211123/2aad8622/attachment.bin>


More information about the lldb-commits mailing list