ldc-developers / ldc

The LLVM-based D Compiler.
http://wiki.dlang.org/LDC
Other
1.21k stars 261 forks source link

DWARF for static members are wrong #4567

Open ghost opened 8 months ago

ghost commented 8 months ago

It appears that LDC generates standard member info, leading GDB to read the memory with an invalid address

sta_mbr

Information generated seem to confirm that

dwex_sta_mbr

kinke commented 8 months ago

The behavior with Ubuntu 22's gdb v12.1 on my box is different; it 'just' shows a garbage value if the global is a TLS var.

E.g., with a thread-global var:

struct S {
    shared static int a = 666;
    int b;
}

int main() {
    S s;
    return s.a;
}
Breakpoint 1, _Dmain () at test.d:8
8       return s.a;
(gdb) p s
$1 = {b = 0, static a = 666}
(gdb) p s.a
$2 = 666
(gdb) p S.a
$3 = 666
(gdb) p test.S.a
$4 = 666
(gdb) p S.b
Cannot reference non-static field "b"
ghost commented 8 months ago

To be frank, I know that the LLVM API for DWARF info has a function for static members. But I cant find an open sourced language that is able to use it correctly. Possibly the problem would be that a GDB "expression" would have to be created to have the propoer access.

In other words...if you fix this problem, that will help, and not only D programmers.