Issue 83839
Summary Wrong Debug Information - Debugger cannot access in-scope structure varialbes after a function call, with -Oo -g compiling options
Labels
Assignees
Reporter edumoot
    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; 
}
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to