gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdb / h8300-tdep.c
index 93f0a65895d4db0312eb2a3d420aa897a88671e8..b569a23f2631cfb1f69d16e639734070b2b24cca 100644 (file)
@@ -1,8 +1,6 @@
 /* Target-machine dependent code for Renesas H8/300, for GDB.
 
-   Copyright (C) 1988, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
-   2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009
-   Free Software Foundation, Inc.
+   Copyright (C) 1988-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -30,9 +28,8 @@
 #include "regcache.h"
 #include "gdbcore.h"
 #include "objfiles.h"
-#include "gdb_assert.h"
 #include "dis-asm.h"
-#include "dwarf2-frame.h"
+#include "dwarf2/frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
 
@@ -71,7 +68,7 @@ struct h8300_frame_cache
   CORE_ADDR sp_offset;
   CORE_ADDR pc;
 
-  /* Flag showing that a frame has been created in the prologue code. */
+  /* Flag showing that a frame has been created in the prologue code.  */
   int uses_fp;
 
   /* Saved registers.  */
@@ -95,25 +92,6 @@ static int is_h8300_normal_mode (struct gdbarch *gdbarch);
                  && !is_h8300_normal_mode (gdbarch)) \
                 ? h8300h_reg_size : h8300_reg_size)
 
-static CORE_ADDR
-h8300_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
-{
-  return frame_unwind_register_unsigned (next_frame, E_PC_REGNUM);
-}
-
-static CORE_ADDR
-h8300_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
-{
-  return frame_unwind_register_unsigned (next_frame, E_SP_REGNUM);
-}
-
-static struct frame_id
-h8300_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
-  CORE_ADDR sp = get_frame_register_unsigned (this_frame, E_SP_REGNUM);
-  return frame_id_build (sp, get_frame_pc (this_frame));
-}
-
 /* Normal frames.  */
 
 /* Allocate and initialize a frame cache.  */
@@ -147,7 +125,7 @@ h8300_init_frame_cache (struct gdbarch *gdbarch,
 #define IS_MOVW_Rn16_SP(x)     (((x) & 0xfff0) == 0x6fe0)
 #define IS_MOVW_EXT(x)         ((x) == 0x78e0)
 #define IS_MOVW_Rn24_SP(x)     (((x) & 0xfff0) == 0x6ba0)
-/* Same instructions as mov.w, just prefixed with 0x0100 */
+/* Same instructions as mov.w, just prefixed with 0x0100 */
 #define IS_MOVL_PRE(x)         ((x) == 0x0100)
 #define IS_MOVL_Rn16_SP(x)     (((x) & 0xfff0) == 0x6fe0)
 #define IS_MOVL_EXT(x)         ((x) == 0x78e0)
@@ -200,10 +178,10 @@ h8300_is_argument_spill (struct gdbarch *gdbarch, CORE_ADDR pc)
       if (IS_MOVB_Rn24_SP (read_memory_unsigned_integer (pc + 2,
                                                         2, byte_order)))
        {
-         LONGEST disp = read_memory_integer (pc + 4, 4, byte_order);
+         ULONGEST disp = read_memory_unsigned_integer (pc + 4, 4, byte_order);
 
          /* ... and d:24 is negative.  */
-         if (disp < 0 && disp > 0xffffff)
+         if ((disp & 0x00800000) != 0)
            return 8;
        }
     }
@@ -219,10 +197,10 @@ h8300_is_argument_spill (struct gdbarch *gdbarch, CORE_ADDR pc)
       if (IS_MOVW_Rn24_SP (read_memory_unsigned_integer (pc + 2,
                                                         2, byte_order)))
        {
-         LONGEST disp = read_memory_integer (pc + 4, 4, byte_order);
+         ULONGEST disp = read_memory_unsigned_integer (pc + 4, 4, byte_order);
 
          /* ... and d:24 is negative.  */
-         if (disp < 0 && disp > 0xffffff)
+         if ((disp & 0x00800000) != 0)
            return 8;
        }
     }
