2004-06-06 Randolph Chung <tausq@debian.org>
[deliverable/binutils-gdb.git] / gdb / m68k-tdep.c
index d0c4f0e15ee983d08dc7fa59f9dbe9099c75af85..0f81d39199f9a221aa6cf91a589598e53bb925a3 100644 (file)
@@ -129,6 +129,62 @@ m68k_register_name (int regnum)
   else
     return register_names[regnum];
 }
+\f
+/* Return nonzero if a value of type TYPE stored in register REGNUM
+   needs any special handling.  */
+
+static int
+m68k_convert_register_p (int regnum, struct type *type)
+{
+  return (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FP0_REGNUM + 7);
+}
+
+/* Read a value of type TYPE from register REGNUM in frame FRAME, and
+   return its contents in TO.  */
+
+static void
+m68k_register_to_value (struct frame_info *frame, int regnum,
+                       struct type *type, void *to)
+{
+  char from[M68K_MAX_REGISTER_SIZE];
+
+  /* We only support floating-point values.  */
+  if (TYPE_CODE (type) != TYPE_CODE_FLT)
+    {
+      warning ("Cannot convert floating-point register value "
+              "to non-floating-point type.");
+      return;
+    }
+
+  /* Convert to TYPE.  This should be a no-op if TYPE is equivalent to
+     the extended floating-point format used by the FPU.  */
+  get_frame_register (frame, regnum, from);
+  convert_typed_floating (from, builtin_type_m68881_ext, to, type);
+}
+
+/* Write the contents FROM of a value of type TYPE into register
+   REGNUM in frame FRAME.  */
+
+static void
+m68k_value_to_register (struct frame_info *frame, int regnum,
+                       struct type *type, const void *from)
+{
+  char to[M68K_MAX_REGISTER_SIZE];
+
+  /* We only support floating-point values.  */
+  if (TYPE_CODE (type) != TYPE_CODE_FLT)
+    {
+      warning ("Cannot convert non-floating-point type "
+              "to floating-point register value.");
+      return;
+    }
+
+  /* Convert from TYPE.  This should be a no-op if TYPE is equivalent
+     to the extended floating-point format used by the FPU.  */
+  convert_typed_floating (from, type, to, builtin_type_m68881_ext);
+  put_frame_register (frame, regnum, to);
+}
+
 \f
 /* There is a fair number of calling conventions that are in somewhat
    wide use.  The 68000/08/10 don't support an FPU, not even as a
@@ -304,7 +360,27 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct type *type,
 
   if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
       && !m68k_reg_struct_return_p (gdbarch, type))
-    return RETURN_VALUE_STRUCT_CONVENTION;
+    {
+      /* The System V ABI says that:
+
+        "A function returning a structure or union also sets %a0 to
+        the value it finds in %a0.  Thus when the caller receives
+        control again, the address of the returned object resides in
+        register %a0."
+
+        So the ABI guarantees that we can always find the return
+        value just after the function has returned.  */
+
+      if (readbuf)
+       {
+         ULONGEST addr;
+
+         regcache_raw_read_unsigned (regcache, M68K_A0_REGNUM, &addr);
+         read_memory (addr, readbuf, TYPE_LENGTH (type));
+       }
+
+      return RETURN_VALUE_ABI_RETURNS_ADDRESS;
+    }
 
   /* This special case is for structures consisting of a single
      `float' or `double' member.  These structures are returned in
@@ -328,78 +404,8 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct type *type,
 }
 \f
 
-/* A function that tells us whether the function invocation represented
-   by fi does not have a frame on the stack associated with it.  If it
-   does not, FRAMELESS is set to 1, else 0.  */
-
-static int
-m68k_frameless_function_invocation (struct frame_info *fi)
-{
-  if (get_frame_type (fi) == SIGTRAMP_FRAME)
-    return 0;
-  else
-    return legacy_frameless_look_for_prologue (fi);
-}
-
-int
-delta68_in_sigtramp (CORE_ADDR pc, char *name)
-{
-  if (name != NULL)
-    return strcmp (name, "_sigcode") == 0;
-  else
-    return 0;
-}
-
-CORE_ADDR
-delta68_frame_args_address (struct frame_info *frame_info)
-{
-  /* we assume here that the only frameless functions are the system calls
-     or other functions who do not put anything on the stack. */
-  if (get_frame_type (frame_info) == SIGTRAMP_FRAME)
-    return get_frame_base (frame_info) + 12;
-  else if (legacy_frameless_look_for_prologue (frame_info))
-    {
-      /* Check for an interrupted system call */
-      if (get_next_frame (frame_info) && (get_frame_type (get_next_frame (frame_info)) == SIGTRAMP_FRAME))
-       return get_frame_base (get_next_frame (frame_info)) + 16;
-      else
-       return get_frame_base (frame_info) + 4;
-    }
-  else
-    return get_frame_base (frame_info);
-}
-
-CORE_ADDR
-delta68_frame_saved_pc (struct frame_info *frame_info)
-{
-  return read_memory_unsigned_integer (delta68_frame_args_address (frame_info)
-                                      + 4, 4);
-}
-
-int
-delta68_frame_num_args (struct frame_info *fi)
-{
-  int val;
-  CORE_ADDR pc = DEPRECATED_FRAME_SAVED_PC (fi);
-  int insn = read_memory_unsigned_integer (pc, 2);
-  val = 0;
-  if (insn == 0047757 || insn == 0157374)      /* lea W(sp),sp or addaw #W,sp */
-    val = read_memory_integer (pc + 2, 2);
-  else if ((insn & 0170777) == 0050217 /* addql #N, sp */
-          || (insn & 0170777) == 0050117)      /* addqw */
-    {
-      val = (insn >> 9) & 7;
-      if (val == 0)
-       val = 8;
-    }
-  else if (insn == 0157774)    /* addal #WW, sp */
-    val = read_memory_integer (pc + 2, 4);
-  val >>= 2;
-  return val;
-}
-
 static CORE_ADDR
