]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
vla: update type from newly created value
authorSanimir Agovic <sanimir.agovic@intel.com>
Mon, 14 Oct 2013 07:36:13 +0000 (08:36 +0100)
committerJoel Brobecker <brobecker@adacore.com>
Mon, 14 Apr 2014 16:15:33 +0000 (09:15 -0700)
Constructing a value based on a type and address might change the type
of the newly constructed value. Thus re-fetch type via value_type to ensure
we have the correct type at hand.

gdb/ChangeLog

* ada-lang.c (ada_value_primitive_packed_val): Re-fetch type from value.
(ada_template_to_fixed_record_type_1): Likewise.
(ada_to_fixed_type_1): Likewise.
* cp-valprint.c (cp_print_value_fields_rtti): Likewise.
(cp_print_value): Likewise.
* d-valprint.c (dynamic_array_type): Likewise.
* findvar.c (address_of_variable): Likewise.
* jv-valprint.c (java_value_print): Likewise.
* valops.c (value_ind): Likewise.
* value.c (coerce_ref): Likewise.

gdb/ChangeLog
gdb/ada-lang.c
gdb/cp-valprint.c
gdb/d-valprint.c
gdb/jv-valprint.c
gdb/valops.c
gdb/value.c

index c7efe6298ba654a4225324860e3ee10c48f98ba0..955db91ca5869ec2938e5d09e9b6e46b2e0ead23 100644 (file)
@@ -1,3 +1,17 @@
+2014-04-14  Sanimir Agovic  <sanimir.agovic@intel.com>
+
+       * ada-lang.c (ada_value_primitive_packed_val): Re-fetch type from
+       value.
+       (ada_template_to_fixed_record_type_1): Likewise.
+       (ada_to_fixed_type_1): Likewise.
+       * cp-valprint.c (cp_print_value_fields_rtti): Likewise.
+       (cp_print_value): Likewise.
+       * d-valprint.c (dynamic_array_type): Likewise.
+       * findvar.c (address_of_variable): Likewise.
+       * jv-valprint.c (java_value_print): Likewise.
+       * valops.c (value_ind): Likewise.
+       * value.c (coerce_ref): Likewise.
+
 2014-04-14  Sanimir Agovic  <sanimir.agovic@intel.com>
 
        * eval.c (evaluate_subexp_for_sizeof) <UNOP_IND>: Create an indirect
index 95447585964b80eacf9b64c88a59814b5086fbd9..e268ebad3aad98ecb1438f037b870cb61b075d61 100644 (file)
@@ -2406,6 +2406,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
   else if (VALUE_LVAL (obj) == lval_memory && value_lazy (obj))
     {
       v = value_at (type, value_address (obj));
+      type = value_type (v);
       bytes = (unsigned char *) alloca (len);
       read_memory (value_address (v) + offset, bytes, len);
     }
@@ -7888,6 +7889,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
                 size first before creating the value.  */
              check_size (rtype);
              dval = value_from_contents_and_address (rtype, valaddr, address);
+             rtype = value_type (dval);
            }
           else
             dval = dval0;
