gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdb / sh-tdep.c
index 7f1519158a55ca2bc63a32cb71cb4cc15ee2f85a..f134cf1c917c73b9fd272500e5c61eacceb91935 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for Renesas Super-H, for GDB.
 
-   Copyright (C) 1993-2005, 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 1993-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -24,7 +24,7 @@
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
-#include "dwarf2-frame.h"
+#include "dwarf2/frame.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "gdbcmd.h"
 #include "value.h"
 #include "dis-asm.h"
 #include "inferior.h"
-#include "gdb_string.h"
-#include "gdb_assert.h"
 #include "arch-utils.h"
-#include "floatformat.h"
 #include "regcache.h"
-#include "doublest.h"
+#include "target-float.h"
 #include "osabi.h"
 #include "reggroups.h"
 #include "regset.h"
 #include "objfiles.h"
 
 #include "sh-tdep.h"
-#include "sh64-tdep.h"
 
 #include "elf-bfd.h"
 #include "solib-svr4.h"
@@ -54,6 +50,7 @@
 #include "dwarf2.h"
 /* registers numbers shared with the simulator.  */
 #include "gdb/sim-sh.h"
+#include <algorithm>
 
 /* List of "set sh ..." and "show sh ..." commands.  */
 static struct cmd_list_element *setshcmdlist = NULL;
