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

    <tr>
        <th>Summary</th>
        <td>
            [lldb bug] lldb is unable to parse DW_AT_location which points to a list of DW_AT_const_value
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Tested on top-of-tree lldb
Given the following code:
```
int a;
volatile int b;
static int func_11(int b) {
  int i = 0;
  for (; i < 10; i++) {
    int c;
 continue;
  }
  a = 0;
  return 0;
}
int main() { func_11(b); }
```
Compile using the latest `gcc` version 12, which generates the following DWARF DIE for `i`
```
 <4><ad>: Abbrev Number: 10 (DW_TAG_variable)
    <ae>   DW_AT_abstract_origin: <0xd4>
    <b2> DW_AT_location    : 0x22 (location list)
    <b6>   DW_AT_GNU_locviews: 0xc
/* Something in the middle */
 <2><d4>: Abbrev Number: 2 (DW_TAG_variable)
    <d5>   DW_AT_name        : i
    <d7> DW_AT_decl_file   : 1
    <d7>   DW_AT_decl_line   : 4
    <d8> DW_AT_decl_column : 7
    <d9>   DW_AT_type        : <0x41>
/* Something in the middle */
Symbol "i" is multi-location:
  Range 0x40110c-0x40110c: the constant 0
  Range 0x40110c-0x40110c: the constant 1
  Range 0x40110c-0x40110c: the constant 2
  Range 0x40110c-0x40110c: the constant 3
  Range 0x40110c-0x40110c: the constant 4
  Range 0x40110c-0x40110c: the constant 5
  Range 0x40110c-0x40110c: the constant 6
  Range 0x40110c-0x40110c: the constant 7
  Range 0x40110c-0x40110c: the constant 8
  Range 0x40110c-0x40110c: the constant 9
  Range 0x40110c-0x401116: the constant 10
.
```

Only the last location is valid, I tried to trace into `lldb` to locate where went wrong, the `SymbolFileDWARF::ParseVariableDIE` indeed parses the variable `i`, but I am not sure when `lldb` loses the track of variable `i`.

I also tried to trace into the `Block.cpp` and its mechanism of inserting variables. It seems that it indeed insert `i` into some block, but it never made it to the frame...
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVlGP2joT_TXmZQRynBDIAw8sLBUv_T61vbePyIkHcOvYyHag---vxoGUpaurywotiX3OmZljM7YMQR8s4oJNX9h0PZJdPDq_-HGxx7dR7dTb4huGiAqchehOY7cfR48Ixqia8TXjy0_6jBbiEWHvjHEXbQ_QOIUsX_YAVvLrJ71qG0Gy_KV_OzsjozYINFwPwyHKqJs0uO9ss8syJuY9RFTAZlcYJIQGlq-BD2SAvfPAxJzlL2lyBRlPz0y8pM87iV6k-U1vnI3adngnyGbr26P8I5rH2Hl7NzSgSbiV2lIufdC7cqgUympAPxi1cu2JnOkCWUoGGxkxRGAlPzQNKzmc0QftLGSCiRVcjro5wgEtegI-rMn6-_LLBtbb196dkush0kNgcqxg-SvLV1Kl7yUs69rjGT53bY2eBjJODq-_774tP-3O0mtZG6SKBleJjix_BYD1993y207WIXrZxJ3z-qAtqbB8xX-pFOyeVwvi9SzjGhmpyDS1BP5LCAo9jBsd4mPgurwP_OnzXyRz1ngJvURzLVxsmFjCV9diPJJJut_JrVbKIDCREIMpojelz_cjU8R_8ERN71OzskW4_pGCfo-d_fZBYWN2e9oQPTL7AAn3WKPtDVu8x84fVBtnutYm5Ow9srpXjW-nd7mmxSuyYfGecPPrW1s7A0wIzYQAHaDtTNTj26IOzQPgi7QHBP6r4FnGm_HtgRIg8cbZEKWNwJ8lZM8SxLOE_FlC8Sxh-iyhfJYwe5Ywf5ZQ_SshK_9cuOtSTz7sXv3__1nzdu2ZIcLQK3SAszRaUbvcQvQaFUQH1JbSEeSoMaazreQ0kYgIlyN6hAvaCBfv7IHoJM5K3u_kjTaYGixt3Hz5f-kD_n1tAOvtK6lpqxAVnGiq7823DjE0Y7GCuouwBdmCdRFC51Nse5-VcTc-Zf0T3P4Pocm9E1uQJrgPa72W8GJc83PSnE4kL60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