From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Tom de Vries <tdevries@suse.de>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb/testsuite] Fix gdb.fortran/array-slices.exp with -m32
Date: Fri, 15 Jan 2021 10:26:45 +0000 [thread overview]
Message-ID: <20210115102645.GI265215@embecosm.com> (raw)
In-Reply-To: <20210115100322.GA3283@delia>
* Tom de Vries <tdevries@suse.de> [2021-01-15 11:03:23 +0100]:
> Hi,
>
> 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.
>
> Any comments?
>
> Thanks,
> - Tom
>
> [gdb/testsuite] Fix gdb.fortran/array-slices.exp with -m32
>
> 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.
LGTM.
Thanks,
Andrew
>
> ---
> gdb/testsuite/gdb.fortran/array-slices.exp | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
> index f45a299b268..45753d9baea 100644
> --- a/gdb/testsuite/gdb.fortran/array-slices.exp
> +++ b/gdb/testsuite/gdb.fortran/array-slices.exp
> @@ -208,7 +208,7 @@ proc run_test { repack } {
> set start_addr [get_hexadecimal_valueof "&${full_var_name}" \
> "start unknown"]
> set end_addr [get_hexadecimal_valueof \
> - "(&${full_var_name}) + sizeof (${full_var_name})" \
> + "$start_addr + sizeof (${full_var_name})" \
> "end unknown"]
>
> # The Fortran compiler can choose to either send a descriptor that
prev parent reply other threads:[~2021-01-15 10:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-15 10:03 Tom de Vries
2021-01-15 10:26 ` Andrew Burgess [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210115102645.GI265215@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=tdevries@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox