*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / xstormy16-tdep.c
index 3171858dbc8056e436a0bbacb75234be156df51c..48ac1a28a2b91235acb8c433ccaafc27c58f37b5 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for the Sanyo Xstormy16a (LC590000) processor.
 
-   Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -27,6 +27,7 @@
 #include "regcache.h"
 #include "gdbcore.h"
 #include "objfiles.h"
+#include "dis-asm.h"
 
 struct gdbarch_tdep
 {
@@ -150,16 +151,6 @@ xstormy16_register_raw_size (int regnum)
     return xstormy16_reg_size;
 }
 
-/* Function: xstormy16_register_virtual_size
-   Returns the number of bytes occupied by the register as represented
-   internally by gdb. */
-
-static int
-xstormy16_register_virtual_size (int regnum)
-{
-  return xstormy16_register_raw_size (regnum);
-}
-
 /* Function: xstormy16_reg_virtual_type 
    Returns the default type for register N. */
 
@@ -220,7 +211,7 @@ xstormy16_extract_return_value (struct type *type, char *regbuf, char *valbuf)
       /* Scalar return values of <= 12 bytes are returned in 
          E_1ST_ARG_REGNUM to E_LST_ARG_REGNUM. */
       memcpy (valbuf,
-             &regbuf[REGISTER_BYTE (E_1ST_ARG_REGNUM)] + offset,
+             &regbuf[DEPRECATED_REGISTER_BYTE (E_1ST_ARG_REGNUM)] + offset,
              TYPE_LENGTH (type));
     }
   else
@@ -228,8 +219,8 @@ xstormy16_extract_return_value (struct type *type, char *regbuf, char *valbuf)
       /* Aggregates and return values > 12 bytes are returned in memory,
          pointed to by R2. */
       return_buffer =
-       extract_unsigned_integer (regbuf + REGISTER_BYTE (E_PTR_RET_REGNUM),
-                                 REGISTER_RAW_SIZE (E_PTR_RET_REGNUM));
+       extract_unsigned_integer (regbuf + DEPRECATED_REGISTER_BYTE (E_PTR_RET_REGNUM),
+                                 DEPRECATED_REGISTER_RAW_SIZE (E_PTR_RET_REGNUM));
 
       read_memory (return_buffer, valbuf, TYPE_LENGTH (type));
     }
@@ -307,12 +298,12 @@ xstormy16_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
    (which may or may not be the same as before).
 */
 
-CORE_ADDR
+static CORE_ADDR
 xstormy16_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
 {
   unsigned char buf[xstormy16_pc_size];
 
-  store_unsigned_integer (buf, xstormy16_pc_size, CALL_DUMMY_ADDRESS ());
+  store_unsigned_integer (buf, xstormy16_pc_size, entry_point_address ());
   write_memory (sp, buf, xstormy16_pc_size);
   return sp + xstormy16_pc_size;
 }
@@ -342,15 +333,15 @@ xstormy16_pop_frame (void)
     {
       /* Restore the saved regs. */
       for (i = 0; i < NUM_REGS; i++)
-       if (get_frame_saved_regs (fi)[i])
+       if (deprecated_get_frame_saved_regs (fi)[i])
          {
            if (i == SP_REGNUM)
-             write_register (i, get_frame_saved_regs (fi)[i]);
+             write_register (i, deprecated_get_frame_saved_regs (fi)[i]);
            else if (i == E_PC_REGNUM)
-             write_register (i, read_memory_integer (get_frame_saved_regs (fi)[i],
+             write_register (i, read_memory_integer (deprecated_get_frame_saved_regs (fi)[i],
                                                      xstormy16_pc_size));
            else
-             write_register (i, read_memory_integer (get_frame_saved_regs (fi)[i],
+             write_register (i, read_memory_integer (deprecated_get_frame_saved_regs (fi)[i],
                                                      xstormy16_reg_size));
          }
       /* Restore the PC */
@@ -392,7 +383,7 @@ xstormy16_store_return_value (struct type *type, char *valbuf)
     }
   else if (xstormy16_type_is_scalar (type) &&
           TYPE_LENGTH (type) <= E_MAX_RETTYPE_SIZE_IN_REGS)
-    deprecated_write_register_bytes (REGISTER_BYTE (E_1ST_ARG_REGNUM),
+    deprecated_write_register_bytes (DEPRECATED_REGISTER_BYTE (E_1ST_ARG_REGNUM),
                                     valbuf, TYPE_LENGTH (type));
   else
     {
@@ -408,10 +399,14 @@ xstormy16_store_return_value (struct type *type, char *valbuf)
 */
 
 static CORE_ADDR
-xstormy16_extract_struct_value_address (char *regbuf)
+xstormy16_extract_struct_value_address (struct regcache *regcache)
 {
-  return extract_unsigned_integer (regbuf + xstormy16_register_byte (E_PTR_RET_REGNUM),
-                                  xstormy16_reg_size);
+  /* FIXME: cagney/2004-01-17: Does the ABI guarantee that the return
+     address regster is preserved across function calls?  Probably
+     not, making this function wrong.  */
+  ULONGEST val;
+  regcache_raw_read_unsigned (regcache, E_PTR_RET_REGNUM, &val);
+  return val;
 }
 
 /* Function: xstormy16_use_struct_convention 
@@ -491,7 +486,7 @@ xstormy16_scan_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
          if (fi)
            {
              regnum = inst & 0x000f;
-             get_frame_saved_regs (fi)[regnum] = get_frame_extra_info (fi)->framesize;
+             deprecated_get_frame_saved_regs (fi)[regnum] = get_frame_extra_info (fi)->framesize;
              get_frame_extra_info (fi)->framesize += xstormy16_reg_size;
            }
        }
@@ -547,7 +542,7 @@ xstormy16_scan_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
              if (offset & 0x0800)
                offset -= 0x1000;
 
-             get_frame_saved_regs (fi)[regnum] = get_frame_extra_info (fi)->framesize + offset;
+             deprecated_get_frame_saved_regs (fi)[regnum] = get_frame_extra_info (fi)->framesize + offset;
            }
          next_addr += xstormy16_inst_size;
        }
@@ -594,12 +589,12 @@ xstormy16_scan_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
          previous value would have been pushed).  */
       if (get_frame_extra_info (fi)->frameless_p)
        {
-         get_frame_saved_regs (fi)[E_SP_REGNUM] = sp - get_frame_extra_info (fi)->framesize;
+         deprecated_get_frame_saved_regs (fi)[E_SP_REGNUM] = sp - get_frame_extra_info (fi)->framesize;
          deprecated_update_frame_base_hack (fi, sp);
        }
       else
        {
-         get_frame_saved_regs (fi)[E_SP_REGNUM] = fp - get_frame_extra_info (fi)->framesize;
+         deprecated_get_frame_saved_regs (fi)[E_SP_REGNUM] = fp - get_frame_extra_info (fi)->framesize;
          deprecated_update_frame_base_hack (fi, fp);
        }
 
@@ -608,11 +603,11 @@ xstormy16_scan_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
          sp, fp and framesize. We know the beginning of the frame
          so we can translate the register offsets to real addresses. */
       for (regnum = 0; regnum < E_SP_REGNUM; ++regnum)
-       if (get_frame_saved_regs (fi)[regnum])
-         get_frame_saved_regs (fi)[regnum] += get_frame_saved_regs (fi)[E_SP_REGNUM];
+       if (deprecated_get_frame_saved_regs (fi)[regnum])
+         deprecated_get_frame_saved_regs (fi)[regnum] += deprecated_get_frame_saved_regs (fi)[E_SP_REGNUM];
 
       /* Save address of PC on stack. */
-      get_frame_saved_regs (fi)[E_PC_REGNUM] = get_frame_saved_regs (fi)[E_SP_REGNUM];
+      deprecated_get_frame_saved_regs (fi)[E_PC_REGNUM] = deprecated_get_frame_saved_regs (fi)[E_SP_REGNUM];
     }
 
   return next_addr;
@@ -732,7 +727,7 @@ xstormy16_frame_init_saved_regs (struct frame_info *fi)
 {
   CORE_ADDR func_addr, func_end;
 
-  if (!get_frame_saved_regs (fi))
+  if (!deprecated_get_frame_saved_regs (fi))
     {
       frame_saved_regs_zalloc (fi);
 
@@ -764,7 +759,7 @@ xstormy16_frame_saved_pc (struct frame_info *fi)
     }
   else
     {
-      saved_pc = read_memory_unsigned_integer (get_frame_saved_regs (fi)[E_PC_REGNUM],
+      saved_pc = read_memory_unsigned_integer (deprecated_get_frame_saved_regs (fi)[E_PC_REGNUM],
                                               xstormy16_pc_size);
     }
 
@@ -995,7 +990,7 @@ xstormy16_stack_align (CORE_ADDR addr)
   return addr;
 }
 
-void
+static void
 xstormy16_save_dummy_frame_tos (CORE_ADDR sp)
 {
   generic_save_dummy_frame_tos (sp - xstormy16_pc_size);
@@ -1025,7 +1020,7 @@ xstormy16_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* 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);
+  set_gdbarch_deprecated_init_frame_pc (gdbarch, deprecated_init_frame_pc_default);
 
   /*
    * Basic register fields and methods.
@@ -1039,12 +1034,12 @@ xstormy16_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_register_name (gdbarch, xstormy16_register_name);
   set_gdbarch_deprecated_register_size (gdbarch, xstormy16_reg_size);
   set_gdbarch_deprecated_register_bytes (gdbarch, E_ALL_REGS_SIZE);
-  set_gdbarch_register_byte (gdbarch, xstormy16_register_byte);
-  set_gdbarch_register_raw_size (gdbarch, xstormy16_register_raw_size);
+  set_gdbarch_deprecated_register_byte (gdbarch, xstormy16_register_byte);
+  set_gdbarch_deprecated_register_raw_size (gdbarch, xstormy16_register_raw_size);
   set_gdbarch_deprecated_max_register_raw_size (gdbarch, xstormy16_pc_size);
-  set_gdbarch_register_virtual_size (gdbarch, xstormy16_register_raw_size);
+  set_gdbarch_deprecated_register_virtual_size (gdbarch, xstormy16_register_raw_size);
   set_gdbarch_deprecated_max_register_virtual_size (gdbarch, 4);
-  set_gdbarch_register_virtual_type (gdbarch, xstormy16_reg_virtual_type);
+  set_gdbarch_deprecated_register_virtual_type (gdbarch, xstormy16_reg_virtual_type);
 
   /*
    * Frame Info
@@ -1068,11 +1063,6 @@ xstormy16_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
    */
   /* Stack grows up. */
   set_gdbarch_inner_than (gdbarch, core_addr_greaterthan);
-  /* PC stops zero byte after a trap instruction
-     (which means: exactly on trap instruction). */
-  set_gdbarch_decr_pc_after_break (gdbarch, 0);
-  /* This value is almost never non-zero... */
-  set_gdbarch_function_start_offset (gdbarch, 0);
   /* This value is almost never non-zero... */
   set_gdbarch_frame_args_skip (gdbarch, 0);
 
@@ -1102,9 +1092,9 @@ xstormy16_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_address_to_pointer (gdbarch, xstormy16_address_to_pointer);
   set_gdbarch_pointer_to_address (gdbarch, xstormy16_pointer_to_address);
 
-  set_gdbarch_stack_align (gdbarch, xstormy16_stack_align);
+  set_gdbarch_deprecated_stack_align (gdbarch, xstormy16_stack_align);
 
-  set_gdbarch_save_dummy_frame_tos (gdbarch, xstormy16_save_dummy_frame_tos);
+  set_gdbarch_deprecated_save_dummy_frame_tos (gdbarch, xstormy16_save_dummy_frame_tos);
 
   set_gdbarch_skip_trampoline_code (gdbarch, xstormy16_skip_trampoline_code);
 
@@ -1114,6 +1104,8 @@ xstormy16_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Should be using push_dummy_call.  */
   set_gdbarch_deprecated_dummy_write_sp (gdbarch, deprecated_write_sp);
 
+  set_gdbarch_print_insn (gdbarch, print_insn_xstormy16);
+
   return gdbarch;
 }
 
@@ -1121,11 +1113,10 @@ xstormy16_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
    Initializer function for the Sanyo Xstormy16a module.
    Called by gdb at start-up. */
 
+extern initialize_file_ftype _initialize_xstormy16_tdep; /* -Wmissing-prototypes */
+
 void
 _initialize_xstormy16_tdep (void)
 {
-  extern int print_insn_xstormy16 ();
-
   register_gdbarch_init (bfd_arch_xstormy16, xstormy16_gdbarch_init);
-  deprecated_tm_print_insn = print_insn_xstormy16;
 }
This page took 0.028135 seconds and 4 git commands to generate.