2005-02-07 Andrew Cagney <cagney@gnu.org>
authorAndrew Cagney <cagney@redhat.com>
Mon, 7 Feb 2005 23:51:03 +0000 (23:51 +0000)
committerAndrew Cagney <cagney@redhat.com>
Mon, 7 Feb 2005 23:51:03 +0000 (23:51 +0000)
* value.h (deprecated_set_value_type): Declare.
* value.c (deprecated_set_value_type): Define.
* hpacc-abi.c, gnu-v2-abi.c, cp-valprint.c: Update.
* c-valprint.c, jv-lang.c, objc-lang.c, ada-lang.c: Update.
* infcall.c, printcmd.c, valops.c, eval.c, p-exp.y: Update.
* ax-gdb.c, tracepoint.c: Update.

17 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/ax-gdb.c
gdb/c-valprint.c
gdb/cp-valprint.c
gdb/eval.c
gdb/gnu-v2-abi.c
gdb/hpacc-abi.c
gdb/infcall.c
gdb/jv-lang.c
gdb/objc-lang.c
gdb/p-exp.y
gdb/printcmd.c
gdb/tracepoint.c
gdb/valops.c
gdb/value.c
gdb/value.h

index 7d35eb8..fca3e11 100644 (file)
@@ -1,5 +1,12 @@
 2005-02-07  Andrew Cagney  <cagney@gnu.org>
 
+       * value.h (deprecated_set_value_type): Declare.
+       * value.c (deprecated_set_value_type): Define.
+       * hpacc-abi.c, gnu-v2-abi.c, cp-valprint.c: Update.
+       * c-valprint.c, jv-lang.c, objc-lang.c, ada-lang.c: Update.
+       * infcall.c, printcmd.c, valops.c, eval.c, p-exp.y: Update.
+       * ax-gdb.c, tracepoint.c: Update.
+
        * value.h (deprecated_value_lval_hack)
        (deprecated_value_address_hack) 
        (deprecated_value_internalvar_hack) 
index 222ead4..3526505 100644 (file)
@@ -1547,7 +1547,7 @@ ada_coerce_to_simple_array_type (struct type *type)
   struct value *mark = value_mark ();
   struct value *dummy = value_from_longest (builtin_type_long, 0);
   struct type *result;
-  dummy->type = type;
+  deprecated_set_value_type (dummy, type);
   result = ada_type_of_array (dummy, 0);
   value_free_to_mark (mark);
   return result;
@@ -2041,7 +2041,7 @@ ada_value_assign (struct value *toval, struct value *fromval)
       val = value_copy (toval);
       memcpy (value_contents_raw (val), value_contents (fromval),
               TYPE_LENGTH (type));
-      val->type = type;
+      deprecated_set_value_type (val, type);
 
       return val;
     }
@@ -7047,7 +7047,7 @@ coerce_for_assign (struct type *type, struct value *val)
           || TYPE_LENGTH (TYPE_TARGET_TYPE (type2))
           != TYPE_LENGTH (TYPE_TARGET_TYPE (type2)))
         error (_("Incompatible types in assignment"));
-      val->type = type;
+      deprecated_set_value_type (val, type);
     }
   return val;
 }
index eb971ae..98d9ef5 100644 (file)
@@ -1424,7 +1424,7 @@ gen_repeat (union exp_element **pc, struct agent_expr *ax,
 
     if (!v)
       error (_("Right operand of `@' must be a constant, in agent expressions."));
-    if (TYPE_CODE (v->type) != TYPE_CODE_INT)
+    if (TYPE_CODE (value_type (v)) != TYPE_CODE_INT)
       error (_("Right operand of `@' must be an integer."));
     length = value_as_long (v);
     if (length <= 0)
index a18ef0f..948f5d8 100644 (file)
@@ -531,7 +531,7 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
               */
              struct value *temparg;
              temparg=value_copy(val);
-             temparg->type = lookup_pointer_type (TYPE_TARGET_TYPE(type));
+             deprecated_set_value_type (temparg, lookup_pointer_type (TYPE_TARGET_TYPE(type)));
              val=temparg;
            }
          /* Pointer to class, check real type of object */