-m68k_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
                      struct value **args, CORE_ADDR sp, int struct_return,
                      CORE_ADDR struct_addr)
@@ -1107,12 +1113,10 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* Stack grows down. */
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
-  set_gdbarch_parm_boundary (gdbarch, 32);
 
   set_gdbarch_believe_pcc_promotion (gdbarch, 1);
   set_gdbarch_decr_pc_after_break (gdbarch, 2);
 
-  set_gdbarch_deprecated_frameless_function_invocation (gdbarch, m68k_frameless_function_invocation);
   set_gdbarch_frame_args_skip (gdbarch, 8);
 
   set_gdbarch_register_type (gdbarch, m68k_register_type);
@@ -1123,6 +1127,9 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_pc_regnum (gdbarch, M68K_PC_REGNUM);
   set_gdbarch_ps_regnum (gdbarch, M68K_PS_REGNUM);
   set_gdbarch_fp0_regnum (gdbarch, M68K_FP0_REGNUM);
+  set_gdbarch_convert_register_p (gdbarch, m68k_convert_register_p);
+  set_gdbarch_register_to_value (gdbarch,  m68k_register_to_value);
+  set_gdbarch_value_to_register (gdbarch, m68k_value_to_register);
 
   set_gdbarch_push_dummy_call (gdbarch, m68k_push_dummy_call);
   set_gdbarch_return_value (gdbarch, m68k_return_value);
@@ -1137,7 +1144,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep->jb_pc = -1;
 #endif
   tdep->struct_value_regnum = M68K_A1_REGNUM;
-  tdep->struct_return = pcc_struct_return;
+  tdep->struct_return = reg_struct_return;
 
   /* Frame unwinder.  */
   set_gdbarch_unwind_dummy_id (gdbarch, m68k_unwind_dummy_id);
This page took 0.028063 seconds and 4 git commands to generate.