<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62094>62094</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [LLDB Bug] DW_OP_stack_value does not terminate the evaluation process as specified in the DWARFv5 standard
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jwnhy
      </td>
    </tr>
</table>

<pre>
    ```c
#include "stdint.h"
struct S0 {
  signed a : 25;
  const int b;
};
int c, d;
int func_29(uint64_t p1, struct S0 p2, uint16_t p3) {
  d = p2.a;
  p2.a = 0;
}
int main() {
  struct S0 e[] = {{}, {}, {}, {}, {5, 0}, {338810, 4728}};
  func_29(c, e[5], 0);
}
```

Given the above source, compiled with GCC 12.2.0 -O1.
GCC generates the following DWARF information for `p2`.
```
DW_OP_const4u: 338810; 
DW_OP_stack_value; 
DW_OP_bit_piece: size: 25 offset: 0; 
DW_OP_bit_piece: size: 39 offset: 0
```

It specifies in the DWARFv5 standard that `DW_OP_stack_value` terminates the evaluation process, but `LLDB` did not do that.
Though it can be argued that GCC should not generate these redundant information...

> The DW_OP_stack_value operation specifies that the object does not exist in memory but its value is nonetheless known and is at the top of the DWARF expression stack. In this form of location description, the DWARF expression represents the actual value of the object, rather than its location. **The DW_OP_stack_value operation terminates the expression.**

Result in the following fault (tested on top-of-tree lldb):
```
error: error: Couldn't materialize: couldn't get the value of variable p2: unable to extract DW_OP_bit_piece(bit_size = 39, bit_offset = 0) from an address value.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVV2P2joT_jXmZrRRcCAkF1yw8FJVqtRXPZV6iRx7QtwaO7Iddvf8-qNx2MCyu6qEiO3xzDzzzIdFCPpoEdds-ciWu5kYYuf8-veT7V5mjVMva1bm40-yfMfyDeOFttIMCoFxHqLSNmYd43wUh-gH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