This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: lambda expression support


Hi,

On 09/03/2018, Uri Moszkowicz <uri@4refs.com> wrote:
> Hi,
> It seems like GDB doesn't support debug support for C++ lambda expressions
> is still incomplete. Is that right or am I missing something? Are there
> plans for better support or do you all have another debugger you can
> recommend for them?
>
> I tried recently with GDB 8.1 on SuSE11. Things I'd like to be able to do
> is examine the local variables in a lambda expression after a crash in one,
> see the line at which the crash occurred, and set breakpoints in them.
Did this not work for you when you tried? I've just checked, and it
does work out for me with GDB 8.1.50.20180205-git. See this session:
---------------
bash$ cat test.cc
int main()
{
    const auto lam=[]
    {
        int x=2534;
        int y=x*x;
        int z=333;
        int w=z-z;
        int v=y/w;
        int u=y/x;
    };
    lam();
}
bash$ g++ test.cc -std=c++0x -o test -g
bash$ gdb ./test -ex r
Reading symbols from ./test...done.
Starting program: /tmp/test

Program received signal SIGFPE, Arithmetic exception.
0x080483b1 in operator() (this=0xffffd437) at test.cc:9
9               int v=y/w;
(gdb) p y
$1 = 6421156
(gdb) p w
$2 = 0
--------

As you can see, GDB does report the line number (9 here) of the crash
and is able to print the variables (y and w here).
>
> Thanks,
> Uri
>

Regards,
Ruslan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]