<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97484>97484</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
lldb failed to evaluate address: ouldn't materialize: couldn't get the value of variable g_12: failed to read memory DW_OP_piece(4) from file address 0x4028 error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
edumoot
</td>
</tr>
</table>
<pre>
LLDB failed to compute the address of the static global structure variable, `g_3`, some components of which have been optimized out . We can reproduce this in llvm18.1.2, 17.0.6, and 16.0.3. Details can be seen in the following:
```
clang 4.c -g -O3 -o 4.out
lldb 4.out
(lldb) br set -l 18
Breakpoint 1: where = 4.out`main [inlined] func_1 at 4.c:18:16, address = 0x0000000000001130
(lldb) r
[…]
* thread #1, name = '4.out', stop reason = breakpoint 1.1
frame #0: 0x0000555555555130 4.out`main [inlined] func_1 at 4.c:18:16
15 for (g_5 = 0; (g_5 < 2); g_5++)
16 {
17 int l_20 = 0x95342363;
-> 18 g_3.f2 = (l_20 & 0U);
19 }
20 return g_5;
21 }
(lldb) p g_3
error: Couldn't materialize: couldn't get the value of variable g_3: failed to read memory DW_OP_piece(4) from file address 0x4028
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
(lldb)
```
while GDB works well.
```
gdb 4.out
(gdb) b 18
Breakpoint 1 at 0x1130: file 4.c, line 18.
(gdb) r
[…]
Breakpoint 1, func_1 () at 4.c:18
18 g_3.f2 = (l_20 & 0U);
(gdb) p g_3
$1 = {f0 = <optimised out>, f1 = <optimised out>, f2 = 3303, f3 = 0, f4 = <optimised out>}
(gdb)
```
The source code lists below
`cat 4.c`
```
struct S0 {
const unsigned long f0;
unsigned long f1;
int f2: 25;
unsigned int f3: 1;
unsigned short f4;
};
static struct S0 g_3 = {4294967295UL, 0x2EAC4530, 3303, 0, 1U};
static int g_5 = 0x6EC7516A;
static const unsigned short func_1(void)
{
struct S0 *l_2 = &g_3;
for (g_5 = 0; (g_5 < 2); g_5++)
{
int l_20 = 0x95342363;
g_3.f2 = (l_20 & 0U);
}
return g_5;
}
int main(void)
{
func_1();
return 0;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVtuu2jgXfhpzs0TkQ5zDBRec9q9_VKmVplUvkZM4wVMTI8fZ0D79yE4gYZepptMiBLGX1-dvnSO6TjWtlCvEN4jvFqJ3R2NXsupPxrhFYaqvq3fvdhuohdKyAmegNKdz7yS4owRRVVZ2HZg6LDsnnCqh0aYQGjpn-9L1VsKrsEoUWiK6BZTg5sBQgv2iMycZAE0rWxdwLkdVHuEoXiUUUrZgzk6d1DdZgekdRPBZQilasPJsTdWXnofqQLWg9euJZBGJqEcmaYSjxD-JtgKSRDhiEeykE0p3AaGQ0PkLVBu410Zrc1Ftg9ga4R3Ca89x-IZlqUXbQByVsGxg-Z7B0kAceVKDXOuqGDZGdZr5LURzKCx00sFSA8kG4cZK8eVsVOuAILaGy1FaCYjtRoQEn4RqAfGNarVqZYX4Duq-LQ8EhPMsEFuTzP8MRo6B8Aj4imcfQhj-jpAdd_gG7SnKMFoniO9ux9bgjlaKChBlxKO34jSQQzQd-NE0hM-ZM1gpOtMGcTGzKiIDHABAbQMAZdjbOvDjtw9h-L8YfQMnHADhPFxjLCCaNQc--AGxzbTeAkU091vNgSO6Cd98gknuMCjdwLSf3vf9x5umDxSPjs45iylLGGKbQWOJ2B5I9qDTHFhU09F_2aBNE8CfBj7TVfmMwu6-TfF920rX2zYYMNOjJBy468zifPaXD7vSWmO9-7em11WLaOrgJJy0Smj1TXpJOUka6UJVvArdS1-WtxIOgGw96wchU07yZOxX2H0-vP9wOCtZSkSz2FOorTlBrfTULPA1xjR7wyo8jEWuWtiZ_VWWvQstY8brg5VnYeXHm_iP_3_cX88eVpn2O_Of1vHwezl6Sv_bbeBi7J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