[Lldb-commits] [PATCH] D133461: [LLDB][NativePDB] Set block address range.
Zequan Wu via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 8 14:52:00 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG32530e0493c1: [LLDB][NativePDB] Set block address range. (authored by zequanwu).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133461/new/
https://reviews.llvm.org/D133461
Files:
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/test/Shell/SymbolFile/NativePDB/blocks.cpp
Index: lldb/test/Shell/SymbolFile/NativePDB/blocks.cpp
===================================================================
--- /dev/null
+++ lldb/test/Shell/SymbolFile/NativePDB/blocks.cpp
@@ -0,0 +1,20 @@
+// clang-format off
+// REQUIRES: lld, x86
+
+// Test block range is set.
+// RUN: %clang_cl --target=x86_64-windows-msvc -Od -Z7 -GS- -c /Fo%t.obj -- %s
+// RUN: lld-link -debug:full -nodefaultlib -entry:main -base:0x140000000 %t.obj -out:%t.exe -pdb:%t.pdb
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb %t.exe -o "image lookup -a 0x140001014 -v" | FileCheck %s
+
+int main() {
+ int count = 0;
+ for (int i = 0; i < 3; ++i) {
+ ++count;
+ }
+ return count;
+}
+
+// CHECK: Function: id = {{.*}}, name = "main", range = [0x0000000140001000-0x000000014000104b)
+// CHECK-NEXT: FuncType: id = {{.*}}, byte-size = 0, compiler_type = "int (void)"
+// CHECK-NEXT: Blocks: id = {{.*}}, range = [0x140001000-0x14000104b)
+// CHECK-NEXT: id = {{.*}}, range = [0x140001014-0x140001042)
Index: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -363,6 +363,24 @@
lldbassert(block.Parent != 0);
PdbCompilandSymId parent_id(block_id.modi, block.Parent);
Block &parent_block = GetOrCreateBlock(parent_id);
+ Function *func = parent_block.CalculateSymbolContextFunction();
+ lldbassert(func);
+ lldb::addr_t block_base =
+ m_index->MakeVirtualAddress(block.Segment, block.CodeOffset);
+ lldb::addr_t func_base =
+ func->GetAddressRange().GetBaseAddress().GetFileAddress();
+ Block::Range range = Block::Range(block_base - func_base, block.CodeSize);
+ if (block_base >= func_base)
+ child_block->AddRange(range);
+ else {
+ GetObjectFile()->GetModule()->ReportError(
+ "S_BLOCK32 at modi: %d offset: %d: adding range [0x%" PRIx64
+ "-0x%" PRIx64 ") which has a base that is less than the function's "
+ "low PC 0x%" PRIx64 ". Please file a bug and attach the file at the "
+ "start of this error message",
+ block_id.modi, block_id.offset, block_base,
+ block_base + block.CodeSize, func_base);
+ }
parent_block.AddChild(child_block);
m_ast->GetOrCreateBlockDecl(block_id);
m_blocks.insert({opaque_block_uid, child_block});
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133461.458886.patch
Type: text/x-patch
Size: 2499 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220908/fe8397d7/attachment.bin>
More information about the lldb-commits
mailing list