[Lldb-commits] [lldb] [lldb] Truncate an over-wide symbol address in the IR interpreter (PR #210372)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Fri Jul 17 09:43:44 PDT 2026
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/210372
IRInterpreter::ResolveConstantValue built a pointer-width APInt directly from the address returned by FindSymbol. That address can be wider than a target pointer, because lldb records extra information in the high bits on some targets, such as the code/memory address-space tag on WebAssembly.
A 32-bit pointer then cannot hold the tagged address and the APInt constructor asserts, aborting the debugger when a function-valued expression is evaluated (for example `expr main`).
Truncate to the pointer width instead of asserting, matching the idiom already used in DWARFExpression. On targets whose addresses fit in a pointer this is a no-op.
>From ac12dff018f9ae8a144aa7cf4898f6245a1460f5 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Fri, 17 Jul 2026 09:41:52 -0700
Subject: [PATCH] [lldb] Truncate an over-wide symbol address in the IR
interpreter
IRInterpreter::ResolveConstantValue built a pointer-width APInt directly
from the address returned by FindSymbol. That address can be wider than a
target pointer, because lldb records extra information in the high bits on
some targets, such as the code/memory address-space tag on WebAssembly.
A 32-bit pointer then cannot hold the tagged address and the APInt
constructor asserts, aborting the debugger when a function-valued
expression is evaluated (for example `expr main`).
Truncate to the pointer width instead of asserting, matching the idiom
already used in DWARFExpression. On targets whose addresses fit in a
pointer this is a no-op.
---
lldb/source/Expression/IRInterpreter.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp
index 163f9dac384eb..8a696c27fb262 100644
--- a/lldb/source/Expression/IRInterpreter.cpp
+++ b/lldb/source/Expression/IRInterpreter.cpp
@@ -267,7 +267,12 @@ class InterpreterStackFrame {
lldb::addr_t addr = m_execution_unit.FindSymbol(name, missing_weak);
if (addr == LLDB_INVALID_ADDRESS)
return false;
- value = APInt(m_target_data.getPointerSizeInBits(), addr);
+ // A resolved symbol address may be wider than a target pointer when we
+ // store extra information in the high bits, such as an address-space
+ // tag. Truncate to the pointer width rather than asserting. When the
+ // address already fits this is a no-op.
+ value = APInt(m_target_data.getPointerSizeInBits(), addr,
+ /*isSigned=*/false, /*implicitTrunc=*/true);
return true;
}
break;
More information about the lldb-commits
mailing list