public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug tdep/31015] [gdb, ppc64le] FAIL: gdb.ada/array_return.exp: value printed by finish of Create_Small_Float_Vector
Date: Thu, 02 Nov 2023 18:04:17 +0000	[thread overview]
Message-ID: <bug-31015-4717-0DCsQPSXDp@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31015-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=31015

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cb9045becc6b76b9d7a257ad7e98d853fe8f7acb

commit cb9045becc6b76b9d7a257ad7e98d853fe8f7acb
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu Nov 2 19:05:21 2023 +0100

    [gdb/tdep] Fix nr array elements in ppc64_aggregate_candidate

    On AlmaLinux 9.2 powerpc64le I run into:
    ...
    (gdb) PASS: gdb.ada/array_return.exp: continuing to
Create_Small_Float_Vector
    finish^M
    Run till exit from #0  pck.create_small_float_vector () at pck.adb:30^M
    0x00000000100022d4 in p () at p.adb:25^M
    25         Vector := Create_Small_Float_Vector;^M
    Value returned is $3 = (2.80259693e-45, 2.80259693e-45)^M
    (gdb) FAIL: gdb.ada/array_return.exp: value printed by finish of
Create_Small_Float_Vector
    ...
    while this is expected:
    ...
    Value returned is $3 = (4.25, 4.25)^M
    ...

    The problem is here in ppc64_aggregate_candidate:
    ...
                      if (!get_array_bounds (type, &low_bound, &high_bound))
                        return -1;
                      count *= high_bound - low_bound
    ...

    The array type (containing 2 elements) is:
    ...
       type Small_Float_Vector is array (1 .. 2) of Float;
    ...
    so we have:
    ...
    (gdb) p low_bound
    $1 = 1
    (gdb) p high_bound
    $2 = 2
    ...
    but we calculate the number of elements in the array using
    "high_bound - low_bound", which is 1.

    Consequently, gdb fails to correctly classify the type as a ELFv2
homogeneous
    aggregate.

    Fix this by calculating the number of elements in the array by using
    "high_bound - low_bound + 1" instead.

    Furthermore, high_bound can (in general, though perhaps not here) also be
    smaller than low_bound, so to be safe take that into account as well:
    ...
              LONGEST nr_array_elements = (low_bound > high_bound
                                           ? 0
                                           : (high_bound - low_bound + 1));
              count *= nr_array_elements;
    ...

    Tested on powerpc64le-linux.

    Approved-By: Ulrich Weigand <uweigand@de.ibm.com>

    PR tdep/31015
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31015

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2023-11-02 18:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31  9:37 [Bug gdb/31015] New: " vries at gcc dot gnu.org
2023-10-31 15:32 ` [Bug gdb/31015] " vries at gcc dot gnu.org
2023-10-31 15:35 ` [Bug tdep/31015] " vries at gcc dot gnu.org
2023-11-01  7:49 ` vries at gcc dot gnu.org
2023-11-02 18:04 ` cvs-commit at gcc dot gnu.org [this message]
2023-11-02 18:07 ` vries at gcc dot gnu.org

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=bug-31015-4717-0DCsQPSXDp@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).