index 42a07fc..2cff8e7 100644 (file)
@@ -786,7 +786,8 @@ cp_print_hpacc_virtual_table_entries (struct type *type, int *vfuncs,
          /* adjust by offset */
          vf->aligner.contents[0] += 4 * (HP_ACC_VFUNC_START + vx);
          vf = value_ind (vf);  /* get the entry */
-         vf->type = value_type (v);    /* make it a pointer */
+         /* make it a pointer */
+         deprecated_set_value_type (vf, value_type (v));
 
          /* print out the entry */
          val_print (value_type (vf), value_contents (vf), 0, 0,
index 79a8ffd..4f1f25a 100644 (file)
@@ -945,8 +945,8 @@ evaluate_subexp_standard (struct type *expect_type,
        if (gnu_runtime && (method != NULL))
          {
            /* Function objc_msg_lookup returns a pointer.  */
-           argvec[0]->type
-             = lookup_function_type (lookup_pointer_type (value_type (argvec[0])));
+           deprecated_set_value_type (argvec[0],
+                                      lookup_function_type (lookup_pointer_type (value_type (argvec[0]))));
            argvec[0] = call_function_by_hand (argvec[0], nargs + 2, argvec + 1);
          }
 
@@ -1030,7 +1030,7 @@ evaluate_subexp_standard (struct type *expect_type,
            }
          else
            {
-             arg1->type = lookup_pointer_type (TYPE_TARGET_TYPE (value_type (arg1)));
+             deprecated_set_value_type (arg1, lookup_pointer_type (TYPE_TARGET_TYPE (value_type (arg1))));
            }
        got_it:
 
@@ -1688,7 +1688,7 @@ evaluate_subexp_standard (struct type *expect_type,
           type, this will ensure that value_subscript()
           returns the correct type value */
 
-       arg1->type = tmp_type;
+       deprecated_set_value_type (arg1, tmp_type);
        return value_ind (value_add (value_coerce_array (arg1), arg2));
       }
 
index c555786..87f4e9c 100644 (file)
@@ -177,7 +177,7 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j,
   else
     error ("I'm confused:  virtual function table has bad type");
   /* Reinstantiate the function pointer with the correct type.  */
-  vfn->type = lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j));
+  deprecated_set_value_type (vfn, lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j)));
 
   *arg1p = arg1;
   return vfn;
index 9f86c15..a0836e0 100644 (file)
@@ -168,7 +168,7 @@ hpacc_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j,
 
   /* Wrap this addr in a value and return pointer */
   vp = allocate_value (ftype);
-  vp->type = ftype;
+  deprecated_set_value_type (vp, ftype);
   VALUE_ADDRESS (vp) = coreptr;
 
   /* pai: (temp) do we need the value_ind stuff in value_fn_field? */
index 667a07f..f91777c 100644 (file)
@@ -96,7 +96,7 @@ value_arg_coerce (struct value *arg, struct type *param_type,
          && TYPE_CODE (arg_type) != TYPE_CODE_PTR)
        {
          arg = value_addr (arg);
-         arg->type = param_type;
+         deprecated_set_value_type (arg, param_type);
          return arg;
        }
       break;
index bc2264f..230ee86 100644 (file)
@@ -320,7 +320,7 @@ type_from_class (struct value *clas)
       temp = clas;
       /* Set array element type. */
       temp = value_struct_elt (&temp, NULL, "methods", NULL, "structure");
-      temp->type = lookup_pointer_type (value_type (clas));
+      deprecated_set_value_type (temp, lookup_pointer_type (value_type (clas)));
       TYPE_TARGET_TYPE (type) = type_from_class (temp);
     }
 
@@ -890,7 +890,7 @@ evaluate_subexp_java (struct type *expect_type, struct expression *exp,
          /* Get CLASS_ELEMENT_TYPE of the array type. */
          temp = value_struct_elt (&temp, NULL, "methods",
                                   NULL, "structure");
-         temp->type = value_type (clas);
+         deprecated_set_value_type (temp, value_type (clas));
          el_type = type_from_class (temp);
          if (TYPE_CODE (el_type) == TYPE_CODE_STRUCT)
            el_type = lookup_pointer_type (el_type);
index 8ddffa8..41dd8e8 100644 (file)
@@ -204,7 +204,7 @@ value_nsstring (char *ptr, int len)
   else
     error ("NSString: internal error -- no way to create new NSString");
 
-  nsstringValue->type = type;
+  deprecated_set_value_type (nsstringValue, type);
   return nsstringValue;
 }
 
index a80f8e9..5a61276 100644 (file)
@@ -521,7 +521,7 @@ exp :       THIS
                          /* we need type of this */
                          this_val = value_of_this (0); 
                          if (this_val)
-                           this_type = this_val->type;
+                           this_type = value_type (this_val);
                          else
                            this_type = NULL;
                          if (this_type)
@@ -672,7 +672,7 @@ variable:   name_not_typename
                              /* we need type of this */
                              this_val = value_of_this (0); 
                              if (this_val)
-                               this_type = this_val->type;
+                               this_type = value_type (this_val);
                              else
                                this_type = NULL;
                              if (this_type)
index c735d2c..524dd39 100644 (file)
@@ -1904,9 +1904,9 @@ printf_command (char *arg, int from_tty)
          {
            struct type *type = value_type (val_args[nargs]);
            if (TYPE_LENGTH (type) == sizeof (float))
-             val_args[nargs]->type = builtin_type_float;
+             deprecated_set_value_type (val_args[nargs], builtin_type_float);
            if (TYPE_LENGTH (type) == sizeof (double))
-             val_args[nargs]->type = builtin_type_double;
+             deprecated_set_value_type (val_args[nargs], builtin_type_double);
          }
        nargs++;
        s = s1;
index 74a0d55..6de409e 100644 (file)
@@ -296,7 +296,7 @@ set_traceframe_context (CORE_ADDR trace_pc)
       func_string = create_array_type (func_string,
                                       builtin_type_char, func_range);
       func_val = allocate_value (func_string);
-      func_val->type = func_string;
+      deprecated_set_value_type (func_val, func_string);
       memcpy (value_contents_raw (func_val),
              DEPRECATED_SYMBOL_NAME (traceframe_fun),
              len);
@@ -318,7 +318,7 @@ set_traceframe_context (CORE_ADDR trace_pc)
       file_string = create_array_type (file_string,
                                       builtin_type_char, file_range);
       file_val = allocate_value (file_string);
-      file_val->type = file_string;
+      deprecated_set_value_type (file_val, file_string);
       memcpy (value_contents_raw (file_val),
              traceframe_sal.symtab->filename,
              len);
index 942ef16..56e4645 100644 (file)
@@ -240,8 +240,8 @@ value_cast (struct type *type, struct value *arg2)
                                          TYPE_TARGET_TYPE (range_type),
                                          low_bound,
                                          new_length + low_bound - 1);
-         arg2->type = create_array_type ((struct type *) NULL,
-                                         element_type, range_type);
+         deprecated_set_value_type (arg2, create_array_type ((struct type *) NULL,
+                                                             element_type, range_type));
          return arg2;
        }
     }
@@ -282,7 +282,7 @@ value_cast (struct type *type, struct value *arg2)
                                         arg2, 0, type2, 1);
       if (v)
        {
-         v->type = type;
+         deprecated_set_value_type (v, type);
          return v;
        }
     }
@@ -380,7 +380,7 @@ value_cast (struct type *type, struct value *arg2)
                  if (v)
                    {
                      v = value_addr (v);
-                     v->type = type;
+                     deprecated_set_value_type (v, type);
                      return v;
                    }
                }
