Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@mips.com>
To: gdb-patches@sourceware.org
Cc: David Ung <davidu@mips.com>, "Maciej W. Rozycki" <macro@linux-mips.org>
Subject: mips-tdep.c: Fix new-ABI handling of composite types
Date: Fri, 21 Sep 2007 15:28:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.61.0709211606200.20543@perivale.mips.com> (raw)

Hello,

 This patch fixes 2 new-ABI regressions in the test suite.  Here's David's 
original comment attached to the change:

 "Currently if structs size is not a multiple of mips_abi_regsize(),
they are put in both places (stack and argument registers).  But
the N32/N64 abi says that the caller does not reserve space for
the register arguments, it's upto the callee to do that.  Doing so
inside gdb would cause the simulated program to incorrectly access
fields of the struct if the size of the struct extends pass the
argument registers onto the stack."

The comment within the change provides a similar explanation.

 Tested for n32 using the mipsisa32-sde-elf target, with the 
mips-sim-sde64/-mips64/-EB and mips-sim-sde64/-mips64/-EL boards removing 
the following failures:

(gdb) FAIL: gdb.base/call-ar-st.exp: print sum_array_print(10, *list1, *list2, *list3, *list4)
(gdb) FAIL: gdb.base/call-rt-st.exp: print print_one_large_struct(*list1)

2007-09-21  David Ung  <davidu@mips.com>
            Maciej W. Rozycki  <macro@mips.com>

	* mips-tdep.c (mips_n32n64_push_dummy_call): Per N32/N64 ABI
	rules do not treat composite types specially.

 OK to apply?

  Maciej

12430.diff
Index: binutils-quilt/src/gdb/mips-tdep.c
===================================================================
--- binutils-quilt.orig/src/gdb/mips-tdep.c	2007-08-28 16:16:55.000000000 +0100
+++ binutils-quilt/src/gdb/mips-tdep.c	2007-08-28 16:53:33.000000000 +0100
@@ -2928,12 +2928,14 @@
 	  /* Copy the argument to general registers or the stack in
 	     register-sized pieces.  Large arguments are split between
 	     registers and stack.  */
-	  /* Note: structs whose size is not a multiple of MIPS64_REGSIZE
-	     are treated specially: Irix cc passes them in registers
-	     where gcc sometimes puts them on the stack.  For maximum
-	     compatibility, we will put them in both places.  */
-	  int odd_sized_struct = (len > MIPS64_REGSIZE
-				  && len % MIPS64_REGSIZE != 0);
+	  /* For N32/N64, structs, unions, or other composite types are
+	     treated as a sequence of doublewords, and are passed in integer
+	     or floating point registers as though they were simple scalar
+	     parameters to the extent that they fit, with any excess on the
+	     stack packed according to the normal memory layout of the
+	     object.
+	     The caller does not reserve space for the register arguments;
+	     the callee is responsible for reserving it if required.  */
 	  /* Note: Floating-point values that didn't fit into an FP
 	     register are only written to memory.  */
 	  while (len > 0)
@@ -2950,8 +2952,7 @@
 		gdb_assert (argreg > MIPS_LAST_ARG_REGNUM);
 
 	      /* Write this portion of the argument to the stack.  */
-	      if (argreg > MIPS_LAST_ARG_REGNUM
-		  || odd_sized_struct)
+	      if (argreg > MIPS_LAST_ARG_REGNUM)
 		{
 		  /* Should shorter than int integer values be
 		     promoted to int before being stored? */


             reply	other threads:[~2007-09-21 15:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-21 15:28 Maciej W. Rozycki [this message]
2007-09-21 15:40 ` Daniel Jacobowitz

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=Pine.LNX.4.61.0709211606200.20543@perivale.mips.com \
    --to=macro@mips.com \
    --cc=davidu@mips.com \
    --cc=gdb-patches@sourceware.org \
    --cc=macro@linux-mips.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