[Lldb-commits] [PATCH] D113724: [LLDB][NativePDB] Fix missing symbol info when backtrace minidump

Zequan Wu via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 11 17:49:58 PST 2021


zequanwu created this revision.
zequanwu added reviewers: rnk, labath, teemperor, shafik.
zequanwu requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: lldb-commits, sstefan1.
Herald added a project: LLDB.

I don't know how to add tests for this. I tested locally with a minidump, a pdb
and the executable.
Before this change, the following comand fail to give symbol information for
backtrace because the `m_comp_units` in `m_index->compilands()` was always
empty, changed to use `GetCompileUnitAtIndex` to create CU when failed to find
one at given index.

  lldb -O 'target create GoogleDriveFS.exe --core GoogleDriveFS.dmp' -o 'target symbols add GoogleDriveFS.pdb' -o 'bt'


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113724

Files:
  lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp


Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -945,11 +945,11 @@
     llvm::Optional<uint16_t> modi = m_index->GetModuleIndexForVa(file_addr);
     if (!modi)
       return 0;
-    CompilandIndexItem *cci = m_index->compilands().GetCompiland(*modi);
-    if (!cci)
+    CompUnitSP cu_sp = GetCompileUnitAtIndex(modi.getValue());
+    if (!cu_sp)
       return 0;
 
-    sc.comp_unit = GetOrCreateCompileUnit(*cci).get();
+    sc.comp_unit = cu_sp.get();
     resolved_flags |= eSymbolContextCompUnit;
   }
 
Index: lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -1013,9 +1013,22 @@
   llvm::StringRef proc_name = proc.Name;
   proc_name.consume_front(context_name);
   proc_name.consume_front("::");
-
-  clang::FunctionDecl *function_decl = m_clang.CreateFunctionDeclaration(
-      parent, OptionalClangModuleID(), proc_name, func_ct, storage, false);
+  clang::FunctionDecl *function_decl = nullptr;
+  if (parent->isRecord()) {
+    clang::QualType parent_qt = llvm::dyn_cast<clang::TypeDecl>(parent)
+                                    ->getTypeForDecl()
+                                    ->getCanonicalTypeInternal();
+    // TODO: Get other information for this method.
+    function_decl = m_clang.AddMethodToCXXRecordType(
+        ToCompilerType(parent_qt).GetOpaqueQualType(), proc_name,
+        /*mangled_name=*/nullptr, func_ct, lldb::AccessType::eAccessPublic,
+        /*is_virtual=*/false, /*is_static=*/false,
+        /*is_inline=*/false, /*is_explicit=*/false,
+        /*is_attr_used=*/false, /*is_artificial=*/false);
+  } else {
+    function_decl = m_clang.CreateFunctionDeclaration(
+        parent, OptionalClangModuleID(), proc_name, func_ct, storage, false);
+  }
 
   lldbassert(m_uid_to_decl.count(toOpaqueUid(func_id)) == 0);
   m_uid_to_decl[toOpaqueUid(func_id)] = function_decl;
@@ -1023,8 +1036,9 @@
   status.resolved = true;
   status.uid = toOpaqueUid(func_id);
   m_decl_to_status.insert({function_decl, status});
-
-  CreateFunctionParameters(func_id, *function_decl, func_type->getNumParams());
+  if (!parent->isRecord())
+    CreateFunctionParameters(func_id, *function_decl,
+                             func_type->getNumParams());
 
   return function_decl;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113724.386702.patch
Type: text/x-patch
Size: 2655 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211112/06853240/attachment.bin>


More information about the lldb-commits mailing list