From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5803 invoked by alias); 15 Jul 2011 09:03:20 -0000 Received: (qmail 5793 invoked by uid 22791); 15 Jul 2011 09:03:18 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL,BAYES_00,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from mtaout20.012.net.il (HELO mtaout20.012.net.il) (80.179.55.166) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 15 Jul 2011 09:03:03 +0000 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0LOD00J00AGHAJ00@a-mtaout20.012.net.il> for gdb-patches@sourceware.org; Fri, 15 Jul 2011 12:02:44 +0300 (IDT) Received: from HOME-C4E4A596F7 ([77.127.219.136]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LOD00JZNAGJA300@a-mtaout20.012.net.il>; Fri, 15 Jul 2011 12:02:44 +0300 (IDT) Date: Fri, 15 Jul 2011 14:17:00 -0000 From: Eli Zaretskii Subject: Re: [doc patch] whatis vs. ptype - the difference In-reply-to: <20110712183130.GA15349@host1.jankratochvil.net> To: Jan Kratochvil Cc: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <8339i7j4ng.fsf@gnu.org> References: <20110712183130.GA15349@host1.jankratochvil.net> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-07/txt/msg00383.txt.bz2 How about the text below? The only nit that I'm not yet sure about is at the end: "typedefs ... at the pointer target". What do you mean by that? can you show an example? @item whatis [@var{arg}] Print the data type of @var{arg}, which can be either an expression or a name of a data type. With no argument, print the data type of @code{$}, the last value in the value history. 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. If @var{arg} is a variable or an expression, @code{whatis} prints its literal type as it is used in the source code. If the type was defined using a @code{typedef}, @code{whatis} will @emph{not} print the data type underlying the @code{typedef}. If the type of the variable or the expression is a compound data type, such as @code{struct} or @code{class}, @code{whatis} never prints their fields or members. It just prints the @code{struct}/@code{class} name (a.k.a.@: its @dfn{tag}). If you want to see the members of such a compound data type, use @code{ptype}. If @var{arg} is a type name that was defined using @code{typedef}, @code{whatis} @dfn{unrolls} only one level of that @code{typedef}. Unrolling means that @code{whatis} will show the underlying type used in the @code{typedef} declaration of @var{arg}. However, if that underlying type is also a @code{typedef}, @code{whatis} will not unroll it. For C code, the type names may also have the form @samp{class @var{class-name}}, @samp{struct @var{struct-tag}}, @samp{union @var{union-tag}} or @samp{enum @var{enum-tag}}. [...] Contrary to @code{whatis}, @code{ptype} always unrolls any @code{typedef}s in its argument declaration, whether the argument is a variable, expression, or a data type. This means that @code{ptype} of a variable or an expression will not print literally its type as present in the source code---use @code{whatis} for that. Any @code{typedef}s in fields of a @samp{struct} or at the pointer target are always preserved by @code{ptype}.