Bug 31514 - [gdb/testsuite] FAIL: gdb.ada/tagged-lookup.exp: only one CU expanded
Summary: [gdb/testsuite] FAIL: gdb.ada/tagged-lookup.exp: only one CU expanded
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: testsuite (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 15.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-20 10:24 UTC by Tom de Vries
Modified: 2024-03-25 14:29 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
passing gdb.log (on openSUSE Tumbleweed) (2.37 KB, text/x-log)
2024-03-20 15:31 UTC, Tom de Vries
Details
failing gdb.log (on openSUSE Leap 15.4) (1.70 KB, text/x-log)
2024-03-20 16:38 UTC, Tom de Vries
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2024-03-20 10:24:33 UTC
On openSUSE Leap 15.4, using gcc 7.5.0, I'm running into:
...
FAIL: gdb.ada/tagged-lookup.exp: only one CU expanded
...

In more detail:
...
(gdb) set debug symtab-create 1^M
(gdb) PASS: gdb.ada/tagged-lookup.exp: set debug symtab-create 1
print *the_local_var^M
[symtab-create] start_subfile: name = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb, name_for_id = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb^M
[symtab-create] start_subfile: name = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb, name_for_id = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb^M
[symtab-create] start_subfile: found existing symtab with name_for_id /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb^M
[symtab-create] start_subfile: name = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb, name_for_id = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb^M
[symtab-create] start_subfile: found existing symtab with name_for_id /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb^M
[symtab-create] start_subfile: name = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.ads, name_for_id = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.ads^M
[symtab-create] start_subfile: name = a-tags.adb, name_for_id = /home/abuild/rpmbuild/BUILD/gcc-7.5.0+r278197/obj-x86_64-suse-linux/gcc/ada/rts/a-tags.adb^M
[symtab-create] start_subfile: name = s-htable.adb, name_for_id = /home/abuild/rpmbuild/BUILD/gcc-7.5.0+r278197/obj-x86_64-suse-linux/gcc/ada/rts/s-htable.adb^M
[symtab-create] start_subfile: name = a-tags.adb, name_for_id = /home/abuild/rpmbuild/BUILD/gcc-7.5.0+r278197/obj-x86_64-suse-linux/gcc/ada/rts/a-tags.adb^M
[symtab-create] start_subfile: found existing symtab with name_for_id /home/abuild/rpmbuild/BUILD/gcc-7.5.0+r278197/obj-x86_64-suse-linux/gcc/ada/rts/a-tags.adb^M
  ...
[symtab-create] start_subfile: name = s-valllu.ads, name_for_id = /home/abuild/rpmbuild/BUILD/gcc-7.5.0+r278197/obj-x86_64-suse-linux/gcc/ada/rts/s-valllu.ads^M
$1 = (n => 2)^M
(gdb) FAIL: gdb.ada/tagged-lookup.exp: only one CU expanded
...
Comment 1 Tom de Vries 2024-03-20 15:31:41 UTC
Created attachment 15420 [details]
passing gdb.log (on openSUSE Tumbleweed)
Comment 2 Tom de Vries 2024-03-20 15:57:24 UTC
(In reply to Tom de Vries from comment #1)
> Created attachment 15420 [details]
> passing gdb.log (on openSUSE Tumbleweed)

Grepping reveals pck2.adb only:
...
$ egrep "start_subfile: name = .*(pck|pck2)\.adb" ~/gdb.log
[symtab-create] start_subfile: name = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb, name_for_id = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb
[symtab-create] start_subfile: name = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb, name_for_id = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb
[symtab-create] start_subfile: name = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb, name_for_id = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb
[symtab-create] start_subfile: name = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb, name_for_id = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb
...
Comment 3 Tom de Vries 2024-03-20 16:37:13 UTC
(In reply to Tom de Vries from comment #2)
> (In reply to Tom de Vries from comment #1)
> > Created attachment 15420 [details]
> > passing gdb.log (on openSUSE Tumbleweed)
> 
> Grepping reveals pck2.adb only:

And in the failing case, no matches at all:
...
$ egrep "start_subfile: name = .*(pck|pck2)\.adb" gdb.log
$
...
Comment 4 Tom de Vries 2024-03-20 16:38:14 UTC
Created attachment 15421 [details]
failing gdb.log (on openSUSE Leap 15.4)
Comment 5 Tom de Vries 2024-03-21 07:34:11 UTC
Installed gcc-13 on Leap 15.4.

Passes with gcc-13, fails with gcc-12, 11, 10, 9, 8 and 7.

With gcc-13, we have pck2.adb, pck2.ads, b~foo.adb and b~foo.ads:
...
$ grep "start_subfile: name = .*tagged-lookup" gdb.log | sort -u
[symtab-create] start_subfile: name = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb, name_for_id = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb
[symtab-create] start_subfile: name = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb, name_for_id = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb
[symtab-create] start_subfile: name = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.ads, name_for_id = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.ads
[symtab-create] start_subfile: name = /data/vries/gdb/src/gdb/testsuite/gdb.ada/tagged-lookup/pck2.ads, name_for_id = /data/vries/gdb/src/gdb/testsuite/gdb.ada/tagged-lookup/pck2.ads
...

With gcc-12, we have just b~foo.adb and b~foo.ads:
...
$ grep "start_subfile: name = .*tagged-lookup" gdb.log | sort -u
[symtab-create] start_subfile: name = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb, name_for_id = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb
[symtab-create] start_subfile: name = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.ads, name_for_id = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.ads
...
Comment 6 Tom de Vries 2024-03-21 07:50:43 UTC
With the patch reverted, we have the following.

With gcc-13, we have pck2.adb, pck2.ads, pck.adb, pck.ads, b~foo.adb, b~foo.ads:
...
$ grep "start_subfile: name = .*tagged-lookup" gdb.log | sort -u
[symtab-create] start_subfile: name = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb, name_for_id = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb
[symtab-create] start_subfile: name = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck.adb, name_for_id = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck.adb
[symtab-create] start_subfile: name = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb, name_for_id = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb
[symtab-create] start_subfile: name = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.ads, name_for_id = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.ads
[symtab-create] start_subfile: name = /data/vries/gdb/src/gdb/testsuite/gdb.ada/tagged-lookup/pck2.ads, name_for_id = /data/vries/gdb/src/gdb/testsuite/gdb.ada/tagged-lookup/pck2.ads
[symtab-create] start_subfile: name = /data/vries/gdb/src/gdb/testsuite/gdb.ada/tagged-lookup/pck.ads, name_for_id = /data/vries/gdb/src/gdb/testsuite/gdb.ada/tagged-lookup/pck.ads
...

With gcc-12, the same:
...
$ grep "start_subfile: name = .*tagged-lookup" gdb.log | sort -u
[symtab-create] start_subfile: name = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb, name_for_id = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck2.adb
[symtab-create] start_subfile: name = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck.adb, name_for_id = /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.ada/tagged-lookup/pck.adb
[symtab-create] start_subfile: name = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb, name_for_id = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.adb
[symtab-create] start_subfile: name = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.ads, name_for_id = /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.ada/tagged-lookup/b~foo.ads
[symtab-create] start_subfile: name = /data/vries/gdb/src/gdb/testsuite/gdb.ada/tagged-lookup/pck2.ads, name_for_id = /data/vries/gdb/src/gdb/testsuite/gdb.ada/tagged-lookup/pck2.ads
[symtab-create] start_subfile: name = /data/vries/gdb/src/gdb/testsuite/gdb.ada/tagged-lookup/pck.ads, name_for_id = /data/vries/gdb/src/gdb/testsuite/gdb.ada/tagged-lookup/pck.ads
...
Comment 7 Tom de Vries 2024-03-21 08:00:49 UTC
Tentative patch:
...
diff --git a/gdb/testsuite/gdb.ada/tagged-lookup.exp b/gdb/testsuite/gdb.ada/tagged-lookup.exp
index 4bc088ba8d5..3803319c505 100644
--- a/gdb/testsuite/gdb.ada/tagged-lookup.exp
+++ b/gdb/testsuite/gdb.ada/tagged-lookup.exp
@@ -52,7 +52,7 @@ gdb_test_multiple "print *the_local_var" "only one CU expanded" -lbl {
 	exp_continue
     }
     -re -wrap ".* = \\\(n => $decimal\\\)" {
-	if {$found_pck + $found_pck2 == 1} {
+	if {$found_pck + $found_pck2 <= 1} {
 	    pass $gdb_test_name
 	} else {
 	    fail $gdb_test_name
...

It detects the fail with fix reverted for gcc-12 and gcc-13, though not before.

And it make the test pass for gcc-12 and gcc-13 with the fix present.
Comment 9 Sourceware Commits 2024-03-25 14:28:46 UTC
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=874f4887f0361e953f7098459ae60a5f894d362a

commit 874f4887f0361e953f7098459ae60a5f894d362a
Author: Tom de Vries <tdevries@suse.de>
Date:   Mon Mar 25 15:28:35 2024 +0100

    [gdb/testsuite] Fix gdb.ada/tagged-lookup.exp with gcc <= 12
    
    With gcc 13, test-case gdb.ada/tagged-lookup.exp passes for me, but with gcc
    12, I get:
    ...
    (gdb) set debug symtab-create 1^M
    (gdb) print *the_local_var^M
      ...
    $1 = (n => 2)^M
    (gdb) FAIL: gdb.ada/tagged-lookup.exp: only one CU expanded
    ...
    
    The problem is that this fails:
    ...
        -re -wrap ".* = \\\(n => $decimal\\\)" {
            if {$found_pck + $found_pck2 == 1} {
                pass $gdb_test_name
            } else {
                fail $gdb_test_name
            }
    ...
    because $found_pck == 0 and $found_pck2 == 0.
    
    Indeed, with gcc 13 we have:
    ...
    $ grep "start_subfile: name = .*/tagged-lookup/" gdb.log | sed 's%.*/%%'
    b~foo.adb
    b~foo.adb
    b~foo.adb
    b~foo.ads
    pck2.adb
    pck2.adb
    pck2.ads
    pck2.adb
    pck2.ads
    ...
    and with gcc 12:
    ...
    $ grep "start_subfile: name = .*/tagged-lookup/" gdb.log | sed 's%.*/%%'
    b~foo.adb
    b~foo.adb
    b~foo.adb
    b~foo.ads
    ...
    
    Fix this by checking for "$found_pck + $found_pck2 <= 1" instead.
    
    Tested on x86_64-linux.
    
    Approved-By: Tom Tromey <tom@tromey.com>
    
    PR testsuite/31514
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31514
Comment 10 Tom de Vries 2024-03-25 14:29:14 UTC
Fixed.