gdb/
[binutils-gdb.git] / gdb / v850-tdep.c
index 03ae1618d31a01891e96935ef5bdfa47cc138b1a..851ba079414d7d44ac0dbfc589b347ca576df232 100644 (file)
@@ -1,5 +1,6 @@
 /* Target-dependent code for the NEC V850 for GDB, the GNU debugger.
-   Copyright 1996, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -172,10 +173,6 @@ v850_processor_type_table[] =
     v850e_reg_names, bfd_mach_v850e
   }
   ,
-  {
-    v850e_reg_names, bfd_mach_v850ea
-  }
-  ,
   {
     NULL, 0
   }
@@ -804,10 +801,10 @@ CORE_ADDR
 v850_find_callers_reg (struct frame_info *fi, int regnum)
 {
   for (; fi; fi = fi->next)
-    if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
-      return deprecated_read_register_dummy (fi->pc, fi->frame, regnum);
-    else if (fi->saved_regs[regnum] != 0)
-      return read_memory_unsigned_integer (fi->saved_regs[regnum],
+    if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi), fi->frame, fi->frame))
+      return deprecated_read_register_dummy (get_frame_pc (fi), fi->frame, regnum);
+    else if (get_frame_saved_regs (fi)[regnum] != 0)
+      return read_memory_unsigned_integer (get_frame_saved_regs (fi)[regnum],
                                           v850_register_raw_size (regnum));
 
   return read_register (regnum);
@@ -830,7 +827,7 @@ v850_frame_chain (struct frame_info *fi)
   callers_pc = FRAME_SAVED_PC (fi);
   /* If caller is a call-dummy, then our FP bears no relation to his FP! */
   fp = v850_find_callers_reg (fi, E_FP_RAW_REGNUM);
-  if (PC_IN_CALL_DUMMY (callers_pc, fp, fp))
+  if (DEPRECATED_PC_IN_CALL_DUMMY (callers_pc, fp, fp))
     return fp;                 /* caller is call-dummy: return oldest value of FP */
 
   /* Caller is NOT a call-dummy, so everything else should just work.
@@ -887,19 +884,19 @@ v850_pop_frame (void)
   struct frame_info *frame = get_current_frame ();
   int regnum;
 
-  if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
+  if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (frame), frame->frame, frame->frame))
     generic_pop_dummy_frame ();
   else
     {
       write_register (E_PC_REGNUM, FRAME_SAVED_PC (frame));
 
       for (regnum = 0; regnum < E_NUM_REGS; regnum++)
-       if (frame->saved_regs[regnum] != 0)
+       if (get_frame_saved_regs (frame)[regnum] != 0)
          write_register (regnum,
-                     read_memory_unsigned_integer (frame->saved_regs[regnum],
+                     read_memory_unsigned_integer (get_frame_saved_regs (frame)[regnum],
                                             v850_register_raw_size (regnum)));
 
-      write_register (E_SP_REGNUM, FRAME_FP (frame));
+      write_register (E_SP_REGNUM, get_frame_base (frame));
     }
 
   flush_cached_frames ();
@@ -1013,8 +1010,8 @@ v850_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
 CORE_ADDR
 v850_frame_saved_pc (struct frame_info *fi)
 {
-  if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
-    return deprecated_read_register_dummy (fi->pc, fi->frame, E_PC_REGNUM);
+  if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi), fi->frame, fi->frame))
+    return deprecated_read_register_dummy (get_frame_pc (fi), fi->frame, E_PC_REGNUM);
   else
     return v850_find_callers_reg (fi, E_RP_REGNUM);
 }
@@ -1093,8 +1090,8 @@ v850_store_return_value (struct type *type, char *valbuf)
   CORE_ADDR return_buffer;
 
   if (!v850_use_struct_convention (0, type))
-    write_register_bytes (REGISTER_BYTE (E_V0_REGNUM), valbuf, 
-                         TYPE_LENGTH (type));
+    deprecated_write_register_bytes (REGISTER_BYTE (E_V0_REGNUM), valbuf,
+                                    TYPE_LENGTH (type));
   else
     {
       return_buffer = read_register (E_V0_REGNUM);
@@ -1109,32 +1106,32 @@ v850_frame_init_saved_regs (struct frame_info *fi)
   struct pifsr pifsrs[E_NUM_REGS + 1], *pifsr;
   CORE_ADDR func_addr, func_end;
 
-  if (!fi->saved_regs)
+  if (!get_frame_saved_regs (fi))
     {
       frame_saved_regs_zalloc (fi);
 
       /* The call dummy doesn't save any registers on the stack, so we
          can return now.  */
-      if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+      if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi), fi->frame, fi->frame))
        return;
 
       /* Find the beginning of this function, so we can analyze its
          prologue. */
-      if (find_pc_partial_function (fi->pc, NULL, &func_addr, &func_end))
+      if (find_pc_partial_function (get_frame_pc (fi), NULL, &func_addr, &func_end))
        {
          pi.pifsrs = pifsrs;
 
-         v850_scan_prologue (fi->pc, &pi);
+         v850_scan_prologue (get_frame_pc (fi), &pi);
 
          if (!fi->next && pi.framereg == E_SP_REGNUM)
-           fi->frame = read_register (pi.framereg) - pi.frameoffset;
+           deprecated_update_frame_base_hack (fi, read_register (pi.framereg) - pi.frameoffset);
 
          for (pifsr = pifsrs; pifsr->framereg; pifsr++)
            {
-             fi->saved_regs[pifsr->reg] = pifsr->offset + fi->frame;
+             get_frame_saved_regs (fi)[pifsr->reg] = pifsr->offset + fi->frame;
 
              if (pifsr->framereg == E_SP_REGNUM)
-               fi->saved_regs[pifsr->reg] += pi.frameoffset;
+               get_frame_saved_regs (fi)[pifsr->reg] += pi.frameoffset;
            }
        }
       /* Else we're out of luck (can't debug completely stripped code). 
@@ -1147,7 +1144,7 @@ v850_frame_init_saved_regs (struct frame_info *fi)
    registers.  Most of the work is done in scan_prologue().
 
    Note that when we are called for the last frame (currently active frame),
-   that fi->pc and fi->frame will already be setup.  However, fi->frame will
+   that get_frame_pc (fi) and fi->frame will already be setup.  However, fi->frame will
    be valid only if this routine uses FP.  For previous frames, fi-frame will
    always be correct (since that is derived from v850_frame_chain ()).
 
@@ -1161,7 +1158,7 @@ v850_init_extra_frame_info (int fromleaf, struct frame_info *fi)
   struct prologue_info pi;
 
   if (fi->next)
-    fi->pc = FRAME_SAVED_PC (fi->next);
+    deprecated_update_frame_pc_hack (fi, FRAME_SAVED_PC (fi->next));
 
   v850_frame_init_saved_regs (fi);
 }
@@ -1201,6 +1198,10 @@ v850_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   gdbarch = gdbarch_alloc (&info, 0);
 
+  /* NOTE: cagney/2002-12-06: This can be deleted when this arch is
+     ready to unwind the PC first (see frame.c:get_prev_frame()).  */
+  set_gdbarch_deprecated_init_frame_pc (gdbarch, init_frame_pc_default);
+
   for (i = 0; v850_processor_type_table[i].regnames != NULL; i++)
     {
       if (v850_processor_type_table[i].mach == info.bfd_arch_info->mach)
@@ -1237,13 +1238,10 @@ v850_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_init_extra_frame_info (gdbarch, v850_init_extra_frame_info);
   set_gdbarch_frame_init_saved_regs (gdbarch, v850_frame_init_saved_regs);
   set_gdbarch_frame_chain (gdbarch, v850_frame_chain);
-  set_gdbarch_get_saved_register (gdbarch, generic_unwind_get_saved_register);
   set_gdbarch_saved_pc_after_call (gdbarch, v850_saved_pc_after_call);
   set_gdbarch_frame_saved_pc (gdbarch, v850_frame_saved_pc);
   set_gdbarch_skip_prologue (gdbarch, v850_skip_prologue);
   set_gdbarch_frame_chain_valid (gdbarch, generic_file_frame_chain_valid);
-  set_gdbarch_frame_args_address (gdbarch, default_frame_address);
-  set_gdbarch_frame_locals_address (gdbarch, default_frame_address);
 
   /* 
    * Miscelany
@@ -1259,14 +1257,11 @@ v850_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_frame_args_skip (gdbarch, 0);
   /* OK to default this value to 'unknown'. */
   set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
-  /* W/o prototype, coerce float args to double. */
-  set_gdbarch_coerce_float_to_double (gdbarch, standard_coerce_float_to_double);
 
   /*
    * Call Dummies
    * 
    * These values and methods are used when gdb calls a target function.  */
-  set_gdbarch_use_generic_dummy_frames (gdbarch, 1);
   set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame);
   set_gdbarch_push_return_address (gdbarch, v850_push_return_address);
   set_gdbarch_deprecated_extract_return_value (gdbarch, v850_extract_return_value);
@@ -1276,13 +1271,11 @@ v850_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_deprecated_store_return_value (gdbarch, v850_store_return_value);
   set_gdbarch_deprecated_extract_struct_value_address (gdbarch, v850_extract_struct_value_address);
   set_gdbarch_use_struct_convention (gdbarch, v850_use_struct_convention);
-  set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT);
   set_gdbarch_call_dummy_address (gdbarch, entry_point_address);
   set_gdbarch_call_dummy_start_offset (gdbarch, 0);
   set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
   set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1);
   set_gdbarch_call_dummy_length (gdbarch, 0);
-  set_gdbarch_pc_in_call_dummy (gdbarch, generic_pc_in_call_dummy);
   set_gdbarch_call_dummy_p (gdbarch, 1);
   set_gdbarch_call_dummy_words (gdbarch, call_dummy_nil);
   set_gdbarch_sizeof_call_dummy_words (gdbarch, 0);