@@ -239,14 +217,13 @@ h8300_is_argument_spill (struct gdbarch *gdbarch, CORE_ADDR pc)
        }
       else if (IS_MOVL_EXT (w2))
        {
-         int w3 = read_memory_integer (pc + 4, 2, byte_order);
-
          if (IS_MOVL_Rn24_SP (read_memory_integer (pc + 4, 2, byte_order)))
            {
-             LONGEST disp = read_memory_integer (pc + 6, 4, byte_order);
+             ULONGEST disp = read_memory_unsigned_integer (pc + 6, 4,
+                                                           byte_order);
 
              /* ... and d:24 is negative.  */
-             if (disp < 0 && disp > 0xffffff)
+             if ((disp & 0x00800000) != 0)
                return 10;
            }
        }
@@ -431,12 +408,11 @@ h8300_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct h8300_frame_cache *cache;
-  char buf[4];
   int i;
   CORE_ADDR current_pc;
 
   if (*this_cache)
-    return *this_cache;
+    return (struct h8300_frame_cache *) *this_cache;
 
   cache = FRAME_OBSTACK_ZALLOC (struct h8300_frame_cache);
   h8300_init_frame_cache (gdbarch, cache);
@@ -526,6 +502,7 @@ h8300_frame_prev_register (struct frame_info *this_frame, void **this_cache,
 
 static const struct frame_unwind h8300_frame_unwind = {
   NORMAL_FRAME,
+  default_frame_unwind_stop_reason,
   h8300_frame_this_id,
   h8300_frame_prev_register,
   NULL,
@@ -639,7 +616,8 @@ static CORE_ADDR
 h8300_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)
+                      function_call_return_method return_method,
+                      CORE_ADDR struct_addr)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int stack_alloc = 0, stack_offset = 0;
@@ -662,7 +640,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
      If we're returning a structure by value, then we must pass a
      pointer to the buffer for the return value as an invisible first
      argument.  */
-  if (struct_return)
+  if (return_method == return_method_struct)
     regcache_cooked_write_unsigned (regcache, reg++, struct_addr);
 
   for (argument = 0; argument < nargs; argument++)
@@ -673,10 +651,11 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
       /* Pad the argument appropriately.  */
       int padded_len = align_up (len, wordsize);
-      gdb_byte *padded = alloca (padded_len);
+      /* Use std::vector here to get zero initialization.  */
+      std::vector<gdb_byte> padded (padded_len);
 
