gdb/testsuite: Fix race condition in gdb.base/skip.exp
[deliverable/binutils-gdb.git] / gdb / score-tdep.c
index 47da1c81d7d64d9e20e04ffaeed11028ef6b6a13..0ec0e35943a017ad8569f76223b5811e157038fa 100644 (file)
@@ -1,7 +1,7 @@
 /* Target-dependent code for the S+core architecture, for GDB,
    the GNU Debugger.
 
-   Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2006-2020 Free Software Foundation, Inc.
 
    Contributed by Qinwei (qinwei@sunnorth.com.cn)
    Contributed by Ching-Peng Lin (cplin@sunplus.com)
@@ -22,7 +22,6 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "gdb_assert.h"
 #include "inferior.h"
 #include "symtab.h"
 #include "objfiles.h"
@@ -42,9 +41,9 @@
     ((unsigned)((_i) << (31 - (_ms))) >> (31 - (_ms) + (_ls)))
 
 typedef struct{
-    unsigned long long v;
-    unsigned long long raw;
-    unsigned int len;
+  unsigned long long v;
+  unsigned long long raw;
+  unsigned int len;
 }inst_t;
 
 struct score_frame_cache
@@ -56,78 +55,15 @@ struct score_frame_cache
 
 static int target_mach = bfd_mach_score7;
 
-#if WITH_SIM
-int
-score_target_can_use_watch (int type, int cnt, int othertype)
-{
-  if (strcmp (current_target.to_shortname, "sim") == 0)
-      return soc_gh_can_use_watch (type, cnt);
-  return (*current_target.to_can_use_hw_breakpoint) (type, cnt, othertype);
-}
-
-int
-score_stopped_by_watch (void)
-{
-  if (strcmp (current_target.to_shortname, "sim") == 0)
-      return soc_gh_stopped_by_watch ();
-  return (*current_target.to_stopped_by_watchpoint) ();
-}
-
-int
-score_target_insert_watchpoint (CORE_ADDR addr, int len, int type)
-{
-  if (strcmp (current_target.to_shortname, "sim") == 0)
-      return soc_gh_add_watch (addr, len, type);
-  return (*current_target.to_insert_watchpoint) (addr, len, type); 
-}
-
-int
-score_target_remove_watchpoint (CORE_ADDR addr, int len, int type)
-{
-  if (strcmp (current_target.to_shortname, "sim") == 0)
-      return soc_gh_del_watch (addr, len, type);
-  return (*current_target.to_remove_watchpoint) (addr, len, type); 
-}
-
-int
-score_target_insert_hw_breakpoint (struct gdbarch *gdbarch,
-                                  struct bp_target_info * bp_tgt)
-{
-  if (strcmp (current_target.to_shortname, "sim") == 0)
-      return soc_gh_add_hardbp (bp_tgt->placed_address);
-  return (*current_target.to_insert_hw_breakpoint) (gdbarch, bp_tgt);
-}
-
-int
-score_target_remove_hw_breakpoint (struct gdbarch *gdbarch,
-                                  struct bp_target_info * bp_tgt)
-{
-  if (strcmp (current_target.to_shortname, "sim") == 0)
-      return soc_gh_del_hardbp (bp_tgt->placed_address);
-  return (*current_target.to_remove_hw_breakpoint) (gdbarch, bp_tgt); 
-}
-#endif
-
 static struct type *
 score_register_type (struct gdbarch *gdbarch, int regnum)
 {
   gdb_assert (regnum >= 0 
-              && regnum < ((target_mach == bfd_mach_score7) ? SCORE7_NUM_REGS : SCORE3_NUM_REGS));
+              && regnum < ((target_mach == bfd_mach_score7)
+                          ? SCORE7_NUM_REGS : SCORE3_NUM_REGS));
   return builtin_type (gdbarch)->builtin_uint32;
 }
 
-static CORE_ADDR
-score_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
-{
-  return frame_unwind_register_unsigned (next_frame, SCORE_SP_REGNUM);
-}
-
-static CORE_ADDR
-score_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
-{
-  return frame_unwind_register_unsigned (next_frame, SCORE_PC_REGNUM);
-}
-
 static const char *
 score7_register_name (struct gdbarch *gdbarch, int regnum)
 {
@@ -172,26 +108,18 @@ static int
 score_register_sim_regno (struct gdbarch *gdbarch, int regnum)
 {
   gdb_assert (regnum >= 0 
-              && regnum < ((target_mach == bfd_mach_score7) ? SCORE7_NUM_REGS : SCORE3_NUM_REGS));
+              && regnum < ((target_mach == bfd_mach_score7)
+                          ? SCORE7_NUM_REGS : SCORE3_NUM_REGS));
   return regnum;
 }
 #endif
 
-static int
-score_print_insn (bfd_vma memaddr, struct disassemble_info *info)
-{
-  if (info->endian == BFD_ENDIAN_BIG)
-    return print_insn_big_score (memaddr, info);
-  else
-    return print_insn_little_score (memaddr, info);
-}
-
 static inst_t *
-score7_fetch_inst (struct gdbarch *gdbarch, CORE_ADDR addr, char *memblock)
+score7_fetch_inst (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *memblock)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   static inst_t inst = { 0, 0, 0 };
-  char buf[SCORE_INSTLEN] = { 0 };
+  gdb_byte buf[SCORE_INSTLEN] = { 0 };
   int big;
   int ret;
 
@@ -206,7 +134,7 @@ score7_fetch_inst (struct gdbarch *gdbarch, CORE_ADDR addr, char *memblock)
       ret = target_read_memory (addr & ~0x3, buf, SCORE_INSTLEN);
       if (ret)
         {
-          error ("Error: target_read_memory in file:%s, line:%d!",
+          error (_("Error: target_read_memory in file:%s, line:%d!"),
                   __FILE__, __LINE__);
           return 0;
         }
@@ -271,7 +199,6 @@ score3_adjust_pc_and_fetch_inst (CORE_ADDR *pcptr, int *lenptr,
 
 #define EXTRACT_LEN 2
   CORE_ADDR adjust_pc = *pcptr & ~0x1;
-  int inst_len;
   gdb_byte buf[5][EXTRACT_LEN] =
     {
       {'\0', '\0'},
@@ -299,7 +226,7 @@ score3_adjust_pc_and_fetch_inst (CORE_ADDR *pcptr, int *lenptr,
           buf[i][0] = '\0';
           buf[i][1] = '\0';
          if (i == 2)
-            error ("Error: target_read_memory in file:%s, line:%d!",
+            error (_("Error: target_read_memory in file:%s, line:%d!"),
                   __FILE__, __LINE__);
         }
 
@@ -358,69 +285,88 @@ score3_adjust_pc_and_fetch_inst (CORE_ADDR *pcptr, int *lenptr,
   return &inst;
 }
 
-static const gdb_byte *
-score7_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
-                          int *lenptr)
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
+static int
+score7_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
-  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  gdb_byte buf[SCORE_INSTLEN] = { 0 };
   int ret;
   unsigned int raw;
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  gdb_byte buf[SCORE_INSTLEN] = { 0 };
 
   if ((ret = target_read_memory (*pcptr & ~0x3, buf, SCORE_INSTLEN)) != 0)
     {
-      error ("Error: target_read_memory in file:%s, line:%d!",
-             __FILE__, __LINE__);
+      error (_("Error: target_read_memory in file:%s, line:%d!"),
+            __FILE__, __LINE__);
     }
   raw = extract_unsigned_integer (buf, SCORE_INSTLEN, byte_order);
 
-  if (byte_order == BFD_ENDIAN_BIG)
+  if (!(raw & 0x80008000))
     {
-      if (!(raw & 0x80008000))
-        {
-          /* 16bits instruction.  */
-          static gdb_byte big_breakpoint16[] = { 0x60, 0x02 };
-          *pcptr &= ~0x1;
-          *lenptr = sizeof (big_breakpoint16);
-          return big_breakpoint16;
-        }
+      /* 16bits instruction.  */
+      *pcptr &= ~0x1;
+      return 2;
+    }
+  else
+    {
+      /* 32bits instruction.  */
+      *pcptr &= ~0x3;
+      return 4;
+    }
+}
+
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
+static const gdb_byte *
+score7_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
+{
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
+  *size = kind;
+
+  if (kind == 4)
+    {
+      static gdb_byte big_breakpoint32[] = { 0x80, 0x00, 0x80, 0x06 };
+      static gdb_byte little_breakpoint32[] = { 0x06, 0x80, 0x00, 0x80 };
+
+      if (byte_order == BFD_ENDIAN_BIG)
+       return big_breakpoint32;
       else
-        {
-          /* 32bits instruction.  */
-          static gdb_byte big_breakpoint32[] = { 0x80, 0x00, 0x80, 0x06 };
-          *pcptr &= ~0x3;
-          *lenptr = sizeof (big_breakpoint32);
-          return big_breakpoint32;
-        }
+       return little_breakpoint32;
     }
   else
     {
-      if (!(raw & 0x80008000))
-        {
-          /* 16bits instruction.  */
-          static gdb_byte little_breakpoint16[] = { 0x02, 0x60 };
-          *pcptr &= ~0x1;
-          *lenptr = sizeof (little_breakpoint16);
-          return little_breakpoint16;
-        }
+      static gdb_byte big_breakpoint16[] = { 0x60, 0x02 };
+      static gdb_byte little_breakpoint16[] = { 0x02, 0x60 };
+
+      if (byte_order == BFD_ENDIAN_BIG)
+       return big_breakpoint16;
       else
-        {
-          /* 32bits instruction.  */
-          static gdb_byte little_breakpoint32[] = { 0x06, 0x80, 0x00, 0x80 };
-          *pcptr &= ~0x3;
-          *lenptr = sizeof (little_breakpoint32);
-          return little_breakpoint32;
-        }
+       return little_breakpoint16;
     }
 }
 
