Blame SOURCES/gdb-testsuite26997-fix-array-slices-m32.patch

4a80f0
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
4a80f0
From: Keith Seitz <keiths@redhat.com>
4a80f0
Date: Thu, 10 Jun 2021 11:08:25 -0700
4a80f0
Subject: gdb-testsuite26997-fix-array-slices-m32.patch
4a80f0
4a80f0
;; Backport "Fix gdb.fortran/array-slices.exp with -m32"
4a80f0
;; (Tom de Vres)
4a80f0
4a80f0
   commit 10f92414d6d4a5f8eb8cbb2bf39ca86c1f9c1da5
4a80f0
   Author: Tom de Vries <tdevries@suse.de>
4a80f0
   Date:   Fri Jan 15 12:14:45 2021 +0100
4a80f0
4a80f0
    [gdb/testsuite] Fix gdb.fortran/array-slices.exp with -m32
4a80f0
4a80f0
    When running test-case gdb.fortran/array-slices.exp with target board
4a80f0
    unix/-m32, we run into:
4a80f0
    ...
4a80f0
    (gdb) print /x &array4d^M
4a80f0
    $69 = 0xffffb620^M
4a80f0
    (gdb) print /x (&array4d) + sizeof (array4d)^M
4a80f0
    $70 = 0x95c620^M
4a80f0
    (gdb) FAIL: gdb.fortran/array-slices.exp: repack=on: test 9: check sizes match
4a80f0
    ...
4a80f0
    The expressions calculate the start and end of an array, but the calculation
4a80f0
    of the end expression has an unexpected result (given that it lies before the
4a80f0
    start of the array).  By printing "sizeof (array4d)" as a separate
4a80f0
    expression:
4a80f0
    ...
4a80f0
    (gdb) print /x sizeof (array4d)
4a80f0
    $1 = 0xc40
4a80f0
    ...
4a80f0
    it becomes clear we expected to get 0xffffb620 + 0xc40 == 0xffffc260 instead.
4a80f0
4a80f0
    The problem is that using the '&' returns a pointer type:
4a80f0
    ...
4a80f0
    (gdb) p &array4d
4a80f0
    $5 = (PTR TO -> ( integer(kind=4) (-3:3,7:10,-3:3,-10:-7) )) 0xffffbe00
4a80f0
    ...
4a80f0
    which has the consequence that the addition is done as pointer arithmetic.
4a80f0
4a80f0
    Fix this by using the result of "print /x &array4d" instead of &array4d in the
4a80f0
    addition.
4a80f0
4a80f0
    Tested on x86_64-linux.
4a80f0
4a80f0
    gdb/testsuite/ChangeLog:
4a80f0
4a80f0
    2021-01-15  Tom de Vries  <tdevries@suse.de>
4a80f0
4a80f0
            PR testsuite/26997
4a80f0
            * gdb.fortran/array-slices.exp (run_test): Avoid pointer arithmetic
4a80f0
            when adding sizeof.
4a80f0
4a80f0
diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
4a80f0
--- a/gdb/testsuite/gdb.fortran/array-slices.exp
4a80f0
+++ b/gdb/testsuite/gdb.fortran/array-slices.exp
4a80f0
@@ -208,8 +208,9 @@ proc run_test { repack } {
4a80f0
 	    set start_addr [get_hexadecimal_valueof "&${full_var_name}" \
4a80f0
 				"start unknown"]
4a80f0
 	    set end_addr [get_hexadecimal_valueof \
4a80f0
-			      "(&${full_var_name}) + sizeof (${full_var_name})" \
4a80f0
-			      "end unknown"]
4a80f0
+			      "$start_addr + sizeof (${full_var_name})" \
4a80f0
+			      "end unknown" \
4a80f0
+			      "get end address of ${full_var_name}"]
4a80f0
 
4a80f0
 	    # The Fortran compiler can choose to either send a descriptor that
4a80f0
 	    # describes the array slice to the subroutine, or it can repack the