From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32666 invoked by alias); 12 Jan 2009 12:42:44 -0000 Received: (qmail 32655 invoked by uid 22791); 12 Jan 2009 12:42:41 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 12 Jan 2009 12:42:03 +0000 Received: (qmail 13321 invoked from network); 12 Jan 2009 12:42:00 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 12 Jan 2009 12:42:00 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Abstract out common code for copying value locations Date: Mon, 12 Jan 2009 12:42:00 -0000 User-Agent: KMail/1.9.10 Cc: Joel Brobecker MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_pqzaJoTwuKBi1qo" Message-Id: <200901121242.17257.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-01/txt/msg00252.txt.bz2 --Boundary-00=_pqzaJoTwuKBi1qo Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 292 Hello, Here's a mostly mechanical patch of Jim's that we've had in our tree for a while. It will be useful for followup patches, but it still looks worth it as an independent cleanup. Joel, is the ada bit OK? I've tested this on x86_64-linux, and spotted no regressions. -- Pedro Alves --Boundary-00=_pqzaJoTwuKBi1qo Content-Type: text/x-diff; charset="iso 8859-15"; name="set_value_component_location.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="set_value_component_location.diff" Content-length: 6318 2009-01-12 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/ada-lang.c | 10 ++++------ gdb/valarith.c | 12 ++---------- gdb/valops.c | 10 ++-------- gdb/value.c | 16 ++++++++++++---- gdb/value.h | 5 +++++ 5 files changed, 25 insertions(+), 28 deletions(-) Index: gdb/ada-lang.c =================================================================== --- gdb/ada-lang.c.orig 2009-01-11 15:40:12.000000000 +0000 +++ gdb/ada-lang.c 2009-01-12 11:25:23.000000000 +0000 @@ -483,10 +483,10 @@ coerce_unspec_val_to_type (struct value 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 v 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) Index: gdb/value.c =================================================================== --- gdb/value.c.orig 2009-01-11 15:40:12.000000000 +0000 +++ gdb/value.c 2009-01-12 11:25:23.000000000 +0000 @@ -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 *arg 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; Index: gdb/value.h =================================================================== --- gdb/value.h.orig 2009-01-11 15:40:12.000000000 +0000 +++ gdb/value.h 2009-01-12 12:40:32.000000000 +0000 @@ -205,6 +205,11 @@ extern void set_value_optimized_out (str 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. */ Index: gdb/valops.c =================================================================== --- gdb/valops.c.orig 2009-01-11 15:40:12.000000000 +0000 +++ gdb/valops.c 2009-01-12 11:25:23.000000000 +0000 @@ -1575,8 +1575,7 @@ search_struct_field (char *name, struct 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 lo 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); } Index: gdb/valarith.c =================================================================== --- gdb/valarith.c.orig 2009-01-11 15:40:12.000000000 +0000 +++ gdb/valarith.c 2009-01-12 11:25:23.000000000 +0000 @@ -233,11 +233,7 @@ value_subscripted_rvalue (struct value * 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 * 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)); --Boundary-00=_pqzaJoTwuKBi1qo--