Re: [patchv3] Fix crash on optimized-out entry data values

Pedro Alves
2014-07-14T18:02:43Z

On 07/11/2014 04:37 PM, Jan Kratochvil wrote:
> On Wed, 09 Jul 2014 17:31:21 +0200, Jan Kratochvil wrote:
>> On Wed, 09 Jul 2014 13:52:00 +0200, Pedro Alves wrote:
>>> On 07/09/2014 11:33 AM, Jan Kratochvil wrote:
>>>> --- a/gdb/value.c
>>>> +++ b/gdb/value.c
>>>> @@ -198,12 +198,13 @@ struct value
>>>> unsigned int lazy : 1;
>>>>
>>>> /* If nonzero, this is the value of a variable that does not
>>>> - actually exist in the program. If nonzero, and LVAL is
>>>> + actually fully exist in the program. If nonzero, and LVAL is
>>>> lval_register, this is a register ($pc, $sp, etc., never a
>>>> program variable) that has not been saved in the frame. All
>>>> optimized-out values are treated pretty much the same, except
>>>> registers have a different string representation and related
>>>> - error strings. */
>>>> + error strings. It is true also for only partially optimized
>>>> + out variables - see the 'unavailable' field below. */
>>>> unsigned int optimized_out : 1;
>>>>
>>>> /* If value is a variable, is it initialized or not. */
>>>> @@ -334,7 +335,10 @@ struct value
>>>> valid if lazy is nonzero. */
>>>> gdb_byte *contents;
>>>>
>>>> - /* Unavailable ranges in CONTENTS. We mark unavailable ranges,
>>>> + /* If OPTIMIZED_OUT is false then UNAVAILABLE must be VEC_empty
>>>> + (not necessarily NULL).
>>>
>>> Hmm, why? We can collect only part of a non-optimized out value.
>>> What am I missing?
>>
>> I miss some documentation how these availability fields interact together.
>
> From a comment in mail
> Message-Id: <201102071427.55970.pedro@codesourcery.com>
> We give preference to printing <optimized out> rather
> than <unavailable>, since if a value had been optimized out
> at compile time, it can never be collected at run-time.
>
> it seems it is just reversed, that 'unavailable' can exist only for
> !optimized_out and it cannot exist for for optimized_out values.

Not really true either. A value can be partially optimized out.
And then when e.g., inspecting a traceframe or a partial core dump,
the bits that are not optimized out may well not have been
collected, so those will be unavailable. I'm sending you a different
patch in a bit.

--
Pedro Alves