Bug 17632

Summary: No locals for lambdas in initialiser lists
Product: gdb Reporter: khaurbeille+sourceware
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED MOVED    
Severity: minor CC: ssbssa
Priority: P2    
Version: 7.6   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Project(s) to access: ssh public key:
Attachments: Example code

Description khaurbeille+sourceware 2014-11-21 17:04:01 UTC
Created attachment 7961 [details]
Example code

GDB is not able to display local variables for lambda functions that are used in an initialiser list. Lambda functions in regular code work fine.

Steps to reproduce:
Compile attached file (GCC 4.8.3) with c++11 and debug info enabled
Run gdb on the executable
Run the following commands:
break 10
break 22
run
info locals
c
info locals

Actual results:
1st info locals:
std::__ioinit = {static _S_refcount = <optimized out>, static _S_synced_with_stdio = <optimized out>}

2nd info locals:
b = 4
c = @0x7fffffffddac: 4

Expected results:
Similar outputs for the 2 info locals

Stepping works as expected inside both lambdas.
Comment 1 Hannes Domani 2023-12-29 16:59:46 UTC
This was a debug info bug on gcc side that was fixed a while ago.

If you compile this with a gcc >= 6.1, then the output looks like this:
```
Reading symbols from gdb-17632.exe...done.
(gdb) b 10
Breakpoint 1 at 0x4a0778: file gdb-17632.cpp, line 10.
(gdb) b 22
Breakpoint 2 at 0x401668: file gdb-17632.cpp, line 22.
(gdb) r
Starting program: C:\src\tests\gdb-17632.exe
[New Thread 6852.0x1bd8]

Breakpoint 1, Breaker::Breaker(int)::{lambda()#1}::operator()() const (__closure=0x22fde0) at gdb-17632.cpp:10
10          b++;
(gdb) info locals
b = 2
c = @0x22fe08: 2
(gdb) c
Continuing.
3

Breakpoint 2, <lambda()>::operator()(void) const (__closure=0x22fe40) at gdb-17632.cpp:22
22            b++;
(gdb) info locals
b = 4
c = @0x22fe2c: 4
```