-static const gdb_byte *
-score3_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
-                          int *lenptr)
+/* Implement the breakpoint_kind_from_pc gdbarch method.  */
+
+static int
+score3_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  CORE_ADDR adjust_pc = *pcptr; 
   int len;
+
+  score3_adjust_pc_and_fetch_inst (pcptr, &len, byte_order);
+
+  return len;
+}
+
+/* Implement the sw_breakpoint_from_kind gdbarch method.  */
+
+static const gdb_byte *
+score3_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
+{
+  int index = 0;
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   static gdb_byte score_break_insns[6][6] = {
     /* The following three instructions are big endian.  */
     { 0x00, 0x20 },
@@ -431,18 +377,10 @@ score3_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
     { 0x00, 0x80, 0x06, 0x00 },
     { 0x00, 0x80, 0x00, 0x80, 0x00, 0x00 }};
 
-  gdb_byte *p = NULL;
-  int index = 0;
-
-  score3_adjust_pc_and_fetch_inst (&adjust_pc, &len, byte_order);
-
-  index = ((byte_order == BFD_ENDIAN_BIG) ? 0 : 3) + (len / 2 - 1);
-  p = score_break_insns[index];
-
-  *pcptr = adjust_pc;
-  *lenptr = len;
+  *size = kind;
 
-  return p;
+  index = ((byte_order == BFD_ENDIAN_BIG) ? 0 : 3) + (kind / 2 - 1);
+  return score_break_insns[index];
 }
 
 static CORE_ADDR
