]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2003-06-06 Andrew Cagney <cagney@redhat.com>
authorAndrew Cagney <cagney@redhat.com>
Sun, 8 Jun 2003 22:14:42 +0000 (22:14 +0000)
committerAndrew Cagney <cagney@redhat.com>
Sun, 8 Jun 2003 22:14:42 +0000 (22:14 +0000)
* frame.h (put_frame_register): Declare.
* frame.c (put_frame_register): New function.

* arch-utils.c: Include "gdbcore.h".
(legacy_convert_register_p): Add "type" parameter.
(legacy_register_to_value): Rewrite, use "frame" to get the
register value.
(legacy_value_to_register): Rewrite, use "frame" to find the
register's location before storing.
* arch-utils.h (legacy_convert_register_p): Update.
(legacy_register_to_value, legacy_value_to_register): Update.

* Makefile.in (arch-utils.o): Update dependencies.

* findvar.c (value_from_register): Rewrite, eliminate use of
REGISTER_CONVERT_TO_TYPE, pass "type" to CONVERT_REGISTER_P, pass
"frame" to REGISTER_TO_VALUE.

* gdbarch.sh (CONVERT_REGISTER_P): Add "type" parameter.
(REGISTER_TO_VALUE, VALUE_TO_REGISTER): Replace raw buffer
parameter with "frame".
* gdbarch.h, gdbarch.c: Re-generate.

* mips-tdep.c (mips_convert_register_p): New function.
(mips_value_to_register): Replace mips_register_convert_from_type.
(mips_register_to_value): Replace mips_register_convert_to_type.
(mips_gdbarch_init): Set conver_register_p, value_to_register and
register_to_value.

* valops.c (value_assign): Move the CONVERT_REGISTER code to the
lval_reg_frame_relative + lval_register branch of the switch.  Do
not use REGISTER_CONVERT_FROM_TYPE.  Use put_frame_register.

gdb/ChangeLog
gdb/arch-utils.c
gdb/arch-utils.h
gdb/findvar.c
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/mips-tdep.c
gdb/valops.c

index 83f1191699ab30b749b84cb9f3ad9cfeb9d9e809..21c37c8369dbf28ff57536ecaccb35e8561bc5a8 100644 (file)
@@ -19,8 +19,8 @@
        "frame" to REGISTER_TO_VALUE.
 
        * gdbarch.sh (CONVERT_REGISTER_P): Add "type" parameter.
-       (REGISTER_TO_VALUE, VALUE_TO_REGISTER): Replace "type", "from" and
-       "to" parameters with "frame" and "value".
+       (REGISTER_TO_VALUE, VALUE_TO_REGISTER): Replace raw buffer
+       parameter with "frame".
        * gdbarch.h, gdbarch.c: Re-generate.
        
        * mips-tdep.c (mips_convert_register_p): New function.
index d437b1e308a8e376ccdd80e6a6dda3074b4b4bc0..907bac1191d615136b7f1f6f666c381dd348ad80 100644 (file)
@@ -448,47 +448,22 @@ legacy_convert_register_p (int regnum, struct type *type)
 
 void
 legacy_register_to_value (struct frame_info *frame, int regnum,
-                         struct value *v)
+                         struct type *type, void *to)
 {
   char from[MAX_REGISTER_SIZE];
-  int realnum;
-  int optim;
-  enum lval_type lval;
-  CORE_ADDR addr;
-  frame_register (frame, regnum, &optim, &lval, &addr, &realnum, from);
-  REGISTER_CONVERT_TO_VIRTUAL (regnum, VALUE_TYPE (v), from,
-                              VALUE_CONTENTS_RAW (v));
-  VALUE_LVAL (v) = lval;
-  VALUE_REGNO (v) = realnum;
-  VALUE_ADDRESS (v) = addr;
-  /* Note: This function is just trying to keep old code alive, don't
-     let it handle anything other than a few obvious cases.  */
-  gdb_assert (lval == lval_register || lval == lval_memory);
-  VALUE_OPTIMIZED_OUT (v) = optim;
+  frame_read_register (frame, regnum, from);
+  REGISTER_CONVERT_TO_VIRTUAL (regnum, type, from, to);
 }
 
 void
