This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [2/3] [PATCH] value_optimized_out and value_fetch_lazy
- From: "Andrew Burgess" <aburgess at broadcom dot com>
- To: gdb-patches at sourceware dot org
- Cc: "Pedro Alves" <palves at redhat dot com>
- Date: Thu, 4 Jul 2013 12:22:57 +0100
- Subject: Re: [2/3] [PATCH] value_optimized_out and value_fetch_lazy
- References: <51B5A95F dot 7090400 at broadcom dot com> <51C1D347 dot 3020906 at redhat dot com> <51D1C522 dot 5060507 at broadcom dot com> <51D470E8 dot 1080708 at redhat dot com>
On 03/07/2013 7:43 PM, Pedro Alves wrote:
> On 07/01/2013 07:06 PM, Andrew Burgess wrote:
>> Here's the improved patch, ok to apply?
>
> OK, with ...
>
>> gdb/ChangeLog
>>
>> 2013-07-01 Andrew Burgess <aburgess@broadcom.com>
>>
>> * stack.c (read_frame_arg): No longer need to fetch lazy values,
>> checking for optimized out will ensure lazy values are loaded.
>
> Write:
>
> * stack.c (read_frame_arg): No longer fetch lazy values.
>
>> * value.c (value_optimized_out): If the value is not already marked
>> optimized out, and is lazy then fetch it so we can know for sure
>> if the value is optimized out.
>
> Write:
>
> * value.c (value_optimized_out): If the value is not already marked
> optimized out, and is lazy then fetch it.
>
> and put the "so we can know for sure if the value is optimized out." comment
> in the sources.
>
>> (value_primitive_field): Move optimized out check later to later in
>> the function after we have loaded any lazy values.
>
> "later to later" sounds like a later too much. It'd be great to have a
> comment in the sources about this detail.
>
>> (value_fetch_lazy): Use optimized out flag directly rather than
>> calling optimized_out method to avoid triggering recursion.
>
> Write:
>
> (value_fetch_lazy): Use optimized out flag directly rather than
> calling optimized_out method.
>
> and put the "to avoid triggering recursion." comment in the sources.
>
Applied with the following ChangeLog:
gdb/ChangeLog
* stack.c (read_frame_arg): No longer fetch lazy values.
* value.c (value_optimized_out): If the value is not already
marked optimized out, and is lazy then fetch it.
(value_primitive_field): Move optimized out check to later in the
function, after we have loaded any lazy values.
(value_fetch_lazy): Use optimized out flag directly rather than
calling optimized_out method.
And these additional comments:
diff --git a/gdb/value.c b/gdb/value.c
index e3a60dd..abaf23b 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1054,6 +1054,8 @@ value_contents_equal (struct value *val1, struct value *val2)
int
value_optimized_out (struct value *value)
{
+ /* We can only know if a value is optimized out once we have tried to
+ fetch it. */
if (!value->optimized_out && value->lazy)
value_fetch_lazy (value);
@@ -2677,6 +2679,9 @@ value_primitive_field (struct value *arg1, int offset,
if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1))
value_fetch_lazy (arg1);
+ /* The optimized_out flag is only set correctly once a lazy value is
+ loaded, having just loaded some lazy values we should check the
+ optimized out case now. */
if (arg1->optimized_out)
v = allocate_optimized_out_value (type);
else
@@ -2715,6 +2720,9 @@ value_primitive_field (struct value *arg1, int offset,
if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1))
value_fetch_lazy (arg1);
+ /* The optimized_out flag is only set correctly once a lazy value is
+ loaded, having just loaded some lazy values we should check for
+ the optimized out case now. */
if (arg1->optimized_out)
v = allocate_optimized_out_value (type);
else if (value_lazy (arg1))
@@ -3541,6 +3549,9 @@ value_fetch_lazy (struct value *val)
else if (VALUE_LVAL (val) == lval_computed
&& value_computed_funcs (val)->read != NULL)
value_computed_funcs (val)->read (val);
+ /* Don't call value_optimized_out on val, doing so would result in a
+ recursive call back to value_fetch_lazy, instead check the
+ optimized_out flag directly. */
else if (val->optimized_out)
/* Keep it optimized out. */;
else
Thanks,
Andrew