@@ -7990,7 +7992,10 @@ ada_template_to_fixed_record_type_1 (struct type *type,
       off = TYPE_FIELD_BITPOS (rtype, variant_field);
 
       if (dval0 == NULL)
-        dval = value_from_contents_and_address (rtype, valaddr, address);
+       {
+         dval = value_from_contents_and_address (rtype, valaddr, address);
+         rtype = value_type (dval);
+       }
       else
         dval = dval0;
 
@@ -8131,7 +8136,10 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
     return type;
 
   if (dval0 == NULL)
-    dval = value_from_contents_and_address (type, valaddr, address);
+    {
+      dval = value_from_contents_and_address (type, valaddr, address);
+      type = value_type (dval);
+    }
   else
     dval = dval0;
 
@@ -8429,6 +8437,7 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr,
              value_from_contents_and_address (fixed_record_type,
                                               valaddr,
                                               address);
+            fixed_record_type = value_type (obj);
             if (real_type != NULL)
               return to_fixed_record_type
                (real_type, NULL,
index 2d366b9b182fd890604b0363f3befc7718614166..3e1d6ededd57112afa62c98bd68d3abd4e381df0 100644 (file)
@@ -443,6 +443,7 @@ cp_print_value_fields_rtti (struct type *type,
       /* Ugh, we have to convert back to a value here.  */
       value = value_from_contents_and_address (type, valaddr + offset,
                                               address + offset);
+      type = value_type (value);
       /* We don't actually care about most of the result here -- just
         the type.  We already have the correct offset, due to how
         val_print was initially called.  */
@@ -545,6 +546,7 @@ cp_print_value (struct type *type, struct type *real_type,
                  base_val = value_from_contents_and_address (baseclass,
                                                              buf,
                                                              address + boffset);
+                 baseclass = value_type (base_val);
                  thisoffset = 0;
                  boffset = 0;
                  thistype = baseclass;
index 90095cd53e5812f57a01495da142c06161874b63..755f180dc51f35c21095ae39a23baa6748e00781 100644 (file)
@@ -59,6 +59,7 @@ dynamic_array_type (struct type *type, const gdb_byte *valaddr,
 
       true_type = lookup_array_range_type (true_type, 0, length - 1);
       ival = value_at (true_type, addr);
+      true_type = value_type (ival);
 
       d_val_print (true_type,
                   value_contents_for_printing (ival),
index 82bdd9bf32b8a6da5c0087dc8a6b9ac299c50260..a7bb4944f62969174402280c0cb7843dd495403b 100644 (file)
@@ -65,6 +65,7 @@ java_value_print (struct value *val, struct ui_file *stream,
          type = lookup_pointer_type (type);
 
          val = value_at (type, address);
+         type = value_type (val);
        }
     }
 
index 46e2639ab9fed4a9a7e2811b54939e5f8d4ffe07..a1553795e5e1a04a0a07a8c3cb392aad82327c69 100644 (file)
@@ -266,6 +266,7 @@ value_cast_structs (struct type *type, struct value *v2)
        {
          v = value_full_object (v2, real_type, full, top, using_enc);
          v = value_at_lazy (real_type, value_address (v));
+         real_type = value_type (v);
 
          /* We might be trying to cast to the outermost enclosing
             type, in which case search_struct_field won't work.  */
@@ -801,6 +802,7 @@ value_dynamic_cast (struct type *type, struct value *arg)
     return value_at_lazy (type, addr);
 
   tem = value_at (type, addr);
+  type = value_type (tem);
 
   /* The first dynamic check specified in 5.2.7.  */
   if (is_public_ancestor (arg_type, TYPE_TARGET_TYPE (resolved_type)))
@@ -1320,6 +1322,7 @@ address_of_variable (struct symbol *var, const struct block *b)
      Lazy evaluation pays off here.  */
 
   val = value_of_variable (var, b);
+  type = value_type (val);
 
   if ((VALUE_LVAL (val) == lval_memory && value_lazy (val))
       || TYPE_CODE (type) == TYPE_CODE_FUNC)
@@ -1568,6 +1571,7 @@ value_ind (struct value *arg1)
                              (value_as_address (arg1)
                               - value_pointed_to_offset (arg1)));
 
+      enc_type = value_type (arg2);
       return readjust_indirect_value_type (arg2, enc_type, base_type, arg1);
     }
 
index 9cc5e4469e59ac67be2482646a5c9b42f52556a7..d125a0913a916f8034dd6310aa22f2ee4843803a 100644 (file)
@@ -3505,6 +3505,7 @@ coerce_ref (struct value *arg)
   retval = value_at_lazy (enc_type,
                           unpack_pointer (value_type (arg),
                                           value_contents (arg)));
+  enc_type = value_type (retval);
   return readjust_indirect_value_type (retval, enc_type,
                                        value_type_arg_tmp, arg);
 }