*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / d10v-tdep.c
index cb2ce4745d3025cbbeeed8cf40da8bfbcce9331a..14fd95a032f1cdd115314fa261f57e38dfa543a0 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "defs.h"
 #include "frame.h"
-#include "obstack.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "gdbcmd.h"
@@ -115,7 +114,7 @@ d10v_frame_chain_valid (CORE_ADDR chain, struct frame_info *frame)
 {
   if (chain != 0 && frame != NULL)
     {
-      if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
+      if (DEPRECATED_PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
        return 1;       /* Path back from a call dummy must be valid. */
       return ((frame)->pc > IMEM_START
              && !inside_main_func (frame->pc));
@@ -187,7 +186,7 @@ enum ts2_regnums
     TS2_A0_REGNUM = 35
   };
 
-static char *
+static const char *
 d10v_ts2_register_name (int reg_nr)
 {
   static char *register_names[] =
@@ -213,7 +212,7 @@ enum ts3_regnums
     TS3_A0_REGNUM = 32
   };
 
-static char *
+static const char *
 d10v_ts3_register_name (int reg_nr)
 {
   static char *register_names[] =
@@ -482,9 +481,20 @@ d10v_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
 static void
 d10v_store_return_value (struct type *type, char *valbuf)
 {
-  write_register_bytes (REGISTER_BYTE (RET1_REGNUM),
-                       valbuf,
-                       TYPE_LENGTH (type));
+  char tmp = 0;
+  /* Only char return values need to be shifted right within R0.  */
+  if (TYPE_LENGTH (type) == 1
+      && TYPE_CODE (type) == TYPE_CODE_INT)
+    {
+      /* zero the high byte */
+      deprecated_write_register_bytes (REGISTER_BYTE (RET1_REGNUM), &tmp, 1);
+      /* copy the low byte */
+      deprecated_write_register_bytes (REGISTER_BYTE (RET1_REGNUM) + 1,
+                                      valbuf, 1);
+    }
+  else
+    deprecated_write_register_bytes (REGISTER_BYTE (RET1_REGNUM),
+                                    valbuf, TYPE_LENGTH (type));
 }
 
 /* Extract from an array REGBUF containing the (raw) register state
@@ -502,10 +512,10 @@ d10v_extract_struct_value_address (char *regbuf)
 static CORE_ADDR
 d10v_frame_saved_pc (struct frame_info *frame)
 {
-  if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
-    return d10v_make_iaddr (generic_read_register_dummy (frame->pc, 
-                                                        frame->frame, 
-                                                        PC_REGNUM));
+  if (DEPRECATED_PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
+    return d10v_make_iaddr (deprecated_read_register_dummy (frame->pc, 
+                                                           frame->frame, 
+                                                           PC_REGNUM));
   else
     return ((frame)->extra_info->return_pc);
 }
@@ -537,7 +547,7 @@ do_d10v_pop_frame (struct frame_info *fi)
   int regnum;
   char raw_buffer[8];
 
-  fp = FRAME_FP (fi);
+  fp = get_frame_base (fi);
   /* fill out fsr with the address of where each */
   /* register was stored in the frame */
   d10v_frame_init_saved_regs (fi);
@@ -548,7 +558,8 @@ do_d10v_pop_frame (struct frame_info *fi)
       if (fi->saved_regs[regnum])
        {
          read_memory (fi->saved_regs[regnum], raw_buffer, REGISTER_RAW_SIZE (regnum));
-         write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, REGISTER_RAW_SIZE (regnum));
+         deprecated_write_register_bytes (REGISTER_BYTE (regnum), raw_buffer,
+                                          REGISTER_RAW_SIZE (regnum));
        }
     }
   for (regnum = 0; regnum < SP_REGNUM; regnum++)
@@ -666,10 +677,10 @@ d10v_skip_prologue (CORE_ADDR pc)
   return pc;
 }
 
-/* Given a GDB frame, determine the address of the calling function's frame.
-   This will be used to create a new GDB frame struct, and then
-   INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame.
- */
+/* Given a GDB frame, determine the address of the calling function's
+   frame.  This will be used to create a new GDB frame struct, and
+   then INIT_EXTRA_FRAME_INFO and DEPRECATED_INIT_FRAME_PC will be
  called for the new frame.  */
 
 static CORE_ADDR
 d10v_frame_chain (struct frame_info *fi)
@@ -677,7 +688,7 @@ d10v_frame_chain (struct frame_info *fi)
   CORE_ADDR addr;
 
   /* A generic call dummy's frame is the same as caller's.  */
-  if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+  if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
     return fi->frame;
 
   d10v_frame_init_saved_regs (fi);
