[gdb/testsuite] Fix gdb.fortran/array-slices.exp with -m32
authorTom de Vries <tdevries@suse.de>
Fri, 15 Jan 2021 11:14:45 +0000 (12:14 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 15 Jan 2021 11:14:45 +0000 (12:14 +0100)
commit10f92414d6d4a5f8eb8cbb2bf39ca86c1f9c1da5
tree8c3581d9cfbf931a2eebe8d2134dcd98adc767a9
parent4bb5732e27bb43c354f4c55312316604b62a3a0f
[gdb/testsuite] Fix gdb.fortran/array-slices.exp with -m32

When running test-case gdb.fortran/array-slices.exp with target board
unix/-m32, we run into:
...
(gdb) print /x &array4d^M
$69 = 0xffffb620^M
(gdb) print /x (&array4d) + sizeof (array4d)^M
$70 = 0x95c620^M
(gdb) FAIL: gdb.fortran/array-slices.exp: repack=on: test 9: check sizes match
...
The expressions calculate the start and end of an array, but the calculation
of the end expression has an unexpected result (given that it lies before the
start of the array).  By printing "sizeof (array4d)" as a separate
expression:
...
(gdb) print /x sizeof (array4d)
$1 = 0xc40
...
it becomes clear we expected to get 0xffffb620 + 0xc40 == 0xffffc260 instead.

The problem is that using the '&' returns a pointer type:
...
(gdb) p &array4d
$5 = (PTR TO -> ( integer(kind=4) (-3:3,7:10,-3:3,-10:-7) )) 0xffffbe00
...
which has the consequence that the addition is done as pointer arithmetic.

Fix this by using the result of "print /x &array4d" instead of &array4d in the
addition.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-01-15  Tom de Vries  <tdevries@suse.de>

PR testsuite/26997
* gdb.fortran/array-slices.exp (run_test): Avoid pointer arithmetic
when adding sizeof.
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.fortran/array-slices.exp
This page took 0.024452 seconds and 4 git commands to generate.