@@ -405,7 +405,7 @@ value_cast (struct type *type, struct value *arg2)
            }
          /* No superclass found, just fall through to change ptr type.  */
        }
-      arg2->type = type;
+      deprecated_set_value_type (arg2, type);
       arg2 = value_change_enclosing_type (arg2, type);
       set_value_pointed_to_offset (arg2, 0);   /* pai: chk_val */
       return arg2;
@@ -730,7 +730,7 @@ value_assign (struct value *toval, struct value *fromval)
   val = value_copy (toval);
   memcpy (value_contents_raw (val), value_contents (fromval),
          TYPE_LENGTH (type));
-  val->type = type;
+  deprecated_set_value_type (val, type);
   val = value_change_enclosing_type (val, value_enclosing_type (fromval));
   set_value_embedded_offset (val, value_embedded_offset (fromval));
   set_value_pointed_to_offset (val, value_pointed_to_offset (fromval));
@@ -855,7 +855,7 @@ value_addr (struct value *arg1)
          We keep the same location information, which is efficient,
          and allows &(&X) to get the location containing the reference. */
       arg2 = value_copy (arg1);
-      arg2->type = lookup_pointer_type (TYPE_TARGET_TYPE (type));
+      deprecated_set_value_type (arg2, lookup_pointer_type (TYPE_TARGET_TYPE (type)));
       return arg2;
     }
   if (TYPE_CODE (type) == TYPE_CODE_FUNC)
@@ -911,7 +911,7 @@ value_ind (struct value *arg1)
       arg2 = value_at_lazy (enc_type, (value_as_address (arg1)
                                       - value_pointed_to_offset (arg1)));
       /* Re-adjust type */
-      arg2->type = TYPE_TARGET_TYPE (base_type);
+      deprecated_set_value_type (arg2, TYPE_TARGET_TYPE (base_type));
       /* Add embedding info */
       arg2 = value_change_enclosing_type (arg2, enc_type);
       set_value_embedded_offset (arg2, value_pointed_to_offset (arg1));
@@ -2625,7 +2625,7 @@ value_full_object (struct value *argp, struct type *rtype, int xfull, int xtop,
      used for its computation. */
   new_val = value_at_lazy (real_type, VALUE_ADDRESS (argp) - top +
                           (using_enc ? 0 : value_embedded_offset (argp)));
-  new_val->type = value_type (argp);
+  deprecated_set_value_type (new_val, value_type (argp));
   set_value_embedded_offset (new_val, (using_enc
                                       ? top + value_embedded_offset (argp)
                                       : top));
index 1a8796e..e338dd2 100644 (file)
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+/* Hack so that value.h can detect when it's being included by
+   value.c.  */
+#define VALUE_C
+
 #include "defs.h"
 #include "gdb_string.h"
 #include "symtab.h"
@@ -128,6 +132,11 @@ value_type (struct value *value)
 {
   return value->type;
 }
+void
+deprecated_set_value_type (struct value *value, struct type *type)
+{
+  value->type = type;
+}
 
 int
 value_offset (struct value *value)
index 3905b1a..762f1f2 100644 (file)
@@ -80,7 +80,11 @@ struct value
   struct frame_id frame_id;
 
   /* Type of the value.  */
+#ifdef VALUE_C
   struct type *type;
+#else
+  struct type *xtype;
+#endif
 
   /* If a value represents a C++ object, then the `type' field gives
      the object's compile-time type.  If the object actually belongs
@@ -174,6 +178,11 @@ struct value
 
 
 extern struct type *value_type (struct value *);
+/* This is being used to change the type of an existing value, that
+   code should instead be creating a new value with the changed type
+   (but possibly shared content).  */
+extern void deprecated_set_value_type (struct value *value,
+                                      struct type *type);
 extern int value_bitsize (struct value *);
 extern int value_bitpos (struct value *);
 extern int value_offset (struct value *);