ldc-developers / ldc

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

Fixes needed for newer GDB versions #4389

Open JohanEngelen opened 1 year ago

JohanEngelen commented 1 year ago

Tests debuginfo/{classtypes,print}_gdb.d fail with newer GDB versions, and are now disabled for FreeBSD. See e.g. https://github.com/ldc-developers/ldc/pull/4373

the-horo commented 8 months ago

I'm hitting this on Gentoo as well:

LLD 17.0.6
Lit version:  17.0.6dev
-- Testing: 2 tests, 2 workers --
FAIL: LDC :: debuginfo/print_gdb.d (1 of 2)
******************** TEST 'LDC :: debuginfo/print_gdb.d' FAILED ********************
Script:
--
: 'RUN: at line 6';   /home/happy/git/ldc/build-ldc/bin/ldc2  -I/home/happy/git/ldc/tests/debuginfo -g -of=/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/print_gdb.d.tmp /home/happy/git/ldc/tests/debuginfo/print_gdb.d /home/happy/git/ldc/tests/debuginfo/inputs/import_a.d /home/happy/git/ldc/tests/debuginfo/inputs/import_b.d
: 'RUN: at line 7';   sed -e "/^\\/\\/ GDB:/!d" -e "s,// GDB:,," /home/happy/git/ldc/tests/debuginfo/print_gdb.d >/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/print_gdb.d.tmp.gdb
: 'RUN: at line 8';   env LANG=C gdb /home/happy/git/ldc/build-ldc/tests/debuginfo/Output/print_gdb.d.tmp --batch -x /home/happy/git/ldc/build-ldc/tests/debuginfo/Output/print_gdb.d.tmp.gdb >/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/print_gdb.d.tmp.out 2>&1
: 'RUN: at line 9';   FileCheck /home/happy/git/ldc/tests/debuginfo/print_gdb.d -check-prefix=CHECK < /home/happy/git/ldc/build-ldc/tests/debuginfo/Output/print_gdb.d.tmp.out
--
Exit Code: 1

Command Output (stdout):
--
$ ":" "RUN: at line 6"
$ "/home/happy/git/ldc/build-ldc/bin/ldc2" "-I/home/happy/git/ldc/tests/debuginfo" "-g" "-of=/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/print_gdb.d.tmp" "/home/happy/git/ldc/tests/debuginfo/print_gdb.d" "/home/happy/git/ldc/tests/debuginfo/inputs/import_a.d" "/home/happy/git/ldc/tests/debuginfo/inputs/import_b.d"
$ ":" "RUN: at line 7"
$ "sed" "-e" "/^\/\/ GDB:/!d" "-e" "s,// GDB:,," "/home/happy/git/ldc/tests/debuginfo/print_gdb.d"
$ ":" "RUN: at line 8"
$ "env" "LANG=C" "gdb" "/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/print_gdb.d.tmp" "--batch" "-x" "/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/print_gdb.d.tmp.gdb"
# redirected output from '/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/print_gdb.d.tmp.out':
gdb: warning: Couldn't determine a path for the index cache directory.
Breakpoint 1 at 0x198d8: file home/happy/git/ldc/tests/debuginfo/print_gdb.d, line 58.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib64/libthread_db.so.1".

Breakpoint 1, _Dmain () at home/happy/git/ldc/tests/debuginfo/print_gdb.d:58
58      uint n = 5;
Breakpoint 2 at 0x55555556d92a: file home/happy/git/ldc/tests/debuginfo/print_gdb.d, line 78.

Breakpoint 2, _Dmain () at home/happy/git/ldc/tests/debuginfo/print_gdb.d:78
78      sB strB;
/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/print_gdb.d.tmp.gdb:5: Error in sourced command file:
No symbol "globVal" in current context.

note: command had no output on stdout or stderr
error: command failed with exit status: 1

--

********************
FAIL: LDC :: debuginfo/classtypes_gdb.d (2 of 2)
******************** TEST 'LDC :: debuginfo/classtypes_gdb.d' FAILED ********************
Script:
--
: 'RUN: at line 6';   /home/happy/git/ldc/build-ldc/bin/ldc2  -g -of=/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/classtypes_gdb.d.tmp /home/happy/git/ldc/tests/debuginfo/classtypes_gdb.d
: 'RUN: at line 7';   sed -e "/^\\/\\/ GDB:/!d" -e "s,// GDB:,," /home/happy/git/ldc/tests/debuginfo/classtypes_gdb.d >/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/classtypes_gdb.d.tmp.gdb
: 'RUN: at line 8';   gdb /home/happy/git/ldc/build-ldc/tests/debuginfo/Output/classtypes_gdb.d.tmp --batch -x /home/happy/git/ldc/build-ldc/tests/debuginfo/Output/classtypes_gdb.d.tmp.gdb >/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/classtypes_gdb.d.tmp.out 2>&1
: 'RUN: at line 9';   FileCheck /home/happy/git/ldc/tests/debuginfo/classtypes_gdb.d -check-prefix=CHECK < /home/happy/git/ldc/build-ldc/tests/debuginfo/Output/classtypes_gdb.d.tmp.out
--
Exit Code: 1

