* MAINTAINERS (frv): New ISA entry.
[deliverable/binutils-gdb.git] / gdb / valops.c
index 5523c5dbedbb9e56e0981455139aa528924c8715..9d02a3502988bf8d4f4199ea1e60cf08d68679fc 100644 (file)
@@ -35,6 +35,8 @@
 #include "cp-abi.h"
 #include "block.h"
 #include "infcall.h"
+#include "dictionary.h"
+#include "cp-support.h"
 
 #include <errno.h>
 #include "gdb_string.h"
@@ -87,7 +89,7 @@ struct value *
 find_function_in_inferior (const char *name)
 {
   register struct symbol *sym;
-  sym = lookup_symbol (name, 0, VAR_NAMESPACE, 0, NULL);
+  sym = lookup_symbol (name, 0, VAR_DOMAIN, 0, NULL);
   if (sym != NULL)
     {
       if (SYMBOL_CLASS (sym) != LOC_BLOCK)
@@ -480,7 +482,7 @@ value_assign (struct value *toval, struct value *fromval)
 {
   register struct type *type;
   struct value *val;
-  char *raw_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
+  char raw_buffer[MAX_REGISTER_SIZE];
   int use_buffer = 0;
   struct frame_id old_frame;
 
@@ -496,22 +498,6 @@ value_assign (struct value *toval, struct value *fromval)
     COERCE_ARRAY (fromval);
   CHECK_TYPEDEF (type);
 
-  /* 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.  */
-
-  if (VALUE_REGNO (toval) >= 0)
-    {
-      int regno = VALUE_REGNO (toval);
-      if (CONVERT_REGISTER_P (regno))
-       {
-         struct type *fromtype = check_typedef (VALUE_TYPE (fromval));
-         VALUE_TO_REGISTER (fromtype, regno, VALUE_CONTENTS (fromval), raw_buffer);
-         use_buffer = REGISTER_RAW_SIZE (regno);
-       }
-    }
-
   /* Since modifying a register can trash the frame chain, and modifying memory
      can trash the frame cache, we save the old frame and then restore the new
      frame afterwards.  */
@@ -585,17 +571,8 @@ value_assign (struct value *toval, struct value *fromval)
     case lval_reg_frame_relative:
     case lval_register:
       {
-       /* value is stored in a series of registers in the frame
-          specified by the structure.  Copy that value out, modify
-          it, and copy it back in.  */
-       int amount_copied;
-       int amount_to_copy;
-       char *buffer;
-       int value_reg;
-       int reg_offset;
-       int byte_offset;
-       int regno;
        struct frame_info *frame;
+       int value_reg;
 
        /* Figure out which frame this is in currently.  */
        if (VALUE_LVAL (toval) == lval_register)
@@ -605,102 +582,83 @@ value_assign (struct value *toval, struct value *fromval)
          }
        else
          {
-           for (frame = get_current_frame ();
-                frame && get_frame_base (frame) != VALUE_FRAME (toval);
-                frame = get_prev_frame (frame))
-             ;
+           frame = frame_find_by_id (VALUE_FRAME_ID (toval));
            value_reg = VALUE_FRAME_REGNUM (toval);
          }
 
        if (!frame)
          error ("Value being assigned to is no longer active.");
-
-       /* Locate the first register that falls in the value that
-           needs to be transfered.  Compute the offset of the value in
-           that register.  */
-       {
-         int offset;
-         for (reg_offset = value_reg, offset = 0;
-              offset + REGISTER_RAW_SIZE (reg_offset) <= VALUE_OFFSET (toval);
-              reg_offset++);
-         byte_offset = VALUE_OFFSET (toval) - offset;
-       }
-
-       /* Compute the number of register aligned values that need to
-           be copied.  */
-       if (VALUE_BITSIZE (toval))
-         amount_to_copy = byte_offset + 1;
-       else
-         amount_to_copy = byte_offset + TYPE_LENGTH (type);
-
-       /* And a bounce buffer.  Be slightly over generous.  */
-       buffer = (char *) alloca (amount_to_copy
-                                 + MAX_REGISTER_RAW_SIZE);
-
-       /* Copy it in.  */
-       for (regno = reg_offset, amount_copied = 0;
-            amount_copied < amount_to_copy;
-            amount_copied += REGISTER_RAW_SIZE (regno), regno++)
-         {
-           frame_register_read (frame, regno, buffer + amount_copied);
-         }
        
-       /* Modify what needs to be modified.  */
-       if (VALUE_BITSIZE (toval))
+       if (VALUE_LVAL (toval) == lval_reg_frame_relative
+           && CONVERT_REGISTER_P (VALUE_FRAME_REGNUM (toval), type))
          {
-           modify_field (buffer + byte_offset,
-                         value_as_long (fromval),
-                         VALUE_BITPOS (toval), VALUE_BITSIZE (toval));
-         }
-       else if (use_buffer)
-         {
-           memcpy (buffer + VALUE_OFFSET (toval), raw_buffer, use_buffer);
+           /* If TOVAL is a special machine register requiring
+              conversion of program values to a special raw format.  */
+           VALUE_TO_REGISTER (frame, VALUE_FRAME_REGNUM (toval),
+                              type, VALUE_CONTENTS (fromval));
          }
        else
          {
-           memcpy (buffer + byte_offset, VALUE_CONTENTS (fromval),
-                   TYPE_LENGTH (type));
-           /* Do any conversion necessary when storing this type to
-              more than one register.  */
-#ifdef REGISTER_CONVERT_FROM_TYPE
-           REGISTER_CONVERT_FROM_TYPE (value_reg, type,
-                                       (buffer + byte_offset));
-#endif
-         }
+           /* TOVAL is stored in a series of registers in the frame
+              specified by the structure.  Copy that value out,
+              modify it, and copy it back in.  */
+           int amount_copied;
+           int amount_to_copy;
+           char *buffer;
+           int reg_offset;
+           int byte_offset;
+           int regno;
+
+           /* Locate the first register that falls in the value that
+              needs to be transfered.  Compute the offset of the
+              value in that register.  */
+           {
+             int offset;
+             for (reg_offset = value_reg, offset = 0;
+                  offset + REGISTER_RAW_SIZE (reg_offset) <= VALUE_OFFSET (toval);
+                  reg_offset++);
+             byte_offset = VALUE_OFFSET (toval) - offset;
+           }
 
-       /* Copy it out.  */
-       for (regno = reg_offset, amount_copied = 0;
-            amount_copied < amount_to_copy;
-            amount_copied += REGISTER_RAW_SIZE (regno), regno++)
-         {
-           enum lval_type lval;
-           CORE_ADDR addr;
-           int optim;
-           int realnum;
+           /* Compute the number of register aligned values that need
+              to be copied.  */
+           if (VALUE_BITSIZE (toval))
+             amount_to_copy = byte_offset + 1;
+           else
+             amount_to_copy = byte_offset + TYPE_LENGTH (type);
            
-           /* Just find out where to put it.  */
-           frame_register (frame, regno, &optim, &lval, &addr, &realnum,
-                           NULL);
+           /* And a bounce buffer.  Be slightly over generous.  */
+           buffer = (char *) alloca (amount_to_copy + MAX_REGISTER_SIZE);
+
+           /* Copy it in.  */
+           for (regno = reg_offset, amount_copied = 0;
+                amount_copied < amount_to_copy;
+                amount_copied += REGISTER_RAW_SIZE (regno), regno++)
+             frame_register_read (frame, regno, buffer + amount_copied);
            
-           if (optim)
-             error ("Attempt to assign to a value that was optimized out.");
-           if (lval == lval_memory)
-             write_memory (addr, buffer + amount_copied,
-                           REGISTER_RAW_SIZE (regno));
-           else if (lval == lval_register)
-             regcache_cooked_write (current_regcache, realnum,
-                                    (buffer + amount_copied));
+           /* Modify what needs to be modified.  */
+           if (VALUE_BITSIZE (toval))
+             modify_field (buffer + byte_offset,
+                           value_as_long (fromval),
+                           VALUE_BITPOS (toval), VALUE_BITSIZE (toval));
+           else if (use_buffer)
+             memcpy (buffer + VALUE_OFFSET (toval), raw_buffer, use_buffer);
            else
-             error ("Attempt to assign to an unmodifiable value.");
-         }
+             memcpy (buffer + byte_offset, VALUE_CONTENTS (fromval),
+                     TYPE_LENGTH (type));
+
+           /* Copy it out.  */
+           for (regno = reg_offset, amount_copied = 0;
+                amount_copied < amount_to_copy;
+                amount_copied += REGISTER_RAW_SIZE (regno), regno++)
+             put_frame_register (frame, regno, buffer + amount_copied);
 
+         }
        if (register_changed_hook)
          register_changed_hook (-1);
        target_changed_event ();
-
+       break;
       }
-      break;
-      
       
     default:
       error ("Left operand of assignment is not an lvalue.");
@@ -963,7 +921,7 @@ CORE_ADDR
 push_word (CORE_ADDR sp, ULONGEST word)
 {
   register int len = DEPRECATED_REGISTER_SIZE;
-  char *buffer = alloca (MAX_REGISTER_RAW_SIZE);
+  char buffer[MAX_REGISTER_SIZE];
 
   store_unsigned_integer (buffer, len, word);
   if (INNER_THAN (1, 2))
@@ -2351,7 +2309,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
          else
            {
              struct symbol *s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
-                                               0, VAR_NAMESPACE, 0, NULL);
+                                               0, VAR_DOMAIN, 0, NULL);
              if (s == NULL)
                {
                  v = 0;
@@ -2479,7 +2437,6 @@ value_of_local (const char *name, int complain)
 {
   struct symbol *func, *sym;
   struct block *b;
-  int i;
   struct value * ret;
 
   if (deprecated_selected_frame == 0)
@@ -2500,8 +2457,7 @@ value_of_local (const char *name, int complain)
     }
 
   b = SYMBOL_BLOCK_VALUE (func);
-  i = BLOCK_NSYMS (b);
-  if (i <= 0)
+  if (dict_empty (BLOCK_DICT (b)))
     {
       if (complain)
        error ("no args, no `%s'", name);
@@ -2511,7 +2467,7 @@ value_of_local (const char *name, int complain)
 
   /* Calling lookup_block_symbol is necessary to get the LOC_REGISTER
      symbol instead of the LOC_ARG one (if both exist).  */
-  sym = lookup_block_symbol (b, name, NULL, VAR_NAMESPACE);
+  sym = lookup_block_symbol (b, name, NULL, VAR_DOMAIN);
   if (sym == NULL)
     {
       if (complain)
This page took 0.027213 seconds and 4 git commands to generate.