This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] ada-lang.c:coerce_unspec_val_to_type: Preserve laziness.
- From: Pedro Alves <palves at redhat dot com>
- To: Andrew Burgess <aburgess at broadcom dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 05 Jul 2013 11:41:18 +0100
- Subject: Re: [PATCH] ada-lang.c:coerce_unspec_val_to_type: Preserve laziness.
- References: <20130704182244 dot 16683 dot 55719 dot stgit at brno dot lan> <51D6A00A dot 2050803 at broadcom dot com>
On 07/05/2013 11:29 AM, Andrew Burgess wrote:
> On 04/07/2013 7:22 PM, Pedro Alves wrote:
>> ada-lang.c:coerce_unspec_val_to_type does:
>>
>> if (value_lazy (val)
>> || TYPE_LENGTH (type) > TYPE_LENGTH (value_type (val)))
>> result = allocate_value_lazy (type);
>> else
>> {
>> result = allocate_value (type);
>> memcpy (value_contents_raw (result), value_contents (val),
>> TYPE_LENGTH (type));
>> }
>> set_value_component_location (result, val);
>> set_value_bitsize (result, value_bitsize (val));
>> set_value_bitpos (result, value_bitpos (val));
>> set_value_address (result, value_address (val));
>> set_value_optimized_out (result, value_optimized_out (val));
>>
>> Notice that before value_optimized_out was made to auto-fetch lazy
>> values, VAL would end up still lazy if it was lazy on entry. It's not
>> really a problem here if VAL is lazy, and VAL->optimized_out is 0,
>> because RESULT is also left lazy. IOW, this just wants to copy the
>> VAL->optimized_out flag to RESULT->optimized_out, nothing else.
>>
>> The patch adds the value_optimized_out_const function for that.
>
> As an alternative, this patch avoids the new _const function,
> I move the setting of the optimized_out value into the else case where we know val is no longer lazy.
>
> Cheers,
> Andrew
>
>
> diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
> index 8240fee..ea7b579 100644
> --- a/gdb/ada-lang.c
> +++ b/gdb/ada-lang.c
> @@ -576,12 +576,14 @@ coerce_unspec_val_to_type (struct value *val, struct type *type)
> result = allocate_value (type);
> memcpy (value_contents_raw (result), value_contents (val),
> TYPE_LENGTH (type));
> + /* Only copy the optimized out setting if val is not lazy. If it
> + is lazy then the optimized_out flag will always be false. */
> + set_value_optimized_out (result, value_optimized_out (val));
> }
> set_value_component_location (result, val);
> set_value_bitsize (result, value_bitsize (val));
> set_value_bitpos (result, value_bitpos (val));
> set_value_address (result, value_address (val));
> - set_value_optimized_out (result, value_optimized_out (val));
> return result;
That works, but I had originally discarded such an approach
because it looked brittle to me. E.g., I was toying with optimizing
value_optimized_out by only fetching lazy values if it really can't
avoid it, and such a change would render this subtly broken.
--
Pedro Alves