-legacy_value_to_register (struct frame_info *frame, struct value *v)
+legacy_value_to_register (struct frame_info *frame, int regnum,
+                         struct type *type, const void *tmp)
 {
-  struct gdbarch *gdbarch = get_frame_arch (frame);
   char to[MAX_REGISTER_SIZE];
-  REGISTER_CONVERT_TO_RAW (VALUE_TYPE (v), VALUE_REGNO (v),
-                          VALUE_CONTENTS (v), to);
-  switch (VALUE_LVAL (v))
-    {
-    case lval_register:
-      /* FIXME: How to get from the frame to the, several levels
-         inner, regcache?  */
-      regcache_cooked_write (current_regcache, VALUE_REGNO (v), to);
-      break;
-    case lval_memory:
-      write_memory (VALUE_ADDRESS (v), to,
-                   register_size (gdbarch, (VALUE_REGNO (v))));
-      break;
-    default:
-      internal_error (__FILE__, __LINE__, "Unhandled lval %d",
-                     (int) VALUE_LVAL (v));
-    }
+  char *from = alloca (TYPE_LENGTH (type));
+  memcpy (from, from, TYPE_LENGTH (type));
+  REGISTER_CONVERT_TO_RAW (type, regnum, from, to);
+  put_frame_register (frame, regnum, to);
 }
 
 \f
index 1e7425cc7bed7b4fe7dd6c38c5469ba3371e0d47..f9010c48e8c75859275091334bc062715ddc1bca 100644 (file)
@@ -166,8 +166,10 @@ extern int legacy_pc_in_sigtramp (CORE_ADDR pc, char *name);
    type of a corresponding variable.  These legacy functions preserve
    that overloaded behavour in existing targets.  */
 extern int legacy_convert_register_p (int regnum, struct type *type);
-extern void legacy_register_to_value (struct frame_info *frame, int regnum, struct value *v);
-extern void legacy_value_to_register (struct frame_info *frame, struct value *v);
+extern void legacy_register_to_value (struct frame_info *frame, int regnum,
+                                     struct type *type, void *to);
+extern void legacy_value_to_register (struct frame_info *frame, int regnum,
+                                     struct type *type, const void *from);
 
 /* For compatibility with older architectures, returns
    (LEGACY_SIM_REGNO_IGNORE) when the register doesn't have a valid
index 5bcb1e8aba96be85692d0dff906c248e929afac7..0f8c9b0217644b92ff7b653c2e6fb6f78baa0009 100644 (file)
@@ -630,10 +630,6 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
 
   if (CONVERT_REGISTER_P (regnum, type))
     {
-      int realnum;
-      int optim;
-      enum lval_type lval;
-      CORE_ADDR addr;
       /* The ISA/ABI need to something weird when obtaining the
          specified value from this register.  It might need to
          re-order non-adjacent, starting with REGNUM (see MIPS and
@@ -641,7 +637,10 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
          the corresponding [integer] type (see Alpha).  The assumption
          is that REGISTER_TO_VALUE populates the entire value
          including the location.  */
