From 3fff9862d5229def9318912c2de64a03dab74532 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Mon, 21 Nov 2016 14:15:06 +0000 Subject: Create subobject value in pretty printer Nowadays, we create a value of subobject in pretty printer with 'address' being used, value = value_from_contents_and_address (type, valaddr + embedded_offset, address + embedded_offset); set_value_component_location (value, val); /* set_value_component_location resets the address, so we may need to set it again. */ if (VALUE_LVAL (value) != lval_internalvar && VALUE_LVAL (value) != lval_internalvar_component && VALUE_LVAL (value) != lval_computed) set_value_address (value, address + embedded_offset); value_from_contents_and_address creates a value from memory, but the value we are pretty-printing may not from memory at all. Instead of using value_from_contents_and_address, we create a value of subobject with the same location as object's but different offset. We avoid using address in this way. As a result, parameter 'address' in apply_val_pretty_printer is no longer needed, we can remove it in next step. We've already had the location of the 'whole' value, so it is safe to assume we can create a value of 'component' or 'suboject' value at the same location but with different offset. gdb: 2016-11-21 Yao Qi * guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer): Don't call value_from_contents_and_address and set_value_address. Call value_from_component. * python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Likewise. * value.c (value_from_component): New function. * value.h (value_from_component): Likewise. * valarith.c (value_subscripted_rvalue): Call value_from_component. --- gdb/valarith.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'gdb/valarith.c') diff --git a/gdb/valarith.c b/gdb/valarith.c index 2c56110..efa41ed 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -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_NEXT_FRAME_ID (v) = VALUE_NEXT_FRAME_ID (array); - set_value_offset (v, value_offset (array) + elt_offs); - return v; + return value_from_component (array, elt_type, elt_offs); } -- cgit v1.1