Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andreas Arnez <arnez@linux.ibm.com>
To: gdb-patches@sourceware.org
Cc: Ulrich Weigand <uweigand@de.ibm.com>
Subject: [PATCH] s390: Fix infcalls passing a single-field struct with static members
Date: Fri, 11 Oct 2019 14:50:00 -0000	[thread overview]
Message-ID: <m3tv8f5oc1.fsf@oc0404454431.ibm.com> (raw)

The infcall-nested-structs test case yields 36 FAILs on s390x because GCC
and GDB disagree on how to pass a C++ struct like this as an argument to a
function:

  struct s { float x; static float y; };

For the purpose of argument passing, GCC ignores static fields, while GDB
does not.  Thus GCC passes the argument in a floating-point register and
GDB passes it via memory.

Fix this by explicitly ignoring static fields when detecting single-field
structs.

gdb/ChangeLog:

	* s390-tdep.c (s390_effective_inner_type): Ignore static fields
	when unwrapping single-field structs.
---
 gdb/s390-tdep.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index e7f1215e1a..6bd0528cf4 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -1637,11 +1637,26 @@ s390_address_class_name_to_type_flags (struct gdbarch *gdbarch,
 static struct type *
 s390_effective_inner_type (struct type *type, unsigned int min_size)
 {
-  while (TYPE_CODE (type) == TYPE_CODE_STRUCT
-	 && TYPE_NFIELDS (type) == 1)
+  while (TYPE_CODE (type) == TYPE_CODE_STRUCT)
     {
-      struct type *inner = check_typedef (TYPE_FIELD_TYPE (type, 0));
+      struct type *inner = NULL;
 
+      /* Find a non-static field, if any.  Unless there's exactly one,
+	 abort the unwrapping.  */
+      for (int i = 0; i < TYPE_NFIELDS (type); i++)
+	{
+	  struct field f = TYPE_FIELD (type, i);
+
+	  if (field_is_static (&f))
+	    continue;
+	  if (inner != NULL)
+	    return type;
+	  inner = FIELD_TYPE (f);
+	}
+
+      if (inner == NULL)
+	break;
+      inner = check_typedef (inner);
       if (TYPE_LENGTH (inner) < min_size)
 	break;
       type = inner;
-- 
2.17.0


             reply	other threads:[~2019-10-11 14:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 14:50 Andreas Arnez [this message]
2019-10-11 17:46 ` Tom Tromey
2019-10-15 12:23   ` Andreas Arnez

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=m3tv8f5oc1.fsf@oc0404454431.ibm.com \
    --to=arnez@linux.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=uweigand@de.ibm.com \
    /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