-      memset (padded, 0, padded_len);
-      memcpy (len < wordsize ? padded + padded_len - len : padded,
+      memcpy ((len < wordsize ? padded.data () + padded_len - len
+              : padded.data ()),
              contents, len);
 
       /* Could the argument fit in the remaining registers?  */
@@ -687,7 +666,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
          if (len > wordsize && len % wordsize)
            {
              /* I feel so unclean.  */
-             write_memory (sp + stack_offset, padded, padded_len);
+             write_memory (sp + stack_offset, padded.data (), padded_len);
              stack_offset += padded_len;
 
              /* That's right --- even though we passed the argument
@@ -698,15 +677,14 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
          else
            {
              /* Heavens to Betsy --- it's really going in registers!
-                It would be nice if we could use write_register_bytes
-                here, but on the h8/300s, there are gaps between
-                the registers in the register file.  */
+                Note that on the h8/300s, there are gaps between the
+                registers in the register file.  */
              int offset;
 
              for (offset = 0; offset < padded_len; offset += wordsize)
                {
                  ULONGEST word
-                   = extract_unsigned_integer (padded + offset,
+                   = extract_unsigned_integer (&padded[offset],
                                                wordsize, byte_order);
                  regcache_cooked_write_unsigned (regcache, reg++, word);
                }
@@ -715,7 +693,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       else
        {
          /* It doesn't fit in registers!  Onto the stack it goes.  */
-         write_memory (sp + stack_offset, padded, padded_len);
+         write_memory (sp + stack_offset, padded.data (), padded_len);
          stack_offset += padded_len;
 
          /* Once one argument has spilled onto the stack, all
@@ -742,9 +720,9 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
 static void
 h8300_extract_return_value (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);
   ULONGEST c, addr;
@@ -760,10 +738,10 @@ h8300_extract_return_value (struct type *type, struct regcache *regcache,
       regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
       store_unsigned_integer (valbuf, 2, byte_order, c);
       regcache_cooked_read_unsigned (regcache, E_RET1_REGNUM, &c);
-      store_unsigned_integer ((void *)((char *) valbuf + 2), 2, byte_order, c);
+      store_unsigned_integer (valbuf + 2, 2, byte_order, c);
       break;
     case 8:                    /* long long is now 8 bytes.  */
-      if (TYPE_CODE (type) == TYPE_CODE_INT)
+      if (type->code () == TYPE_CODE_INT)
        {
          regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &addr);
          c = read_memory_unsigned_integer ((CORE_ADDR) addr, len, byte_order);
@@ -771,7 +749,7 @@ h8300_extract_return_value (struct type *type, struct regcache *regcache,
        }
       else
        {
-         error ("I don't know how this 8 byte value is returned.");
+         error (_("I don't know how this 8 byte value is returned."));
        }
       break;
     }
@@ -779,33 +757,31 @@ h8300_extract_return_value (struct type *type, struct regcache *regcache,
 
 static void
 h8300h_extract_return_value (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);
-  ULONGEST c, addr;
+  ULONGEST c;
 
-  switch (len)
+  switch (TYPE_LENGTH (type))
     {
     case 1:
     case 2:
     case 4:
       regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
-      store_unsigned_integer (valbuf, len, byte_order, c);
+      store_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order, c);
       break;
     case 8:                    /* long long is now 8 bytes.  */
-      if (TYPE_CODE (type) == TYPE_CODE_INT)
+      if (type->code () == TYPE_CODE_INT)
        {
          regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
          store_unsigned_integer (valbuf, 4, byte_order, c);
          regcache_cooked_read_unsigned (regcache, E_RET1_REGNUM, &c);
-         store_unsigned_integer ((void *) ((char *) valbuf + 4), 4,
-                                 byte_order, c);
+         store_unsigned_integer (valbuf + 4, 4, byte_order, c);
        }
       else
        {
-         error ("I don't know how this 8 byte value is returned.");
+         error (_("I don't know how this 8 byte value is returned."));
        }
       break;
     }
@@ -815,10 +791,10 @@ static int
 h8300_use_struct_convention (struct type *value_type)
 {
   /* Types of 1, 2 or 4 bytes are returned in R0/R1, everything else on the
-     stack. */
+     stack.  */
 
-  if (TYPE_CODE (value_type) == TYPE_CODE_STRUCT
-      || TYPE_CODE (value_type) == TYPE_CODE_UNION)
+  if (value_type->code () == TYPE_CODE_STRUCT
+      || value_type->code () == TYPE_CODE_UNION)
     return 1;
   return !(TYPE_LENGTH (value_type) == 1
           || TYPE_LENGTH (value_type) == 2
@@ -829,15 +805,15 @@ static int
 h8300h_use_struct_convention (struct type *value_type)
 {
   /* Types of 1, 2 or 4 bytes are returned in R0, INT types of 8 bytes are
-     returned in R0/R1, everything else on the stack. */
-  if (TYPE_CODE (value_type) == TYPE_CODE_STRUCT
-      || TYPE_CODE (value_type) == TYPE_CODE_UNION)
+     returned in R0/R1, everything else on the stack.  */
+  if (value_type->code () == TYPE_CODE_STRUCT
+      || value_type->code () == TYPE_CODE_UNION)
     return 1;
   return !(TYPE_LENGTH (value_type) == 1
           || TYPE_LENGTH (value_type) == 2
           || TYPE_LENGTH (value_type) == 4
           || (TYPE_LENGTH (value_type) == 8
-              && TYPE_CODE (value_type) == TYPE_CODE_INT));
+              && value_type->code () == TYPE_CODE_INT));
 }
 
 /* Function: store_return_value
@@ -846,52 +822,51 @@ h8300h_use_struct_convention (struct type *value_type)
 
 static void
 h8300_store_return_value (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);
-  int len = TYPE_LENGTH (type);
   ULONGEST val;
 
-  switch (len)
+  switch (TYPE_LENGTH (type))
     {
     case 1:
-    case 2:                    /* short... */
-      val = extract_unsigned_integer (valbuf, len, byte_order);
+    case 2:                    /* short...  */
+      val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order);
       regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, val);
       break;
     case 4:                    /* long, float */
-      val = extract_unsigned_integer (valbuf, len, byte_order);
+      val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order);
       regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM,
                                      (val >> 16) & 0xffff);
       regcache_cooked_write_unsigned (regcache, E_RET1_REGNUM, val & 0xffff);
       break;
