Create subobject value in pretty printer
[deliverable/binutils-gdb.git] / gdb / valarith.c
index de6fcfd79abb2f3b6a1b341c36736ac949826cf3..efa41ed06568b0f5e29926d841fd67371d0c6600 100644 (file)
@@ -194,7 +194,6 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
   struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
   ULONGEST elt_size = type_length_units (elt_type);
   ULONGEST elt_offs = elt_size * (index - lowerbound);
-  struct value *v;
 
   if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
                             && elt_offs >= type_length_units (array_type)))
@@ -215,21 +214,7 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
       elt_type = resolve_dynamic_type (elt_type, NULL, address);
     }
 
-  if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
-    v = allocate_value_lazy (elt_type);
-  else
-    {
-      v = allocate_value (elt_type);
-      value_contents_copy (v, value_embedded_offset (v),
-                          array, value_embedded_offset (array) + elt_offs,
-                          elt_size);
-    }
-
-  set_value_component_location (v, array);
-  VALUE_REGNUM (v) = VALUE_REGNUM (array);
-  VALUE_FRAME_ID (v) = VALUE_FRAME_ID (array);
-  set_value_offset (v, value_offset (array) + elt_offs);
-  return v;
+  return value_from_component (array, elt_type, elt_offs);
 }
 
 \f
This page took 0.023271 seconds and 4 git commands to generate.