[PATCH] ns32k return value cleanup

Jason R Thorpe thorpej@wasabisystems.com
Sun May 26 18:04:00 GMT 2002


...and one other tweak.  Committed per multi-arch rule.

        * ns32k-tdep.c (ns32k_saved_pc_after_call,
        ns32k_store_struct_return, ns32k_extract_return_value,
        ns32k_store_return_value, ns32k_extract_struct_value_address): New
        functions.
        * config/ns32k/tm-umax.h (SAVED_PC_AFTER_CALL): Define as
        ns32k_saved_pc_after_call.
        (STORE_STRUCT_RETURN): Define as ns32k_store_struct_return.
        (EXTRACT_RETURN_VALUE): Define as ns32k_extract_return_value.
        (STORE_RETURN_VALUE): Define as ns32k_store_return_value.
        (EXTRACT_STRUCT_VALUE_ADDRESS): Define as 
        ns32k_extract_struct_value_address.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>
-------------- next part --------------
Index: ns32k-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ns32k-tdep.c,v
retrieving revision 1.11
diff -u -r1.11 ns32k-tdep.c
--- ns32k-tdep.c	26 May 2002 22:27:00 -0000	1.11
+++ ns32k-tdep.c	26 May 2002 22:56:08 -0000
@@ -120,6 +120,17 @@
   return (builtin_type_double);
 }
 
+/* Immediately after a function call, return the saved PC.  Can't
+   always go through the frames for this because on some systems,
+   the new frame is not set up until the new function executes some
+   instructions.  */
+
+CORE_ADDR
+ns32k_saved_pc_after_call (struct frame_info *frame)
+{
+  return (read_memory_integer (read_register (SP_REGNUM), 4));
+}
+
 /* Advance PC across any function entry prologue instructions
    to reach some "real" code.  */
 
@@ -431,6 +442,33 @@
   flipped = - nargs * 4;
   flip_bytes (&flipped, 4);
   store_unsigned_integer (dummy + NS32K_CALL_DUMMY_NARGS, 4, flipped);
+}
+
+void
+ns32k_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
+{
+  /* On this machine, this is a no-op (Encore Umax didn't use GCC).  */
+}
+
+void
+ns32k_extract_return_value (struct type *valtype, char *regbuf, char *valbuf)
+{
+  memcpy (valbuf,
+          regbuf + REGISTER_BYTE (TYPE_CODE (valtype) == TYPE_CODE_FLT ?
+				  FP0_REGNUM : 0), TYPE_LENGTH (valtype));
+}
+
+void
+ns32k_store_return_value (struct type *valtype, char *valbuf)
+{
+  write_register_bytes (TYPE_CODE (valtype) == TYPE_CODE_FLT ?
+			FP0_REGNUM : 0, valbuf, TYPE_LENGTH (valtype));
+}
+
+CORE_ADDR
+ns32k_extract_struct_value_address (char *regbuf)
+{
+  return (extract_address (regbuf + REGISTER_BYTE (0), REGISTER_RAW_SIZE (0)));
 }
 
 void
Index: config/ns32k/tm-umax.h
===================================================================
RCS file: /cvs/src/src/gdb/config/ns32k/tm-umax.h,v
retrieving revision 1.13
diff -u -r1.13 tm-umax.h
--- config/ns32k/tm-umax.h	26 May 2002 22:27:01 -0000	1.13
+++ config/ns32k/tm-umax.h	26 May 2002 22:56:13 -0000
@@ -21,6 +21,9 @@
 
 #include "regcache.h"
 
+struct value;
+struct type;
+
 /* Need to get function ends by adding this to epilogue address from .bf
    record, not using x_fsize field.  */
 #define FUNCTION_EPILOGUE_SIZE 4
@@ -36,13 +39,8 @@
 extern CORE_ADDR umax_skip_prologue (CORE_ADDR);
 #define SKIP_PROLOGUE(pc) (umax_skip_prologue (pc))
 
-/* Immediately after a function call, return the saved pc.
-   Can't always go through the frames for this because on some machines
-   the new frame is not set up until the new function executes
-   some instructions.  */
-
-#define SAVED_PC_AFTER_CALL(frame) \
-	read_memory_integer (read_register (SP_REGNUM), 4)
+CORE_ADDR ns32k_saved_pc_after_call (struct frame_info *);
+#define SAVED_PC_AFTER_CALL(frame) ns32k_saved_pc_after_call ((frame))
 
 /* Address of end of stack space.  */
 
@@ -126,32 +124,21 @@
 struct type *ns32k_register_virtual_type (int);
 #define REGISTER_VIRTUAL_TYPE(N) ns32k_register_virtual_type ((N))
 
-/* Store the address of the place in which to copy the structure the
-   subroutine will return.  This is called from call_function.
-
-   On this machine this is a no-op, because gcc isn't used on it
-   yet.  So this calling convention is not used. */
-
-#define STORE_STRUCT_RETURN(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,
-   into VALBUF.  */
+extern void ns32k_store_struct_return (CORE_ADDR, CORE_ADDR);
+#define STORE_STRUCT_RETURN(ADDR, SP) \
+  ns32k_store_struct_return ((ADDR), (SP))
 
+extern void ns32k_extract_return_value (struct type *, char *, char *);
 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
-  memcpy (VALBUF, REGBUF+REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), TYPE_LENGTH (TYPE))
-
-/* Write into appropriate registers a function return value
-   of type TYPE, given in virtual format.  */
+  ns32k_extract_return_value ((TYPE), (REGBUF), (VALBUF))
 
+extern void ns32k_store_return_value (struct type *, char *);
 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
-  write_register_bytes (REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), VALBUF, TYPE_LENGTH (TYPE))
-
-/* Extract from an array REGBUF containing the (raw) register state
-   the address in which a function should return its structure value,
-   as a CORE_ADDR (or an expression that can be used as one).  */
+  ns32k_store_return_value ((TYPE), (VALBUF))
 
-#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
+extern CORE_ADDR ns32k_extract_struct_value_address (char *);
+#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
+  ns32k_extract_struct_value_address ((REGBUF))
 
 /* Describe the pointer in each stack frame to the previous stack frame
    (its caller).  */
@@ -198,8 +185,6 @@
 
 #define CALL_DUMMY_START_OFFSET	3
 
-struct value;
-struct type;
 extern void ns32k_fix_call_dummy (char *, CORE_ADDR, CORE_ADDR, int,
                                   struct value **, struct type *, int);
 #define FIX_CALL_DUMMY(dummy, pc, fun, nargs, args, type, gcc_p) \


More information about the Gdb-patches mailing list