-    case 8:                    /* long long, double and long double are all defined
-                                  as 4 byte types so far so this shouldn't happen.  */
-      error ("I don't know how to return an 8 byte value.");
+    case 8:                    /* long long, double and long double
+                                  are all defined as 4 byte types so
+                                  far so this shouldn't happen.  */
+      error (_("I don't know how to return an 8 byte value."));
       break;
     }
 }
 
 static void
 h8300h_store_return_value (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);
-  int len = TYPE_LENGTH (type);
   ULONGEST val;
 
-  switch (len)
+  switch (TYPE_LENGTH (type))
     {
     case 1:
     case 2:
     case 4:                    /* long, float */
-      val = extract_unsigned_integer (valbuf, len, byte_order);
+      val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order);
       regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, val);
       break;
     case 8:
-      val = extract_unsigned_integer (valbuf, len, byte_order);
+      val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order);
       regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM,
                                      (val >> 32) & 0xffffffff);
       regcache_cooked_write_unsigned (regcache, E_RET1_REGNUM,
@@ -901,7 +876,7 @@ h8300h_store_return_value (struct type *type, struct regcache *regcache,
 }
 
 static enum return_value_convention
-h8300_return_value (struct gdbarch *gdbarch, struct type *func_type,
+h8300_return_value (struct gdbarch *gdbarch, struct value *function,
                    struct type *type, struct regcache *regcache,
                    gdb_byte *readbuf, const gdb_byte *writebuf)
 {
@@ -915,7 +890,7 @@ h8300_return_value (struct gdbarch *gdbarch, struct type *func_type,
 }
 
 static enum return_value_convention
-h8300h_return_value (struct gdbarch *gdbarch, struct type *func_type,
+h8300h_return_value (struct gdbarch *gdbarch, struct value *function,
                     struct type *type, struct regcache *regcache,
                     gdb_byte *readbuf, const gdb_byte *writebuf)
 {
@@ -938,60 +913,85 @@ h8300h_return_value (struct gdbarch *gdbarch, struct type *func_type,
   return RETURN_VALUE_REGISTER_CONVENTION;
 }
 
-static struct cmd_list_element *setmachinelist;
+/* Implementation of 'register_sim_regno' gdbarch method.  */
+
+static int
+h8300_register_sim_regno (struct gdbarch *gdbarch, int regnum)
+{
+  /* Only makes sense to supply raw registers.  */
+  gdb_assert (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch));
+
+  /* We hide the raw ccr from the user by making it nameless.  Because
+     the default register_sim_regno hook returns
+     LEGACY_SIM_REGNO_IGNORE for unnamed registers, we need to
+     override it.  The sim register numbering is compatible with
+     gdb's.  */
+  return regnum;
+}
+
+static const char *
+h8300_register_name_common (const char *regnames[], int numregs,
+                           struct gdbarch *gdbarch, int regno)
+{
+  if (regno < 0
+      || regno >= numregs)
+    internal_error (__FILE__, __LINE__,
+                   _("h8300_register_name_common: illegal register number %d"),
+                   regno);
+  else
+    return regnames[regno];
+}
 
 static const char *
 h8300_register_name (struct gdbarch *gdbarch, int regno)
 {
   /* The register names change depending on which h8300 processor
-     type is selected. */
-  static char *register_names[] = {
+     type is selected.  */
+  static const char *register_names[] = {
     "r0", "r1", "r2", "r3", "r4", "r5", "r6",
     "sp", "", "pc", "cycles", "tick", "inst",
     "ccr",                     /* pseudo register */
   };
-  if (regno < 0
-      || regno >= (sizeof (register_names) / sizeof (*register_names)))
-    internal_error (__FILE__, __LINE__,
-                   "h8300_register_name: illegal register number %d", regno);
-  else
-    return register_names[regno];
+  return h8300_register_name_common(register_names, ARRAY_SIZE(register_names),
+                                   gdbarch, regno);
+}
+
+static const char *
+h8300h_register_name (struct gdbarch *gdbarch, int regno)
+{
+  static const char *register_names[] = {
+    "er0", "er1", "er2", "er3", "er4", "er5", "er6",
+    "sp", "", "pc", "cycles", "tick", "inst",
+    "ccr",                     /* pseudo register */
+  };
+  return h8300_register_name_common(register_names, ARRAY_SIZE(register_names),
+                                   gdbarch, regno);
 }
 
 static const char *
 h8300s_register_name (struct gdbarch *gdbarch, int regno)
 {
-  static char *register_names[] = {
+  static const char *register_names[] = {
     "er0", "er1", "er2", "er3", "er4", "er5", "er6",
     "sp", "", "pc", "cycles", "", "tick", "inst",
     "mach", "macl",
     "ccr", "exr"               /* pseudo registers */
   };
-  if (regno < 0
-      || regno >= (sizeof (register_names) / sizeof (*register_names)))
-    internal_error (__FILE__, __LINE__,
-                   "h8300s_register_name: illegal register number %d",
-                   regno);
-  else
-    return register_names[regno];
+  return h8300_register_name_common(register_names, ARRAY_SIZE(register_names),
+                                   gdbarch, regno);
 }
 
 static const char *
 h8300sx_register_name (struct gdbarch *gdbarch, int regno)
 {
-  static char *register_names[] = {
+  static const char *register_names[] = {
     "er0", "er1", "er2", "er3", "er4", "er5", "er6",
     "sp", "", "pc", "cycles", "", "tick", "inst",
     "mach", "macl", "sbr", "vbr",
     "ccr", "exr"               /* pseudo registers */
   };
-  if (regno < 0
-      || regno >= (sizeof (register_names) / sizeof (*register_names)))
-    internal_error (__FILE__, __LINE__,
-                   "h8300sx_register_name: illegal register number %d",
-                   regno);
-  else
-    return register_names[regno];
+  return h8300_register_name_common(register_names, ARRAY_SIZE(register_names),
+                                   gdbarch, regno);
 }
 
 static void
@@ -1041,7 +1041,7 @@ h8300_print_register (struct gdbarch *gdbarch, struct ui_file *file,
        fprintf_filtered (file, "u> ");
       if ((C | Z) == 1)
        fprintf_filtered (file, "u<= ");
-      if ((C == 0))
+      if (C == 0)
        fprintf_filtered (file, "u>= ");
       if (C == 1)
        fprintf_filtered (file, "u< ");
@@ -1121,10 +1121,10 @@ h8300_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
 static struct type *
 h8300_register_type (struct gdbarch *gdbarch, int regno)
 {
-  if (regno < 0 || regno >= gdbarch_num_regs (gdbarch)
-                           + gdbarch_num_pseudo_regs (gdbarch))
+  if (regno < 0 || regno >= gdbarch_num_cooked_regs (gdbarch))
     internal_error (__FILE__, __LINE__,
-                   "h8300_register_type: illegal register number %d", regno);
+                   _("h8300_register_type: illegal register number %d"),
+                   regno);
   else
     {
       switch (regno)
@@ -1147,17 +1147,57 @@ h8300_register_type (struct gdbarch *gdbarch, int regno)
     }
 }
 
+/* Helpers for h8300_pseudo_register_read.  We expose ccr/exr as
+   pseudo-registers to users with smaller sizes than the corresponding
+   raw registers.  These helpers extend/narrow the values.  */
+
+static enum register_status
+pseudo_from_raw_register (struct gdbarch *gdbarch, readable_regcache *regcache,
+                         gdb_byte *buf, int pseudo_regno, int raw_regno)
+{
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  enum register_status status;
+  ULONGEST val;
+
+  status = regcache->raw_read (raw_regno, &val);
+  if (status == REG_VALID)
+    store_unsigned_integer (buf,
+                           register_size (gdbarch, pseudo_regno),
+                           byte_order, val);
+  return status;
+}
+
+/* See pseudo_from_raw_register.  */
+
 static void
+raw_from_pseudo_register (struct gdbarch *gdbarch, struct regcache *regcache,
+                         const gdb_byte *buf, int raw_regno, int pseudo_regno)
+{
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  ULONGEST val;
+
+  val = extract_unsigned_integer (buf, register_size (gdbarch, pseudo_regno),
+                                 byte_order);
+  regcache_raw_write_unsigned (regcache, raw_regno, val);
+}
+
+static enum register_status
 h8300_pseudo_register_read (struct gdbarch *gdbarch,
-                           struct regcache *regcache, int regno,
+                           readable_regcache *regcache, int regno,
                            gdb_byte *buf)
 {
   if (regno == E_PSEUDO_CCR_REGNUM (gdbarch))
-    regcache_raw_read (regcache, E_CCR_REGNUM, buf);
+    {
+      return pseudo_from_raw_register (gdbarch, regcache, buf,
+                                      regno, E_CCR_REGNUM);
+    }
   else if (regno == E_PSEUDO_EXR_REGNUM (gdbarch))
-    regcache_raw_read (regcache, E_EXR_REGNUM, buf);
+    {
+      return pseudo_from_raw_register (gdbarch, regcache, buf,
+                                      regno, E_EXR_REGNUM);
+    }
   else
-    regcache_raw_read (regcache, regno, buf);
+    return regcache->raw_read (regno, buf);
 }
 
 static void
@@ -1166,11 +1206,11 @@ h8300_pseudo_register_write (struct gdbarch *gdbarch,
                             const gdb_byte *buf)
 {
   if (regno == E_PSEUDO_CCR_REGNUM (gdbarch))
-    regcache_raw_write (regcache, E_CCR_REGNUM, buf);
+    raw_from_pseudo_register (gdbarch, regcache, buf, E_CCR_REGNUM, regno);
   else if (regno == E_PSEUDO_EXR_REGNUM (gdbarch))
-    regcache_raw_write (regcache, E_EXR_REGNUM, buf);
+    raw_from_pseudo_register (gdbarch, regcache, buf, E_EXR_REGNUM, regno);
   else
-    regcache_raw_write (regcache, regno, buf);
+    regcache->raw_write (regno, buf);
 }
 
 static int
@@ -1191,66 +1231,46 @@ h8300s_dbg_reg_to_regnum (struct gdbarch *gdbarch, int regno)
   return regno;
 }
 
-const static unsigned char *
-h8300_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
-                         int *lenptr)
-{
-  /*static unsigned char breakpoint[] = { 0x7A, 0xFF }; *//* ??? */
-  static unsigned char breakpoint[] = { 0x01, 0x80 };  /* Sleep */
-
-  *lenptr = sizeof (breakpoint);
-  return breakpoint;
-}
+/*static unsigned char breakpoint[] = { 0x7A, 0xFF }; *//* ??? */
+constexpr gdb_byte h8300_break_insn[] = { 0x01, 0x80 };        /* Sleep */
 
-static void
-h8300_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
-                       struct frame_info *frame, const char *args)
-{
-  fprintf_filtered (file, "\
-No floating-point info available for this processor.\n");
-}
+typedef BP_MANIPULATION (h8300_break_insn) h8300_breakpoint;
 
 static struct gdbarch *
 h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
-  struct gdbarch_tdep *tdep = NULL;
   struct gdbarch *gdbarch;
 
   arches = gdbarch_list_lookup_by_info (arches, &info);
   if (arches != NULL)
     return arches->gdbarch;
 
-#if 0
-  tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
-#endif
-
   if (info.bfd_arch_info->arch != bfd_arch_h8300)
     return NULL;
 
   gdbarch = gdbarch_alloc (&info, 0);
 
+  set_gdbarch_register_sim_regno (gdbarch, h8300_register_sim_regno);
+
   switch (info.bfd_arch_info->mach)
     {
     case bfd_mach_h8300:
       set_gdbarch_num_regs (gdbarch, 13);
       set_gdbarch_num_pseudo_regs (gdbarch, 1);
-      set_gdbarch_ecoff_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);
       set_gdbarch_dwarf2_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);
       set_gdbarch_stab_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);
       set_gdbarch_register_name (gdbarch, h8300_register_name);
       set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
       set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
       set_gdbarch_return_value (gdbarch, h8300_return_value);
-      set_gdbarch_print_insn (gdbarch, print_insn_h8300);
       break;
     case bfd_mach_h8300h:
     case bfd_mach_h8300hn:
       set_gdbarch_num_regs (gdbarch, 13);
       set_gdbarch_num_pseudo_regs (gdbarch, 1);
-      set_gdbarch_ecoff_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);
       set_gdbarch_dwarf2_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);
       set_gdbarch_stab_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);