-      REGISTER_TO_VALUE (frame, regnum, v);
+      REGISTER_TO_VALUE (frame, regnum, type, VALUE_CONTENTS_RAW (v));
+      VALUE_LVAL (v) = lval_reg_frame_relative;
+      VALUE_FRAME_ID (v) = get_frame_id (frame);
+      VALUE_FRAME_REGNUM (v) = regnum;
     }
   else
     {
index 3d129cdfbd22898f74d1720b85d4d13e684b0a21..ffab6231d8d2d820b142f1027d85eec90a1a2605 100644 (file)
@@ -2140,8 +2140,8 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
   /* Macro might contain `[{}]' when not multi-arch */
   fprintf_unfiltered (file,
                       "gdbarch_dump: %s # %s\n",
-                      "REGISTER_TO_VALUE(frame, regnum, v)",
-                      XSTRING (REGISTER_TO_VALUE (frame, regnum, v)));
+                      "REGISTER_TO_VALUE(frame, regnum, type, buf)",
+                      XSTRING (REGISTER_TO_VALUE (frame, regnum, type, buf)));
 #endif
   if (GDB_MULTI_ARCH)
     fprintf_unfiltered (file,
@@ -2636,8 +2636,8 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
   /* Macro might contain `[{}]' when not multi-arch */
   fprintf_unfiltered (file,
                       "gdbarch_dump: %s # %s\n",
-                      "VALUE_TO_REGISTER(frame, v)",
-                      XSTRING (VALUE_TO_REGISTER (frame, v)));
+                      "VALUE_TO_REGISTER(frame, regnum, type, buf)",
+                      XSTRING (VALUE_TO_REGISTER (frame, regnum, type, buf)));
 #endif
   if (GDB_MULTI_ARCH)
     fprintf_unfiltered (file,
@@ -4133,7 +4133,7 @@ set_gdbarch_convert_register_p (struct gdbarch *gdbarch,
 }
 
 void
-gdbarch_register_to_value (struct gdbarch *gdbarch, struct frame_info *frame, int regnum, struct value *v)
+gdbarch_register_to_value (struct gdbarch *gdbarch, struct frame_info *frame, int regnum, struct type *type, void *buf)
 {
   gdb_assert (gdbarch != NULL);
   if (gdbarch->register_to_value == 0)
@@ -4141,7 +4141,7 @@ gdbarch_register_to_value (struct gdbarch *gdbarch, struct frame_info *frame, in
                     "gdbarch: gdbarch_register_to_value invalid");
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_register_to_value called\n");
-  gdbarch->register_to_value (frame, regnum, v);
+  gdbarch->register_to_value (frame, regnum, type, buf);
 }
 
 void
@@ -4152,7 +4152,7 @@ set_gdbarch_register_to_value (struct gdbarch *gdbarch,
 }
 
 void
-gdbarch_value_to_register (struct gdbarch *gdbarch, struct frame_info *frame, struct value *v)
+gdbarch_value_to_register (struct gdbarch *gdbarch, struct frame_info *frame, int regnum, struct type *type, const void *buf)
 {
   gdb_assert (gdbarch != NULL);
   if (gdbarch->value_to_register == 0)
@@ -4160,7 +4160,7 @@ gdbarch_value_to_register (struct gdbarch *gdbarch, struct frame_info *frame, st
                     "gdbarch: gdbarch_value_to_register invalid");
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_value_to_register called\n");
-  gdbarch->value_to_register (frame, v);
+  gdbarch->value_to_register (frame, regnum, type, buf);
 }
 
 void
index 7920bba0604cb950ae75ce46c4a147c90fbb5c8a..ccd85093247309339f7260535a5b6e5179998612 100644 (file)
@@ -1466,32 +1466,32 @@ extern void set_gdbarch_convert_register_p (struct gdbarch *gdbarch, gdbarch_con
 
 /* Default (function) for non- multi-arch platforms. */
 #if (!GDB_MULTI_ARCH) && !defined (REGISTER_TO_VALUE)
-#define REGISTER_TO_VALUE(frame, regnum, v) (legacy_register_to_value (frame, regnum, v))
+#define REGISTER_TO_VALUE(frame, regnum, type, buf) (legacy_register_to_value (frame, regnum, type, buf))
 #endif
 
-typedef void (gdbarch_register_to_value_ftype) (struct frame_info *frame, int regnum, struct value *v);
-extern void gdbarch_register_to_value (struct gdbarch *gdbarch, struct frame_info *frame, int regnum, struct value *v);
+typedef void (gdbarch_register_to_value_ftype) (struct frame_info *frame, int regnum, struct type *type, void *buf);
+extern void gdbarch_register_to_value (struct gdbarch *gdbarch, struct frame_info *frame, int regnum, struct type *type, void *buf);
 extern void set_gdbarch_register_to_value (struct gdbarch *gdbarch, gdbarch_register_to_value_ftype *register_to_value);
 #if (GDB_MULTI_ARCH >= GDB_MULTI_ARCH_PARTIAL) && defined (REGISTER_TO_VALUE)
 #error "Non multi-arch definition of REGISTER_TO_VALUE"
 #endif
 #if !defined (REGISTER_TO_VALUE)
-#define REGISTER_TO_VALUE(frame, regnum, v) (gdbarch_register_to_value (current_gdbarch, frame, regnum, v))
+#define REGISTER_TO_VALUE(frame, regnum, type, buf) (gdbarch_register_to_value (current_gdbarch, frame, regnum, type, buf))
 #endif
 
 /* Default (function) for non- multi-arch platforms. */
 #if (!GDB_MULTI_ARCH) && !defined (VALUE_TO_REGISTER)
-#define VALUE_TO_REGISTER(frame, v) (legacy_value_to_register (frame, v))
+#define VALUE_TO_REGISTER(frame, regnum, type, buf) (legacy_value_to_register (frame, regnum, type, buf))
 #endif
 
-typedef void (gdbarch_value_to_register_ftype) (struct frame_info *frame, struct value *v);
-extern void gdbarch_value_to_register (struct gdbarch *gdbarch, struct frame_info *frame, struct value *v);
+typedef void (gdbarch_value_to_register_ftype) (struct frame_info *frame, int regnum, struct type *type, const void *buf);
+extern void gdbarch_value_to_register (struct gdbarch *gdbarch, struct frame_info *frame, int regnum, struct type *type, const void *buf);
 extern void set_gdbarch_value_to_register (struct gdbarch *gdbarch, gdbarch_value_to_register_ftype *value_to_register);
 #if (GDB_MULTI_ARCH >= GDB_MULTI_ARCH_PARTIAL) && defined (VALUE_TO_REGISTER)
 #error "Non multi-arch definition of VALUE_TO_REGISTER"
 #endif
 #if !defined (VALUE_TO_REGISTER)
-#define VALUE_TO_REGISTER(frame, v) (gdbarch_value_to_register (current_gdbarch, frame, v))
+#define VALUE_TO_REGISTER(frame, regnum, type, buf) (gdbarch_value_to_register (current_gdbarch, frame, regnum, type, buf))
 #endif
 
 /* Default (function) for non- multi-arch platforms. */
index c577ba00198cb69ec8fd137a485b5741921d4141..e875407f298eeca44f5ae4e4fbd237a70b87c461 100755 (executable)
@@ -558,8 +558,8 @@ f:2:REGISTER_CONVERT_TO_VIRTUAL:void:register_convert_to_virtual:int regnum, str
 f:2:REGISTER_CONVERT_TO_RAW:void:register_convert_to_raw:struct type *type, int regnum, char *from, char *to:type, regnum, from, to:::0::0
 #
 f:1:CONVERT_REGISTER_P:int:convert_register_p:int regnum, struct type *type:regnum, type::0:legacy_convert_register_p::0
-f:1:REGISTER_TO_VALUE:void:register_to_value:struct frame_info *frame, int regnum, struct value *v:frame, regnum, v::0:legacy_register_to_value::0
-f:1:VALUE_TO_REGISTER:void:value_to_register:struct frame_info *frame, struct value *v:frame, v::0:legacy_value_to_register::0
+f:1:REGISTER_TO_VALUE:void:register_to_value:struct frame_info *frame, int regnum, struct type *type, void *buf:frame, regnum, type, buf::0:legacy_register_to_value::0
+f:1:VALUE_TO_REGISTER:void:value_to_register:struct frame_info *frame, int regnum, struct type *type, const void *buf:frame, regnum, type, buf::0:legacy_value_to_register::0
 #
 f:2:POINTER_TO_ADDRESS:CORE_ADDR:pointer_to_address:struct type *type, const void *buf:type, buf:::unsigned_pointer_to_address::0
 f:2:ADDRESS_TO_POINTER:void:address_to_pointer:struct type *type, void *buf, CORE_ADDR addr:type, buf, addr:::unsigned_address_to_pointer::0
index 2f2cc2fce35abcf666c1334bfb078a13f6cfdb9e..0c7acaf95df3bb8c19130798a3fae8b49276f9e5 100644 (file)
@@ -646,21 +646,18 @@ mips_convert_register_p (int regnum, struct type *type)
 
 void
 mips_register_to_value (struct frame_info *frame, int regnum,
-                       struct value *v)
+                       struct type *type, void *to)
 {
-  frame_read_register (frame, regnum + 0, VALUE_CONTENTS_RAW (v) + 4);
-  frame_read_register (frame, regnum + 1, VALUE_CONTENTS_RAW (v) + 0);
-  VALUE_LVAL (v) = lval_reg_frame_relative;
-  VALUE_FRAME_ID (v) = get_frame_id (frame);
-  VALUE_FRAME_REGNUM (v) = regnum;
+  frame_read_register (frame, regnum + 0, (char *) to + 4);
+  frame_read_register (frame, regnum + 1, (char *) to + 0);
 }
 
 void
-mips_value_to_register (struct frame_info *frame, struct value *v)
+mips_value_to_register (struct frame_info *frame, int regnum,
+                       struct type *type, const void *from)
 {
-  int regnum = VALUE_FRAME_REGNUM (v);
-  put_frame_register (frame, regnum + 0, VALUE_CONTENTS (v) + 4);
-  put_frame_register (frame, regnum + 1, VALUE_CONTENTS (v) + 0);
+  put_frame_register (frame, regnum + 0, (const char *) + 4);
+  put_frame_register (frame, regnum + 1, (const char *) + 0);
 }
 
 /* Return the GDB type object for the "standard" data type
index 1115bdfd6948be9440fa8823bc943b80a6918543..f4406adcc17899bcbf2174337051e92c1770a0b5 100644 (file)
@@ -587,14 +587,14 @@ value_assign (struct value *toval, struct value *fromval)
        if (!frame)
          error ("Value being assigned to is no longer active.");
        
-       if (CONVERT_REGISTER_P (VALUE_REGNO (toval), VALUE_TYPE (toval)))
+       if (VALUE_LVAL (toval) == lval_reg_frame_relative
+           && CONVERT_REGISTER_P (VALUE_FRAME_REGNUM (toval),
+                                  VALUE_TYPE (toval)))
          {
            /* If TOVAL is a special machine register requiring
-              conversion of program values to a special raw format,
-              convert FROMVAL's contents now, with result in
-              `raw_buffer', and set USE_BUFFER to the number of bytes
-              to write.  Let VALUE_TO_REGISTER sort out the mess.  */
-           VALUE_TO_REGISTER (frame, fromval);
+              conversion of program values to a special raw format.  */
+           VALUE_TO_REGISTER (frame, VALUE_FRAME_REGNUM (toval),
+                              VALUE_TYPE (toval), VALUE_CONTENTS (toval));
          }
        else
          {