[Lldb-commits] [PATCH] D113821: [LLDB][NativePDB] Fix image lookup by address

Zequan Wu via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 12 17:39:50 PST 2021


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

`image lookup -a ` doesn't work because the compilands list is always empty.
Create CU at given index if doesn't exit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113821

Files:
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/test/Shell/SymbolFile/NativePDB/lookup-by-address.cpp


Index: lldb/test/Shell/SymbolFile/NativePDB/lookup-by-address.cpp
===================================================================
--- /dev/null
+++ lldb/test/Shell/SymbolFile/NativePDB/lookup-by-address.cpp
@@ -0,0 +1,20 @@
+// clang-format off
+// REQUIRES: lld, x86
+
+// RUN: %clang_cl --target=x86_64-windows-msvc -Od -Z7 -GR- -c /Fo%t.obj -- %s
+// RUN: lld-link -debug:full -nodefaultlib -entry:main %t.obj -out:%t.exe -pdb:%t.pdb
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -O "target create %t.exe" -o "image lookup -n main" -o "exit" > %t.out
+// RUN: FileCheck --input-file=%t.out %s --check-prefix=NAME
+// RUN: address=`grep "Address:" %t.out | sed "s/.*Address: lookup-by-address.cpp.tmp.exe\[\(.*\)\].*/\1/"`
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -O "target create %t.exe" -o "image lookup -a $address" -o "exit" | FileCheck %s --check-prefix=ADDRESS
+int main(int argc, char **argv) {
+  return 0;
+}
+
+// NAME: image lookup -n main
+// NAME: Address: lookup-by-address.cpp.tmp.exe[{{.*}}] (lookup-by-address.cpp.tmp.exe..text
+// NAME: Summary: lookup-by-address.cpp.tmp.exe`main at lookup-by-address.cpp:10
+
+// ADDRESS: image lookup -a {{.*}}
+// ADDRESS: Address: lookup-by-address.cpp.tmp.exe[{{.*}}] (lookup-by-address.cpp.tmp.exe..text
+// ADDRESS: Summary: lookup-by-address.cpp.tmp.exe`main at lookup-by-address.cpp:10
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;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113821.386989.patch
Type: text/x-patch
Size: 2106 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211113/811280bc/attachment.bin>


More information about the lldb-commits mailing list