-      set_gdbarch_register_name (gdbarch, h8300_register_name);
+      set_gdbarch_register_name (gdbarch, h8300h_register_name);
       if (info.bfd_arch_info->mach != bfd_mach_h8300hn)
        {
          set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
@@ -1262,13 +1282,11 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
          set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
        }
       set_gdbarch_return_value (gdbarch, h8300h_return_value);
-      set_gdbarch_print_insn (gdbarch, print_insn_h8300h);
       break;
     case bfd_mach_h8300s:
     case bfd_mach_h8300sn:
       set_gdbarch_num_regs (gdbarch, 16);
       set_gdbarch_num_pseudo_regs (gdbarch, 2);
-      set_gdbarch_ecoff_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
       set_gdbarch_dwarf2_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
       set_gdbarch_stab_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
       set_gdbarch_register_name (gdbarch, h8300s_register_name);
@@ -1283,13 +1301,11 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
          set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
        }
       set_gdbarch_return_value (gdbarch, h8300h_return_value);
-      set_gdbarch_print_insn (gdbarch, print_insn_h8300s);
       break;
     case bfd_mach_h8300sx:
     case bfd_mach_h8300sxn:
       set_gdbarch_num_regs (gdbarch, 18);
       set_gdbarch_num_pseudo_regs (gdbarch, 2);
