*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / score-tdep.c
index d97310729f59332fe1178eaf60d5158715c0cf1d..50fd5af20d6509429737ea68faa2834653a9e61d 100644 (file)
@@ -1,7 +1,7 @@
 /* Target-dependent code for the S+core architecture, for GDB,
    the GNU Debugger.
 
-   Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    Contributed by Qinwei (qinwei@sunnorth.com.cn)
    Contributed by Ching-Peng Lin (cplin@sunplus.com)
@@ -100,7 +100,7 @@ score_compare_pdr_entries (const void *a, const void *b)
 
 static void
 score_analyze_pdr_section (CORE_ADDR startaddr, CORE_ADDR pc,
-                           struct frame_info *next_frame,
+                           struct frame_info *this_frame,
                            struct score_frame_cache *this_cache)
 {
   struct symbol *sym;
@@ -268,7 +268,7 @@ static struct type *
 score_register_type (struct gdbarch *gdbarch, int regnum)
 {
   gdb_assert (regnum >= 0 && regnum < SCORE_NUM_REGS);
-  return builtin_type_uint32;
+  return builtin_type (gdbarch)->builtin_uint32;
 }
 
 static CORE_ADDR
@@ -305,7 +305,7 @@ score_register_name (struct gdbarch *gdbarch, int regnum)
 }
 
 static int
-score_register_sim_regno (int regnum)
+score_register_sim_regno (struct gdbarch *gdbarch, int regnum)
 {
   gdb_assert (regnum >= 0 && regnum < SCORE_NUM_REGS);
   return regnum;
@@ -314,7 +314,7 @@ score_register_sim_regno (int regnum)
 static int
 score_print_insn (bfd_vma memaddr, struct disassemble_info *info)
 {
-  if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+  if (info->endian == BFD_ENDIAN_BIG)
     return print_insn_big_score (memaddr, info);
   else
     return print_insn_little_score (memaddr, info);
@@ -324,6 +324,7 @@ static const gdb_byte *
 score_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
                          int *lenptr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[SCORE_INSTLEN] = { 0 };
   int ret;
   unsigned int raw;
@@ -333,9 +334,9 @@ score_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
       error ("Error: target_read_memory in file:%s, line:%d!",
              __FILE__, __LINE__);
     }
-  raw = extract_unsigned_integer (buf, SCORE_INSTLEN);
+  raw = extract_unsigned_integer (buf, SCORE_INSTLEN, byte_order);
 
-  if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
+  if (byte_order == BFD_ENDIAN_BIG)
     {
       if (!(raw & 0x80008000))
         {
@@ -414,8 +415,8 @@ score_xfer_register (struct regcache *regcache, int regnum, int length,
 }
 
 static enum return_value_convention
-score_return_value (struct gdbarch *gdbarch, struct type *type,
-                    struct regcache *regcache,
+score_return_value (struct gdbarch *gdbarch, struct type *func_type,
+                   struct type *type, struct regcache *regcache,
                     gdb_byte * readbuf, const gdb_byte * writebuf)
 {
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT
@@ -442,12 +443,11 @@ score_return_value (struct gdbarch *gdbarch, struct type *type,
 }
 
 static struct frame_id
-score_unwind_dummy_id (struct gdbarch *gdbarch,
-                       struct frame_info *next_frame)
+score_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
 {
   return frame_id_build (
-           frame_unwind_register_unsigned (next_frame, SCORE_SP_REGNUM),
-           frame_pc_unwind (next_frame));
+           get_frame_register_unsigned (this_frame, SCORE_SP_REGNUM),
+           get_frame_pc (this_frame));
 }
 
 static int
@@ -477,6 +477,7 @@ score_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                        int nargs, struct value **args, CORE_ADDR sp,
                        int struct_return, CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int argnum;
   int argreg;
   int arglen = 0;
@@ -554,7 +555,8 @@ score_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       while (arglen > 0)
         {
           int partial_len = arglen < SCORE_REGSIZE ? arglen : SCORE_REGSIZE;
-          ULONGEST regval = extract_unsigned_integer (val, partial_len);
+          ULONGEST regval = extract_unsigned_integer (val, partial_len,
+                                                     byte_order);
 
           /* The last part of a arg should shift left when
              gdbarch_byte_order is BFD_ENDIAN_BIG.  */
