<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/83839>83839</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Wrong Debug Information - Debugger cannot access in-scope structure varialbes after a function call, with -Oo -g compiling options
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
edumoot
</td>
</tr>
</table>
<pre>
LLVM commit (17.0.6), [6009fe18](https://github.com/llvm/llvm-project/commit/6009708b4367171ccdbf4b5905cb6a803753fe18)
LLVM commit (16.0.3), [da3cb08c](https://github.com/llvm/llvm-project/commit/da3cd333bea572fb10470f610a27f22bcb84b08c)
LLVM commit (14.0.6), [f28cb1d1](https://github.com/llvm/llvm-project/commit/f28c006a5895fc0e329fe15fead81e37457cb1d1)
Reproduce with:
```command
clang -g -O0 case.c -o case.out
lldb case.out
```
Result(set a breakpoint at main function and then debug step by step)
```lldb
(lldb) s
Process 1423951 stopped
* thread #1, name = 'case.out', stop reason = step in
frame #0: 0x00005555555551bf case.out`fun_b at case.c:23:18
20 int b = 2;
21 int *c = &a;
22 struct S0 d = {2,-1,3,5,-6,7};
-> 23 (*c) = fun_a(b);
24 return d;
25 }
26
(lldb) p d
(S0) $1 = (f0 = 2, f1 = -1, 0, f2 = 3, 0, f3 = 5, f4 = -6, f5 = 7)
(lldb) s
Process 1423951 stopped
* thread #1, name = 'case.out', stop reason = step in
frame #0: 0x00005555555551e7 case.out`fun_a(p=2) at case.c:15:12
12
13 static int fun_a(int p)
14 {
-> 15 return a;
16 }
17
18 static struct S0 fun_b(void)
(lldb) s
Process 1423951 stopped
* thread #1, name = 'case.out', stop reason = step in
frame #0: 0x00005555555551c7 case.out`fun_b at case.c:23:12
20 int b = 2;
21 int *c = &a;
22 struct S0 d = {2,-1,3,5,-6,7};
-> 23 (*c) = fun_a(b);
24 return d;
25 }
26
(lldb) p d
error: Couldn't materialize: couldn't get the value of variable d: variable not available
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
(lldb) s
Process 1423951 stopped
* thread #1, name = 'case.out', stop reason = step in
frame #0: 0x00005555555551d3 case.out`fun_b at case.c:24:5
21 int *c = &a;
22 struct S0 d = {2,-1,3,5,-6,7};
23 (*c) = fun_a(b);
-> 24 return d;
25 }
26
27 int main(void)
(lldb) p d
error: Couldn't materialize: couldn't get the value of variable d: variable not available
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
```
`cat case.c`
```c source file
#include <stdio.h>
struct S0 {
unsigned f0 : 7;
signed f1 : 2;
signed f2 : 29;
unsigned f3 : 20;
signed f4;
unsigned f5 : 26;
};
static int a = -1;
static int fun_a(int p)
{
return a;
}
static struct S0 fun_b(void)
{
int b = 2;
int *c = &a;
struct S0 d = {2,-1,3,5,-6,7};
(*c) = fun_a(b);
return d;
}
int main(void)
{
struct S0 a = fun_b();
printf("%d\n",a.f5);
return 0;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcV1-P27gR_zT0y8AGOZRE-cEPXnsXSJEiQRO0jwVFUrZaWRRIapv00x9IrSXbu5tcLkiQu8XCEmeG84fzGw1Het8cOmM2JL8j-X4hh3C0bmP0cLI2LCqrP2_evv3n30HZ06kJQLBkYkVXBcE1wR2Q_K6gdF0bVpJ8T7A8htB7wrcEHwg-HJpwHKqVsieCD237eH4se2f_Y1Qg-DAqJvgQ9QhaVhkvBBNMKV3VWZWvaa6qQpaUi5wnO7gmdE_o9tavYkVXfPZLS64qWqrv9Svq0ZzzyshcYF0xmglaF4xKFDVipaoyS3Ze8yu7Pq8aS1Uxzb7Xr6iH0kLm5TqvFTUcYxry2khdMsNFlovRztmv8fcfpndWD8rA_5pwjJZHZkHH_6hfdnqkqlZ2B1geYPmOgpLerBQs7fhmhzAKta2ubkiTtrNNP7SBYOlNAAmVM_K_vW26ADLASTYd1EOnQmM7kJ2GcDQdaFMNB_DB9FB9Ts-b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