-      set_gdbarch_ecoff_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
       set_gdbarch_dwarf2_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
       set_gdbarch_stab_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);
       set_gdbarch_register_name (gdbarch, h8300sx_register_name);
@@ -1304,7 +1320,6 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
          set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
        }
       set_gdbarch_return_value (gdbarch, h8300h_return_value);
-      set_gdbarch_print_insn (gdbarch, print_insn_h8300s);
       break;
     }
 
@@ -1319,7 +1334,6 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_pc_regnum (gdbarch, E_PC_REGNUM);
   set_gdbarch_register_type (gdbarch, h8300_register_type);
   set_gdbarch_print_registers_info (gdbarch, h8300_print_registers_info);
-  set_gdbarch_print_float_info (gdbarch, h8300_print_float_info);
 
   /*
    * Frame Info
@@ -1327,26 +1341,32 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_skip_prologue (gdbarch, h8300_skip_prologue);
 
   /* Frame unwinder.  */
-  set_gdbarch_unwind_pc (gdbarch, h8300_unwind_pc);
-  set_gdbarch_unwind_sp (gdbarch, h8300_unwind_sp);
-  set_gdbarch_dummy_id (gdbarch, h8300_dummy_id);
   frame_base_set_default (gdbarch, &h8300_frame_base);
 
   /* 
-   * Miscelany
+   * Miscellany
    */