@@ -688,7 +699,7 @@ d10v_frame_chain (struct frame_info *fi)
     {
       /* This is meant to halt the backtrace at "_start".
         Make sure we don't halt it at a generic dummy frame. */
-      if (!PC_IN_CALL_DUMMY (fi->extra_info->return_pc, 0, 0))
+      if (!DEPRECATED_PC_IN_CALL_DUMMY (fi->extra_info->return_pc, 0, 0))
        return (CORE_ADDR) 0;
     }
 
@@ -900,13 +911,13 @@ d10v_init_extra_frame_info (int fromleaf, struct frame_info *fi)
 
   /* If fi->pc is zero, but this is not the outermost frame, 
      then let's snatch the return_pc from the callee, so that
-     PC_IN_CALL_DUMMY will work.  */
+     DEPRECATED_PC_IN_CALL_DUMMY will work.  */
   if (fi->pc == 0 && fi->level != 0 && fi->next != NULL)
     fi->pc = d10v_frame_saved_pc (fi->next);
 
   /* 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 (fi->pc, fi->frame, fi->frame))
     {
       return;
     }
@@ -967,7 +978,7 @@ show_regs (char *args, int from_tty)
       char num[MAX_REGISTER_RAW_SIZE];
       int i;
       printf_filtered ("  ");
-      read_register_gen (a, (char *) &num);
+      deprecated_read_register_gen (a, (char *) &num);
       for (i = 0; i < MAX_REGISTER_RAW_SIZE; i++)
        {
          printf_filtered ("%02x", (num[i] & 0xff));
@@ -1075,6 +1086,15 @@ d10v_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
   int i;
   int regnum = ARG1_REGNUM;
   struct stack_item *si = NULL;
+  long val;
+
+  /* If struct_return is true, then the struct return address will
+     consume one argument-passing register.  No need to actually 
+     write the value to the register -- that's done by 
+     d10v_store_struct_return().  */
+
+  if (struct_return)
+    regnum++;
 
   /* Fill in registers and arg lists */
   for (i = 0; i < nargs; i++)
@@ -1083,39 +1103,38 @@ d10v_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
       struct type *type = check_typedef (VALUE_TYPE (arg));
       char *contents = VALUE_CONTENTS (arg);
       int len = TYPE_LENGTH (type);
+      int aligned_regnum = (regnum + 1) & ~1;
+
       /* printf ("push: type=%d len=%d\n", TYPE_CODE (type), len); */
+      if (len <= 2 && regnum <= ARGN_REGNUM)
+       /* fits in a single register, do not align */
+       {
+         val = extract_unsigned_integer (contents, len);
+         write_register (regnum++, val);
+       }
+      else if (len <= (ARGN_REGNUM - aligned_regnum + 1) * 2)
+       /* value fits in remaining registers, store keeping left
+          aligned */
        {
-         int aligned_regnum = (regnum + 1) & ~1;
-         if (len <= 2 && regnum <= ARGN_REGNUM)
-           /* fits in a single register, do not align */
+         int b;
+         regnum = aligned_regnum;
+         for (b = 0; b < (len & ~1); b += 2)
            {
-             long val = extract_unsigned_integer (contents, len);
+             val = extract_unsigned_integer (&contents[b], 2);
              write_register (regnum++, val);
            }
-         else if (len <= (ARGN_REGNUM - aligned_regnum + 1) * 2)
-           /* value fits in remaining registers, store keeping left
-              aligned */
-           {
-             int b;
-             regnum = aligned_regnum;
-             for (b = 0; b < (len & ~1); b += 2)
-               {
-                 long val = extract_unsigned_integer (&contents[b], 2);
-                 write_register (regnum++, val);
-               }
-             if (b < len)
-               {
-                 long val = extract_unsigned_integer (&contents[b], 1);
-                 write_register (regnum++, (val << 8));
-               }
-           }
-         else
+         if (b < len)
            {
-             /* arg will go onto stack */
-             regnum = ARGN_REGNUM + 1;
-             si = push_stack_item (si, contents, len);
+             val = extract_unsigned_integer (&contents[b], 1);
+             write_register (regnum++, (val << 8));
            }
        }
+      else
+       {
+         /* arg will go onto stack */
+         regnum = ARGN_REGNUM + 1;
+         si = push_stack_item (si, contents, len);
+       }
     }
 
   while (si)
