* elf64-sparc.c (sparc64_elf_relocate_section): Ignore overflows
[deliverable/binutils-gdb.git] / gdb / m68k-tdep.c
index d860cfb8ebcaada857481e8ab361795ccc1ea362..cb2bb10adc8d2cb812a95782a807630fa837ab2c 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
@@ -329,7 +405,7 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct type *type,
 \f
 
 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)
@@ -786,8 +862,12 @@ m68k_frame_prev_register (struct frame_info *next_frame, void **this_cache,
       return;
     }
 
-  frame_register_unwind (next_frame, regnum,
-                        optimizedp, lvalp, addrp, realnump, valuep);
+  *optimizedp = 0;
+  *lvalp = lval_register;
+  *addrp = 0;
+  *realnump = regnum;
+  if (valuep)
+    frame_unwind_register (next_frame, (*realnump), valuep);
 }
 
 static const struct frame_unwind m68k_frame_unwind =
@@ -887,10 +967,10 @@ supply_gregset (gregset_t *gregsetp)
 
   for (regi = 0; regi < R_PC; regi++)
     {
-      supply_register (regi, (char *) (regp + regi));
+      regcache_raw_supply (current_regcache, regi, (char *) (regp + regi));
     }
-  supply_register (PS_REGNUM, (char *) (regp + R_PS));
-  supply_register (PC_REGNUM, (char *) (regp + R_PC));
+  regcache_raw_supply (current_regcache, PS_REGNUM, (char *) (regp + R_PS));
+  regcache_raw_supply (current_regcache, PC_REGNUM, (char *) (regp + R_PC));
 }
 
 void
@@ -902,12 +982,12 @@ fill_gregset (gregset_t *gregsetp, int regno)
   for (regi = 0; regi < R_PC; regi++)
     {
       if (regno == -1 || regno == regi)
-       regcache_collect (regi, regp + regi);
+       regcache_raw_collect (current_regcache, regi, regp + regi);
     }
   if (regno == -1 || regno == PS_REGNUM)
-    regcache_collect (PS_REGNUM, regp + R_PS);
+    regcache_raw_collect (current_regcache, PS_REGNUM, regp + R_PS);
   if (regno == -1 || regno == PC_REGNUM)
-    regcache_collect (PC_REGNUM, regp + R_PC);
+    regcache_raw_collect (current_regcache, PC_REGNUM, regp + R_PC);
 }
 
 #if defined (FP0_REGNUM)
@@ -925,11 +1005,14 @@ supply_fpregset (fpregset_t *fpregsetp)
   for (regi = FP0_REGNUM; regi < M68K_FPC_REGNUM; regi++)
     {
       from = (char *) &(fpregsetp->f_fpregs[regi - FP0_REGNUM][0]);
-      supply_register (regi, from);
+      regcache_raw_supply (current_regcache, regi, from);
     }
-  supply_register (M68K_FPC_REGNUM, (char *) &(fpregsetp->f_pcr));
-  supply_register (M68K_FPS_REGNUM, (char *) &(fpregsetp->f_psr));
-  supply_register (M68K_FPI_REGNUM, (char *) &(fpregsetp->f_fpiaddr));
+  regcache_raw_supply (current_regcache, M68K_FPC_REGNUM,
+                      (char *) &(fpregsetp->f_pcr));
+  regcache_raw_supply (current_regcache, M68K_FPS_REGNUM,
+                      (char *) &(fpregsetp->f_psr));
+  regcache_raw_supply (current_regcache, M68K_FPI_REGNUM,
+                      (char *) &(fpregsetp->f_fpiaddr));
 }
 
 /*  Given a pointer to a floating point register set in /proc format
@@ -945,14 +1028,18 @@ fill_fpregset (fpregset_t *fpregsetp, int regno)
   for (regi = FP0_REGNUM; regi < M68K_FPC_REGNUM; regi++)
     {
       if (regno == -1 || regno == regi)
-       regcache_collect (regi, &fpregsetp->f_fpregs[regi - FP0_REGNUM][0]);
+       regcache_raw_collect (current_regcache, regi,
+                             &fpregsetp->f_fpregs[regi - FP0_REGNUM][0]);
     }
   if (regno == -1 || regno == M68K_FPC_REGNUM)
-    regcache_collect (M68K_FPC_REGNUM, &fpregsetp->f_pcr);
+    regcache_raw_collect (current_regcache, M68K_FPC_REGNUM,
+                         &fpregsetp->f_pcr);
   if (regno == -1 || regno == M68K_FPS_REGNUM)
-    regcache_collect (M68K_FPS_REGNUM, &fpregsetp->f_psr);
+    regcache_raw_collect (current_regcache, M68K_FPS_REGNUM,
+                         &fpregsetp->f_psr);
   if (regno == -1 || regno == M68K_FPI_REGNUM)
-    regcache_collect (M68K_FPI_REGNUM, &fpregsetp->f_fpiaddr);
+    regcache_raw_collect (current_regcache, M68K_FPI_REGNUM,
+                         &fpregsetp->f_fpiaddr);
 }
 
 #endif /* defined (FP0_REGNUM) */
@@ -964,7 +1051,7 @@ fill_fpregset (fpregset_t *fpregsetp, int regno)
    we extract the pc (JB_PC) that we will land at.  The pc is copied into PC.
    This routine returns true on success. */
 
-int
+static int
 m68k_get_longjmp_target (CORE_ADDR *pc)
 {
   char *buf;
@@ -1051,6 +1138,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);
This page took 0.032116 seconds and 4 git commands to generate.