Author: Zequan Wu Date: 2021-11-15T12:30:23-08:00 New Revision: f17404a733c18f0aa8ff98255dbae0f592982222
URL: https://github.com/llvm/llvm-project/commit/f17404a733c18f0aa8ff98255dbae0f592982222 DIFF: https://github.com/llvm/llvm-project/commit/f17404a733c18f0aa8ff98255dbae0f592982222.diff LOG: [LLDB][NativePDB] Fix image lookup by address `image lookup -a ` doesn't work because the compilands list is always empty. Create CU at given index if doesn't exit. Differential Revision: https://reviews.llvm.org/D113821 Added: lldb/test/Shell/SymbolFile/NativePDB/lookup-by-address.cpp Modified: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index 7a734c9c60d9e..8af90cb66e874 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -945,11 +945,11 @@ uint32_t SymbolFileNativePDB::ResolveSymbolContext( 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; } diff --git a/lldb/test/Shell/SymbolFile/NativePDB/lookup-by-address.cpp b/lldb/test/Shell/SymbolFile/NativePDB/lookup-by-address.cpp new file mode 100644 index 0000000000000..a2c00a48bf9ea --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/lookup-by-address.cpp @@ -0,0 +1,13 @@ +// 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 -base:0x400000 -out:%t.exe -pdb:%t.pdb +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -O "target create %t.exe" -o "image lookup -a 0x401000" -o "exit" | FileCheck %s --check-prefix=ADDRESS +int main(int argc, char **argv) { + return 0; +} + +// ADDRESS: image lookup -a 0x401000 +// ADDRESS: Address: lookup-by-address.cpp.tmp.exe[0x{{0+}}401000] (lookup-by-address.cpp.tmp.exe..text +// ADDRESS: Summary: lookup-by-address.cpp.tmp.exe`main at lookup-by-address.cpp:7 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits