2004-05-01 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / xstormy16-tdep.c
index 8e283b861ea39dfb6fd36546be3523b385134bfa..6ca97331aac6e6bf41bc2666f2336c4f2dd3de5e 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for the Sanyo Xstormy16a (LC590000) processor.
 
-   Copyright 2001, 2002 Free Software Foundation, Inc.
+   Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "defs.h"
 #include "value.h"
 #include "inferior.h"
-#include "symfile.h"
 #include "arch-utils.h"
 #include "regcache.h"
 #include "gdbcore.h"
 #include "objfiles.h"
+#include "dis-asm.h"
 
 struct gdbarch_tdep
 {
@@ -150,16 +150,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. */
 
@@ -177,16 +167,116 @@ xstormy16_reg_virtual_type (int regnum)
 }
 
 /* Function: xstormy16_get_saved_register
-   Find a register's saved value on the call stack. */
+   Find a register's saved value on the call stack.
+
+   Find register number REGNUM relative to FRAME and put its (raw,
+   target format) contents in *RAW_BUFFER.
+
+   Set *OPTIMIZED if the variable was optimized out (and thus can't be
+   fetched).  Note that this is never set to anything other than zero
+   in this implementation.
+
+   Set *LVAL to lval_memory, lval_register, or not_lval, depending on
+   whether the value was fetched from memory, from a register, or in a
+   strange and non-modifiable way (e.g. a frame pointer which was
+   calculated rather than fetched).  We will use not_lval for values
+   fetched from generic dummy frames.
+
+   Set *ADDRP to the address, either in memory or as a
+   DEPRECATED_REGISTER_BYTE offset into the registers array.  If the
+   value is stored in a dummy frame, set *ADDRP to zero.
+
+   The argument RAW_BUFFER must point to aligned memory.
+
+   The GET_SAVED_REGISTER architecture interface is entirely
+   redundant.  New architectures should implement per-frame unwinders
+   (ref "frame-unwind.h").  */
 
 static void
-xstormy16_get_saved_register (char *raw_buffer,
-                             int *optimized,
+xstormy16_get_saved_register (char *raw_buffer, int *optimized,
                              CORE_ADDR *addrp,
-                             struct frame_info *fi,
-                             int regnum, enum lval_type *lval)
+                             struct frame_info *frame, int regnum,
+                             enum lval_type *lval)
 {
-  generic_get_saved_register (raw_buffer, optimized, addrp, fi, regnum, lval);
+  if (!target_has_registers)
+    error ("No registers.");
+
+  /* Normal systems don't optimize out things with register numbers.  */
+  if (optimized != NULL)
+    *optimized = 0;
+
+  if (addrp)                   /* default assumption: not found in memory */
+    *addrp = 0;
+
+  /* Note: since the current frame's registers could only have been
+     saved by frames INTERIOR TO the current frame, we skip examining
+     the current frame itself: otherwise, we would be getting the
+     previous frame's registers which were saved by the current frame.  */
+
+  if (frame != NULL)
+    {
+      for (frame = get_next_frame (frame);
+          get_frame_type (frame) != SENTINEL_FRAME;
+          frame = get_next_frame (frame))
+       {
+         if (get_frame_type (frame) == DUMMY_FRAME)
+           {
+             if (lval)         /* found it in a CALL_DUMMY frame */
+               *lval = not_lval;
+             if (raw_buffer)
+               {
+                 LONGEST val;
+                 /* FIXME: cagney/2002-06-26: This should be via the
+                    gdbarch_register_read() method so that it, on the
+                    fly, constructs either a raw or pseudo register
+                    from the raw register cache.  */
+                 val = deprecated_read_register_dummy (get_frame_pc (frame),
+                                                       get_frame_base (frame),
+                                                       regnum);
+                 store_unsigned_integer (raw_buffer,
+                                         DEPRECATED_REGISTER_RAW_SIZE (regnum),
+                                         val);
+               }
+             return;
+           }
+
+         DEPRECATED_FRAME_INIT_SAVED_REGS (frame);
+         if (deprecated_get_frame_saved_regs (frame) != NULL
+             && deprecated_get_frame_saved_regs (frame)[regnum] != 0)
+           {
+             if (lval)         /* found it saved on the stack */
+               *lval = lval_memory;
+             if (regnum == SP_REGNUM)
+               {
+                 if (raw_buffer)       /* SP register treated specially */
+                   /* NOTE: cagney/2003-05-09: In-line store_address()
+                       with it's body - store_unsigned_integer().  */
+                   store_unsigned_integer (raw_buffer,
+                                           DEPRECATED_REGISTER_RAW_SIZE (regnum),
+                                           deprecated_get_frame_saved_regs (frame)[regnum]);
+               }
+             else
+               {
+                 if (addrp)    /* any other register */
+                   *addrp = deprecated_get_frame_saved_regs (frame)[regnum];
+                 if (raw_buffer)
+                   read_memory (deprecated_get_frame_saved_regs (frame)[regnum], raw_buffer,
+                                DEPRECATED_REGISTER_RAW_SIZE (regnum));
+               }
+             return;
+           }
+       }
+    }
+
+  /* If we get thru the loop to this point, it means the register was
+     not saved in any frame.  Return the actual live-register value.  */
+
+  if (lval)                    /* found it in a live register */
+    *lval = lval_register;
+  if (addrp)
+    *addrp = DEPRECATED_REGISTER_BYTE (regnum);
+  if (raw_buffer)
+    deprecated_read_register_gen (regnum, raw_buffer);
 }
 
 /* Function: xstormy16_type_is_scalar
@@ -220,7 +310,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 +318,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_address (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 +397,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;
 }
@@ -333,27 +423,28 @@ xstormy16_pop_frame (void)
   if (fi == NULL)
     return;                    /* paranoia */
 
-  if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+  if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi), get_frame_base (fi),
+                                  get_frame_base (fi)))
     {
-      generic_pop_dummy_frame ();
+      deprecated_pop_dummy_frame ();
     }
   else
     {
       /* Restore the saved regs. */
       for (i = 0; i < NUM_REGS; i++)
-       if (fi->saved_regs[i])
+       if (deprecated_get_frame_saved_regs (fi)[i])
          {
            if (i == SP_REGNUM)
-             write_register (i, fi->saved_regs[i]);
+             write_register (i, deprecated_get_frame_saved_regs (fi)[i]);
            else if (i == E_PC_REGNUM)
-             write_register (i, read_memory_integer (fi->saved_regs[i],
+             write_register (i, read_memory_integer (deprecated_get_frame_saved_regs (fi)[i],
                                                      xstormy16_pc_size));
            else
-             write_register (i, read_memory_integer (fi->saved_regs[i],
+             write_register (i, read_memory_integer (deprecated_get_frame_saved_regs (fi)[i],
                                                      xstormy16_reg_size));
          }
       /* Restore the PC */
-      write_register (PC_REGNUM, FRAME_SAVED_PC (fi));
+      write_register (PC_REGNUM, DEPRECATED_FRAME_SAVED_PC (fi));
       flush_cached_frames ();
     }
   return;
@@ -387,12 +478,12 @@ xstormy16_store_return_value (struct type *type, char *valbuf)
       /* Add leading zeros to the value. */
       memset (buf, 0, xstormy16_reg_size);
       memcpy (buf, valbuf, 1);
-      write_register_gen (E_1ST_ARG_REGNUM, buf);
+      deprecated_write_register_gen (E_1ST_ARG_REGNUM, buf);
     }
   else if (xstormy16_type_is_scalar (type) &&
           TYPE_LENGTH (type) <= E_MAX_RETTYPE_SIZE_IN_REGS)
-    write_register_bytes (REGISTER_BYTE (E_1ST_ARG_REGNUM),
-                         valbuf, TYPE_LENGTH (type));
+    deprecated_write_register_bytes (DEPRECATED_REGISTER_BYTE (E_1ST_ARG_REGNUM),
+                                    valbuf, TYPE_LENGTH (type));
   else
     {
       return_buffer = read_register (E_PTR_RET_REGNUM);
@@ -407,11 +498,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_address (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 
@@ -439,7 +533,7 @@ xstormy16_frame_saved_register (struct frame_info *fi, int regnum)
   int size = xstormy16_register_raw_size (regnum);
   char *buf = (char *) alloca (size);
 
-  generic_get_saved_register (buf, NULL, NULL, fi, regnum, NULL);
+  xstormy16_get_saved_register (buf, NULL, NULL, fi, regnum, NULL);
   return (CORE_ADDR) extract_unsigned_integer (buf, size);
 }
 
@@ -466,7 +560,8 @@ xstormy16_scan_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
   if (fi)
     {
       /* In a call dummy, don't touch the frame. */
-      if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+      if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi), get_frame_base (fi),
+                                      get_frame_base (fi)))
        return start_addr;
 
       /* Grab the frame-relative values of SP and FP, needed below. 
@@ -476,7 +571,7 @@ xstormy16_scan_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
       fp = xstormy16_frame_saved_register (fi, E_FP_REGNUM);
 
       /* Initialize framesize with size of PC put on stack by CALLF inst. */
-      fi->extra_info->framesize = xstormy16_pc_size;
+      get_frame_extra_info (fi)->framesize = xstormy16_pc_size;
     }
   for (next_addr = start_addr;
        next_addr < end_addr; next_addr += xstormy16_inst_size)
@@ -490,8 +585,8 @@ xstormy16_scan_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
          if (fi)
            {
              regnum = inst & 0x000f;
-             fi->saved_regs[regnum] = fi->extra_info->framesize;
-             fi->extra_info->framesize += xstormy16_reg_size;
+             deprecated_get_frame_saved_regs (fi)[regnum] = get_frame_extra_info (fi)->framesize;
+             get_frame_extra_info (fi)->framesize += xstormy16_reg_size;
            }
        }
 
@@ -499,28 +594,28 @@ xstormy16_scan_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
       else if (inst == 0x301f || inst == 0x303f)       /* inc r15, #0x1/#0x3 */
        {
          if (fi)               /* Record the frame size. */
-           fi->extra_info->framesize += ((inst & 0x0030) >> 4) + 1;
+           get_frame_extra_info (fi)->framesize += ((inst & 0x0030) >> 4) + 1;
        }
 
       /* optional stack allocation for args and local vars > 4 && < 16 byte */
       else if ((inst & 0xff0f) == 0x510f)      /* 51Hf   add r15, #0xH */
        {
          if (fi)               /* Record the frame size. */
-           fi->extra_info->framesize += (inst & 0x00f0) >> 4;
+           get_frame_extra_info (fi)->framesize += (inst & 0x00f0) >> 4;
        }
 
       /* optional stack allocation for args and local vars >= 16 byte */
       else if (inst == 0x314f && inst2 >= 0x0010)      /* 314f HHHH  add r15, #0xH */
        {
          if (fi)               /* Record the frame size. */
-           fi->extra_info->framesize += inst2;
+           get_frame_extra_info (fi)->framesize += inst2;
          next_addr += xstormy16_inst_size;
        }
 
       else if (inst == 0x46fd) /* mov r13, r15 */
        {
          if (fi)               /* Record that the frame pointer is in use. */
-           fi->extra_info->frameless_p = 0;
+           get_frame_extra_info (fi)->frameless_p = 0;
          if (frameless)
            *frameless = 0;
        }
@@ -546,7 +641,7 @@ xstormy16_scan_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
              if (offset & 0x0800)
                offset -= 0x1000;
 
-             fi->saved_regs[regnum] = fi->extra_info->framesize + offset;
+             deprecated_get_frame_saved_regs (fi)[regnum] = get_frame_extra_info (fi)->framesize + offset;
            }
          next_addr += xstormy16_inst_size;
        }
@@ -591,15 +686,15 @@ xstormy16_scan_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
          by convention what we put here is simply the previous 
          _value_ of the SP (as opposed to an address where the
          previous value would have been pushed).  */
-      if (fi->extra_info->frameless_p)
+      if (get_frame_extra_info (fi)->frameless_p)
        {
-         fi->saved_regs[E_SP_REGNUM] = sp - fi->extra_info->framesize;
-         fi->frame = sp;
+         deprecated_get_frame_saved_regs (fi)[E_SP_REGNUM] = sp - get_frame_extra_info (fi)->framesize;
+         deprecated_update_frame_base_hack (fi, sp);
        }
       else
        {
-         fi->saved_regs[E_SP_REGNUM] = fp - fi->extra_info->framesize;
-         fi->frame = fp;
+         deprecated_get_frame_saved_regs (fi)[E_SP_REGNUM] = fp - get_frame_extra_info (fi)->framesize;
+         deprecated_update_frame_base_hack (fi, fp);
        }
 
       /* So far only offsets to the beginning of the frame are
@@ -607,11 +702,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 (fi->saved_regs[regnum])
-         fi->saved_regs[regnum] += fi->saved_regs[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. */
-      fi->saved_regs[E_PC_REGNUM] = fi->saved_regs[E_SP_REGNUM];
+      deprecated_get_frame_saved_regs (fi)[E_PC_REGNUM] = deprecated_get_frame_saved_regs (fi)[E_SP_REGNUM];
     }
 
   return next_addr;
@@ -646,7 +741,7 @@ xstormy16_skip_prologue (CORE_ADDR pc)
         return plg_end;
 
       /* Found a function.  */
-      sym = lookup_symbol (func_name, NULL, VAR_NAMESPACE, NULL, NULL);
+      sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL, NULL);
       /* Don't use line number debug info for assembly source files. */
       if (sym && SYMBOL_LANGUAGE (sym) != language_asm)
        {
@@ -721,25 +816,24 @@ xstormy16_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
    actual value of the previous frame's stack register. 
 
    This function may be called in any context where the saved register
-   values may be needed (backtrace, frame_info, get_saved_register).
-   On many targets, it is called directly by init_extra_frame_info, 
-   in part because the information may be needed immediately by 
-   frame_chain.
-*/
+   values may be needed (backtrace, frame_info, frame_register).  On
+   many targets, it is called directly by init_extra_frame_info, in
+   part because the information may be needed immediately by
+   frame_chain.  */
 
 static void
 xstormy16_frame_init_saved_regs (struct frame_info *fi)
 {
   CORE_ADDR func_addr, func_end;
 
-  if (!fi->saved_regs)
+  if (!deprecated_get_frame_saved_regs (fi))
     {
       frame_saved_regs_zalloc (fi);
 
       /* Find the beginning of this function, so we can analyze its
          prologue. */
-      if (find_pc_partial_function (fi->pc, NULL, &func_addr, &func_end))
-       xstormy16_scan_prologue (func_addr, fi->pc, fi, NULL);
+      if (find_pc_partial_function (get_frame_pc (fi), NULL, &func_addr, &func_end))
+       xstormy16_scan_prologue (func_addr, get_frame_pc (fi), fi, NULL);
       /* Else we're out of luck (can't debug completely stripped code). 
          FIXME. */
     }
@@ -747,22 +841,24 @@ xstormy16_frame_init_saved_regs (struct frame_info *fi)
 
 /* Function: xstormy16_frame_saved_pc
    Returns the return address for the selected frame. 
-   Called by frame_info, frame_chain_valid, and sometimes by
-   get_prev_frame.
-*/
+   Called by frame_info, legacy_frame_chain_valid, and sometimes by
+   get_prev_frame.  */
 
 static CORE_ADDR
 xstormy16_frame_saved_pc (struct frame_info *fi)
 {
   CORE_ADDR saved_pc;
 
-  if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+  if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi), get_frame_base (fi),
+                                  get_frame_base (fi)))
     {
-      saved_pc = generic_read_register_dummy (fi->pc, fi->frame, E_PC_REGNUM);
+      saved_pc = deprecated_read_register_dummy (get_frame_pc (fi),
+                                                get_frame_base (fi),
+                                                E_PC_REGNUM);
     }
   else
     {
-      saved_pc = read_memory_unsigned_integer (fi->saved_regs[E_PC_REGNUM],
+      saved_pc = read_memory_unsigned_integer (deprecated_get_frame_saved_regs (fi)[E_PC_REGNUM],
                                               xstormy16_pc_size);
     }
 
@@ -778,29 +874,28 @@ xstormy16_frame_saved_pc (struct frame_info *fi)
 static void
 xstormy16_init_extra_frame_info (int fromleaf, struct frame_info *fi)
 {
-  if (!fi->extra_info)
+  if (!get_frame_extra_info (fi))
     {
-      fi->extra_info = (struct frame_extra_info *)
-       frame_obstack_alloc (sizeof (struct frame_extra_info));
-      fi->extra_info->framesize = 0;
-      fi->extra_info->frameless_p = 1; /* Default frameless, detect framed */
+      frame_extra_info_zalloc (fi, sizeof (struct frame_extra_info));
+      get_frame_extra_info (fi)->framesize = 0;
+      get_frame_extra_info (fi)->frameless_p = 1;      /* Default frameless, detect framed */
 
       /* By default, the fi->frame is set to the value of the FP reg by gdb.
          This may not always be right; we may be in a frameless function,
          or we may be in the prologue, before the FP has been set up.
          Unfortunately, we can't make this determination without first
          calling scan_prologue, and we can't do that unles we know the
-         fi->pc.  */
+         get_frame_pc (fi).  */
 
-      if (!fi->pc)
+      if (!get_frame_pc (fi))
        {
          /* Sometimes we are called from get_prev_frame without
             the PC being set up first.  Long history, don't ask.
             Fortunately this will never happen from the outermost
             frame, so we should be able to get the saved pc from
             the next frame. */
-         if (fi->next)
-           fi->pc = xstormy16_frame_saved_pc (fi->next);
+         if (get_next_frame (fi))
+           deprecated_update_frame_pc_hack (fi, xstormy16_frame_saved_pc (get_next_frame (fi)));
        }
 
       /* Take care of the saved_regs right here (non-lazy). */
@@ -816,32 +911,32 @@ xstormy16_init_extra_frame_info (int fromleaf, struct frame_info *fi)
 static CORE_ADDR
 xstormy16_frame_chain (struct frame_info *fi)
 {
-  if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+  if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi), get_frame_base (fi),
+                                  get_frame_base (fi)))
     {
       /* Call dummy's frame is the same as caller's.  */
-      return fi->frame;
+      return get_frame_base (fi);
     }
   else
     {
       /* Return computed offset from this frame's fp. */
-      return fi->frame - fi->extra_info->framesize;
+      return get_frame_base (fi) - get_frame_extra_info (fi)->framesize;
     }
 }
 
 static int
 xstormy16_frame_chain_valid (CORE_ADDR chain, struct frame_info *thisframe)
 {
-  return chain < 0x8000 && FRAME_SAVED_PC (thisframe) >= 0x8000 &&
-    (thisframe->extra_info->frameless_p ||
-     thisframe->frame - thisframe->extra_info->framesize == chain);
+  return chain < 0x8000 && DEPRECATED_FRAME_SAVED_PC (thisframe) >= 0x8000 &&
+    (get_frame_extra_info (thisframe)->frameless_p ||
+     get_frame_base (thisframe) - get_frame_extra_info (thisframe)->framesize == chain);
 }
 
-/* Function: xstormy16_saved_pc_after_call
-   Returns the previous PC immediately after a function call.
-   This function is meant to bypass the regular get_saved_register
-   mechanism, ie. it is meant to work even if the frame isn't complete. 
-   Called by step_over_function, and sometimes by get_prev_frame.
-*/
+/* Function: xstormy16_saved_pc_after_call Returns the previous PC
+   immediately after a function call.  This function is meant to
+   bypass the regular frame_register() mechanism, ie. it is meant to
+   work even if the frame isn't complete.  Called by
+   step_over_function, and sometimes by get_prev_frame.  */
 
 static CORE_ADDR
 xstormy16_saved_pc_after_call (struct frame_info *ignore)
@@ -957,10 +1052,10 @@ xstormy16_in_solib_call_trampoline (CORE_ADDR pc, char *name)
 }
 
 static CORE_ADDR
-xstormy16_pointer_to_address (struct type *type, void *buf)
+xstormy16_pointer_to_address (struct type *type, const void *buf)
 {
   enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
-  CORE_ADDR addr = extract_address (buf, TYPE_LENGTH (type));
+  CORE_ADDR addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
 
   if (target == TYPE_CODE_FUNC || target == TYPE_CODE_METHOD)
     {
@@ -983,7 +1078,7 @@ xstormy16_address_to_pointer (struct type *type, void *buf, CORE_ADDR addr)
       if (addr2)
        addr = addr2;
     }
-  store_address (buf, TYPE_LENGTH (type), addr);
+  store_unsigned_integer (buf, TYPE_LENGTH (type), addr);
 }
 
 static CORE_ADDR
@@ -994,7 +1089,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);
@@ -1022,6 +1117,10 @@ xstormy16_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, deprecated_init_frame_pc_default);
+
   /*
    * Basic register fields and methods.
    */
@@ -1029,33 +1128,31 @@ xstormy16_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_num_regs (gdbarch, E_NUM_REGS);
   set_gdbarch_num_pseudo_regs (gdbarch, 0);
   set_gdbarch_sp_regnum (gdbarch, E_SP_REGNUM);
-  set_gdbarch_fp_regnum (gdbarch, E_FP_REGNUM);
+  set_gdbarch_deprecated_fp_regnum (gdbarch, E_FP_REGNUM);
   set_gdbarch_pc_regnum (gdbarch, E_PC_REGNUM);
   set_gdbarch_register_name (gdbarch, xstormy16_register_name);
-  set_gdbarch_register_size (gdbarch, xstormy16_reg_size);
-  set_gdbarch_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_max_register_raw_size (gdbarch, xstormy16_pc_size);
-  set_gdbarch_register_virtual_size (gdbarch, xstormy16_register_raw_size);
-  set_gdbarch_max_register_virtual_size (gdbarch, 4);
-  set_gdbarch_register_virtual_type (gdbarch, xstormy16_reg_virtual_type);
+  set_gdbarch_deprecated_register_size (gdbarch, xstormy16_reg_size);
+  set_gdbarch_deprecated_register_bytes (gdbarch, E_ALL_REGS_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_deprecated_register_virtual_size (gdbarch, xstormy16_register_raw_size);
+  set_gdbarch_deprecated_max_register_virtual_size (gdbarch, 4);
+  set_gdbarch_deprecated_register_virtual_type (gdbarch, xstormy16_reg_virtual_type);
 
   /*
    * Frame Info
    */
-  set_gdbarch_init_extra_frame_info (gdbarch,
+  set_gdbarch_deprecated_init_extra_frame_info (gdbarch,
                                     xstormy16_init_extra_frame_info);
-  set_gdbarch_frame_init_saved_regs (gdbarch,
+  set_gdbarch_deprecated_frame_init_saved_regs (gdbarch,
                                     xstormy16_frame_init_saved_regs);
-  set_gdbarch_frame_chain (gdbarch, xstormy16_frame_chain);
-  set_gdbarch_get_saved_register (gdbarch, xstormy16_get_saved_register);
-  set_gdbarch_saved_pc_after_call (gdbarch, xstormy16_saved_pc_after_call);
-  set_gdbarch_frame_saved_pc (gdbarch, xstormy16_frame_saved_pc);
+  set_gdbarch_deprecated_frame_chain (gdbarch, xstormy16_frame_chain);
+  set_gdbarch_deprecated_get_saved_register (gdbarch, xstormy16_get_saved_register);
+  set_gdbarch_deprecated_saved_pc_after_call (gdbarch, xstormy16_saved_pc_after_call);
+  set_gdbarch_deprecated_frame_saved_pc (gdbarch, xstormy16_frame_saved_pc);
   set_gdbarch_skip_prologue (gdbarch, xstormy16_skip_prologue);
-  set_gdbarch_frame_chain_valid (gdbarch, xstormy16_frame_chain_valid);
-  set_gdbarch_frame_args_address (gdbarch, default_frame_address);
-  set_gdbarch_frame_locals_address (gdbarch, default_frame_address);
+  set_gdbarch_deprecated_frame_chain_valid (gdbarch, xstormy16_frame_chain_valid);
 
   set_gdbarch_in_function_epilogue_p (gdbarch,
                                      xstormy16_in_function_epilogue_p);
@@ -1065,50 +1162,25 @@ 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);
-  /* 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, xstormy16_push_return_address);
+  set_gdbarch_deprecated_push_return_address (gdbarch, xstormy16_push_return_address);
   set_gdbarch_deprecated_extract_return_value (gdbarch, xstormy16_extract_return_value);
-  set_gdbarch_push_arguments (gdbarch, xstormy16_push_arguments);
-  set_gdbarch_pop_frame (gdbarch, xstormy16_pop_frame);
-  set_gdbarch_store_struct_return (gdbarch, xstormy16_store_struct_return);
-  set_gdbarch_store_return_value (gdbarch, xstormy16_store_return_value);
+  set_gdbarch_deprecated_push_arguments (gdbarch, xstormy16_push_arguments);
+  set_gdbarch_deprecated_pop_frame (gdbarch, xstormy16_pop_frame);
+  set_gdbarch_deprecated_store_struct_return (gdbarch, xstormy16_store_struct_return);
+  set_gdbarch_deprecated_store_return_value (gdbarch, xstormy16_store_return_value);
   set_gdbarch_deprecated_extract_struct_value_address (gdbarch, xstormy16_extract_struct_value_address);
   set_gdbarch_use_struct_convention (gdbarch,
                                     xstormy16_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_words);
-  set_gdbarch_sizeof_call_dummy_words (gdbarch, 0);
-  set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
-  /* set_gdbarch_call_dummy_stack_adjust */
-  set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy);
+  set_gdbarch_deprecated_call_dummy_words (gdbarch, call_dummy_words);
+  set_gdbarch_deprecated_sizeof_call_dummy_words (gdbarch, 0);
   set_gdbarch_breakpoint_from_pc (gdbarch, xstormy16_breakpoint_from_pc);
 
+  set_gdbarch_char_signed (gdbarch, 0);
   set_gdbarch_int_bit (gdbarch, 2 * TARGET_CHAR_BIT);
   set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
   set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
@@ -1117,16 +1189,20 @@ 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_extra_stack_alignment_needed (gdbarch, 0);
+  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);
 
   set_gdbarch_in_solib_call_trampoline (gdbarch,
                                        xstormy16_in_solib_call_trampoline);
 
+  /* 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;
 }
 
@@ -1134,11 +1210,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);
-  tm_print_insn = print_insn_xstormy16;
 }
This page took 0.040351 seconds and 4 git commands to generate.