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

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