diff options
author | Pedro Alves <palves@redhat.com> | 2009-01-13 10:34:31 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2009-01-13 10:34:31 +0000 |
commit | 74bcbdf3cea56564d1f9f597c8458b86ed71f621 (patch) | |
tree | 1ab2d8991bf751064e627c0f1cd8ba18a63357e2 | |
parent | d7dc3873fbc2c722d5ee850341be49028dc5c6b0 (diff) | |
download | binutils-74bcbdf3cea56564d1f9f597c8458b86ed71f621.tar.gz binutils-74bcbdf3cea56564d1f9f597c8458b86ed71f621.tar.bz2 binutils-74bcbdf3cea56564d1f9f597c8458b86ed71f621.zip |
2009-01-13 Jim Blandy <jimb@codesourcery.com>
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.
-rw-r--r-- | gdb/ChangeLog | 12 | ||||
-rw-r--r-- | gdb/ada-lang.c | 10 | ||||
-rw-r--r-- | gdb/valarith.c | 12 | ||||
-rw-r--r-- | gdb/valops.c | 10 | ||||
-rw-r--r-- | gdb/value.c | 16 | ||||
-rw-r--r-- | gdb/value.h | 5 |
6 files changed, 37 insertions, 28 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f3a69382b3c..4fcbeda14f2 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2009-01-13 Jim Blandy <jimb@codesourcery.com> + + 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. + 2009-01-13 Joel Brobecker <brobecker@adacore.com> * MAINTAINERS (GLOBAL MAINTAINERS): Add Tom Tromey. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 71d99b0ae3f..656e771e9b5 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -483,10 +483,10 @@ coerce_unspec_val_to_type (struct value *val, struct type *type) check_size (type); result = allocate_value (type); - VALUE_LVAL (result) = VALUE_LVAL (val); + set_value_component_location (result, val); set_value_bitsize (result, value_bitsize (val)); set_value_bitpos (result, value_bitpos (val)); - VALUE_ADDRESS (result) = VALUE_ADDRESS (val) + value_offset (val); + VALUE_ADDRESS (result) += value_offset (val); if (value_lazy (val) || TYPE_LENGTH (type) > TYPE_LENGTH (value_type (val))) set_value_lazy (result, 1); @@ -2018,10 +2018,8 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr, if (obj != NULL) { - VALUE_LVAL (v) = VALUE_LVAL (obj); - if (VALUE_LVAL (obj) == lval_internalvar) - VALUE_LVAL (v) = lval_internalvar_component; - VALUE_ADDRESS (v) = VALUE_ADDRESS (obj) + value_offset (obj) + offset; + set_value_component_location (v, obj); + VALUE_ADDRESS (v) += value_offset (obj) + offset; set_value_bitpos (v, bit_offset + value_bitpos (obj)); set_value_bitsize (v, bit_size); if (value_bitpos (v) >= HOST_CHAR_BIT) diff --git a/gdb/valarith.c b/gdb/valarith.c index 48f2e95513d..f38cdb842fc 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -233,11 +233,7 @@ value_subscripted_rvalue (struct value *array, struct value *idx, int lowerbound memcpy (value_contents_writeable (v), value_contents (array) + elt_offs, elt_size); - if (VALUE_LVAL (array) == lval_internalvar) - VALUE_LVAL (v) = lval_internalvar_component; - else - VALUE_LVAL (v) = VALUE_LVAL (array); - VALUE_ADDRESS (v) = VALUE_ADDRESS (array); + 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); @@ -277,11 +273,7 @@ value_bitstring_subscript (struct type *type, set_value_bitpos (v, bit_index); set_value_bitsize (v, 1); - - VALUE_LVAL (v) = VALUE_LVAL (bitstring); - if (VALUE_LVAL (bitstring) == lval_internalvar) - VALUE_LVAL (v) = lval_internalvar_component; - VALUE_ADDRESS (v) = VALUE_ADDRESS (bitstring); + set_value_component_location (v, bitstring); VALUE_FRAME_ID (v) = VALUE_FRAME_ID (bitstring); set_value_offset (v, offset + value_offset (bitstring)); diff --git a/gdb/valops.c b/gdb/valops.c index fe011d04462..30e74fa9f99 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1575,8 +1575,7 @@ search_struct_field (char *name, struct value *arg1, int offset, value_contents_raw (arg1) + boffset, TYPE_LENGTH (basetype)); } - VALUE_LVAL (v2) = VALUE_LVAL (arg1); - VALUE_ADDRESS (v2) = VALUE_ADDRESS (arg1); + set_value_component_location (v2, arg1); VALUE_FRAME_ID (v2) = VALUE_FRAME_ID (arg1); set_value_offset (v2, value_offset (arg1) + boffset); } @@ -2984,12 +2983,7 @@ value_slice (struct value *array, int lowbound, int length) TYPE_LENGTH (slice_type)); } - if (VALUE_LVAL (array) == lval_internalvar) - VALUE_LVAL (slice) = lval_internalvar_component; - else - VALUE_LVAL (slice) = VALUE_LVAL (array); - - VALUE_ADDRESS (slice) = VALUE_ADDRESS (array); + set_value_component_location (slice, array); VALUE_FRAME_ID (slice) = VALUE_FRAME_ID (array); set_value_offset (slice, value_offset (array) + offset); } diff --git a/gdb/value.c b/gdb/value.c index 1068f1d67d1..f0c8463dc54 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; diff --git a/gdb/value.h b/gdb/value.h index 4c28aa255dd..ecdcf259d7b 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -205,6 +205,11 @@ extern void set_value_optimized_out (struct value *value, int val); extern int value_initialized (struct value *); extern void set_value_initialized (struct value *, int); +/* Set COMPONENT's location as appropriate for a component of WHOLE + --- regardless of what kind of lvalue WHOLE is. */ +extern void set_value_component_location (struct value *component, + struct value *whole); + /* While the following fields are per- VALUE .CONTENT .PIECE (i.e., a single value might have multiple LVALs), this hacked interface is limited to just the first PIECE. Expect further change. */ |