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

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