@@ -641,8 +643,9 @@ score_adjust_memblock_ptr (char **memblock, CORE_ADDR prev_pc,
 }
 
 static inst_t *
-score_fetch_inst (CORE_ADDR addr, char *memblock)
+score_fetch_inst (struct gdbarch *gdbarch, CORE_ADDR addr, char *memblock)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   static inst_t inst = { 0, 0 };
   char buf[SCORE_INSTLEN] = { 0 };
   int big;
@@ -665,10 +668,10 @@ score_fetch_inst (CORE_ADDR addr, char *memblock)
         }
     }
 
-  inst.raw = extract_unsigned_integer (buf, SCORE_INSTLEN);
+  inst.raw = extract_unsigned_integer (buf, SCORE_INSTLEN, byte_order);
   inst.is15 = !(inst.raw & 0x80008000);
   inst.v = RM_PBITS (inst.raw);
-  big = (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG);
+  big = (byte_order == BFD_ENDIAN_BIG);
   if (inst.is15)
     {
       if (big ^ ((addr & 0x2) == 2))
@@ -680,13 +683,13 @@ score_fetch_inst (CORE_ADDR addr, char *memblock)
 }
 
 static CORE_ADDR
-score_skip_prologue (CORE_ADDR pc)
+score_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   CORE_ADDR cpc = pc;
   int iscan = 32, stack_sub = 0;
   while (iscan-- > 0)
     {
-      inst_t *inst = score_fetch_inst (cpc, NULL);
+      inst_t *inst = score_fetch_inst (gdbarch, cpc, NULL);
       if (!inst)
         break;
       if (!inst->is15 && !stack_sub
@@ -731,7 +734,7 @@ score_skip_prologue (CORE_ADDR pc)
 static int
 score_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR cur_pc)
 {
-  inst_t *inst = score_fetch_inst (cur_pc, NULL);
+  inst_t *inst = score_fetch_inst (gdbarch, cur_pc, NULL);
 
   if (inst->v == 0x23)
     return 1;   /* mv! r0, r2 */
@@ -754,9 +757,10 @@ score_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR cur_pc)
 
 static void
 score_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
-                        struct frame_info *next_frame,
+                        struct frame_info *this_frame,
                         struct score_frame_cache *this_cache)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   CORE_ADDR sp;
   CORE_ADDR fp;
   CORE_ADDR cur_pc = startaddr;
@@ -776,8 +780,8 @@ score_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
   memblock_ptr = memblock =
     score_malloc_and_get_memblock (startaddr, pc - startaddr);
 
-  sp = frame_unwind_register_unsigned (next_frame, SCORE_SP_REGNUM);
-  fp = frame_unwind_register_unsigned (next_frame, SCORE_FP_REGNUM);
+  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)
     {
@@ -787,13 +791,13 @@ score_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
           /* Reading memory block from target succefully and got all
              the instructions(from STARTADDR to PC) needed.  */
           score_adjust_memblock_ptr (&memblock, prev_pc, cur_pc);
-          inst = score_fetch_inst (cur_pc, memblock);
+          inst = score_fetch_inst (gdbarch, cur_pc, memblock);
         }
       else
         {
           /* Otherwise, we fetch 4 bytes from target, and GDB also
              work correctly.  */
-          inst = score_fetch_inst (cur_pc, NULL);
+          inst = score_fetch_inst (gdbarch, cur_pc, NULL);
         }
 
       if (inst->is15 == 1)
@@ -895,7 +899,7 @@ score_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
                 {
                   unsigned int save_v = inst->v;
                   inst_t *inst2 =
-                    score_fetch_inst (cur_pc + SCORE_INSTLEN, NULL);
+                    score_fetch_inst (gdbarch, cur_pc + SCORE_INSTLEN, NULL);
                   if (inst2->v == 0x23)
                     {
                       /* mv! r0, r2 */
@@ -937,7 +941,7 @@ score_analyze_prologue (CORE_ADDR startaddr, CORE_ADDR pc,
 }
 
 static struct score_frame_cache *
-score_make_prologue_cache (struct frame_info *next_frame, void **this_cache)
+score_make_prologue_cache (struct frame_info *this_frame, void **this_cache)
 {
   struct score_frame_cache *cache;
 
@@ -946,17 +950,17 @@ score_make_prologue_cache (struct frame_info *next_frame, void **this_cache)
 
   cache = FRAME_OBSTACK_ZALLOC (struct score_frame_cache);
   (*this_cache) = cache;
-  cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
+  cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
 
   /* Analyze the prologue.  */
   {
-    const CORE_ADDR pc = frame_pc_unwind (next_frame);
+    const CORE_ADDR pc = get_frame_pc (this_frame);
     CORE_ADDR start_addr;
 
     find_pc_partial_function (pc, NULL, &start_addr, NULL);
     if (start_addr == 0)
       return cache;
-    score_analyze_prologue (start_addr, pc, next_frame, *this_cache);
+    score_analyze_prologue (start_addr, pc, this_frame, *this_cache);
   }
 
   /* Save SP.  */
@@ -966,47 +970,38 @@ score_make_prologue_cache (struct frame_info *next_frame, void **this_cache)
 }
 
 static void
-score_prologue_this_id (struct frame_info *next_frame, void **this_cache,
+score_prologue_this_id (struct frame_info *this_frame, void **this_cache,
                         struct frame_id *this_id)
 {
-  struct score_frame_cache *info = score_make_prologue_cache (next_frame,
+  struct score_frame_cache *info = score_make_prologue_cache (this_frame,
                                                               this_cache);
-  (*this_id) = frame_id_build (info->base,
-                               frame_func_unwind (next_frame, NORMAL_FRAME));
+  (*this_id) = frame_id_build (info->base, get_frame_func (this_frame));
 }
 
-static void
-score_prologue_prev_register (struct frame_info *next_frame,
-                              void **this_cache,
-                              int regnum, int *optimizedp,
-                              enum lval_type *lvalp, CORE_ADDR * addrp,
-                              int *realnump, gdb_byte * valuep)
+static struct value *
+score_prologue_prev_register (struct frame_info *this_frame,
+                              void **this_cache, int regnum)
 {
-  struct score_frame_cache *info = score_make_prologue_cache (next_frame,
+  struct score_frame_cache *info = score_make_prologue_cache (this_frame,
                                                               this_cache);
-  trad_frame_get_prev_register (next_frame, info->saved_regs, regnum,
-                                optimizedp, lvalp, addrp, realnump, valuep);
+  return trad_frame_get_prev_register (this_frame, info->saved_regs, regnum);
 }
 
 static const struct frame_unwind score_prologue_unwind =
 {
   NORMAL_FRAME,
   score_prologue_this_id,
-  score_prologue_prev_register
+  score_prologue_prev_register,
+  NULL,
+  default_frame_sniffer
 };
 
-static const struct frame_unwind *
-score_prologue_sniffer (struct frame_info *next_frame)
-{
-  return &score_prologue_unwind;
-}
-
 static CORE_ADDR
-score_prologue_frame_base_address (struct frame_info *next_frame,
+score_prologue_frame_base_address (struct frame_info *this_frame,
                                    void **this_cache)
 {
   struct score_frame_cache *info =
-    score_make_prologue_cache (next_frame, this_cache);
+    score_make_prologue_cache (this_frame, this_cache);
   return info->fp;
 }
 
@@ -1019,7 +1014,7 @@ static const struct frame_base score_prologue_frame_base =
 };
 
 static const struct frame_base *
-score_prologue_frame_base_sniffer (struct frame_info *next_frame)
+score_prologue_frame_base_sniffer (struct frame_info *this_frame)
 {
   return &score_prologue_frame_base;
 }
@@ -1062,13 +1057,13 @@ 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_unwind_dummy_id (gdbarch, score_unwind_dummy_id);
+  set_gdbarch_dummy_id (gdbarch, score_dummy_id);
   set_gdbarch_push_dummy_call (gdbarch, score_push_dummy_call);
 
   /* Normal frame hooks.  */
-  frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer);
+  dwarf2_append_unwinders (gdbarch);
   frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
-  frame_unwind_append_sniffer (gdbarch, score_prologue_sniffer);
+  frame_unwind_append_unwinder (gdbarch, &score_prologue_unwind);
   frame_base_append_sniffer (gdbarch, score_prologue_frame_base_sniffer);
 
   return gdbarch;
This page took 0.028146 seconds and 4 git commands to generate.