*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / h8300-tdep.c
index f5a8e4df16c95a58b46c1d5f8ecd6fee0d2c1f7b..b83994adf11f7f06e941258132eb4ed2f72b1764 100644 (file)
@@ -7,7 +7,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -16,9 +16,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /*
    Contributed by Steve Chamberlain
@@ -62,8 +60,8 @@ enum gdb_regnum
 
 #define H8300_MAX_NUM_REGS 18
 
-#define E_PSEUDO_CCR_REGNUM (NUM_REGS)
-#define E_PSEUDO_EXR_REGNUM (NUM_REGS+1)
+#define E_PSEUDO_CCR_REGNUM (gdbarch_num_regs (current_gdbarch))
+#define E_PSEUDO_EXR_REGNUM (gdbarch_num_regs (current_gdbarch)+1)
 
 struct h8300_frame_cache
 {
@@ -134,7 +132,7 @@ h8300_init_frame_cache (struct h8300_frame_cache *cache)
 
   /* Saved registers.  We initialize these to -1 since zero is a valid
      offset (that's where %fp is supposed to be stored).  */
-  for (i = 0; i < NUM_REGS; i++)
+  for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++)
     cache->saved_regs[i] = -1;
 }
 
@@ -447,7 +445,7 @@ h8300_frame_cache (struct frame_info *next_frame, void **this_cache)
 
   cache->saved_regs[E_PC_REGNUM] = -BINWORD;
 
-  cache->pc = frame_func_unwind (next_frame);
+  cache->pc = frame_func_unwind (next_frame, NORMAL_FRAME);
   current_pc = frame_pc_unwind (next_frame);
   if (cache->pc != 0)
     h8300_analyze_prologue (cache->pc, current_pc, cache);
@@ -475,7 +473,7 @@ h8300_frame_cache (struct frame_info *next_frame, void **this_cache)
 
   /* Adjust all the saved registers such that they contain addresses
      instead of offsets.  */
-  for (i = 0; i < NUM_REGS; i++)
+  for (i = 0; i < gdbarch_num_regs (get_frame_arch (next_frame)); i++)
     if (cache->saved_regs[i] != -1)
       cache->saved_regs[i] = cache->base - cache->saved_regs[i];
 
@@ -502,6 +500,7 @@ h8300_frame_prev_register (struct frame_info *next_frame, void **this_cache,
                           enum lval_type *lvalp, CORE_ADDR *addrp,
                           int *realnump, gdb_byte *valuep)
 {
+  struct gdbarch *gdbarch = get_frame_arch (next_frame);
   struct h8300_frame_cache *cache =
     h8300_frame_cache (next_frame, this_cache);
 
@@ -518,14 +517,15 @@ h8300_frame_prev_register (struct frame_info *next_frame, void **this_cache,
       return;
     }
 
-  if (regnum < NUM_REGS && cache->saved_regs[regnum] != -1)
+  if (regnum < gdbarch_num_regs (gdbarch)
+      && cache->saved_regs[regnum] != -1)
     {
       *optimizedp = 0;
       *lvalp = lval_memory;
       *addrp = cache->saved_regs[regnum];
       *realnump = -1;
       if (valuep)
-       read_memory (*addrp, valuep, register_size (current_gdbarch, regnum));
+       read_memory (*addrp, valuep, register_size (gdbarch, regnum));
       return;
     }
 
@@ -947,7 +947,7 @@ h8300h_return_value (struct gdbarch *gdbarch, struct type *type,
 static struct cmd_list_element *setmachinelist;
 
 static const char *
-h8300_register_name (int regno)
+h8300_register_name (struct gdbarch *gdbarch, int regno)
 {
   /* The register names change depending on which h8300 processor
      type is selected. */
@@ -965,7 +965,7 @@ h8300_register_name (int regno)
 }
 
 static const char *
-h8300s_register_name (int regno)
+h8300s_register_name (struct gdbarch *gdbarch, int regno)
 {
   static char *register_names[] = {
     "er0", "er1", "er2", "er3", "er4", "er5", "er6",
@@ -983,7 +983,7 @@ h8300s_register_name (int regno)
 }
 
 static const char *
-h8300sx_register_name (int regno)
+h8300sx_register_name (struct gdbarch *gdbarch, int regno)
 {
   static char *register_names[] = {
     "er0", "er1", "er2", "er3", "er4", "er5", "er6",
@@ -1014,7 +1014,7 @@ h8300_print_register (struct gdbarch *gdbarch, struct ui_file *file,
 
   fprintf_filtered (file, "%-14s ", name);
   if ((regno == E_PSEUDO_CCR_REGNUM) || \
-      (regno == E_PSEUDO_EXR_REGNUM && is_h8300smode (current_gdbarch)))
+      (regno == E_PSEUDO_EXR_REGNUM && is_h8300smode (gdbarch)))
     {
       fprintf_filtered (file, "0x%02x        ", (unsigned char) rval);
       print_longest (file, 'u', 1, rval);
@@ -1063,7 +1063,7 @@ h8300_print_register (struct gdbarch *gdbarch, struct ui_file *file,
       if ((Z | (N ^ V)) == 1)
        fprintf_filtered (file, "<= ");
     }
-  else if (regno == E_PSEUDO_EXR_REGNUM && is_h8300smode (current_gdbarch))
+  else if (regno == E_PSEUDO_EXR_REGNUM && is_h8300smode (gdbarch))
     {
       /* EXR register */
       unsigned char l = rval & 0xff;
@@ -1086,10 +1086,10 @@ h8300_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
        h8300_print_register (gdbarch, file, frame, regno);
       h8300_print_register (gdbarch, file, frame, E_PSEUDO_CCR_REGNUM);
       h8300_print_register (gdbarch, file, frame, E_PC_REGNUM);
-      if (is_h8300smode (current_gdbarch))
+      if (is_h8300smode (gdbarch))
        {
          h8300_print_register (gdbarch, file, frame, E_PSEUDO_EXR_REGNUM);
-         if (is_h8300sxmode (current_gdbarch))
+         if (is_h8300sxmode (gdbarch))
            {
              h8300_print_register (gdbarch, file, frame, E_SBR_REGNUM);
              h8300_print_register (gdbarch, file, frame, E_VBR_REGNUM);
@@ -1112,7 +1112,7 @@ h8300_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
       if (regno == E_CCR_REGNUM)
        h8300_print_register (gdbarch, file, frame, E_PSEUDO_CCR_REGNUM);
       else if (regno == E_PSEUDO_EXR_REGNUM
-              && is_h8300smode (current_gdbarch))
+              && is_h8300smode (gdbarch))
        h8300_print_register (gdbarch, file, frame, E_PSEUDO_EXR_REGNUM);
       else
        h8300_print_register (gdbarch, file, frame, regno);
@@ -1122,7 +1122,8 @@ 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 >= NUM_REGS + NUM_PSEUDO_REGS)
+  if (regno < 0 || regno >= gdbarch_num_regs (gdbarch)
+                           + gdbarch_num_pseudo_regs (gdbarch))
     internal_error (__FILE__, __LINE__,
                    "h8300_register_type: illegal register number %d", regno);
   else
@@ -1139,7 +1140,7 @@ h8300_register_type (struct gdbarch *gdbarch, int regno)
            return builtin_type_uint8;
          else if (regno == E_PSEUDO_EXR_REGNUM)
            return builtin_type_uint8;
-         else if (is_h8300hmode (current_gdbarch))
+         else if (is_h8300hmode (gdbarch))
            return builtin_type_int32;
          else
            return builtin_type_int16;
@@ -1192,7 +1193,8 @@ h8300s_dbg_reg_to_regnum (int regno)
 }
 
 const static unsigned char *
-h8300_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
+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 */
This page took 0.026649 seconds and 4 git commands to generate.