Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patchv2] Fix crash on optimized-out entry data values
Date: Wed, 09 Jul 2014 15:31:00 -0000	[thread overview]
Message-ID: <20140709153121.GA7989@host2.jankratochvil.net> (raw)
In-Reply-To: <53BD2CE0.1000308@redhat.com>

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.
value_available_contents_bits_eq is written according to the struct value
comments but they do not correspond to the real world struct value data.

'unavailable' suggests that optimized out variable should have it set to the
full range of the variable.  But struct value with OPTIMIZED_OUT field set
still has UNAVAILABLE empty. As the variable is optimized out the CONTENTS is
also NULL - this causes the crash reproduced by
'gdb.arch/amd64-entry-value-paramref.exp'.

There are also check_validity and check_any_valid methods but how they are
related to the 'unavailable' data field is also not documented.

This patch was my second attempt to fix/document the availability stuff, it
would be useful to suggest how it is designed.


> Does this manage to somehow pass the tests
> under gdb.trace/ (against --target_board=native-gdbserver) ?

You are right, this patch regresses during gdbserver mode.


> > If OPTIMIZED_OUT is true then VEC_empty
> > +     UNAVAILABLE means the whole value range.  Otherwise it specifies
> > +     unavailable ranges in CONTENTS.  We mark unavailable ranges,
> >       rather than available, since the common and default case is for a
> >       value to be available.  This is filled in at value read time.  The
> >       unavailable ranges are tracked in bits.  */
> > @@ -701,6 +705,15 @@ value_available_contents_bits_eq (const struct value *val1, int offset1,
> >    /* See function description in value.h.  */
> >    gdb_assert (!val1->lazy && !val2->lazy);
> >  
> > +  gdb_assert (val1->optimized_out || VEC_empty (range_s, val1->unavailable));
> > +  gdb_assert (val2->optimized_out || VEC_empty (range_s, val2->unavailable));


Thanks,
Jan


  reply	other threads:[~2014-07-09 15:31 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-09 10:33 Jan Kratochvil
2014-07-09 11:52 ` Pedro Alves
2014-07-09 15:31   ` Jan Kratochvil [this message]
2014-07-11 16:07     ` [patchv3] " Jan Kratochvil
2014-07-14  7:02       ` Yao Qi
2014-07-14  8:32         ` Jan Kratochvil
2014-07-14 18:12       ` Pedro Alves
2014-07-14 18:47     ` [PATCH] Handle partially optimized out values similarly to unavailable values (Re: [patchv2] Fix crash on optimized-out entry data values) Pedro Alves
2014-07-17  8:04       ` Jan Kratochvil
2014-07-17  8:35         ` Jan Kratochvil
2014-07-17 13:38         ` Pedro Alves
2014-07-20 15:33           ` [read_frame_arg patch] " Jan Kratochvil
2014-07-22 19:33             ` Pedro Alves
2014-07-22 20:21               ` [commit+7.8] [read_frame_arg patch] Handle partially optimized out values similarly to unavailable values Jan Kratochvil
2014-08-05 17:16                 ` Doug Evans
2014-08-14 18:25                   ` Jan Kratochvil
2014-07-23 14:26               ` [commit] Remove setting value address for reference entry value target data value Jan Kratochvil
2014-07-24 12:51         ` [PATCH v2] Handle partially optimized out values similarly to unavailable values Pedro Alves
2014-08-15 20:13           ` Jan Kratochvil
2014-08-19 23:36             ` Pedro Alves
2014-08-20  0:55               ` Andrew Pinski
2014-08-20  9:46                 ` Pedro Alves
2014-08-20 10:32                   ` [PUSHED] value.c (value_contents_bits_eq): Initialize l,h for gcc, -Wall. (was: Re: [PATCH v2] Handle partially optimized out values similarly to unavailable values) Pedro Alves
2014-08-20 16:28                     ` Andrew Pinski
2014-08-21 19:57               ` Regression for i686 gdb.dwarf2/pieces-optimized-out.exp [Re: [PATCH v2] Handle partially optimized out values similarly to unavailable values] Jan Kratochvil
2014-08-22 16:20                 ` Pedro Alves
2014-08-24 19:56                   ` Jan Kratochvil
2014-09-04 11:36                   ` [pushed] " Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140709153121.GA7989@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox