From 74bcbdf3cea56564d1f9f597c8458b86ed71f621 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 13 Jan 2009 10:34:31 +0000 Subject: 2009-01-13 Jim Blandy Abstract out common code for copying value locations. * value.h (set_value_component_location): New declaration. * value.c (set_value_component_location): New function. (value_primitive_field): Use it. * valarith.c (value_subscript, value_subscripted_rvalue): Same. * valops.c (search_struct_field, value_slice): Same. * ada-lang.c (coerce_unspec_val_to_type) (ada_value_primitive_packed_val): Same. --- gdb/value.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'gdb/value.c') diff --git a/gdb/value.c b/gdb/value.c index 1068f1d..f0c8463 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -627,6 +627,17 @@ value_copy (struct value *arg) } return val; } + +void +set_value_component_location (struct value *component, struct value *whole) +{ + if (VALUE_LVAL (whole) == lval_internalvar) + VALUE_LVAL (component) = lval_internalvar_component; + else + VALUE_LVAL (component) = VALUE_LVAL (whole); + component->location = whole->location; +} + /* Access to the value history. */ @@ -1426,10 +1437,7 @@ value_primitive_field (struct value *arg1, int offset, v->offset = (value_offset (arg1) + offset + value_embedded_offset (arg1)); } - VALUE_LVAL (v) = VALUE_LVAL (arg1); - if (VALUE_LVAL (arg1) == lval_internalvar) - VALUE_LVAL (v) = lval_internalvar_component; - v->location = arg1->location; + set_value_component_location (v, arg1); VALUE_REGNUM (v) = VALUE_REGNUM (arg1); VALUE_FRAME_ID (v) = VALUE_FRAME_ID (arg1); return v; -- cgit v1.1