Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <kettenis@wins.uva.nl>
To: gdb-patches@sources.redhat.com
Subject: [PATCH]: Convert STORE_STRUCT_RETURN to a function for i386.
Date: Mon, 26 Mar 2001 04:22:00 -0000	[thread overview]
Message-ID: <200103261222.f2QCMT103215@delius.kettenis.local> (raw)

When trying to convert the STORE_STRUCT_RETURN in tm-i386.h macro into
a function I discovered that it tried to modify the stack pointer that
gets passed as one of its arguments.  Very naughty, and preventing
turning the macro into a function.  Therefore I moved its
functionality into a newly created i386_push_arguments function.

The attached patch produced no regressions on i586-pc-linux-gnu.  I
cannot check any targets that use the tm-i386v.h header, but I checked
it in nevertheless.

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* i386-tdep.c (i386_push_arguments, i386_store_struct_return): New
	functions.
	* config/i386/tm-i386.h (PUSH_ARGUMENTS): New macro.
	(STORE_STRUCT_RETURN): Redefine in terms of
	i386_store_struct_return.
	(i386_push_arguments, i386_store_struct_return): New prototypes.
	* config/i386/tm-i386v.h (STORE_STRUCT_RETURN): Remove.  It's
	definition was identical to the definition in "i386/tm-i386.h" so
	the new definition should suffice too.

Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.22
diff -u -p -r1.22 i386-tdep.c
--- i386-tdep.c 2001/03/21 11:22:24 1.22
+++ i386-tdep.c 2001/03/26 12:10:20
@@ -694,6 +694,30 @@ get_longjmp_target (CORE_ADDR *pc)
 #endif /* GET_LONGJMP_TARGET */
 \f
 
+CORE_ADDR
+i386_push_arguments (int nargs, value_ptr *args, CORE_ADDR sp,
+		     int struct_return, CORE_ADDR struct_addr)
+{
+  sp = default_push_arguments (nargs, args, sp, struct_return, struct_addr);
+  
+  if (struct_return)
+    {
+      char buf[4];
+
+      sp -= 4;
+      store_address (buf, 4, struct_addr);
+      write_memory (sp, buf, 4);
+    }
+
+  return sp;
+}
+
+void
+i386_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
+{
+  /* Do nothing.  Everything was already done by i386_push_arguments.  */
+}
+
 /* These registers are used for returning integers (and on some
    targets also for returning `struct' and `union' values when their
    size and alignment match an integer type).  */
Index: config/i386/tm-i386.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/tm-i386.h,v
retrieving revision 1.12
diff -u -p -r1.12 tm-i386.h
--- config/i386/tm-i386.h 2001/03/14 23:23:11 1.12
+++ config/i386/tm-i386.h 2001/03/26 12:10:20
@@ -279,16 +279,20 @@ extern void i386_register_convert_to_raw
 extern void i387_float_info (void);
 #define FLOAT_INFO { i387_float_info (); }
 #endif
-
 \f
+
+#define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
+  i386_push_arguments ((nargs), (args), (sp), (struct_return), (struct_addr))
+extern CORE_ADDR i386_push_arguments (int nargs, struct value **args,
+				      CORE_ADDR sp, int struct_return,
+				      CORE_ADDR struct_addr);
+
 /* Store the address of the place in which to copy the structure the
-   subroutine will return.  This is called from call_function. */
+   subroutine will return.  This is called from call_function.  */
 
-#define STORE_STRUCT_RETURN(ADDR, SP) \
-  { char buf[REGISTER_SIZE];	\
-    (SP) -= sizeof (ADDR);	\
-    store_address (buf, sizeof (ADDR), ADDR);	\
-    write_memory ((SP), buf, sizeof (ADDR)); }
+#define STORE_STRUCT_RETURN(addr, sp) \
+  i386_store_struct_return ((addr), (sp))
+extern void i386_store_struct_return (CORE_ADDR addr, CORE_ADDR sp);
 
 /* Extract from an array REGBUF containing the (raw) register state
    a function return value of type TYPE, and copy that, in virtual format,
Index: config/i386/tm-i386v.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/tm-i386v.h,v
retrieving revision 1.4
diff -u -p -r1.4 tm-i386v.h
--- config/i386/tm-i386v.h 2001/03/14 23:23:11 1.4
+++ config/i386/tm-i386v.h 2001/03/26 12:10:20
@@ -34,13 +34,6 @@
 #undef  START_INFERIOR_TRAPS_EXPECTED
 #define START_INFERIOR_TRAPS_EXPECTED 4
 
-#undef  STORE_STRUCT_RETURN
-#define STORE_STRUCT_RETURN(ADDR, SP) \
-  { char buf[REGISTER_SIZE];	\
-    (SP) -= sizeof (ADDR);	\
-    store_address (buf, sizeof (ADDR), ADDR);	\
-    write_memory ((SP), buf, sizeof (ADDR)); }
-
 /* Extract from an array REGBUF containing the (raw) register state
    a function return value of type TYPE, and copy that, in virtual format,
    into VALBUF.  */


                 reply	other threads:[~2001-03-26  4:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200103261222.f2QCMT103215@delius.kettenis.local \
    --to=kettenis@wins.uva.nl \
    --cc=gdb-patches@sources.redhat.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