@@ -69,8 +66,6 @@ static const char *const sh_cc_enum[] = {
 
 static const char *sh_active_calling_convention = sh_cc_gcc;
 
-static void (*sh_show_regs) (struct frame_info *);
-
 #define SH_NUM_REGS 67
 
 struct sh_frame_cache
@@ -97,10 +92,10 @@ sh_is_renesas_calling_convention (struct type *func_type)
     {
       func_type = check_typedef (func_type);
 
-      if (TYPE_CODE (func_type) == TYPE_CODE_PTR)
+      if (func_type->code () == TYPE_CODE_PTR)
         func_type = check_typedef (TYPE_TARGET_TYPE (func_type));
 
-      if (TYPE_CODE (func_type) == TYPE_CODE_FUNC
+      if (func_type->code () == TYPE_CODE_FUNC
           && TYPE_CALLING_CONVENTION (func_type) == DW_CC_GNU_renesas_sh)
         val = 1;
     }
@@ -114,7 +109,7 @@ sh_is_renesas_calling_convention (struct type *func_type)
 static const char *
 sh_sh_register_name (struct gdbarch *gdbarch, int reg_nr)
 {
-  static char *register_names[] = {
+  static const char *register_names[] = {
     "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
     "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
     "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
@@ -136,7 +131,7 @@ sh_sh_register_name (struct gdbarch *gdbarch, int reg_nr)
 static const char *
 sh_sh3_register_name (struct gdbarch *gdbarch, int reg_nr)
 {
-  static char *register_names[] = {
+  static const char *register_names[] = {
     "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
     "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
     "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
@@ -158,7 +153,7 @@ sh_sh3_register_name (struct gdbarch *gdbarch, int reg_nr)
 static const char *
 sh_sh3e_register_name (struct gdbarch *gdbarch, int reg_nr)
 {
-  static char *register_names[] = {
+  static const char *register_names[] = {
     "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
     "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
     "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
@@ -180,7 +175,7 @@ sh_sh3e_register_name (struct gdbarch *gdbarch, int reg_nr)
 static const char *
 sh_sh2e_register_name (struct gdbarch *gdbarch, int reg_nr)
 {
-  static char *register_names[] = {
+  static const char *register_names[] = {
     "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
     "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
     "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
@@ -202,7 +197,7 @@ sh_sh2e_register_name (struct gdbarch *gdbarch, int reg_nr)
 static const char *
 sh_sh2a_register_name (struct gdbarch *gdbarch, int reg_nr)
 {
-  static char *register_names[] = {
+  static const char *register_names[] = {
     /* general registers 0-15 */
     "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
     "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
@@ -242,7 +237,7 @@ sh_sh2a_register_name (struct gdbarch *gdbarch, int reg_nr)
 static const char *
 sh_sh2a_nofpu_register_name (struct gdbarch *gdbarch, int reg_nr)
 {
-  static char *register_names[] = {
+  static const char *register_names[] = {
     /* general registers 0-15 */
     "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
     "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
@@ -282,7 +277,7 @@ sh_sh2a_nofpu_register_name (struct gdbarch *gdbarch, int reg_nr)
 static const char *
 sh_sh_dsp_register_name (struct gdbarch *gdbarch, int reg_nr)
 {
-  static char *register_names[] = {
+  static const char *register_names[] = {
     "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
     "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
     "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
@@ -304,7 +299,7 @@ sh_sh_dsp_register_name (struct gdbarch *gdbarch, int reg_nr)
 static const char *
 sh_sh3_dsp_register_name (struct gdbarch *gdbarch, int reg_nr)
 {
-  static char *register_names[] = {
+  static const char *register_names[] = {
     "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
     "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
     "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
@@ -327,7 +322,7 @@ sh_sh3_dsp_register_name (struct gdbarch *gdbarch, int reg_nr)
 static const char *
 sh_sh4_register_name (struct gdbarch *gdbarch, int reg_nr)
 {
-  static char *register_names[] = {
+  static const char *register_names[] = {
     /* general registers 0-15 */
     "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
     "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
@@ -344,15 +339,16 @@ sh_sh4_register_name (struct gdbarch *gdbarch, int reg_nr)
     "r0b0", "r1b0", "r2b0", "r3b0", "r4b0", "r5b0", "r6b0", "r7b0",
     /* bank 1 51 - 58 */
     "r0b1", "r1b1", "r2b1", "r3b1", "r4b1", "r5b1", "r6b1", "r7b1",
+    /* 59 - 66 */
     "", "", "", "", "", "", "", "",
     /* pseudo bank register.  */
     "",
-    /* double precision (pseudo) 59 - 66 */
+    /* double precision (pseudo) 68 - 75 */
     "dr0", "dr2", "dr4", "dr6", "dr8", "dr10", "dr12", "dr14",
-    /* vectors (pseudo) 67 - 70 */
+    /* vectors (pseudo) 76 - 79 */
     "fv0", "fv4", "fv8", "fv12",
-    /* FIXME: missing XF 71 - 86 */
-    /* FIXME: missing XD 87 - 94 */
+    /* FIXME: missing XF */
+    /* FIXME: missing XD */
   };
   if (reg_nr < 0)
     return NULL;
@@ -364,7 +360,7 @@ sh_sh4_register_name (struct gdbarch *gdbarch, int reg_nr)
 static const char *
 sh_sh4_nofpu_register_name (struct gdbarch *gdbarch, int reg_nr)
 {
-  static char *register_names[] = {
+  static const char *register_names[] = {
     /* general registers 0-15 */
     "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
     "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
@@ -381,12 +377,13 @@ sh_sh4_nofpu_register_name (struct gdbarch *gdbarch, int reg_nr)
     "r0b0", "r1b0", "r2b0", "r3b0", "r4b0", "r5b0", "r6b0", "r7b0",
     /* bank 1 51 - 58 */
     "r0b1", "r1b1", "r2b1", "r3b1", "r4b1", "r5b1", "r6b1", "r7b1",
+    /* 59 - 66 */
     "", "", "", "", "", "", "", "",
     /* pseudo bank register.  */
     "",
-    /* double precision (pseudo) 59 - 66 -- not for nofpu target */
+    /* double precision (pseudo) 68 - 75 -- not for nofpu target */
     "", "", "", "", "", "", "", "",
-    /* vectors (pseudo) 67 - 70 -- not for nofpu target */
+    /* vectors (pseudo) 76 - 79 -- not for nofpu target */
     "", "", "", "",
   };
   if (reg_nr < 0)
@@ -399,7 +396,7 @@ sh_sh4_nofpu_register_name (struct gdbarch *gdbarch, int reg_nr)
 static const char *
 sh_sh4al_dsp_register_name (struct gdbarch *gdbarch, int reg_nr)
 {
-  static char *register_names[] = {
+  static const char *register_names[] = {
     "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
     "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
     "pc", "pr", "gbr", "vbr", "mach", "macl", "sr",
@@ -419,11 +416,20 @@ sh_sh4al_dsp_register_name (struct gdbarch *gdbarch, int reg_nr)
   return register_names[reg_nr];
 }
 
-static const unsigned char *
-sh_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
+static int
+sh_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
-  /* 0xc3c3 is trapa #c3, and it works in big and little endian modes.  */
-  static unsigned char breakpoint[] = { 0xc3, 0xc3 };
+  return 2;
+}
+
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
+static const gdb_byte *
+sh_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
+{
+  *size = kind;
 
   /* For remote stub targets, trapa #20 is used.  */
   if (strcmp (target_shortname, "remote") == 0)
@@ -432,19 +438,18 @@ sh_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
       static unsigned char little_remote_breakpoint[] = { 0x20, 0xc3 };
 
       if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
-       {
-         *lenptr = sizeof (big_remote_breakpoint);
-         return big_remote_breakpoint;
-       }
+       return big_remote_breakpoint;
       else
-       {
-         *lenptr = sizeof (little_remote_breakpoint);
-         return little_remote_breakpoint;
-       }
+       return little_remote_breakpoint;
     }
+  else
+    {
+      /* 0xc3c3 is trapa #c3, and it works in big and little endian
+        modes.  */
+      static unsigned char breakpoint[] = { 0xc3, 0xc3 };
 
-  *lenptr = sizeof (breakpoint);
-  return breakpoint;
+      return breakpoint;
+    }
 }
 
 /* Prologue looks like
@@ -656,7 +661,7 @@ sh_analyze_prologue (struct gdbarch *gdbarch,
        {
          pc += 2;
          /* Don't go any further than six more instructions.  */
-         limit_pc = min (limit_pc, pc + (2 * 6));
+         limit_pc = std::min (limit_pc, pc + (2 * 6));
 
          cache->uses_fp = 1;
          /* At this point, only allow argument register moves to other
@@ -730,7 +735,7 @@ sh_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
     {
       post_prologue_pc = skip_prologue_using_sal (gdbarch, func_addr);
       if (post_prologue_pc != 0)
-        return max (pc, post_prologue_pc);
+        return std::max (pc, post_prologue_pc);
     }
 
   /* Can't determine prologue from the symbol table, need to examine
@@ -747,7 +752,7 @@ sh_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
   /* Do not allow limit_pc to be past the function end, if we know
      where that end is...  */
   if (func_end_addr != 0)
-    limit_pc = min (limit_pc, func_end_addr);
+    limit_pc = std::min (limit_pc, func_end_addr);
 
   cache.sp_offset = -4;
   post_prologue_pc = sh_analyze_prologue (gdbarch, pc, limit_pc, &cache, 0);
@@ -808,11 +813,11 @@ static int
 sh_use_struct_convention (int renesas_abi, struct type *type)
 {
   int len = TYPE_LENGTH (type);
-  int nelem = TYPE_NFIELDS (type);
+  int nelem = type->num_fields ();
 
   /* The Renesas ABI returns aggregate types always on stack.  */
-  if (renesas_abi && (TYPE_CODE (type) == TYPE_CODE_STRUCT
-                     || TYPE_CODE (type) == TYPE_CODE_UNION))
+  if (renesas_abi && (type->code () == TYPE_CODE_STRUCT
+                     || type->code () == TYPE_CODE_UNION))
     return 1;
 
   /* Non-power of 2 length types and types bigger than 8 bytes (which don't
@@ -844,7 +849,7 @@ static int
 sh_use_struct_convention_nofpu (int renesas_abi, struct type *type)
 {
   /* The Renesas ABI returns long longs/doubles etc. always on stack.  */
-  if (renesas_abi && TYPE_NFIELDS (type) == 0 && TYPE_LENGTH (type) >= 8)
+  if (renesas_abi && type->num_fields () == 0 && TYPE_LENGTH (type) >= 8)
     return 1;
   return sh_use_struct_convention (renesas_abi, type);
 }
@@ -907,23 +912,23 @@ sh_frame_align (struct gdbarch *ignore, CORE_ADDR sp)
    not displace any of the other arguments passed in via registers R4
    to R7.  */
 
-/* Helper function to justify value in register according to endianess.  */
-static char *
+/* Helper function to justify value in register according to endianness.  */
+static const gdb_byte *
 sh_justify_value_in_reg (struct gdbarch *gdbarch, struct value *val, int len)
 {
-  static char valbuf[4];
+  static gdb_byte valbuf[4];
 
   memset (valbuf, 0, sizeof (valbuf));
   if (len < 4)
     {
       /* value gets right-justified in the register or stack word.  */
       if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
-       memcpy (valbuf + (4 - len), (char *) value_contents (val), len);
+       memcpy (valbuf + (4 - len), value_contents (val), len);
       else
-       memcpy (valbuf, (char *) value_contents (val), len);
+       memcpy (valbuf, value_contents (val), len);
       return valbuf;
     }
-  return (char *) value_contents (val);
+  return value_contents (val);
 }
 
 /* Helper function to eval number of bytes to allocate on stack.  */
@@ -937,7 +942,7 @@ sh_stack_allocsize (int nargs, struct value **args)
 }
 
 /* Helper functions for getting the float arguments right.  Registers usage
-   depends on the ABI and the endianess.  The comments should enlighten how
+   depends on the ABI and the endianness.  The comments should enlighten how
    it's intended to work.  */
 
 /* This array stores which of the float arg registers are already in use.  */
@@ -1034,20 +1039,18 @@ sh_next_flt_argreg (struct gdbarch *gdbarch, int len, struct type *func_type)
 static int
 sh_treat_as_flt_p (struct type *type)
 {
-  int len = TYPE_LENGTH (type);
-
   /* Ordinary float types are obviously treated as float.  */
-  if (TYPE_CODE (type) == TYPE_CODE_FLT)
+  if (type->code () == TYPE_CODE_FLT)
     return 1;
   /* Otherwise non-struct types are not treated as float.  */
-  if (TYPE_CODE (type) != TYPE_CODE_STRUCT)
+  if (type->code () != TYPE_CODE_STRUCT)
     return 0;
-  /* Otherwise structs with more than one memeber are not treated as float.  */
-  if (TYPE_NFIELDS (type) != 1)
+  /* Otherwise structs with more than one member are not treated as float.  */
+  if (type->num_fields () != 1)
     return 0;
   /* Otherwise if the type of that member is float, the whole type is
      treated as float.  */
-  if (TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_FLT)
+  if (TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_FLT)
     return 1;
   /* Otherwise it's not treated as float.  */
   return 0;
@@ -1059,7 +1062,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
                        struct regcache *regcache,
                        CORE_ADDR bp_addr, int nargs,
                        struct value **args,
-                       CORE_ADDR sp, int struct_return,
+                       CORE_ADDR sp, function_call_return_method return_method,
                        CORE_ADDR struct_addr)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -1070,7 +1073,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
   struct type *func_type = value_type (function);
   struct type *type;
   CORE_ADDR regval;
-  char *val;
+  const gdb_byte *val;
   int len, reg_size = 0;
   int pass_on_stack = 0;
   int treat_as_flt;
@@ -1081,7 +1084,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
      registers have been used so far.  */
   if (sh_is_renesas_calling_convention (func_type)
       && TYPE_VARARGS (func_type))
-    last_reg_arg = TYPE_NFIELDS (func_type) - 2;
+    last_reg_arg = func_type->num_fields () - 2;
 
   /* First force sp to a 4-byte alignment.  */
   sp = sh_frame_align (gdbarch, sp);
@@ -1112,9 +1115,9 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
       /* In Renesas ABI, long longs and aggregate types are always passed
         on stack.  */
       else if (sh_is_renesas_calling_convention (func_type)
-              && ((TYPE_CODE (type) == TYPE_CODE_INT && len == 8)
-                  || TYPE_CODE (type) == TYPE_CODE_STRUCT
-                  || TYPE_CODE (type) == TYPE_CODE_UNION))
+              && ((type->code () == TYPE_CODE_INT && len == 8)
+                  || type->code () == TYPE_CODE_STRUCT
+                  || type->code () == TYPE_CODE_UNION))
        pass_on_stack = 1;
       /* In contrast to non-FPU CPUs, arguments are never split between
         registers and stack.  If an argument doesn't fit in the remaining
@@ -1172,7 +1175,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
        }
     }
 
-  if (struct_return)
+  if (return_method == return_method_struct)
     {
       if (sh_is_renesas_calling_convention (func_type))
        /* If the function uses the Renesas ABI, subtract another 4 bytes from
@@ -1201,7 +1204,8 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
                          struct regcache *regcache,
                          CORE_ADDR bp_addr,
                          int nargs, struct value **args,
-                         CORE_ADDR sp, int struct_return,
+                         CORE_ADDR sp,
+                         function_call_return_method return_method,
                          CORE_ADDR struct_addr)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -1211,7 +1215,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
   struct type *func_type = value_type (function);
   struct type *type;
   CORE_ADDR regval;
-  char *val;
+  const gdb_byte *val;
   int len, reg_size = 0;
   int pass_on_stack = 0;
   int last_reg_arg = INT_MAX;
@@ -1221,7 +1225,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
      registers have been used so far.  */
   if (sh_is_renesas_calling_convention (func_type)
       && TYPE_VARARGS (func_type))
-    last_reg_arg = TYPE_NFIELDS (func_type) - 2;
+    last_reg_arg = func_type->num_fields () - 2;
 
   /* First force sp to a 4-byte alignment.  */
   sp = sh_frame_align (gdbarch, sp);
@@ -1244,10 +1248,10 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
       /* Renesas ABI pushes doubles and long longs entirely on stack.
         Same goes for aggregate types.  */
       if (sh_is_renesas_calling_convention (func_type)
-         && ((TYPE_CODE (type) == TYPE_CODE_INT && len >= 8)
-             || (TYPE_CODE (type) == TYPE_CODE_FLT && len >= 8)
-             || TYPE_CODE (type) == TYPE_CODE_STRUCT
-             || TYPE_CODE (type) == TYPE_CODE_UNION))
+         && ((type->code () == TYPE_CODE_INT && len >= 8)
+             || (type->code () == TYPE_CODE_FLT && len >= 8)
+             || type->code () == TYPE_CODE_STRUCT
+             || type->code () == TYPE_CODE_UNION))
        pass_on_stack = 1;
       while (len > 0)
        {
@@ -1275,7 +1279,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
        }
     }
 
-  if (struct_return)
+  if (return_method == return_method_struct)
     {
       if (sh_is_renesas_calling_convention (func_type))
        /* If the function uses the Renesas ABI, subtract another 4 bytes from
@@ -1304,13 +1308,11 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
    TYPE, and copy that, in virtual format, into VALBUF.  */
 static void
 sh_extract_return_value_nofpu (struct type *type, struct regcache *regcache,
-                              void *valbuf)
+                              gdb_byte *valbuf)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int len = TYPE_LENGTH (type);
-  int return_register = R0_REGNUM;
-  int offset;
 
   if (len <= 4)
     {
@@ -1323,7 +1325,7 @@ sh_extract_return_value_nofpu (struct type *type, struct regcache *regcache,
     {
       int i, regnum = R0_REGNUM;
       for (i = 0; i < len; i += 4)
-       regcache_raw_read (regcache, regnum++, (char *) valbuf + i);
+       regcache->raw_read (regnum++, valbuf + i);
     }
   else
     error (_("bad size for return value"));
@@ -1331,19 +1333,19 @@ sh_extract_return_value_nofpu (struct type *type, struct regcache *regcache,
 
 static void
 sh_extract_return_value_fpu (struct type *type, struct regcache *regcache,
-                            void *valbuf)
+                            gdb_byte *valbuf)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   if (sh_treat_as_flt_p (type))
     {
       int len = TYPE_LENGTH (type);
       int i, regnum = gdbarch_fp0_regnum (gdbarch);
       for (i = 0; i < len; i += 4)
        if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
-         regcache_raw_read (regcache, regnum++,
-                            (char *) valbuf + len - 4 - i);
+         regcache->raw_read (regnum++,
+                            valbuf + len - 4 - i);
        else
-         regcache_raw_read (regcache, regnum++, (char *) valbuf + i);
+         regcache->raw_read (regnum++, valbuf + i);
     }
   else
     sh_extract_return_value_nofpu (type, regcache, valbuf);
@@ -1357,9 +1359,9 @@ sh_extract_return_value_fpu (struct type *type, struct regcache *regcache,
    the result is stored in r0, left-justified.  */
 static void
 sh_store_return_value_nofpu (struct type *type, struct regcache *regcache,
-                            const void *valbuf)
+                            const gdb_byte *valbuf)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST val;
   int len = TYPE_LENGTH (type);
@@ -1373,35 +1375,37 @@ sh_store_return_value_nofpu (struct type *type, struct regcache *regcache,
     {
       int i, regnum = R0_REGNUM;
       for (i = 0; i < len; i += 4)
-       regcache_raw_write (regcache, regnum++, (char *) valbuf + i);
+       regcache->raw_write (regnum++, valbuf + i);
     }
 }
 
 static void
 sh_store_return_value_fpu (struct type *type, struct regcache *regcache,
-                          const void *valbuf)
+                          const gdb_byte *valbuf)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   if (sh_treat_as_flt_p (type))
     {
       int len = TYPE_LENGTH (type);
       int i, regnum = gdbarch_fp0_regnum (gdbarch);
       for (i = 0; i < len; i += 4)
        if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
-         regcache_raw_write (regcache, regnum++,
-                             (char *) valbuf + len - 4 - i);
+         regcache->raw_write (regnum++,
+                             valbuf + len - 4 - i);
        else
-         regcache_raw_write (regcache, regnum++, (char *) valbuf + i);
+         regcache->raw_write (regnum++, valbuf + i);
     }
   else
     sh_store_return_value_nofpu (type, regcache, valbuf);
 }
 
 static enum return_value_convention
-sh_return_value_nofpu (struct gdbarch *gdbarch, struct type *func_type,
+sh_return_value_nofpu (struct gdbarch *gdbarch, struct value *function,
                       struct type *type, struct regcache *regcache,
                       gdb_byte *readbuf, const gdb_byte *writebuf)
 {
+  struct type *func_type = function ? value_type (function) : NULL;
+
   if (sh_use_struct_convention_nofpu (
        sh_is_renesas_calling_convention (func_type), type))
     return RETURN_VALUE_STRUCT_CONVENTION;
@@ -1413,10 +1417,12 @@ sh_return_value_nofpu (struct gdbarch *gdbarch, struct type *func_type,
 }
 
 static enum return_value_convention
-sh_return_value_fpu (struct gdbarch *gdbarch, struct type *func_type,
+sh_return_value_fpu (struct gdbarch *gdbarch, struct value *function,
                     struct type *type, struct regcache *regcache,
                     gdb_byte *readbuf, const gdb_byte *writebuf)
 {
+  struct type *func_type = function ? value_type (function) : NULL;
+
   if (sh_use_struct_convention (
        sh_is_renesas_calling_convention (func_type), type))
     return RETURN_VALUE_STRUCT_CONVENTION;
@@ -1427,714 +1433,6 @@ sh_return_value_fpu (struct gdbarch *gdbarch, struct type *func_type,
   return RETURN_VALUE_REGISTER_CONVENTION;
 }
 
-/* Print the registers in a form similar to the E7000.  */
-
-static void
-sh_generic_show_regs (struct frame_info *frame)
-{
-  printf_filtered
-    ("      PC %s       SR %08lx       PR %08lx     MACH %08lx\n",
-     phex (get_frame_register_unsigned (frame,
-                                       gdbarch_pc_regnum
-                                          (get_frame_arch (frame))), 4),
-     (long) get_frame_register_unsigned (frame, SR_REGNUM),
-     (long) get_frame_register_unsigned (frame, PR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACH_REGNUM));
-
-  printf_filtered
-    ("     GBR %08lx      VBR %08lx                       MACL %08lx\n",
-     (long) get_frame_register_unsigned (frame, GBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, VBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACL_REGNUM));
-
-  printf_filtered
-    ("R0-R7    %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 0),
-     (long) get_frame_register_unsigned (frame, 1),
-     (long) get_frame_register_unsigned (frame, 2),
-     (long) get_frame_register_unsigned (frame, 3),
-     (long) get_frame_register_unsigned (frame, 4),
-     (long) get_frame_register_unsigned (frame, 5),
-     (long) get_frame_register_unsigned (frame, 6),
-     (long) get_frame_register_unsigned (frame, 7));
-  printf_filtered
-    ("R8-R15   %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 8),
-     (long) get_frame_register_unsigned (frame, 9),
-     (long) get_frame_register_unsigned (frame, 10),
-     (long) get_frame_register_unsigned (frame, 11),
-     (long) get_frame_register_unsigned (frame, 12),
-     (long) get_frame_register_unsigned (frame, 13),
-     (long) get_frame_register_unsigned (frame, 14),
-     (long) get_frame_register_unsigned (frame, 15));
-}
-
-static void
-sh3_show_regs (struct frame_info *frame)
-{
-  printf_filtered
-    ("      PC %s       SR %08lx       PR %08lx     MACH %08lx\n",
-     phex (get_frame_register_unsigned (frame,
-                                       gdbarch_pc_regnum
-                                         (get_frame_arch (frame))), 4),
-     (long) get_frame_register_unsigned (frame, SR_REGNUM),
-     (long) get_frame_register_unsigned (frame, PR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACH_REGNUM));
-
-  printf_filtered
-    ("     GBR %08lx      VBR %08lx                       MACL %08lx\n",
-     (long) get_frame_register_unsigned (frame, GBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, VBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACL_REGNUM));
-  printf_filtered
-    ("     SSR %08lx      SPC %08lx\n",
-     (long) get_frame_register_unsigned (frame, SSR_REGNUM),
-     (long) get_frame_register_unsigned (frame, SPC_REGNUM));
-
-  printf_filtered
-    ("R0-R7    %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 0),
-     (long) get_frame_register_unsigned (frame, 1),
-     (long) get_frame_register_unsigned (frame, 2),
-     (long) get_frame_register_unsigned (frame, 3),
-     (long) get_frame_register_unsigned (frame, 4),
-     (long) get_frame_register_unsigned (frame, 5),
-     (long) get_frame_register_unsigned (frame, 6),
-     (long) get_frame_register_unsigned (frame, 7));
-  printf_filtered
-    ("R8-R15   %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 8),
-     (long) get_frame_register_unsigned (frame, 9),
-     (long) get_frame_register_unsigned (frame, 10),
-     (long) get_frame_register_unsigned (frame, 11),
-     (long) get_frame_register_unsigned (frame, 12),
-     (long) get_frame_register_unsigned (frame, 13),
-     (long) get_frame_register_unsigned (frame, 14),
-     (long) get_frame_register_unsigned (frame, 15));
-}
-
-static void
-sh2e_show_regs (struct frame_info *frame)
-{
-  struct gdbarch *gdbarch = get_frame_arch (frame);
-  printf_filtered
-    ("      PC %s       SR %08lx       PR %08lx     MACH %08lx\n",
-     phex (get_frame_register_unsigned (frame,
-                                       gdbarch_pc_regnum (gdbarch)), 4),
-     (long) get_frame_register_unsigned (frame, SR_REGNUM),
-     (long) get_frame_register_unsigned (frame, PR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACH_REGNUM));
-
-  printf_filtered
-    ("     GBR %08lx      VBR %08lx                       MACL %08lx\n",
-     (long) get_frame_register_unsigned (frame, GBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, VBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACL_REGNUM));
-  printf_filtered
-    ("     SSR %08lx      SPC %08lx     FPUL %08lx    FPSCR %08lx\n",
-     (long) get_frame_register_unsigned (frame, SSR_REGNUM),
-     (long) get_frame_register_unsigned (frame, SPC_REGNUM),
-     (long) get_frame_register_unsigned (frame, FPUL_REGNUM),
-     (long) get_frame_register_unsigned (frame, FPSCR_REGNUM));
-
-  printf_filtered
-    ("R0-R7    %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 0),
-     (long) get_frame_register_unsigned (frame, 1),
-     (long) get_frame_register_unsigned (frame, 2),
-     (long) get_frame_register_unsigned (frame, 3),
-     (long) get_frame_register_unsigned (frame, 4),
-     (long) get_frame_register_unsigned (frame, 5),
-     (long) get_frame_register_unsigned (frame, 6),
-     (long) get_frame_register_unsigned (frame, 7));
-  printf_filtered
-    ("R8-R15   %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 8),
-     (long) get_frame_register_unsigned (frame, 9),
-     (long) get_frame_register_unsigned (frame, 10),
-     (long) get_frame_register_unsigned (frame, 11),
-     (long) get_frame_register_unsigned (frame, 12),
-     (long) get_frame_register_unsigned (frame, 13),
-     (long) get_frame_register_unsigned (frame, 14),
-     (long) get_frame_register_unsigned (frame, 15));
-
-  printf_filtered
-    ("FP0-FP7  %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 0),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 1),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 2),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 3),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 4),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 5),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 6),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 7));
-  printf_filtered
-    ("FP8-FP15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 8),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 9),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 10),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 11),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 12),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 13),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 14),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 15));
-}
-
-static void
-sh2a_show_regs (struct frame_info *frame)
-{
-  struct gdbarch *gdbarch = get_frame_arch (frame);
-  int pr = get_frame_register_unsigned (frame, FPSCR_REGNUM) & 0x80000;
-
-  printf_filtered
-    ("      PC %s       SR %08lx       PR %08lx     MACH %08lx\n",
-     phex (get_frame_register_unsigned (frame,
-                                       gdbarch_pc_regnum (gdbarch)), 4),
-     (long) get_frame_register_unsigned (frame, SR_REGNUM),
-     (long) get_frame_register_unsigned (frame, PR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACH_REGNUM));
-
-  printf_filtered
-    ("     GBR %08lx      VBR %08lx      TBR %08lx     MACL %08lx\n",
-     (long) get_frame_register_unsigned (frame, GBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, VBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, TBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACL_REGNUM));
-  printf_filtered
-    ("     SSR %08lx      SPC %08lx     FPUL %08lx    FPSCR %08lx\n",
-     (long) get_frame_register_unsigned (frame, SSR_REGNUM),
-     (long) get_frame_register_unsigned (frame, SPC_REGNUM),
-     (long) get_frame_register_unsigned (frame, FPUL_REGNUM),
-     (long) get_frame_register_unsigned (frame, FPSCR_REGNUM));
-
-  printf_filtered
-    ("R0-R7    %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 0),
-     (long) get_frame_register_unsigned (frame, 1),
-     (long) get_frame_register_unsigned (frame, 2),
-     (long) get_frame_register_unsigned (frame, 3),
-     (long) get_frame_register_unsigned (frame, 4),
-     (long) get_frame_register_unsigned (frame, 5),
-     (long) get_frame_register_unsigned (frame, 6),
-     (long) get_frame_register_unsigned (frame, 7));
-  printf_filtered
-    ("R8-R15   %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 8),
-     (long) get_frame_register_unsigned (frame, 9),
-     (long) get_frame_register_unsigned (frame, 10),
-     (long) get_frame_register_unsigned (frame, 11),
-     (long) get_frame_register_unsigned (frame, 12),
-     (long) get_frame_register_unsigned (frame, 13),
-     (long) get_frame_register_unsigned (frame, 14),
-     (long) get_frame_register_unsigned (frame, 15));
-
-  printf_filtered
-    (pr ? "DR0-DR6  %08lx%08lx  %08lx%08lx  %08lx%08lx  %08lx%08lx\n"
-       : "FP0-FP7  %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 0),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 1),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 2),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 3),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 4),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 5),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 6),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 7));
-  printf_filtered
-    (pr ? "DR8-DR14 %08lx%08lx  %08lx%08lx  %08lx%08lx  %08lx%08lx\n"
-       : "FP8-FP15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 8),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 9),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 10),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 11),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 12),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 13),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 14),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 15));
-  printf_filtered
-    ("BANK=%-3d\n", (int) get_frame_register_unsigned (frame, BANK_REGNUM));
-  printf_filtered
-    ("R0b-R7b  %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 0),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 1),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 2),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 3),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 4),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 5),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 6),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 7));
-  printf_filtered
-    ("R8b-R14b %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 8),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 9),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 10),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 11),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 12),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 13),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 14));
-  printf_filtered
-    ("MACHb=%08lx IVNb=%08lx PRb=%08lx GBRb=%08lx MACLb=%08lx\n",
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 15),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 16),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 17),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 18),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 19));
-}
-
-static void
-sh2a_nofpu_show_regs (struct frame_info *frame)
-{
-  int pr = get_frame_register_unsigned (frame, FPSCR_REGNUM) & 0x80000;
-
-  printf_filtered
-    ("      PC %s       SR %08lx       PR %08lx     MACH %08lx\n",
-     phex (get_frame_register_unsigned (frame,
-                                       gdbarch_pc_regnum
-                                         (get_frame_arch (frame))), 4),
-     (long) get_frame_register_unsigned (frame, SR_REGNUM),
-     (long) get_frame_register_unsigned (frame, PR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACH_REGNUM));
-
-  printf_filtered
-    ("     GBR %08lx      VBR %08lx      TBR %08lx     MACL %08lx\n",
-     (long) get_frame_register_unsigned (frame, GBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, VBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, TBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACL_REGNUM));
-  printf_filtered
-    ("     SSR %08lx      SPC %08lx     FPUL %08lx    FPSCR %08lx\n",
-     (long) get_frame_register_unsigned (frame, SSR_REGNUM),
-     (long) get_frame_register_unsigned (frame, SPC_REGNUM),
-     (long) get_frame_register_unsigned (frame, FPUL_REGNUM),
-     (long) get_frame_register_unsigned (frame, FPSCR_REGNUM));
-
-  printf_filtered
-    ("R0-R7    %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 0),
-     (long) get_frame_register_unsigned (frame, 1),
-     (long) get_frame_register_unsigned (frame, 2),
-     (long) get_frame_register_unsigned (frame, 3),
-     (long) get_frame_register_unsigned (frame, 4),
-     (long) get_frame_register_unsigned (frame, 5),
-     (long) get_frame_register_unsigned (frame, 6),
-     (long) get_frame_register_unsigned (frame, 7));
-  printf_filtered
-    ("R8-R15   %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 8),
-     (long) get_frame_register_unsigned (frame, 9),
-     (long) get_frame_register_unsigned (frame, 10),
-     (long) get_frame_register_unsigned (frame, 11),
-     (long) get_frame_register_unsigned (frame, 12),
-     (long) get_frame_register_unsigned (frame, 13),
-     (long) get_frame_register_unsigned (frame, 14),
-     (long) get_frame_register_unsigned (frame, 15));
-
-  printf_filtered
-    ("BANK=%-3d\n", (int) get_frame_register_unsigned (frame, BANK_REGNUM));
-  printf_filtered
-    ("R0b-R7b  %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 0),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 1),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 2),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 3),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 4),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 5),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 6),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 7));
-  printf_filtered
-    ("R8b-R14b %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 8),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 9),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 10),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 11),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 12),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 13),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 14));
-  printf_filtered
-    ("MACHb=%08lx IVNb=%08lx PRb=%08lx GBRb=%08lx MACLb=%08lx\n",
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 15),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 16),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 17),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 18),
-     (long) get_frame_register_unsigned (frame, R0_BANK0_REGNUM + 19));
-}
-
-static void
-sh3e_show_regs (struct frame_info *frame)
-{
-  struct gdbarch *gdbarch = get_frame_arch (frame);
-  printf_filtered
-    ("      PC %s       SR %08lx       PR %08lx     MACH %08lx\n",
-     phex (get_frame_register_unsigned (frame,
-                                       gdbarch_pc_regnum (gdbarch)), 4),
-     (long) get_frame_register_unsigned (frame, SR_REGNUM),
-     (long) get_frame_register_unsigned (frame, PR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACH_REGNUM));
-
-  printf_filtered
-    ("     GBR %08lx      VBR %08lx                       MACL %08lx\n",
-     (long) get_frame_register_unsigned (frame, GBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, VBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACL_REGNUM));
-  printf_filtered
-    ("     SSR %08lx      SPC %08lx     FPUL %08lx    FPSCR %08lx\n",
-     (long) get_frame_register_unsigned (frame, SSR_REGNUM),
-     (long) get_frame_register_unsigned (frame, SPC_REGNUM),
-     (long) get_frame_register_unsigned (frame, FPUL_REGNUM),
-     (long) get_frame_register_unsigned (frame, FPSCR_REGNUM));
-
-  printf_filtered
-    ("R0-R7    %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 0),
-     (long) get_frame_register_unsigned (frame, 1),
-     (long) get_frame_register_unsigned (frame, 2),
-     (long) get_frame_register_unsigned (frame, 3),
-     (long) get_frame_register_unsigned (frame, 4),
-     (long) get_frame_register_unsigned (frame, 5),
-     (long) get_frame_register_unsigned (frame, 6),
-     (long) get_frame_register_unsigned (frame, 7));
-  printf_filtered
-    ("R8-R15   %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 8),
-     (long) get_frame_register_unsigned (frame, 9),
-     (long) get_frame_register_unsigned (frame, 10),
-     (long) get_frame_register_unsigned (frame, 11),
-     (long) get_frame_register_unsigned (frame, 12),
-     (long) get_frame_register_unsigned (frame, 13),
-     (long) get_frame_register_unsigned (frame, 14),
-     (long) get_frame_register_unsigned (frame, 15));
-
-  printf_filtered
-    ("FP0-FP7  %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 0),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 1),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 2),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 3),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 4),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 5),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 6),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 7));
-  printf_filtered
-    ("FP8-FP15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 8),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 9),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 10),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 11),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 12),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 13),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 14),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 15));
-}
-
-static void
-sh3_dsp_show_regs (struct frame_info *frame)
-{
-  printf_filtered
-    ("      PC %s       SR %08lx       PR %08lx     MACH %08lx\n",
-     phex (get_frame_register_unsigned (frame,
-                                       gdbarch_pc_regnum
-                                         (get_frame_arch (frame))), 4),
-     (long) get_frame_register_unsigned (frame, SR_REGNUM),
-     (long) get_frame_register_unsigned (frame, PR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACH_REGNUM));
-
-  printf_filtered
-    ("     GBR %08lx      VBR %08lx                       MACL %08lx\n",
-     (long) get_frame_register_unsigned (frame, GBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, VBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACL_REGNUM));
-
-  printf_filtered
-    ("     SSR %08lx      SPC %08lx      DSR %08lx\n",
-     (long) get_frame_register_unsigned (frame, SSR_REGNUM),
-     (long) get_frame_register_unsigned (frame, SPC_REGNUM),
-     (long) get_frame_register_unsigned (frame, DSR_REGNUM));
-
-  printf_filtered
-    ("R0-R7    %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 0),
-     (long) get_frame_register_unsigned (frame, 1),
-     (long) get_frame_register_unsigned (frame, 2),
-     (long) get_frame_register_unsigned (frame, 3),
-     (long) get_frame_register_unsigned (frame, 4),
-     (long) get_frame_register_unsigned (frame, 5),
-     (long) get_frame_register_unsigned (frame, 6),
-     (long) get_frame_register_unsigned (frame, 7));
-  printf_filtered
-    ("R8-R15   %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 8),
-     (long) get_frame_register_unsigned (frame, 9),
-     (long) get_frame_register_unsigned (frame, 10),
-     (long) get_frame_register_unsigned (frame, 11),
-     (long) get_frame_register_unsigned (frame, 12),
-     (long) get_frame_register_unsigned (frame, 13),
-     (long) get_frame_register_unsigned (frame, 14),
-     (long) get_frame_register_unsigned (frame, 15));
-
-  printf_filtered
-    ("A0G=%02lx A0=%08lx M0=%08lx X0=%08lx Y0=%08lx RS=%08lx MOD=%08lx\n",
-     (long) get_frame_register_unsigned (frame, A0G_REGNUM) & 0xff,
-     (long) get_frame_register_unsigned (frame, A0_REGNUM),
-     (long) get_frame_register_unsigned (frame, M0_REGNUM),
-     (long) get_frame_register_unsigned (frame, X0_REGNUM),
-     (long) get_frame_register_unsigned (frame, Y0_REGNUM),
-     (long) get_frame_register_unsigned (frame, RS_REGNUM),
-     (long) get_frame_register_unsigned (frame, MOD_REGNUM));
-  printf_filtered
-    ("A1G=%02lx A1=%08lx M1=%08lx X1=%08lx Y1=%08lx RE=%08lx\n",
-     (long) get_frame_register_unsigned (frame, A1G_REGNUM) & 0xff,
-     (long) get_frame_register_unsigned (frame, A1_REGNUM),
-     (long) get_frame_register_unsigned (frame, M1_REGNUM),
-     (long) get_frame_register_unsigned (frame, X1_REGNUM),
-     (long) get_frame_register_unsigned (frame, Y1_REGNUM),
-     (long) get_frame_register_unsigned (frame, RE_REGNUM));
-}
-
-static void
-sh4_show_regs (struct frame_info *frame)
-{
-  struct gdbarch *gdbarch = get_frame_arch (frame);
-  int pr = get_frame_register_unsigned (frame, FPSCR_REGNUM) & 0x80000;
-
-  printf_filtered
-    ("      PC %s       SR %08lx       PR %08lx     MACH %08lx\n",
-     phex (get_frame_register_unsigned (frame,
-                                       gdbarch_pc_regnum (gdbarch)), 4),
-     (long) get_frame_register_unsigned (frame, SR_REGNUM),
-     (long) get_frame_register_unsigned (frame, PR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACH_REGNUM));
-
-  printf_filtered
-    ("     GBR %08lx      VBR %08lx                       MACL %08lx\n",
-     (long) get_frame_register_unsigned (frame, GBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, VBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACL_REGNUM));
-  printf_filtered
-    ("     SSR %08lx      SPC %08lx     FPUL %08lx    FPSCR %08lx\n",
-     (long) get_frame_register_unsigned (frame, SSR_REGNUM),
-     (long) get_frame_register_unsigned (frame, SPC_REGNUM),
-     (long) get_frame_register_unsigned (frame, FPUL_REGNUM),
-     (long) get_frame_register_unsigned (frame, FPSCR_REGNUM));
-
-  printf_filtered
-    ("R0-R7    %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 0),
-     (long) get_frame_register_unsigned (frame, 1),
-     (long) get_frame_register_unsigned (frame, 2),
-     (long) get_frame_register_unsigned (frame, 3),
-     (long) get_frame_register_unsigned (frame, 4),
-     (long) get_frame_register_unsigned (frame, 5),
-     (long) get_frame_register_unsigned (frame, 6),
-     (long) get_frame_register_unsigned (frame, 7));
-  printf_filtered
-    ("R8-R15   %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 8),
-     (long) get_frame_register_unsigned (frame, 9),
-     (long) get_frame_register_unsigned (frame, 10),
-     (long) get_frame_register_unsigned (frame, 11),
-     (long) get_frame_register_unsigned (frame, 12),
-     (long) get_frame_register_unsigned (frame, 13),
-     (long) get_frame_register_unsigned (frame, 14),
-     (long) get_frame_register_unsigned (frame, 15));
-
-  printf_filtered
-    (pr ? "DR0-DR6  %08lx%08lx  %08lx%08lx  %08lx%08lx  %08lx%08lx\n"
-       : "FP0-FP7  %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 0),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 1),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 2),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 3),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 4),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 5),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 6),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 7));
-  printf_filtered
-    (pr ? "DR8-DR14 %08lx%08lx  %08lx%08lx  %08lx%08lx  %08lx%08lx\n"
-       : "FP8-FP15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 8),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 9),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 10),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 11),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 12),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 13),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 14),
-     (long) get_frame_register_unsigned
-             (frame, gdbarch_fp0_regnum (gdbarch) + 15));
-}
-
-static void
-sh4_nofpu_show_regs (struct frame_info *frame)
-{
-  printf_filtered
-    ("      PC %s       SR %08lx       PR %08lx     MACH %08lx\n",
-     phex (get_frame_register_unsigned (frame,
-                                       gdbarch_pc_regnum
-                                         (get_frame_arch (frame))), 4),
-     (long) get_frame_register_unsigned (frame, SR_REGNUM),
-     (long) get_frame_register_unsigned (frame, PR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACH_REGNUM));
-
-  printf_filtered
-    ("     GBR %08lx      VBR %08lx                       MACL %08lx\n",
-     (long) get_frame_register_unsigned (frame, GBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, VBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACL_REGNUM));
-  printf_filtered
-    ("     SSR %08lx      SPC %08lx     FPUL %08lx    FPSCR %08lx\n",
-     (long) get_frame_register_unsigned (frame, SSR_REGNUM),
-     (long) get_frame_register_unsigned (frame, SPC_REGNUM),
-     (long) get_frame_register_unsigned (frame, FPUL_REGNUM),
-     (long) get_frame_register_unsigned (frame, FPSCR_REGNUM));
-
-  printf_filtered
-    ("R0-R7    %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 0),
-     (long) get_frame_register_unsigned (frame, 1),
-     (long) get_frame_register_unsigned (frame, 2),
-     (long) get_frame_register_unsigned (frame, 3),
-     (long) get_frame_register_unsigned (frame, 4),
-     (long) get_frame_register_unsigned (frame, 5),
-     (long) get_frame_register_unsigned (frame, 6),
-     (long) get_frame_register_unsigned (frame, 7));
-  printf_filtered
-    ("R8-R15   %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 8),
-     (long) get_frame_register_unsigned (frame, 9),
-     (long) get_frame_register_unsigned (frame, 10),
-     (long) get_frame_register_unsigned (frame, 11),
-     (long) get_frame_register_unsigned (frame, 12),
-     (long) get_frame_register_unsigned (frame, 13),
-     (long) get_frame_register_unsigned (frame, 14),
-     (long) get_frame_register_unsigned (frame, 15));
-}
-
-static void
-sh_dsp_show_regs (struct frame_info *frame)
-{
-  printf_filtered
-    ("      PC %s       SR %08lx       PR %08lx     MACH %08lx\n",
-     phex (get_frame_register_unsigned (frame,
-                                       gdbarch_pc_regnum
-                                         (get_frame_arch (frame))), 4),
-     (long) get_frame_register_unsigned (frame, SR_REGNUM),
-     (long) get_frame_register_unsigned (frame, PR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACH_REGNUM));
-
-  printf_filtered
-    ("     GBR %08lx      VBR %08lx      DSR %08lx     MACL %08lx\n",
-     (long) get_frame_register_unsigned (frame, GBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, VBR_REGNUM),
-     (long) get_frame_register_unsigned (frame, DSR_REGNUM),
-     (long) get_frame_register_unsigned (frame, MACL_REGNUM));
-
-  printf_filtered
-    ("R0-R7    %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 0),
-     (long) get_frame_register_unsigned (frame, 1),
-     (long) get_frame_register_unsigned (frame, 2),
-     (long) get_frame_register_unsigned (frame, 3),
-     (long) get_frame_register_unsigned (frame, 4),
-     (long) get_frame_register_unsigned (frame, 5),
-     (long) get_frame_register_unsigned (frame, 6),
-     (long) get_frame_register_unsigned (frame, 7));
-  printf_filtered
-    ("R8-R15   %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
-     (long) get_frame_register_unsigned (frame, 8),
-     (long) get_frame_register_unsigned (frame, 9),
-     (long) get_frame_register_unsigned (frame, 10),
-     (long) get_frame_register_unsigned (frame, 11),
-     (long) get_frame_register_unsigned (frame, 12),
-     (long) get_frame_register_unsigned (frame, 13),
-     (long) get_frame_register_unsigned (frame, 14),
-     (long) get_frame_register_unsigned (frame, 15));
-
-  printf_filtered
-    ("A0G=%02lx A0=%08lx M0=%08lx X0=%08lx Y0=%08lx RS=%08lx MOD=%08lx\n",
-     (long) get_frame_register_unsigned (frame, A0G_REGNUM) & 0xff,
-     (long) get_frame_register_unsigned (frame, A0_REGNUM),
-     (long) get_frame_register_unsigned (frame, M0_REGNUM),
-     (long) get_frame_register_unsigned (frame, X0_REGNUM),
-     (long) get_frame_register_unsigned (frame, Y0_REGNUM),
-     (long) get_frame_register_unsigned (frame, RS_REGNUM),
-     (long) get_frame_register_unsigned (frame, MOD_REGNUM));
-  printf_filtered ("A1G=%02lx A1=%08lx M1=%08lx X1=%08lx Y1=%08lx RE=%08lx\n",
-     (long) get_frame_register_unsigned (frame, A1G_REGNUM) & 0xff,
-     (long) get_frame_register_unsigned (frame, A1_REGNUM),
-     (long) get_frame_register_unsigned (frame, M1_REGNUM),
-     (long) get_frame_register_unsigned (frame, X1_REGNUM),
-     (long) get_frame_register_unsigned (frame, Y1_REGNUM),
-     (long) get_frame_register_unsigned (frame, RE_REGNUM));
-}
-
-static void
-sh_show_regs_command (char *args, int from_tty)
-{
-  if (sh_show_regs)
-    (*sh_show_regs) (get_current_frame ());
-}
-
 static struct type *
 sh_sh2a_register_type (struct gdbarch *gdbarch, int reg_nr)
 {
@@ -2229,16 +1527,16 @@ sh_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 
 /* On the sh4, the DRi pseudo registers are problematic if the target
    is little endian.  When the user writes one of those registers, for
-   instance with 'ser var $dr0=1', we want the double to be stored
+   instance with 'set var $dr0=1', we want the double to be stored
    like this: 
-   fr0 = 0x00 0x00 0x00 0x00 0x00 0xf0 0x3f 
-   fr1 = 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
+   fr0 = 0x00 0x00 0xf0 0x3f 
+   fr1 = 0x00 0x00 0x00 0x00 
 
    This corresponds to little endian byte order & big endian word
    order.  However if we let gdb write the register w/o conversion, it
    will write fr0 and fr1 this way:
-   fr0 = 0x00 0x00 0x00 0x00 0x00 0x00 0x00
-   fr1 = 0x00 0x00 0x00 0x00 0x00 0xf0 0x3f
+   fr0 = 0x00 0x00 0x00 0x00
+   fr1 = 0x00 0x00 0xf0 0x3f
    because it will consider fr0 and fr1 as a single LE stretch of memory.
    
    To achieve what we want we must force gdb to store things in
@@ -2247,38 +1545,58 @@ sh_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 
    In case the target is big endian, there is no problem, the
    raw bytes will look like:
-   fr0 = 0x3f 0xf0 0x00 0x00 0x00 0x00 0x00
-   fr1 = 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
+   fr0 = 0x3f 0xf0 0x00 0x00
+   fr1 = 0x00 0x00 0x00 0x00
 
    The other pseudo registers (the FVs) also don't pose a problem
    because they are stored as 4 individual FP elements.  */
 
+static struct type *
+sh_littlebyte_bigword_type (struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  if (tdep->sh_littlebyte_bigword_type == NULL)
+    tdep->sh_littlebyte_bigword_type
+      = arch_float_type (gdbarch, -1, "builtin_type_sh_littlebyte_bigword",
+                         floatformats_ieee_double_littlebyte_bigword);
+
+  return tdep->sh_littlebyte_bigword_type;
+}
+
 static void
-sh_register_convert_to_virtual (int regnum, struct type *type,
-                               char *from, char *to)
+sh_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum,
+                               struct type *type, gdb_byte *from, gdb_byte *to)
 {
-  if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)
+  if (gdbarch_byte_order (gdbarch) != BFD_ENDIAN_LITTLE)
     {
-      DOUBLEST val;
-      floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword,
-                              from, &val);
-      store_typed_floating (to, type, val);
+      /* It is a no-op.  */
+      memcpy (to, from, register_size (gdbarch, regnum));
+      return;
     }
+
+  if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)
+    target_float_convert (from, sh_littlebyte_bigword_type (gdbarch),
+                         to, type);
   else
     error
       ("sh_register_convert_to_virtual called with non DR register number");
 }
 
 static void
-sh_register_convert_to_raw (struct type *type, int regnum,
-                           const void *from, void *to)
+sh_register_convert_to_raw (struct gdbarch *gdbarch, struct type *type,
+                           int regnum, const gdb_byte *from, gdb_byte *to)
 {
-  if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)
+  if (gdbarch_byte_order (gdbarch) != BFD_ENDIAN_LITTLE)
     {
-      DOUBLEST val = extract_typed_floating (from, type);
-      floatformat_from_doublest (&floatformat_ieee_double_littlebyte_bigword,
-                                &val, to);
+      /* It is a no-op.  */
+      memcpy (to, from, register_size (gdbarch, regnum));
+      return;
     }
+
+  if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)
+    target_float_convert (from, type,
+                         to, sh_littlebyte_bigword_type (gdbarch));
   else
     error (_("sh_register_convert_to_raw called with non DR register number"));
 }
@@ -2310,7 +1628,7 @@ dr_reg_base_num (struct gdbarch *gdbarch, int dr_regnum)
 
 static enum register_status
 pseudo_register_read_portions (struct gdbarch *gdbarch,
-                              struct regcache *regcache,
+                              readable_regcache *regcache,
                               int portions,
                               int base_regnum, gdb_byte *buffer)
 {
@@ -2322,7 +1640,7 @@ pseudo_register_read_portions (struct gdbarch *gdbarch,
       gdb_byte *b;
 
       b = buffer + register_size (gdbarch, base_regnum) * portion;
-      status = regcache_raw_read (regcache, base_regnum + portion, b);
+      status = regcache->raw_read (base_regnum + portion, b);
       if (status != REG_VALID)
        return status;
     }
@@ -2331,17 +1649,18 @@ pseudo_register_read_portions (struct gdbarch *gdbarch,
 }
 
 static enum register_status
-sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
+sh_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache,
                         int reg_nr, gdb_byte *buffer)
 {
   int base_regnum;
-  char temp_buffer[MAX_REGISTER_SIZE];
   enum register_status status;
 
   if (reg_nr == PSEUDO_BANK_REGNUM)
-    return regcache_raw_read (regcache, BANK_REGNUM, buffer);
+    return regcache->raw_read (BANK_REGNUM, buffer);
   else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
     {
+      /* Enough space for two float registers.  */
+      gdb_byte temp_buffer[4 * 2];
       base_regnum = dr_reg_base_num (gdbarch, reg_nr);
 
       /* Build the value in the provided buffer.  */
@@ -2350,8 +1669,8 @@ sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
                                              2, base_regnum, temp_buffer);
       if (status == REG_VALID)
        {
-         /* We must pay attention to the endiannes. */
-         sh_register_convert_to_virtual (reg_nr,
+         /* We must pay attention to the endianness. */
+         sh_register_convert_to_virtual (gdbarch, reg_nr,
                                          register_type (gdbarch, reg_nr),
                                          temp_buffer, buffer);
        }
@@ -2374,7 +1693,6 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
                          int reg_nr, const gdb_byte *buffer)
 {
   int base_regnum, portion;
-  char temp_buffer[MAX_REGISTER_SIZE];
 
   if (reg_nr == PSEUDO_BANK_REGNUM)
     {
@@ -2384,21 +1702,23 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
         so that a re-read happens next time it's necessary.  */
       int bregnum;
 
-      regcache_raw_write (regcache, BANK_REGNUM, buffer);
+      regcache->raw_write (BANK_REGNUM, buffer);
       for (bregnum = R0_BANK0_REGNUM; bregnum < MACLB_REGNUM; ++bregnum)
-        regcache_invalidate (regcache, bregnum);
+        regcache->invalidate (bregnum);
     }
   else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM)
     {
+      /* Enough space for two float registers.  */
+      gdb_byte temp_buffer[4 * 2];
       base_regnum = dr_reg_base_num (gdbarch, reg_nr);
 
-      /* We must pay attention to the endiannes.  */
-      sh_register_convert_to_raw (register_type (gdbarch, reg_nr),
+      /* We must pay attention to the endianness.  */
+      sh_register_convert_to_raw (gdbarch, register_type (gdbarch, reg_nr),
                                  reg_nr, buffer, temp_buffer);
 
       /* Write the real regs for which this one is an alias.  */
       for (portion = 0; portion < 2; portion++)
-       regcache_raw_write (regcache, base_regnum + portion,
+       regcache->raw_write (base_regnum + portion,
                            (temp_buffer
                             + register_size (gdbarch,
                                              base_regnum) * portion));
@@ -2409,8 +1729,8 @@ sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
 
       /* Write the real regs for which this one is an alias.  */
       for (portion = 0; portion < 4; portion++)
-       regcache_raw_write (regcache, base_regnum + portion,
-                           ((char *) buffer
+       regcache->raw_write (base_regnum + portion,
+                           (buffer
                             + register_size (gdbarch,
                                              base_regnum) * portion));
     }
@@ -2551,7 +1871,7 @@ sh_frame_cache (struct frame_info *this_frame, void **this_cache)
   int i;
 
   if (*this_cache)
-    return *this_cache;
+    return (struct sh_frame_cache *) *this_cache;
 
   cache = sh_alloc_frame_cache ();
   *this_cache = cache;
@@ -2656,28 +1976,6 @@ static const struct frame_unwind sh_frame_unwind = {
   default_frame_sniffer
 };
 
-static CORE_ADDR
-sh_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
-{
-  return frame_unwind_register_unsigned (next_frame,
-                                        gdbarch_sp_regnum (gdbarch));
-}
-
-static CORE_ADDR
-sh_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
-{
-  return frame_unwind_register_unsigned (next_frame,
-                                        gdbarch_pc_regnum (gdbarch));
-}
-
-static struct frame_id
-sh_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
-  CORE_ADDR sp = get_frame_register_unsigned (this_frame,
-                                             gdbarch_sp_regnum (gdbarch));
-  return frame_id_build (sp, get_frame_pc (this_frame));
-}
-
 static CORE_ADDR
 sh_frame_base_address (struct frame_info *this_frame, void **this_cache)
 {
@@ -2715,7 +2013,7 @@ sh_stub_this_id (struct frame_info *this_frame, void **this_cache,
 
   if (*this_cache == NULL)
     *this_cache = sh_make_stub_cache (this_frame);
-  cache = *this_cache;
+  cache = (struct sh_frame_cache *) *this_cache;
 
   *this_id = frame_id_build (cache->saved_sp, get_frame_pc (this_frame));
 }
@@ -2728,7 +2026,7 @@ sh_stub_unwind_sniffer (const struct frame_unwind *self,
   CORE_ADDR addr_in_block;
 
   addr_in_block = get_frame_address_in_block (this_frame);
-  if (in_plt_section (addr_in_block, NULL))
+  if (in_plt_section (addr_in_block))
     return 1;
 
   return 0;
@@ -2744,11 +2042,14 @@ static const struct frame_unwind sh_stub_unwind =
   sh_stub_unwind_sniffer
 };
 
-/* The epilogue is defined here as the area at the end of a function,
+/* Implement the stack_frame_destroyed_p gdbarch method.
+
+   The epilogue is defined here as the area at the end of a function,
    either on the `ret' instruction itself or after an instruction which
    destroys the function's stack frame.  */
+
 static int
-sh_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
+sh_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR func_addr = 0, func_end = 0;
@@ -2842,7 +2143,7 @@ sh_corefile_supply_regset (const struct regset *regset,
                           struct regcache *regcache,
                           int regnum, const void *regs, size_t len)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   const struct sh_corefile_regmap *regmap = (regset == &sh_corefile_gregset
                                             ? tdep->core_gregmap
@@ -2853,8 +2154,8 @@ sh_corefile_supply_regset (const struct regset *regset,
     {
       if ((regnum == -1 || regnum == regmap[i].regnum)
          && regmap[i].offset + 4 <= len)
-       regcache_raw_supply (regcache, regmap[i].regnum,
-                            (char *)regs + regmap[i].offset);
+       regcache->raw_supply
+         (regmap[i].regnum, (char *) regs + regmap[i].offset);
     }
 }
 
@@ -2868,7 +2169,7 @@ sh_corefile_collect_regset (const struct regset *regset,
                            const struct regcache *regcache,
                            int regnum, void *regs, size_t len)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   const struct sh_corefile_regmap *regmap = (regset == &sh_corefile_gregset
                                             ? tdep->core_gregmap
@@ -2879,7 +2180,7 @@ sh_corefile_collect_regset (const struct regset *regset,
     {
       if ((regnum == -1 || regnum == regmap[i].regnum)
          && regmap[i].offset + 4 <= len)
-       regcache_raw_collect (regcache, regmap[i].regnum,
+       regcache->raw_collect (regmap[i].regnum,
                              (char *)regs + regmap[i].offset);
     }
 }
@@ -2887,34 +2188,47 @@ sh_corefile_collect_regset (const struct regset *regset,
 /* The following two regsets have the same contents, so it is tempting to
    unify them, but they are distiguished by their address, so don't.  */
 
-struct regset sh_corefile_gregset =
+const struct regset sh_corefile_gregset =
 {
   NULL,
   sh_corefile_supply_regset,
   sh_corefile_collect_regset
 };
 
-static struct regset sh_corefile_fpregset =
+static const struct regset sh_corefile_fpregset =
 {
   NULL,
   sh_corefile_supply_regset,
   sh_corefile_collect_regset
 };
 
-static const struct regset *
-sh_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name,
-                            size_t sect_size)
+static void
+sh_iterate_over_regset_sections (struct gdbarch *gdbarch,
+                                iterate_over_regset_sections_cb *cb,
+                                void *cb_data,
+                                const struct regcache *regcache)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
-  if (tdep->core_gregmap && strcmp (sect_name, ".reg") == 0)
-    return &sh_corefile_gregset;
+  if (tdep->core_gregmap != NULL)
+    cb (".reg", tdep->sizeof_gregset, tdep->sizeof_gregset,
+       &sh_corefile_gregset, NULL, cb_data);
 
-  if (tdep->core_fpregmap && strcmp (sect_name, ".reg2") == 0)
-    return &sh_corefile_fpregset;
+  if (tdep->core_fpregmap != NULL)
+    cb (".reg2", tdep->sizeof_fpregset, tdep->sizeof_fpregset,
+       &sh_corefile_fpregset, NULL, cb_data);
+}
 
-  return NULL;
+/* This is the implementation of gdbarch method
+   return_in_first_hidden_param_p.  */
+
+static int
+sh_return_in_first_hidden_param_p (struct gdbarch *gdbarch,
+                                    struct type *type)
+{
+  return 0;
 }
+
 \f
 
 static struct gdbarch *
@@ -2923,57 +2237,6 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   struct gdbarch *gdbarch;
   struct gdbarch_tdep *tdep;
 
-  sh_show_regs = sh_generic_show_regs;
-  switch (info.bfd_arch_info->mach)
-    {
-    case bfd_mach_sh2e:
-      sh_show_regs = sh2e_show_regs;
-      break;
-    case bfd_mach_sh2a:
-      sh_show_regs = sh2a_show_regs;
-      break;
-    case bfd_mach_sh2a_nofpu:
-      sh_show_regs = sh2a_nofpu_show_regs;
-      break;
-    case bfd_mach_sh_dsp:
-      sh_show_regs = sh_dsp_show_regs;
-      break;
-
-    case bfd_mach_sh3:
-    case bfd_mach_sh3_nommu:
-    case bfd_mach_sh2a_nofpu_or_sh3_nommu:
-      sh_show_regs = sh3_show_regs;
-      break;
-
-    case bfd_mach_sh3e:
-    case bfd_mach_sh2a_or_sh3e:
-      sh_show_regs = sh3e_show_regs;
-      break;
-
-    case bfd_mach_sh3_dsp:
-    case bfd_mach_sh4al_dsp:
-      sh_show_regs = sh3_dsp_show_regs;
-      break;
-
-    case bfd_mach_sh4:
-    case bfd_mach_sh4a:
-    case bfd_mach_sh2a_or_sh4:
-      sh_show_regs = sh4_show_regs;
-      break;
-
-    case bfd_mach_sh4_nofpu:
-    case bfd_mach_sh4_nommu_nofpu:
-    case bfd_mach_sh4a_nofpu:
-    case bfd_mach_sh2a_nofpu_or_sh4_nommu_nofpu:
-      sh_show_regs = sh4_nofpu_show_regs;
-      break;
-
-    case bfd_mach_sh5:
-      sh_show_regs = sh64_show_regs;
-      /* SH5 is handled entirely in sh64-tdep.c.  */
-      return sh64_gdbarch_init (info, arches);
-    }
-
   /* If there is already a candidate, use it.  */
   arches = gdbarch_list_lookup_by_info (arches, &info);
   if (arches != NULL)
@@ -2981,13 +2244,17 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* None found, create a new architecture from the information
      provided.  */
-  tdep = XZALLOC (struct gdbarch_tdep);
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
   set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT);
   set_gdbarch_long_bit (gdbarch, 4 * TARGET_CHAR_BIT);
   set_gdbarch_long_long_bit (gdbarch, 8 * TARGET_CHAR_BIT);
+
+  set_gdbarch_wchar_bit (gdbarch, 2 * TARGET_CHAR_BIT);
+  set_gdbarch_wchar_signed (gdbarch, 0);
+
   set_gdbarch_float_bit (gdbarch, 4 * TARGET_CHAR_BIT);
   set_gdbarch_double_bit (gdbarch, 8 * TARGET_CHAR_BIT);
   set_gdbarch_long_double_bit (gdbarch, 8 * TARGET_CHAR_BIT);
@@ -3002,9 +2269,9 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_register_type (gdbarch, sh_default_register_type);
   set_gdbarch_register_reggroup_p (gdbarch, sh_register_reggroup_p);
 
-  set_gdbarch_breakpoint_from_pc (gdbarch, sh_breakpoint_from_pc);
+  set_gdbarch_breakpoint_kind_from_pc (gdbarch, sh_breakpoint_kind_from_pc);
+  set_gdbarch_sw_breakpoint_from_kind (gdbarch, sh_sw_breakpoint_from_kind);
 
-  set_gdbarch_print_insn (gdbarch, print_insn_sh);
   set_gdbarch_register_sim_regno (gdbarch, legacy_register_sim_regno);
 
   set_gdbarch_return_value (gdbarch, sh_return_value_nofpu);
@@ -3013,20 +2280,20 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
 
   set_gdbarch_push_dummy_call (gdbarch, sh_push_dummy_call_nofpu);
+  set_gdbarch_return_in_first_hidden_param_p (gdbarch,
+                                             sh_return_in_first_hidden_param_p);
 
   set_gdbarch_believe_pcc_promotion (gdbarch, 1);
 
   set_gdbarch_frame_align (gdbarch, sh_frame_align);
-  set_gdbarch_unwind_sp (gdbarch, sh_unwind_sp);
-  set_gdbarch_unwind_pc (gdbarch, sh_unwind_pc);
-  set_gdbarch_dummy_id (gdbarch, sh_dummy_id);
   frame_base_set_default (gdbarch, &sh_frame_base);
 
-  set_gdbarch_in_function_epilogue_p (gdbarch, sh_in_function_epilogue_p);
+  set_gdbarch_stack_frame_destroyed_p (gdbarch, sh_stack_frame_destroyed_p);
 
   dwarf2_frame_set_init_reg (gdbarch, sh_dwarf2_frame_init_reg);
 
-  set_gdbarch_regset_from_core_section (gdbarch, sh_regset_from_core_section);
+  set_gdbarch_iterate_over_regset_sections
+    (gdbarch, sh_iterate_over_regset_sections);
 
   switch (info.bfd_arch_info->mach)
     {
@@ -3041,6 +2308,7 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     case bfd_mach_sh2e:
       /* doubles on sh2e and sh3e are actually 4 byte.  */
       set_gdbarch_double_bit (gdbarch, 4 * TARGET_CHAR_BIT);
+      set_gdbarch_double_format (gdbarch, floatformats_ieee_single);
 
       set_gdbarch_register_name (gdbarch, sh_sh2e_register_name);
       set_gdbarch_register_type (gdbarch, sh_sh3e_register_type);
@@ -3086,6 +2354,7 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     case bfd_mach_sh2a_or_sh3e:
       /* doubles on sh2e and sh3e are actually 4 byte.  */
       set_gdbarch_double_bit (gdbarch, 4 * TARGET_CHAR_BIT);
+      set_gdbarch_double_format (gdbarch, floatformats_ieee_single);
 
       set_gdbarch_register_name (gdbarch, sh_sh3e_register_name);
       set_gdbarch_register_type (gdbarch, sh_sh3e_register_type);
@@ -3139,35 +2408,16 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   return gdbarch;
 }
 
-static void
-show_sh_command (char *args, int from_tty)
-{
-  help_list (showshcmdlist, "show sh ", all_commands, gdb_stdout);
-}
-
-static void
-set_sh_command (char *args, int from_tty)
-{
-  printf_unfiltered
-    ("\"set sh\" must be followed by an appropriate subcommand.\n");
-  help_list (setshcmdlist, "set sh ", all_commands, gdb_stdout);
-}
-
-extern initialize_file_ftype _initialize_sh_tdep;  /* -Wmissing-prototypes */
-
+void _initialize_sh_tdep ();
 void
-_initialize_sh_tdep (void)
+_initialize_sh_tdep ()
 {
-  struct cmd_list_element *c;
-
   gdbarch_register (bfd_arch_sh, sh_gdbarch_init, NULL);
 
-  add_com ("regs", class_vars, sh_show_regs_command, _("Print all registers"));
-  
-  add_prefix_cmd ("sh", no_class, set_sh_command, "SH specific commands.",
-                  &setshcmdlist, "set sh ", 0, &setlist);
-  add_prefix_cmd ("sh", no_class, show_sh_command, "SH specific commands.",
-                  &showshcmdlist, "show sh ", 0, &showlist);
+  add_basic_prefix_cmd ("sh", no_class, "SH specific commands.",
+                       &setshcmdlist, "set sh ", 0, &setlist);
+  add_show_prefix_cmd ("sh", no_class, "SH specific commands.",
+                      &showshcmdlist, "show sh ", 0, &showlist);
   
   add_setshow_enum_cmd ("calling-convention", class_vars, sh_cc_enum,
                        &sh_active_calling_convention,
This page took 0.046785 seconds and 4 git commands to generate.