Bug 24539 - gdb.ada/vla.exp fails
Summary: gdb.ada/vla.exp fails
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: ada (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 9.1
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-08 21:13 UTC by Tom de Vries
Modified: 2019-06-14 13:03 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 2019-05-08 21:13:03 UTC
gdb.sum:
...
PASS: gdb.ada/vla.exp: compilation vla.adb
FAIL: gdb.ada/vla.exp: print r00
FAIL: gdb.ada/vla.exp: print r01
FAIL: gdb.ada/vla.exp: print r10
FAIL: gdb.ada/vla.exp: print r22
...

gdb.log:
...
(gdb) break vla.adb:53^M
Breakpoint 1 at 0x401f84: file /data/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/vla/vla.adb, line 53.^M
(gdb) run ^M
Starting program: /data/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.ada/vla/vla ^M
^M
Breakpoint 1, vla () at /data/gdb_versions/devel/binutils-gdb.git/gdb/testsuite/gdb.ada/vla/vla.adb:53^M
53         Process (R00); -- Set breakpoint here^M
(gdb) print r00^M
$1 = (l1 => 0, l2 => 0, i1 => 1, a1 => (), i2 => 2, a2 => (), i3 => 3)^M
(gdb) FAIL: gdb.ada/vla.exp: print r00
print r01^M
$2 = (l1 => 0, l2 => 1, i1 => 1, a1 => (), i2 => 2, a2 => (20), i3 => 3)^M
(gdb) FAIL: gdb.ada/vla.exp: print r01
print r10^M
$3 = (l1 => 1, l2 => 0, i1 => 1, a1 => (10), i2 => 2, a2 => (), i3 => 3)^M
(gdb) FAIL: gdb.ada/vla.exp: print r10
print r22^M
$4 = (l1 => 2, l2 => 2, i1 => 1, a1 => (10, 10), i2 => 2, a2 => (20, 20), i3 => 3)^M
(gdb) FAIL: gdb.ada/vla.exp: print r22
...

There seems to be an order discrepancy:
...
(l1 => 0, l2 => 0, i1 => 1, a1 => (), i2 => 2, a2 => (), i3 => 3)
...
vs:
...
(l1 => 0, l2 => 0, i1 => 1, i2 => 2, i3 => 3, a1 => (), a2 => ())
...
Comment 1 Tom Tromey 2019-05-28 17:06:37 UTC
Which version of gcc/gnat are you using?

I actually think the output you are seeing is more correct,
because it's in the declaration order.  However all the compilers
I have locally seem to emit things in the wrong order.
Comment 2 Tom Tromey 2019-05-28 17:40:26 UTC
I think for gdb it makes sense to simply accept both results.
Meanwhile I filed an internal bug report to get one of the
Gnat compiler engineers to fix the bug.
Comment 3 Tom Tromey 2019-05-28 18:28:39 UTC
I sent a patch.
Comment 4 Tom de Vries 2019-06-10 06:07:37 UTC
(In reply to Tom Tromey from comment #1)
> Which version of gcc/gnat are you using?

Default compilers on openSUSE Leap 15.0:
...
$ gnatmake --version
GNATMAKE 7.4.0
$ gcc --version
gcc (SUSE Linux) 7.4.0
...
Comment 5 Sourceware Commits 2019-06-14 12:56:49 UTC
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

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

commit 9a9e394b05a841bdd9163f280d7ef19cc65634d6
Author: Tom Tromey <tromey@adacore.com>
Date:   Wed May 29 10:21:52 2019 -0600

    Fix gdb.ada/vla.exp
    
    PR ada/24539 concerns a test failure in gdb.ada/vla.exp.
    
    The problem here is that different versions of Gnat emit the
    structure's fields in different orders -- with the order currently
    failing actually being the correct one.
    
    Joel pointed out that this can be fixed by simply adding the
    No_Component_Reordering pragma to the type in question, which is what
    this patch does.
    
    I've reported a Gnat compiler bug internally in hopes of getting the
    underlying problem fixed.
    
    gdb/testsuite/ChangeLog
    2019-06-14  Tom Tromey  <tromey@adacore.com>
    
    	PR ada/24539:
    	* gdb.ada/vla.exp: Update tests.
    	* gdb.ada/vla/vla.adb (Record_Type): Use No_Component_Reordering
    	pragma.
Comment 6 Tom Tromey 2019-06-14 13:03:14 UTC
Fixed.