[Issue 15631] gdb: Parent's scope not considered for symbol lookup

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 26 04:20:26 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=15631

--- Comment #6 from hsteoh at quickfur.ath.cx ---
Ran into similar problem with delegates:

-------------
void fun(void delegate() dg) {
        dg();
}
void main() {
        int x = 123;
        string y = "abc";
        fun({
                x++;
                y ~= "d";
        });
}
-------------

Compiled with `dmd -g prog.d`. In gdb:

------------
(gdb) break prog.main
Breakpoint 1 at 0x43734: file prog.d, line 8.
(gdb) run
Starting program: /tmp/prog 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, prog.main().__lambda3() (__capture=0x7ffff7cad000) at prog.d:8
8                       x++;
(gdb) p x
No symbol "x" in current context.
(gdb) p y
No symbol "y" in current context.
(gdb) p __capture.x
$1 = 123
(gdb) p __capture.y
$2 = "abc"
------------

Apparently `__capture` must be entered explicitly in order to access
closed-over variables.  It would be nice to have symbol lookup automatically
look in __capture.

--


More information about the Digitalmars-d-bugs mailing list