]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Import latest changes from mainline.
authorAndrew Cagney <cagney@redhat.com>
Sun, 12 Jan 2003 20:07:36 +0000 (20:07 +0000)
committerAndrew Cagney <cagney@redhat.com>
Sun, 12 Jan 2003 20:07:36 +0000 (20:07 +0000)
gdb/ChangeLog
gdb/d10v-tdep.c

index 41389f08a72d70c4be59bf244fa7e4d49a4c86e5..7e4be3e9162028642af1b41a8e4fc224a0777e9b 100644 (file)
@@ -1,3 +1,18 @@
+2003-01-12  Andrew Cagney  <ac131313@redhat.com>
+
+       * d10v-tdep.c (d10v_init_extra_frame_info): Remove checks for a
+       dummy frame.
+       (d10v_frame_saved_pc, d10v_frame_chain): Ditto.
+
+2003-01-12  Andrew Cagney  <ac131313@redhat.com>
+
+       * d10v-tdep.c: Include "gdb_assert.h".
+       (d10v_store_return_value): Rewrite to match current interface.
+       (d10v_extract_struct_value_address): Ditto.
+       (d10v_extract_return_value): Ditto.
+       (d10v_gdbarch_init): Set store_restore_value,
+       extract_struct_value_address and extract_return_value.
+
 2003-01-11  Andrew Cagney  <ac131313@redhat.com>
 
        * frame.c (deprecated_update_frame_pc_hack)
index 76b2a6d8022f737489643fe952f00045935c2d4a..63efe4c1540468ec2c70aeb6694ec7c9cc095930 100644 (file)
@@ -42,6 +42,8 @@
 #include "gdb/sim-d10v.h"
 #include "sim-regno.h"
 
+#include "gdb_assert.h"
+
 struct frame_extra_info
   {
     CORE_ADDR return_pc;
@@ -472,22 +474,36 @@ d10v_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
    Things always get returned in RET1_REGNUM, RET2_REGNUM, ... */
 
 static void
-d10v_store_return_value (struct type *type, char *valbuf)
+d10v_store_return_value (struct type *type, struct regcache *regcache,
+                        const void *valbuf)
 {
-  char tmp = 0;
-  /* Only char return values need to be shifted right within R0.  */
+  /* Only char return values need to be shifted right within the first
+     regnum.  */
   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);
+      bfd_byte tmp[2];
+      tmp[1] = *(bfd_byte *)valbuf;
+      regcache_cooked_write (regcache, RET1_REGNUM, tmp);
     }
   else
-    deprecated_write_register_bytes (REGISTER_BYTE (RET1_REGNUM),
-                                    valbuf, TYPE_LENGTH (type));
+    {
+      int reg;
+      /* A structure is never more than 8 bytes long.  See
+         use_struct_convention().  */
+      gdb_assert (TYPE_LENGTH (type) <= 8);
+      /* Write out most registers, stop loop before trying to write
+         out any dangling byte at the end of the buffer.  */
+      for (reg = 0; (reg * 2) + 1 < TYPE_LENGTH (type); reg++)
+       {
+         regcache_cooked_write (regcache, RET1_REGNUM + reg,
+                                (bfd_byte *) valbuf + reg * 2);
+       }
+      /* Write out any dangling byte at the end of the buffer.  */
+      if ((reg * 2) + 1 == TYPE_LENGTH (type))
+       regcache_cooked_write_part (regcache, reg, 0, 1,
+                                   (bfd_byte *) valbuf + reg * 2);
+    }
 }
 
 /* Extract from an array REGBUF containing the (raw) register state
@@ -495,24 +511,17 @@ d10v_store_return_value (struct type *type, char *valbuf)
    as a CORE_ADDR (or an expression that can be used as one).  */
 
 static CORE_ADDR
-d10v_extract_struct_value_address (char *regbuf)
+d10v_extract_struct_value_address (struct regcache *regcache)
 {
-  return (extract_address ((regbuf) + REGISTER_BYTE (ARG1_REGNUM),
-                          REGISTER_RAW_SIZE (ARG1_REGNUM))
-         | DMEM_START);
+  ULONGEST addr;
+  regcache_cooked_read_unsigned (regcache, ARG1_REGNUM, &addr);
+  return (addr | DMEM_START);
 }
 
 static CORE_ADDR
 d10v_frame_saved_pc (struct frame_info *frame)
 {
-  if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (frame),
-                                  get_frame_base (frame),
-                                  get_frame_base (frame)))
-    return d10v_make_iaddr (deprecated_read_register_dummy (get_frame_pc (frame), 
-                                                           get_frame_base (frame), 
-                                                           PC_REGNUM));
-  else
-    return (get_frame_extra_info (frame)->return_pc);
+  return (get_frame_extra_info (frame)->return_pc);
 }
 
 /* Immediately after a function call, return the saved pc.  We can't
@@ -683,10 +692,6 @@ d10v_frame_chain (struct frame_info *fi)
   CORE_ADDR addr;
 
   /* A generic call dummy's frame is the same as caller's.  */
-  if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi), get_frame_base (fi),
-                                  get_frame_base (fi)))
-    return get_frame_base (fi);
-
   d10v_frame_init_saved_regs (fi);
 
   
@@ -695,8 +700,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 (!DEPRECATED_PC_IN_CALL_DUMMY (get_frame_extra_info (fi)->return_pc, 0, 0))
-       return (CORE_ADDR) 0;
+      return (CORE_ADDR) 0;
     }
 
   if (!get_frame_saved_regs (fi)[FP_REGNUM])
@@ -913,15 +917,7 @@ d10v_init_extra_frame_info (int fromleaf, struct frame_info *fi)
 
   /* The call dummy doesn't save any registers on the stack, so we can
      return now.  */
-  if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi), get_frame_base (fi),
-                                  get_frame_base (fi)))
-    {
-      return;
-    }
-  else
-    {
-      d10v_frame_init_saved_regs (fi);
-    }
+  d10v_frame_init_saved_regs (fi);
 }
 
 static void
@@ -1149,8 +1145,8 @@ d10v_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
    extract and copy its value into `valbuf'.  */
 
 static void
-d10v_extract_return_value (struct type *type, char regbuf[REGISTER_BYTES],
-                          char *valbuf)
+d10v_extract_return_value (struct type *type, struct regcache *regcache,
+                          void *valbuf)
 {
   int len;
 #if 0
@@ -1159,25 +1155,34 @@ d10v_extract_return_value (struct type *type, char regbuf[REGISTER_BYTES],
         (int) extract_unsigned_integer (regbuf + REGISTER_BYTE(RET1_REGNUM), 
                                         REGISTER_RAW_SIZE (RET1_REGNUM)));
 #endif
-  len = TYPE_LENGTH (type);
-  if (len == 1)
+  if (TYPE_LENGTH (type) == 1)
     {
-      unsigned short c;
-
-      c = extract_unsigned_integer (regbuf + REGISTER_BYTE (RET1_REGNUM), 
-                                   REGISTER_RAW_SIZE (RET1_REGNUM));
+      ULONGEST c;
+      regcache_cooked_read_unsigned (regcache, RET1_REGNUM, &c);
       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);
+        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. */
+      int reg = RET1_REGNUM;
+      int off = 0;
+      if (TYPE_LENGTH (type) & 1)
+       {
+         regcache_cooked_read_part (regcache, RET1_REGNUM, 1, 1,
+                                    (bfd_byte *)valbuf + off);
+         off++;
+         reg++;
+       }
+      /* Transfer the remaining registers.  */
+      for (; off < TYPE_LENGTH (type); reg++, off += 2)
+       {
+         regcache_cooked_read (regcache, RET1_REGNUM + reg,
+                               (bfd_byte *) valbuf + off);
+       }
     }
 }
 
@@ -1604,14 +1609,14 @@ d10v_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
   set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy);
 
-  set_gdbarch_deprecated_extract_return_value (gdbarch, d10v_extract_return_value);
+  set_gdbarch_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_deprecated_store_return_value (gdbarch, d10v_store_return_value);
-  set_gdbarch_deprecated_extract_struct_value_address (gdbarch, d10v_extract_struct_value_address);
+  set_gdbarch_store_return_value (gdbarch, d10v_store_return_value);
+  set_gdbarch_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);