<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/210972>210972</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[lldb] Address operations (including DW_OP_addr and DW_OP_addrx) retain 64-bit scalars when used as values on 32-bit targets
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jielun-wu
</td>
</tr>
</table>
<pre>
On a 32-bit target, `DW_OP_addr`, `DW_OP_addrx`, and `DW_OP_GNU_addr_index` must obey the 32-bit generic/address width when their locations are consumed as values.
LLDB instead stores all three address forms in 64-bit `Scalar` values and does not canonicalize them to the expression's `address_size` before value consumers use them.
## Source Evidence
The `DW_OP_addr` case in [DWARFExpression.cpp](https://github.com/llvm/llvm-project/blob/main/lldb/source/Expression/DWARFExpression.cpp) pushes its decoded operand directly:
```cpp
stack.push_back(Scalar(op->getRawOperand(0)));
stack.back().SetValueType(Value::ValueType::FileAddress);
```
`getRawOperand` returns `uint64_t`, so this constructs a 64-bit `Scalar` even when the expression's `address_size` is four bytes.
The shared `DW_OP_addrx` / `DW_OP_GNU_addr_index` case similarly reads into `lldb::addr_t`, which is also a `uint64_t`, and pushes it directly:
```cpp
lldb::addr_t value =
eval_ctx.dwarf_cu->ReadAddressFromDebugAddrSection(index);
stack.push_back(Scalar(value));
stack.back().SetValueType(Value::ValueType::FileAddress);
```
Neither producer calls `to_generic`, `TruncOrExtendTo`, or any equivalent normalization to `8 * address_size`. The stack entries therefore remain 64-bit when later consumed as generic values on a 32-bit target.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8lc9v4jgUx_8ac3kqCg6EcMiBLs1eRtPVtLtzRI79IJ4xNutn0zJ__cpOoO202h-XlSJBYvv9_LyvBZHeW8SGLW7ZYjMRMfTON980mmhvnuKkc-rc3FsQUPKbTgcIwu8xMP4LsKrYfN3e_7YVSnlWFe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