@@ -1137,25 +1156,31 @@ d10v_extract_return_value (struct type *type, char regbuf[REGISTER_BYTES],
                           char *valbuf)
 {
   int len;
-  /*    printf("RET: TYPE=%d len=%d r%d=0x%x\n", TYPE_CODE (type), TYPE_LENGTH (type), RET1_REGNUM - R0_REGNUM, (int) extract_unsigned_integer (regbuf + REGISTER_BYTE(RET1_REGNUM), REGISTER_RAW_SIZE (RET1_REGNUM)));  */
+#if 0
+  printf("RET: TYPE=%d len=%d r%d=0x%x\n", TYPE_CODE (type), 
+        TYPE_LENGTH (type), RET1_REGNUM - R0_REGNUM, 
+        (int) extract_unsigned_integer (regbuf + REGISTER_BYTE(RET1_REGNUM), 
+                                        REGISTER_RAW_SIZE (RET1_REGNUM)));
+#endif
+  len = TYPE_LENGTH (type);
+  if (len == 1)
     {
-      len = TYPE_LENGTH (type);
-      if (len == 1)
-       {
-         unsigned short c = extract_unsigned_integer (regbuf + REGISTER_BYTE (RET1_REGNUM), REGISTER_RAW_SIZE (RET1_REGNUM));
-         store_unsigned_integer (valbuf, 1, c);
-       }
-      else if ((len & 1) == 0)
-       memcpy (valbuf, regbuf + REGISTER_BYTE (RET1_REGNUM), len);
-      else
-       {
-         /* For return values of odd size, the first byte is in the
-            least significant part of the first register.  The
-            remaining bytes in remaining registers. Interestingly,
-            when such values are passed in, the last byte is in the
-            most significant byte of that same register - wierd. */
-         memcpy (valbuf, regbuf + REGISTER_BYTE (RET1_REGNUM) + 1, len);
-       }
+      unsigned short c;
+
+      c = extract_unsigned_integer (regbuf + REGISTER_BYTE (RET1_REGNUM), 
+                                   REGISTER_RAW_SIZE (RET1_REGNUM));
+      store_unsigned_integer (valbuf, 1, c);
+    }
+  else if ((len & 1) == 0)
+    memcpy (valbuf, regbuf + REGISTER_BYTE (RET1_REGNUM), len);
+  else
+    {
+      /* For return values of odd size, the first byte is in the
+        least significant part of the first register.  The
+        remaining bytes in remaining registers. Interestingly,
+        when such values are passed in, the last byte is in the
+        most significant byte of that same register - wierd. */
+      memcpy (valbuf, regbuf + REGISTER_BYTE (RET1_REGNUM) + 1, len);
     }
 }
 
@@ -1493,6 +1518,10 @@ d10v_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep = XMALLOC (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
+  /* 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);
+
   switch (info.bfd_arch_info->mach)
     {
     case bfd_mach_d10v_ts2:
@@ -1567,29 +1596,25 @@ d10v_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
                      "d10v_gdbarch_init: bad byte order for float format");
     }
 
-  set_gdbarch_use_generic_dummy_frames (gdbarch, 1);
   set_gdbarch_call_dummy_length (gdbarch, 0);
-  set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT);
   set_gdbarch_call_dummy_address (gdbarch, entry_point_address);
   set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1);
   set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
   set_gdbarch_call_dummy_start_offset (gdbarch, 0);
-  set_gdbarch_pc_in_call_dummy (gdbarch, generic_pc_in_call_dummy);
   set_gdbarch_call_dummy_words (gdbarch, d10v_call_dummy_words);
   set_gdbarch_sizeof_call_dummy_words (gdbarch, sizeof (d10v_call_dummy_words));
   set_gdbarch_call_dummy_p (gdbarch, 1);
   set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
-  set_gdbarch_get_saved_register (gdbarch, generic_get_saved_register);
   set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy);
 
-  set_gdbarch_extract_return_value (gdbarch, d10v_extract_return_value);
+  set_gdbarch_deprecated_extract_return_value (gdbarch, d10v_extract_return_value);
   set_gdbarch_push_arguments (gdbarch, d10v_push_arguments);
   set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame);
   set_gdbarch_push_return_address (gdbarch, d10v_push_return_address);
 
   set_gdbarch_store_struct_return (gdbarch, d10v_store_struct_return);
-  set_gdbarch_store_return_value (gdbarch, d10v_store_return_value);
-  set_gdbarch_extract_struct_value_address (gdbarch, d10v_extract_struct_value_address);
+  set_gdbarch_deprecated_store_return_value (gdbarch, d10v_store_return_value);
+  set_gdbarch_deprecated_extract_struct_value_address (gdbarch, d10v_extract_struct_value_address);
   set_gdbarch_use_struct_convention (gdbarch, d10v_use_struct_convention);
 
   set_gdbarch_frame_init_saved_regs (gdbarch, d10v_frame_init_saved_regs);
@@ -1610,8 +1635,7 @@ d10v_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_frame_chain (gdbarch, d10v_frame_chain);
   set_gdbarch_frame_chain_valid (gdbarch, d10v_frame_chain_valid);
   set_gdbarch_frame_saved_pc (gdbarch, d10v_frame_saved_pc);
-  set_gdbarch_frame_args_address (gdbarch, default_frame_address);
-  set_gdbarch_frame_locals_address (gdbarch, default_frame_address);
+
   set_gdbarch_saved_pc_after_call (gdbarch, d10v_saved_pc_after_call);
   set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
   set_gdbarch_stack_align (gdbarch, d10v_stack_align);
This page took 0.027936 seconds and 4 git commands to generate.