[all-commits] [llvm/llvm-project] da9e8d: [lldb] Unify DW_OP_deref and DW_OP_deref_size impl...

David Peixotto via All-commits all-commits at lists.llvm.org
Mon Dec 1 13:05:49 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: da9e8d5c57c845c852cc676c104c499eff06ae09
      https://github.com/llvm/llvm-project/commit/da9e8d5c57c845c852cc676c104c499eff06ae09
  Author: David Peixotto <peix at meta.com>
  Date:   2025-12-01 (Mon, 01 Dec 2025)

  Changed paths:
    M lldb/source/Expression/DWARFExpression.cpp
    M lldb/unittests/Expression/DWARFExpressionTest.cpp

  Log Message:
  -----------
  [lldb] Unify DW_OP_deref and DW_OP_deref_size implementations (#169587)

This commit unifies the code in the dwarf expression evaluator that
handles these two deref operations. Previously we had similar, but not
identical code for handling them.

The implementation was taken from the DW_OP_deref_size code path since
that handles the general case. We put that code into an
Evaluate_DW_OP_deref_size function and call it with the address size
when evaluating DW_OP_deref.

There were initially two test failures when I made the change. The
`DW_op_deref_no_ptr_fixing` unittest failed because we were not
correctly setting the address size when we created the DataExtractor.
The `DW_OP_deref test` failed because previously the expression
`DW_OP_lit4, DW_OP_deref` would evaluate to a LoadAddress, but the code
for deref_size was evaluating it to a scalar.

The difference was in how it handled a deref of a scalar value type. In
the deref code path we convert a scalar to a load address, but this was
not done in the deref_size code path.

```
  case Value::ValueType::Scalar:
      stack.back().SetValueType(Value::ValueType::LoadAddress);
```

I decided to modify the deref_size code to also convert the value to a
load address to keep the test passing.

There is no functional change intended here. The motivation is to reduce
the number of code paths that implement the deref operation.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list