Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [doc patch] whatis vs. ptype - the difference
Date: Tue, 12 Jul 2011 20:38:00 -0000	[thread overview]
Message-ID: <20110712202811.GA23451@host1.jankratochvil.net> (raw)
In-Reply-To: <8339ibfef5.fsf@gnu.org>

On Tue, 12 Jul 2011 22:10:38 +0200, Eli Zaretskii wrote:
> > +If @var{arg} is an expression (@pxref{Expressions, ,Expressions}), it is not
> > +actually evaluated, and any side-effecting operations (such as assignments or
> > +function calls) inside it do not take place.
> 
> Why is this important?  It doesn't belong to the differences between
> the two commands, AFAIK, does it?

There was not and even after my change there is not any special part of the
text describing the difference.  There is a description of `whatis' and
a description of `ptype'.

I would like a real table there but `info' never shows any real table.
Such as:
       | outer typedefs unrolling           | compound types
----------------------------------------------------------------------
whatis | vars: no unroll, types: one unroll | displayed only type name
ptype  | all unrolled                       | displayed both name and its fields

GDB is missing the ultimate command which would do always the right thing:
dream  | vars: no unroll, types: one unroll | displayed both name and its fields
 - but that is outside of the scope of this doc-only patch.


> >                                      @code{whatis} prints the type of
> > +@var{arg} as used in the source code
> 
> The "as used in the source code" part is confusing.  What exactly does
> it mean, and how, if at all, is that different from ptype?

whatis v -> complex_t
ptype v -> struct complex

The source code uses type `complex_t' type for the variable `v'.


> >                                       possibly including any typedefs.
> 
> "Possibly"?  You mean it sometimes does and sometimes does not?  If
> so, when does it?

"including any possible typedefs" may be right?

That is, if there are any typedefs they are included.  But sure there exist
variables having nothing to do with typedefs (`long x;').


> > +@code{whatis} never prints fields of compound types like @samp{struct}s.
> 
> This part is clear.
> 
> > +@code{whatis} unrolls in such case only one layer of outer typedef at a time.
> 
> This sounds incorrect, because your example says:
> 
> > +complex_t v;
> >  [...]
> >  (@value{GDBP}) whatis v
> > +type = complex_t
> 
> That is, there's no "unrolling" here, not even of a single layer.
> Unless I misunderstood what you mean by "unrolling", that is.

This "unrolls [...] only one layer" is in the paragraph "If @var{arg} is
a type name".  As `v' is a variable the paragraph "If @var{arg} is an
expression" applies instead (where no typedefs unrolling is stated).


> > +Any inner typedefs --- such as fields of @samp{struct} or typedefs at the
> > +pointer target --- are always preserved by both @code{whatis} and @code{ptype}.
> 
> Not clear what that means.  whatis doesn't show struct members at all,
> does it?  If so, how can it "preserve" those fields?

That's true, my mistake, this should be removed from the `whatis' description.


> > +@code{ptype} always unrolls all outer typedefs contrary to @code{whatis}.
> 
> Instead of talking about "unrolling", wouldn't it be better to say
> that ptype recursively looks up the definition of each type until it
> arrives at primitive data types, and prints the result only then?

I would like to avoid "recursive" and keep more at the Frank Eigler's "unroll"
term to state that the first non-typedefs stops the "unrolling".  I found it
is a common confusion when explaining this difference that people think ptype
will display "double real" (and not "real_t real" as it displays).


> > +@code{ptype} of an expression (variable) will not print its real type including
> > +possible typedefs as present in the source code
> 
> Not clear.  The "real" part is getting in the way.  Don't you mean
> "literal", not "real"?

Maybe "literal".  I want to express the major defect of `ptype' - that `ptype v'
does not show `complex_t' anywhere.


> > +Any inner typedefs --- such as fields of @samp{struct} or typedefs at
> > +the pointer target --- are always preserved by both @code{whatis} and
> > +@code{ptype}.
> 
> Not clear: what are "inner typedefs"?  If a struct has a member that
> is itself a struct, what will ptype show about this member?

I have demonstrated the behavior on the `real' field in the sample code.
Inside `struct[' - the `inner typedefs' - are never touched by `ptype'.


> Also, since whatis does not show struct members at all (AFAIU), saying
> "both" here is confusing and misleading, no?

Yes, right.


> I hope answering these questions will allow to rephrase the text so it
> is both accurate and clear.

Depending on your next mail I - or you if you wish - can update the patch.


Thanks,
Jan


  reply	other threads:[~2011-07-12 20:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-12 19:20 Jan Kratochvil
2011-07-12 20:28 ` Eli Zaretskii
2011-07-12 20:38   ` Jan Kratochvil [this message]
2011-07-12 20:43     ` Eli Zaretskii
2011-07-12 20:30 ` Tom Tromey
2011-07-15 14:17 ` Eli Zaretskii
2011-07-15 18:07   ` Jan Kratochvil
2011-07-19 13:52     ` Pedro Alves
2011-07-26  2:58     ` ping: " Jan Kratochvil
2011-07-26  8:36       ` Eli Zaretskii
2011-07-26 18:11         ` Jan Kratochvil

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=20110712202811.GA23451@host1.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /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