-  /* Stack grows up. */
+  /* Stack grows up.  */
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
 
-  set_gdbarch_breakpoint_from_pc (gdbarch, h8300_breakpoint_from_pc);
+  set_gdbarch_breakpoint_kind_from_pc (gdbarch,
+                                      h8300_breakpoint::kind_from_pc);
+  set_gdbarch_sw_breakpoint_from_kind (gdbarch,
+                                      h8300_breakpoint::bp_from_kind);
   set_gdbarch_push_dummy_call (gdbarch, h8300_push_dummy_call);
 
   set_gdbarch_char_signed (gdbarch, 0);
   set_gdbarch_int_bit (gdbarch, 2 * 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_double_bit (gdbarch, 4 * TARGET_CHAR_BIT);
+  set_gdbarch_double_format (gdbarch, floatformats_ieee_single);
   set_gdbarch_long_double_bit (gdbarch, 4 * TARGET_CHAR_BIT);
+  set_gdbarch_long_double_format (gdbarch, floatformats_ieee_single);
 
   set_gdbarch_believe_pcc_promotion (gdbarch, 1);
 
@@ -1358,10 +1378,9 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
 }
 
-extern initialize_file_ftype _initialize_h8300_tdep;   /* -Wmissing-prototypes */
-
+void _initialize_h8300_tdep ();
 void
-_initialize_h8300_tdep (void)
+_initialize_h8300_tdep ()
 {
   register_gdbarch_init (bfd_arch_h8300, h8300_gdbarch_init);
 }
This page took 0.034143 seconds and 4 git commands to generate.