public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug tdep/29247] [gdb, tdep] ../../gdb/ppc-sysv-tdep.c:1945: internal-error: ppc64_sysv_abi_return_value: Assertion `ok' failed
Date: Tue, 14 Jun 2022 14:51:31 +0000	[thread overview]
Message-ID: <bug-29247-4717-Drh9xXiCHi@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-29247-4717@http.sourceware.org/bugzilla/>

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kevinb at sourceware dot org

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
I had problems reproducing this, so I write an all-arch selftest:
...
diff --git a/gdb/gdbarch-selftests.c b/gdb/gdbarch-selftests.c
index 198346bddec..8b6b4c708ab 100644
--- a/gdb/gdbarch-selftests.c
+++ b/gdb/gdbarch-selftests.c
@@ -122,6 +122,19 @@ register_to_value_test (struct gdbarch *gdbarch)
     }
 }

+static void
+blabla (struct gdbarch *gdbarch)
+{
+  struct type *t = builtin_type (gdbarch)->builtin_long_double;
+  struct type *c = init_complex_type ("complex long double", t);
+  struct type *f = lookup_function_type (c);
+  struct value *v
+    = allocate_value_lazy (f);
+
+  gdbarch_return_value (gdbarch, v, c, nullptr, nullptr, nullptr);
+}
+
 } // namespace selftests

 void _initialize_gdbarch_selftests ();
@@ -130,4 +143,6 @@ _initialize_gdbarch_selftests ()
 {
   selftests::register_test_foreach_arch ("register_to_value",
                                         selftests::register_to_value_test);
+  selftests::register_test_foreach_arch ("blabla",
+                                        selftests::blabla);
 }
...

And then downgraded the ok asserts in ppc64_sysv_abi_return_value to errors,
which can be caught:
...
diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
index 6c2fd1bfc99..c0bfd8bcbbd 100644
--- a/gdb/ppc-sysv-tdep.c
+++ b/gdb/ppc-sysv-tdep.c
@@ -1942,7 +1942,9 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch
, struct value *function,
        {
          ok = ppc64_sysv_abi_return_value_base (gdbarch, eltype, regcache,
                                                 readbuf, writebuf, i);
-         gdb_assert (ok);
+         if (!ok)
+           error ("ppc64_sysv_abi_return_value problem");
+

          if (readbuf)
            readbuf += TYPE_LENGTH (eltype);
@@ -1968,7 +1970,8 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch
, struct value *function,
        {
          ok = ppc64_sysv_abi_return_value_base (gdbarch, eltype, regcache,
                                                 readbuf, writebuf, i);
-         gdb_assert (ok);
+         if (!ok)
+           error ("ppc64_sysv_abi_return_value problem");

          if (readbuf)
            readbuf += TYPE_LENGTH (eltype);
@@ -2024,7 +2027,8 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch
, struct value *function,
        {
          ok = ppc64_sysv_abi_return_value_base (gdbarch, eltype, regcache,
                                                 readbuf, writebuf, i);
-         gdb_assert (ok);
+         if (!ok)
+           error ("ppc64_sysv_abi_return_value problem");

          if (readbuf)
            readbuf += TYPE_LENGTH (eltype);
...

I get fails only for the powerpc architecture:
...
$ ./gdb.sh -q -batch -ex "maint selftest blabla" 2>&1 | grep -B1 failed
Running selftest blabla::powerpc:620.
Self test failed: ppc64_sysv_abi_return_value problem
Running selftest blabla::powerpc:630.
Self test failed: ppc64_sysv_abi_return_value problem
--
Running selftest blabla::powerpc:a35.
Self test failed: ppc64_sysv_abi_return_value problem
--
Running selftest blabla::powerpc:common64.
Self test failed: ppc64_sysv_abi_return_value problem
--
Running selftest blabla::powerpc:rs64ii.
Self test failed: ppc64_sysv_abi_return_value problem
Running selftest blabla::powerpc:rs64iii.
Self test failed: ppc64_sysv_abi_return_value problem
--
Running selftest blabla::z80n.
Ran 355 unit tests, 6 failed
...

By debugging and comparing with a passing instance, I narrowed down the
difference to:
...
  /* IBM long double stored in two consecutive FPRs.  */
  if (TYPE_LENGTH (valtype) == 16
      && valtype->code () == TYPE_CODE_FLT
      && (gdbarch_long_double_format (gdbarch)
          == floatformats_ibm_long_double))
    {
...
which is triggered in the passing case, but for the selftest fails because:
...
(gdb) p gdbarch_long_double_format (gdbarch)
$2 = (const floatformat **) 0x2707860 <floatformats_ieee_double>
...
and then no other case triggers.

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

  reply	other threads:[~2022-06-14 14:51 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-14  8:58 [Bug tdep/29247] New: " vries at gcc dot gnu.org
2022-06-14 14:51 ` vries at gcc dot gnu.org [this message]
2022-06-15 11:59 ` [Bug tdep/29247] " vries at gcc dot gnu.org
2022-06-15 13:27 ` vries at gcc dot gnu.org
2022-06-15 14:47 ` vries at gcc dot gnu.org
2022-06-15 14:51 ` vries at gcc dot gnu.org
2022-06-15 15:49 ` vries at gcc dot gnu.org
2022-06-15 15:59 ` vries at gcc dot gnu.org
2022-06-15 22:47 ` vries at gcc dot gnu.org
2022-06-16 13:53 ` jamborm at gcc dot gnu.org
2022-06-20 12:25 ` ulrich.weigand at de dot ibm.com
2022-06-21 16:32 ` cel at us dot ibm.com
2022-06-23 15:19 ` cel at us dot ibm.com
2022-06-23 15:22 ` cel at us dot ibm.com
2022-06-23 15:30 ` ulrich.weigand at de dot ibm.com
2022-06-23 19:56 ` cel at us dot ibm.com
2022-06-24  0:53 ` cel at us dot ibm.com
2022-06-24 11:53 ` ulrich.weigand at de dot ibm.com
2022-06-25  0:42 ` cel at us dot ibm.com
2022-06-25  2:51 ` ulrich.weigand at de dot ibm.com
2022-06-30 22:47 ` cel at us dot ibm.com
2022-07-12  9:15 ` ulrich.weigand at de dot ibm.com
2022-07-13 17:46 ` cel at us dot ibm.com
2022-07-15 15:32 ` cel at us dot ibm.com
2022-07-15 16:09 ` cel at us dot ibm.com
2022-07-27  8:45 ` vries at gcc dot gnu.org
2022-07-27 15:38 ` cel at us dot ibm.com
2022-07-27 15:42 ` vries at gcc dot gnu.org
2022-07-27 16:54 ` cel at us dot ibm.com
2022-09-02 12:55 ` vries at gcc dot gnu.org
2022-09-02 13:09 ` 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-29247-4717-Drh9xXiCHi@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).