This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH]: Convert STORE_STRUCT_RETURN to a function for i386.
- To: gdb-patches at sources dot redhat dot com
- Subject: [PATCH]: Convert STORE_STRUCT_RETURN to a function for i386.
- From: Mark Kettenis <kettenis at wins dot uva dot nl>
- Date: Mon, 26 Mar 2001 14:22:29 +0200
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 */
+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
-
+
+#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. */