Command Output (stdout):
--
$ ":" "RUN: at line 6"
$ "/home/happy/git/ldc/build-ldc/bin/ldc2" "-g" "-of=/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/classtypes_gdb.d.tmp" "/home/happy/git/ldc/tests/debuginfo/classtypes_gdb.d"
$ ":" "RUN: at line 7"
$ "sed" "-e" "/^\/\/ GDB:/!d" "-e" "s,// GDB:,," "/home/happy/git/ldc/tests/debuginfo/classtypes_gdb.d"
$ ":" "RUN: at line 8"
$ "gdb" "/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/classtypes_gdb.d.tmp" "--batch" "-x" "/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/classtypes_gdb.d.tmp.gdb"
# redirected output from '/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/classtypes_gdb.d.tmp.out':
gdb: warning: Couldn't determine a path for the index cache directory.
Breakpoint 1 at 0x199ae: file home/happy/git/ldc/tests/debuginfo/classtypes_gdb.d, line 41.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib64/libthread_db.so.1".

Breakpoint 1, _Dmain () at home/happy/git/ldc/tests/debuginfo/classtypes_gdb.d:41
41      return 0;
$1 = (classtypes_gdb.xyz *) 0x7ffff7bdc020
$2 = {<classtypes_gdb.uv> = {<object.Object> = {<No data fields>}, i = 99}, f = 88.7699966, d = 624.351}
$3 = (classtypes_gdb.xyz *) 0x7ffff7bdc020
$4 = {<classtypes_gdb.uv> = {<object.Object> = {<No data fields>}, i = 99}, f = 88.7699966, d = 624.351}
$5 = {0x0, 0x0, 0x7ffff7bdc040, 0x0}
$6 = {<classtypes_gdb.uv> = {<object.Object> = {<No data fields>}, i = 2}, f = 2, d = 0.98699999999999999}
/home/happy/git/ldc/build-ldc/tests/debuginfo/Output/classtypes_gdb.d.tmp.gdb:9: Error in sourced command file:
'classtypes_gdb.gvar' has unknown type; cast it to its declared type

note: command had no output on stdout or stderr
error: command failed with exit status: 1

--

********************
********************
Failed Tests (2):
  LDC :: debuginfo/classtypes_gdb.d
  LDC :: debuginfo/print_gdb.d

Testing Time: 0.19s
  Failed: 2

With gdb:

GNU gdb (Gentoo 13.2 vanilla) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Should the test be marked XFAIL on all platforms?

kinke commented 8 months ago

This issue includes runnable/gdb{4181,14313}.d from dmd-testsuite (the GDB dmd-testsuite tests are skipped on non-Linux, incl. FreeBSD). They fail e.g. on my Ubuntu 22 box with default gdb v12.1.

kinke commented 8 months ago

Should the test be marked XFAIL on all platforms?

Nope, because it works just fine with gdb < 10 IIRC.

Not sure if it's worth it, but we could extend https://github.com/ldc-developers/ldc/blob/6ede9a4fdfd04724fc28a60e6460993d8344136f/tests/lit.site.cfg.in#L212-L216 and disable the 2 lit-tests with gdb 10+; see https://github.com/ldc-developers/ldc/blob/6ede9a4fdfd04724fc28a60e6460993d8344136f/tests/debuginfo/print_gdb.d#L1

the-horo commented 8 months ago

Not sure if it's worth it, but we could extend

For me it's good enough to know that they are expected to fail on certain versions of gdb and that people are aware of the issue. It would be great if this was reported to gdb I suppose.

liushuyu commented 7 months ago

Hi there, just a heads up: I have opened a bug report on the GDB upstream: https://sourceware.org/bugzilla/show_bug.cgi?id=31580.

kinke commented 7 months ago

Thx for digging! Indeed, I didn't expect gdc to fail too, but it does on my system as well - Ubuntu 22, with distro-default gdc v11.4 and gdb v12.1.

PetarKirov commented 7 months ago

We've had similar issues when packaging historical DMD versions with Nix. Here's the list of tests we had to disable on Linux and macOS: https://github.com/PetarKirov/dlang.nix/blob/main/pkgs/dmd/build-status.nix

liushuyu commented 7 months ago

Hi, there: another heads up: GDB upstream swiftly proposed a fix: https://sourceware.org/pipermail/gdb-patches/2024-March/207686.html. I have verified locally and determined the patch is sufficient to fix the problem described in this issue.

I encourage everyone in this thread to verify if the patch can fix those tests independently. Thanks!