Bug 30908 - [gdb/ada, gcc 13] FAIL: gdb.ada/str_binop_equal.exp: print my_str = "ABCD"
Summary: [gdb/ada, gcc 13] FAIL: gdb.ada/str_binop_equal.exp: print my_str = "ABCD"
Status: RESOLVED DUPLICATE of bug 12607
Alias: None
Product: gdb
Classification: Unclassified
Component: ada (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-26 15:11 UTC by Tom de Vries
Modified: 2024-02-27 15:21 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2023-09-26 15:11:41 UTC
With gcc 13.2.1, I run into a cluster of fails:
...
FAIL: gdb.ada/str_binop_equal.exp: print my_str = "ABCD"
FAIL: gdb.ada/widewide.exp: print my_wws = " helo"
FAIL: gdb.ada/widewide.exp: print my_ws = "wide"
...

I Investigated the middle one, using:
...
+gdb_test "set debug expr 1"                                                                                          
 gdb_test "print my_wws = \" helo\"" " = true"                                                                        
+gdb_test "set debug expr 0"                                                                                          
...

With gcc 7.5.0 I get:
...
(gdb) print my_wws = " helo"^M
Operation: BINOP_EQUAL^M
 Operation: BINOP_EQUAL^M
 Operation: OP_VAR_VALUE^M
  Block symbol:^M
   Symbol: my_wws^M
    Type: array (1 .. 5) of wide_wide_character^M
   Block: 0x2e25f70^M
 Operation: OP_STRING^M
  String:  helo^M
$7 = true^M
(gdb) PASS: gdb.ada/widewide.exp: print my_wws = " helo"
...

With gcc 13.2.1 I get:
...
(gdb) print my_wws = " helo"^M
Operation: OP_FUNCALL^M
 Operation: OP_VAR_VALUE^M
  Block symbol:^M
   Symbol: ada.strings.maps."="^M
    Type: function (a1: <ref> ada.strings.maps.character_set; a2: <ref> ada.strings.maps.character_set) return boolean^M
   Block: 0x3a9e450^M
 Vector:^M
  Operation: OP_VAR_VALUE^M
   Block symbol:^M
    Symbol: my_wws^M
     Type: array (1 .. 5) of wide_wide_character^M
    Block: 0x3855d00^M
  Operation: OP_STRING^M
   String:  helo^M
$7 = false^M
(gdb) FAIL: gdb.ada/widewide.exp: print my_wws = " helo"
...

I don't know what's the cause of the difference, but I'm tentatively classifying this as an ada problem.
Comment 1 Tom Tromey 2023-09-26 15:37:36 UTC
Do you have Ada system debug info installed?
I think there are various problems with overloading,
and the system debuginfo can trigger them.
Maybe this test can be rewritten to avoid this stuff.

I'd like to fix overloading but I'm told it is hard.
Haven't investigated yet for real.
Comment 2 Tom de Vries 2023-09-26 17:14:35 UTC
(In reply to Tom Tromey from comment #1)
> Do you have Ada system debug info installed?

No for both cases.

And after I installed the debug info in both cases using:
...
$ sudo zypper install gcc7-ada-debuginfo libada7-debuginfo
...
and:
...
$ zypper install gcc13-ada-debuginfo libada13-debuginfo
...
there's no change in behaviour.
Comment 3 Tom de Vries 2023-09-26 23:31:09 UTC
It's true though that there is a difference in debug info, in one case the ada__strings__maps__Oeq subprogram is present in the exec, in the other case it's not.

The info is coming from a-strmap.adb in gcc/ada/libgnat dir.

The difference seems to be related to whether a-strmap.o is linked in or not.
Comment 4 Tom de Vries 2023-09-27 06:58:30 UTC
I've reproduced the problem with gcc 7.5.0, with this patch:
...
diff --git a/gdb/testsuite/gdb.ada/widewide/foo.adb b/gdb/testsuite/gdb.ada/widewide/foo.adb
index 858ae176418..04935005637 100644
--- a/gdb/testsuite/gdb.ada/widewide/foo.adb
+++ b/gdb/testsuite/gdb.ada/widewide/foo.adb
@@ -15,6 +15,8 @@
 
 with Pck; use Pck;
 
+with Ada.Strings.Maps; use Ada.Strings.Maps;
+
 procedure Foo is
    Some_Easy : Wide_Wide_Character := 'J';
    Some_Larger : Wide_Wide_Character := Wide_Wide_Character'Val(16#beef#);
...
Comment 5 Tom de Vries 2023-10-01 13:26:30 UTC
Patch adding KFAIL: https://sourceware.org/pipermail/gdb-patches/2023-October/202876.html
Comment 6 Sourceware Commits 2023-10-02 17:48:29 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=89238cfdbaadede9817f0848202f1d34f9885d94

commit 89238cfdbaadede9817f0848202f1d34f9885d94
Author: Tom de Vries <tdevries@suse.de>
Date:   Mon Oct 2 19:48:21 2023 +0200

    [gdb/testsuite] Add KFAIL for PR ada/30908
    
    With gcc 13.2.1, I run into a cluster of fails:
    ...
    FAIL: gdb.ada/str_binop_equal.exp: print my_str = "ABCD"
    FAIL: gdb.ada/widewide.exp: print my_wws = " helo"
    FAIL: gdb.ada/widewide.exp: print my_ws = "wide"
    ...
    
    The problem is that the debug info contains information about function
    ada.strings.maps."=", and gdb uses it to implement the comparison.
    The function is supposed to compare two char sets, not strings, so gdb
    shouldn't use it.  This is PR ada/30908.
    
    I don't see the same problem with gcc 7.5.0, because the exec doesn't contain
    the debug info for the function, because the corresponding object is not
    linked in.  Adter adding "with Ada.Strings.Maps; use Ada.Strings.Maps;" to
    gdb.ada/widewide/foo.adb I run into the same problem with gcc 7.5.0.
    
    Add KFAILs for the PR.
    
    Tested on x86_64-linux:
    - openSUSE Leap 15.4 (using gcc 7.5.0), and
    - openSUSE Tumbleweed (using gcc 13.2.1).
    
    Approved-By: Tom Tromey <tom@tromey.com>
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30908
Comment 7 Tom Tromey 2024-02-26 18:38:02 UTC
I tried adding the with/use line and couldn't reproduce
this with Fedora 38 gcc.
I suspect this was fixed by

commit d56fdf1b976d32762c780a0107b20e61ce768967
Author: Tom Tromey <tromey@adacore.com>
Date:   Tue Nov 28 14:26:56 2023 -0700

    Refine Ada overload matching

... and this is a dup of bug#12607.
However, I can't really be sure.
Comment 8 Tom de Vries 2024-02-27 11:14:19 UTC
(In reply to Tom Tromey from comment #7)
> I tried adding the with/use line and couldn't reproduce
> this with Fedora 38 gcc.
> I suspect this was fixed by
> 
> commit d56fdf1b976d32762c780a0107b20e61ce768967
> Author: Tom Tromey <tromey@adacore.com>
> Date:   Tue Nov 28 14:26:56 2023 -0700
> 
>     Refine Ada overload matching
> 
> ... and this is a dup of bug#12607.
> However, I can't really be sure.

Confirmed, that commit fixes the FAILs in gdb.ada/widewide.exp and gdb.ada/str_binop_equal.exp.

Marking dup, and I'll submit a patch to remove the KFAILs.

*** This bug has been marked as a duplicate of bug 12607 ***
Comment 9 Tom de Vries 2024-02-27 11:23:59 UTC
(In reply to Tom de Vries from comment #8)
> ... and I'll submit a patch to remove the KFAILs.

https://sourceware.org/pipermail/gdb-patches/2024-February/206859.html
Comment 10 Sourceware Commits 2024-02-27 15:21:49 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=0dbca2abb94778204b2c972bcca3855cdbf9afba

commit 0dbca2abb94778204b2c972bcca3855cdbf9afba
Author: Tom de Vries <tdevries@suse.de>
Date:   Tue Feb 27 16:21:56 2024 +0100

    [gdb/testsuite] Remove KFAIL for PR ada/30908
    
    PR ada/30908 turns out to be a duplicate of PR ada/12607, which was fixed by
    commit d56fdf1b976 ("Refine Ada overload matching").
    
    Remove the KFAILs for PR ada/30908.
    
    Tested on x86_64-linux.
    
    Approved-By: Tom Tromey <tom@tromey.com>
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30908