@@ -472,7 +410,8 @@ score_xfer_register (struct regcache *regcache, int regnum, int length,
 {
   int reg_offset = 0;
   gdb_assert (regnum >= 0 
-              && regnum < ((target_mach == bfd_mach_score7) ? SCORE7_NUM_REGS : SCORE3_NUM_REGS));
+              && regnum < ((target_mach == bfd_mach_score7)
+                          ? SCORE7_NUM_REGS : SCORE3_NUM_REGS));
 
   switch (endian)
     {
@@ -486,20 +425,20 @@ score_xfer_register (struct regcache *regcache, int regnum, int length,
       reg_offset = 0;
       break;
     default:
-      error ("Error: score_xfer_register in file:%s, line:%d!",
+      error (_("Error: score_xfer_register in file:%s, line:%d!"),
              __FILE__, __LINE__);
     }
 
   if (readbuf != NULL)
-    regcache_cooked_read_part (regcache, regnum, reg_offset, length,
-                               readbuf + buf_offset);
+    regcache->cooked_read_part (regnum, reg_offset, length,
+                               readbuf + buf_offset);
   if (writebuf != NULL)
-    regcache_cooked_write_part (regcache, regnum, reg_offset, length,
-                                writebuf + buf_offset);
+    regcache->cooked_write_part (regnum, reg_offset, length,
+                                writebuf + buf_offset);
 }
 
 static enum return_value_convention
-score_return_value (struct gdbarch *gdbarch, struct type *func_type,
+score_return_value (struct gdbarch *gdbarch, struct value *function,
                     struct type *type, struct regcache *regcache,
                     gdb_byte * readbuf, const gdb_byte * writebuf)
 {
@@ -516,6 +455,7 @@ score_return_value (struct gdbarch *gdbarch, struct type *func_type,
            offset += SCORE_REGSIZE, regnum++)
         {
           int xfer = SCORE_REGSIZE;
+
           if (offset + xfer > TYPE_LENGTH (type))
             xfer = TYPE_LENGTH (type) - offset;
           score_xfer_register (regcache, regnum, xfer,
@@ -526,14 +466,6 @@ score_return_value (struct gdbarch *gdbarch, struct type *func_type,
     }
 }
 
-static struct frame_id
-score_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
-  return frame_id_build (
-           get_frame_register_unsigned (this_frame, SCORE_SP_REGNUM),
-           get_frame_pc (this_frame));
-}
-
 static int
 score_type_needs_double_align (struct type *type)
 {
@@ -559,7 +491,8 @@ static CORE_ADDR
 score_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 argnum;
@@ -583,7 +516,7 @@ score_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
   /* Step 3, Check if struct return then save the struct address to
      r4 and increase the stack_offset by 4.  */
-  if (struct_return)
+  if (return_method == return_method_struct)
     {
       regcache_cooked_write_unsigned (regcache, argreg++, struct_addr);
       stack_offset += SCORE_REGSIZE;
@@ -599,12 +532,9 @@ score_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       enum type_code typecode = TYPE_CODE (arg_type);
       const gdb_byte *val = value_contents (arg);
       int downward_offset = 0;
-      int odd_sized_struct_p;
       int arg_last_part_p = 0;
 
       arglen = TYPE_LENGTH (arg_type);
-      odd_sized_struct_p = (arglen > SCORE_REGSIZE
-                            && arglen % SCORE_REGSIZE != 0);
 
       /* If a arg should be aligned to 8 bytes (long long or double),
          the value should be put to even register numbers.  */
@@ -738,7 +668,8 @@ score3_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
   while (iscan-- > 0)
     {
       inst_t *inst
-       = score3_adjust_pc_and_fetch_inst (&cpc, NULL, gdbarch_byte_order (gdbarch));
+       = score3_adjust_pc_and_fetch_inst (&cpc, NULL,
+                                          gdbarch_byte_order (gdbarch));
 
       if (!inst)
         break;
@@ -786,8 +717,10 @@ score3_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
   return pc;
 }
 
+/* Implement the stack_frame_destroyed_p gdbarch method. */
+
 static int
-score7_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR cur_pc)
+score7_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR cur_pc)
 {
   inst_t *inst = score7_fetch_inst (gdbarch, cur_pc, NULL);
 
@@ -810,12 +743,15 @@ score7_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR cur_pc)
     return 0;
 }
 
+/* Implement the stack_frame_destroyed_p gdbarch method. */
+
 static int
-score3_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR cur_pc)
+score3_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR cur_pc)
 {
   CORE_ADDR pc = cur_pc;
   inst_t *inst
-    = score3_adjust_pc_and_fetch_inst (&pc, NULL, gdbarch_byte_order (gdbarch));
+    = score3_adjust_pc_and_fetch_inst (&pc, NULL,
+                                      gdbarch_byte_order (gdbarch));
 
   if (inst->len == 2
       && (G_FLD (inst->v, 14, 10) == 0x10)
@@ -854,27 +790,21 @@ score3_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR cur_pc)
     return 0;
 }
 
-static char *
+static gdb_byte *
 score7_malloc_and_get_memblock (CORE_ADDR addr, CORE_ADDR size)
 {
   int ret;
-  char *memblock = NULL;
+  gdb_byte *memblock = NULL;
 
-  if (size < 0)
-    {
-      error ("Error: malloc size < 0 in file:%s, line:%d!",
-             __FILE__, __LINE__);
-      return NULL;
-    }
-  else if (size == 0)
+  if (size == 0)
     return NULL;
 
-  memblock = (char *) xmalloc (size);
+  memblock = (gdb_byte *) xmalloc (size);
   memset (memblock, 0, size);
   ret = target_read_memory (addr & ~0x3, memblock, size);
   if (ret)
     {
-      error ("Error: target_read_memory in file:%s, line:%d!",
+      error (_("Error: target_read_memory in file:%s, line:%d!"),
              __FILE__, __LINE__);
       return NULL;
     }
@@ -882,13 +812,13 @@ score7_malloc_and_get_memblock (CORE_ADDR addr, CORE_ADDR size)
 }
 
 static void
-score7_free_memblock (char *memblock)
+score7_free_memblock (gdb_byte *memblock)
 {
   xfree (memblock);
 }
 
 static void
-score7_adjust_memblock_ptr (char **memblock, CORE_ADDR prev_pc,
+score7_adjust_memblock_ptr (gdb_byte **memblock, CORE_ADDR prev_pc,
                            CORE_ADDR cur_pc)
 {
   if (prev_pc == -1)
@@ -924,8 +854,8 @@ score7_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
   int fp_offset_p = 0;
   int inst_len = 0;
 
-  char *memblock = NULL;
-  char *memblock_ptr = NULL;
+  gdb_byte *memblock = NULL;
+  gdb_byte *memblock_ptr = NULL;
   CORE_ADDR prev_pc = -1;
 
   /* Allocate MEMBLOCK if PC - STARTADDR > 0.  */
@@ -940,7 +870,7 @@ score7_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
       inst_t *inst = NULL;
       if (memblock != NULL)
         {
-          /* Reading memory block from target succefully and got all
+          /* Reading memory block from target successfully and got all
              the instructions(from STARTADDR to PC) needed.  */
           score7_adjust_memblock_ptr (&memblock, prev_pc, cur_pc);
           inst = score7_fetch_inst (gdbarch, cur_pc, memblock);
@@ -952,7 +882,7 @@ score7_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
           inst = score7_fetch_inst (gdbarch, cur_pc, NULL);
         }
 
-      /* FIXME: make a full-power prologue analyzer */
+      /* FIXME: make a full-power prologue analyzer */
       if (inst->len == 2)
         {
           inst_len = SCORE16_INSTLEN;
@@ -988,13 +918,15 @@ score7_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
                    && G_FLD (inst->v, 2, 0) == 0x0)
             {
               /* subei! r0, n */
-              sp_offset += (int) pow (2, G_FLD (inst->v, 6, 3));
+              sp_offset += (int) pow (2.0, G_FLD (inst->v, 6, 3));
             }
           else if (G_FLD (inst->v, 14, 7) == 0xc0
                    && G_FLD (inst->v, 2, 0) == 0x0)
             {
               /* addei! r0, n */
-              sp_offset -= (int) pow (2, G_FLD (inst->v, 6, 3));
+             /* Solaris 11+gcc 5.5 has ambiguous overloads of pow, so we
+                pass 2.0 instead of 2 to get the right one.  */
+              sp_offset -= (int) pow (2.0, G_FLD (inst->v, 6, 3));
             }
         }
       else
@@ -1122,7 +1054,8 @@ score3_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
   CORE_ADDR sp;
   CORE_ADDR fp;
   CORE_ADDR cur_pc = startaddr;
-  enum bfd_endian byte_order = gdbarch_byte_order (get_frame_arch (this_frame));
+  enum bfd_endian byte_order
+    = gdbarch_byte_order (get_frame_arch (this_frame));
 
   int sp_offset = 0;
   int ra_offset = 0;
@@ -1131,18 +1064,16 @@ score3_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
   int fp_offset_p = 0;
   int inst_len = 0;
 
-  CORE_ADDR prev_pc = -1;
-
   sp = get_frame_register_unsigned (this_frame, SCORE_SP_REGNUM);
   fp = get_frame_register_unsigned (this_frame, SCORE_FP_REGNUM);
 
-  for (; cur_pc < pc; prev_pc = cur_pc, cur_pc += inst_len)
+  for (; cur_pc < pc; cur_pc += inst_len)
     {
       inst_t *inst = NULL;
 
       inst = score3_adjust_pc_and_fetch_inst (&cur_pc, &inst_len, byte_order);
 
-      /* FIXME: make a full-power prologue analyzer */
+      /* FIXME: make a full-power prologue analyzer */
       if (inst->len == 2)
         {
           if (G_FLD (inst->v, 14, 12) == 0x0
@@ -1224,11 +1155,11 @@ score3_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
               /* addi! r2, offset */
               if (pc - cur_pc >= 2)
                 {
-                 unsigned int save_v = inst->v;
                  inst_t *inst2;
                  
                  cur_pc += inst->len;
-                 inst2 = score3_adjust_pc_and_fetch_inst (&cur_pc, NULL, byte_order);
+                 inst2 = score3_adjust_pc_and_fetch_inst (&cur_pc, NULL,
+                                                          byte_order);
 
                   if (inst2->len == 2
                       && G_FLD (inst2->v, 14, 10) == 0x10
@@ -1309,11 +1240,11 @@ score3_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
               /* addi r2, offset */
               if (pc - cur_pc >= 2)
                 {
-                 unsigned int save_v = inst->v;
                  inst_t *inst2;
                  
                  cur_pc += inst->len;
-                 inst2 = score3_adjust_pc_and_fetch_inst (&cur_pc, NULL, byte_order);
+                 inst2 = score3_adjust_pc_and_fetch_inst (&cur_pc, NULL,
+                                                          byte_order);
 
                   if (inst2->len == 2
                       && G_FLD (inst2->v, 14, 10) == 0x10
@@ -1363,7 +1294,7 @@ score_make_prologue_cache (struct frame_info *this_frame, void **this_cache)
   struct score_frame_cache *cache;
 
   if ((*this_cache) != NULL)
-    return (*this_cache);
+    return (struct score_frame_cache *) (*this_cache);
 
   cache = FRAME_OBSTACK_ZALLOC (struct score_frame_cache);
   (*this_cache) = cache;
@@ -1379,15 +1310,17 @@ score_make_prologue_cache (struct frame_info *this_frame, void **this_cache)
       return cache;
 
     if (target_mach == bfd_mach_score3)
-      score3_analyze_prologue (start_addr, pc, this_frame, *this_cache);
+      score3_analyze_prologue (start_addr, pc, this_frame,
+                              (struct score_frame_cache *) *this_cache);
     else
-      score7_analyze_prologue (start_addr, pc, this_frame, *this_cache);
+      score7_analyze_prologue (start_addr, pc, this_frame,
+                              (struct score_frame_cache *) *this_cache);
   }
 
   /* Save SP.  */
   trad_frame_set_value (cache->saved_regs, SCORE_SP_REGNUM, cache->base);
 
-  return (*this_cache);
+  return (struct score_frame_cache *) (*this_cache);
 }
 
 static void
@@ -1411,6 +1344,7 @@ score_prologue_prev_register (struct frame_info *this_frame,
 static const struct frame_unwind score_prologue_unwind =
 {
   NORMAL_FRAME,
+  default_frame_unwind_stop_reason,
   score_prologue_this_id,
   score_prologue_prev_register,
   NULL,
@@ -1441,83 +1375,69 @@ score_prologue_frame_base_sniffer (struct frame_info *this_frame)
   return &score_prologue_frame_base;
 }
 
-/* Core file support (dirty hack)
-  
-   The core file MUST be generated by GNU/Linux on S+core */
+/* Core file support.  */
+
+static const struct regcache_map_entry score7_linux_gregmap[] =
+  {
+    /* FIXME: According to the current Linux kernel, r0 is preceded by
+       9 rather than 7 words.  */
+    { 7, REGCACHE_MAP_SKIP, 4 },
+    { 32, 0, 4 },              /* r0 ... r31 */
+    { 1, 55, 4 },              /* CEL */
+    { 1, 54, 4 },              /* CEH */
+    { 1, 53, 4 },              /* sr0, i.e. cnt or COUNTER */
+    { 1, 52, 4 },              /* sr1, i.e. lcr or LDCR */
+    { 1, 51, 4 },              /* sr2, i.e. scr or STCR */
+    { 1, 49, 4 },              /* PC (same slot as EPC) */
+    { 1, 38, 4 },              /* EMA */
+    { 1, 32, 4 },              /* PSR */
+    { 1, 34, 4 },              /* ECR */
+    { 1, 33, 4 },              /* COND */
+    { 0 }
+  };
+
+#define SCORE7_LINUX_EPC_OFFSET (44 * 4)
+#define SCORE7_LINUX_SIZEOF_GREGSET (49 * 4)
 
 static void
 score7_linux_supply_gregset(const struct regset *regset,
-                struct regcache *regcache,
-                int regnum, const void *gregs_buf, size_t len)
+                           struct regcache *regcache,
+                           int regnum, const void *buf,
+                           size_t size)
 {
-    int regno;
-    elf_gregset_t *gregs;
-
-    gdb_assert (regset != NULL);
-    gdb_assert ((regcache != NULL) && (gregs_buf != NULL));
-
-    gregs = (elf_gregset_t *) gregs_buf;
-
-    for (regno = 0; regno < 32; regno++)
-        if (regnum == -1 || regnum == regno)
-            regcache_raw_supply (regcache, regno, gregs->regs + regno);
-
-    {
-        struct sreg {
-                int regnum;
-                void *buf;
-        } sregs [] = {
-                { 55, &(gregs->cel) },  /* CEL */
-                { 54, &(gregs->ceh) },  /* CEH */
-                { 53, &(gregs->sr0) },  /* sr0, i.e. cnt or COUNTER */
-                { 52, &(gregs->sr1) },  /* sr1, i.e. lcr or LDCR */
-                { 51, &(gregs->sr1) },  /* sr2, i.e. scr or STCR */
-
-                /* Exception occured at this address, exactly the PC we want */
-                { 49, &(gregs->cp0_epc) }, /* PC */
-
-                { 38, &(gregs->cp0_ema) }, /* EMA */
-                { 37, &(gregs->cp0_epc) }, /* EPC */
-                { 34, &(gregs->cp0_ecr) }, /* ECR */
-                { 33, &(gregs->cp0_condition) }, /* COND */
-                { 32, &(gregs->cp0_psr) }, /* PSR */
-        };
-
-        for (regno = 0; regno < sizeof(sregs)/sizeof(sregs[0]); regno++)
-           if (regnum == -1 || regnum == sregs[regno].regnum)
-               regcache_raw_supply (regcache, sregs[regno].regnum, sregs[regno].buf);
-    }
+  regcache_supply_regset (regset, regcache, regnum, buf, size);
+
+  /* Supply the EPC from the same slot as the PC.  Note that the
+     collect function will store the PC in that slot.  */
+  if ((regnum == -1 || regnum == SCORE_EPC_REGNUM)
+      && size >= SCORE7_LINUX_EPC_OFFSET + 4)
+    regcache->raw_supply
+      (SCORE_EPC_REGNUM, (const gdb_byte *) buf + SCORE7_LINUX_EPC_OFFSET);
 }
 
-/* Return the appropriate register set from the core section identified
-   by SECT_NAME and SECT_SIZE. */
-
-static const struct regset *
-score7_linux_regset_from_core_section(struct gdbarch *gdbarch,
-                    const char *sect_name, size_t sect_size)
-{
-    struct gdbarch_tdep *tdep;
-
-    gdb_assert (gdbarch != NULL);
-    gdb_assert (sect_name != NULL);
-
-    tdep = gdbarch_tdep (gdbarch);
+static const struct regset score7_linux_gregset =
+  {
+    score7_linux_gregmap,
+    score7_linux_supply_gregset,
+    regcache_collect_regset
+  };
 
-    if (strcmp(sect_name, ".reg") == 0 && sect_size == sizeof(elf_gregset_t))
-    {
-        if (tdep->gregset == NULL)
-            tdep->gregset = regset_alloc (gdbarch, score7_linux_supply_gregset, NULL);
-        return tdep->gregset;
-    }
+/* Iterate over core file register note sections.  */
 
-    return NULL;
+static void
+score7_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
+                                          iterate_over_regset_sections_cb *cb,
+                                          void *cb_data,
+                                          const struct regcache *regcache)
+{
+  cb (".reg", SCORE7_LINUX_SIZEOF_GREGSET, SCORE7_LINUX_SIZEOF_GREGSET,
+      &score7_linux_gregset, NULL, cb_data);
 }
 
 static struct gdbarch *
 score_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
   struct gdbarch *gdbarch;
-  struct gdbarch_tdep *tdep;
   target_mach = info.bfd_arch_info->mach;
 
   arches = gdbarch_list_lookup_by_info (arches, &info);
@@ -1525,8 +1445,7 @@ score_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     {
       return (arches->gdbarch);
     }
-  tdep = xcalloc(1, sizeof(struct gdbarch_tdep));
-  gdbarch = gdbarch_alloc (&info, tdep);
+  gdbarch = gdbarch_alloc (&info, NULL);
 
   set_gdbarch_short_bit (gdbarch, 16);
   set_gdbarch_int_bit (gdbarch, 32);
@@ -1538,30 +1457,37 @@ score_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 #endif
   set_gdbarch_pc_regnum (gdbarch, SCORE_PC_REGNUM);
   set_gdbarch_sp_regnum (gdbarch, SCORE_SP_REGNUM);
-  set_gdbarch_adjust_breakpoint_address (gdbarch, score_adjust_breakpoint_address);
+  set_gdbarch_adjust_breakpoint_address (gdbarch,
+                                        score_adjust_breakpoint_address);
   set_gdbarch_register_type (gdbarch, score_register_type);
   set_gdbarch_frame_align (gdbarch, score_frame_align);
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
-  set_gdbarch_unwind_sp (gdbarch, score_unwind_sp);
-  set_gdbarch_unwind_pc (gdbarch, score_unwind_pc);
-  set_gdbarch_print_insn (gdbarch, score_print_insn);
 
   switch (target_mach)
     {
     case bfd_mach_score7:
-      set_gdbarch_breakpoint_from_pc (gdbarch, score7_breakpoint_from_pc);
+      set_gdbarch_breakpoint_kind_from_pc (gdbarch,
+                                          score7_breakpoint_kind_from_pc);
+      set_gdbarch_sw_breakpoint_from_kind (gdbarch,
+                                          score7_sw_breakpoint_from_kind);
       set_gdbarch_skip_prologue (gdbarch, score7_skip_prologue);
-      set_gdbarch_in_function_epilogue_p (gdbarch, score7_in_function_epilogue_p);
+      set_gdbarch_stack_frame_destroyed_p (gdbarch,
+                                          score7_stack_frame_destroyed_p);
       set_gdbarch_register_name (gdbarch, score7_register_name);
       set_gdbarch_num_regs (gdbarch, SCORE7_NUM_REGS);
-      /* Core file support. */
-      set_gdbarch_regset_from_core_section (gdbarch, score7_linux_regset_from_core_section);
+      /* Core file support.  */
+      set_gdbarch_iterate_over_regset_sections
+       (gdbarch, score7_linux_iterate_over_regset_sections);
       break;
 
     case bfd_mach_score3:
-      set_gdbarch_breakpoint_from_pc (gdbarch, score3_breakpoint_from_pc);
+      set_gdbarch_breakpoint_kind_from_pc (gdbarch,
+                                          score3_breakpoint_kind_from_pc);
+      set_gdbarch_sw_breakpoint_from_kind (gdbarch,
+                                          score3_sw_breakpoint_from_kind);
       set_gdbarch_skip_prologue (gdbarch, score3_skip_prologue);
-      set_gdbarch_in_function_epilogue_p (gdbarch, score3_in_function_epilogue_p);
+      set_gdbarch_stack_frame_destroyed_p (gdbarch,
+                                          score3_stack_frame_destroyed_p);
       set_gdbarch_register_name (gdbarch, score3_register_name);
       set_gdbarch_num_regs (gdbarch, SCORE3_NUM_REGS);
       break;
@@ -1573,7 +1499,6 @@ score_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Dummy frame hooks.  */
   set_gdbarch_return_value (gdbarch, score_return_value);
   set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT);
-  set_gdbarch_dummy_id (gdbarch, score_dummy_id);
   set_gdbarch_push_dummy_call (gdbarch, score_push_dummy_call);
 
   /* Normal frame hooks.  */
@@ -1585,8 +1510,6 @@ score_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   return gdbarch;
 }
 
-extern initialize_file_ftype _initialize_score_tdep;
-
 void
 _initialize_score_tdep (void)
 {
This page took 0.050098 seconds and 4 git commands to generate.