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

> Date: Tue, 12 Jul 2011 20:31:30 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> 
> The patch just describes the current behavior.  With my English waiting for
> a doc review.

Thanks.

I must confess that the new description is not much clearer than the
old one.  After reading it (more than once), I still have no clear
idea of the differences between these two commands.  It's obvious that
ptype does a more thorough job that whatis, but what exactly each one
does and does not do is still in the fog for me.

Below I try to ask specific questions in the hope that they will allow
to make this issue more clear.

> +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?

>                                      @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?

>                                       possibly including any typedefs.

"Possibly"?  You mean it sometimes does and sometimes does not?  If
so, when does it?

> +@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.

> +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?

Btw, a stylistic point: don't leave whitespace around "---", it looks
ugly in print.

> +@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?

> +@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"?

>                                            -- use @code{whatis} for that
                                             ^^
Please use 3 dashes in a row, not 2.

> +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?

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

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

Thanks again for working on this.


  reply	other threads:[~2011-07-12 20:09 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 [this message]
2011-07-12 20:38   ` Jan Kratochvil
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=8339ibfef5.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@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