From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16694 invoked by alias); 15 Sep 2007 09:00:06 -0000 Received: (qmail 16527 invoked by uid 22791); 15 Sep 2007 09:00:04 -0000 X-Spam-Check-By: sourceware.org Received: from heller.inter.net.il (HELO heller.inter.net.il) (213.8.233.23) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 15 Sep 2007 08:59:59 +0000 Received: from HOME-C4E4A596F7 (IGLD-80-230-210-74.inter.net.il [80.230.210.74]) by heller.inter.net.il (MOS 3.7.3a-GA) with ESMTP id DPX72179 (AUTH halo1); Sat, 15 Sep 2007 11:59:51 +0300 (IDT) Date: Sat, 15 Sep 2007 09:00:00 -0000 Message-Id: From: Eli Zaretskii To: Daniel Jacobowitz CC: mark.kettenis@xs4all.nl, jan.kratochvil@redhat.com, gdb-patches@sourceware.org In-reply-to: <20070904205307.GA17062@caradoc.them.org> (message from Daniel Jacobowitz on Tue, 4 Sep 2007 16:53:07 -0400) Subject: Re: [patch] printf "%p" gdb internal error fix Reply-to: Eli Zaretskii References: <20060910172037.GA3886@host0.dyn.jankratochvil.net> <200609101931.k8AJVF4m026090@elgar.sibelius.xs4all.nl> <20070904141926.GA27477@caradoc.them.org> <20070904205307.GA17062@caradoc.them.org> 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: 2007-09/txt/msg00186.txt.bz2 > Date: Tue, 4 Sep 2007 16:53:07 -0400 > From: Daniel Jacobowitz > Cc: mark.kettenis@xs4all.nl, jan.kratochvil@redhat.com, > gdb-patches@sourceware.org > > On Tue, Sep 04, 2007 at 11:43:14PM +0300, Eli Zaretskii wrote: > > Thanks, but what about a companion patch for the manual? > > I don't believe that one is necessary; the manual says only "exactly > as if your program were to execute the C subroutine". Never liked such references too much, but I guess a full-fledged description of conversion specifiers will have to wait for another rainy day. Until then, here's what I committed, in order to bring the manual in line with the code, and at least tell what features of a C-standard `printf' are _not_ supported: 2007-09-15 Eli Zaretskii * gdb.texinfo (Output): Spell out which features of C's printf are not supported by GDB's printf. Index: gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.429 diff -u -r1.429 gdb.texinfo --- gdb.texinfo 5 Sep 2007 00:51:48 -0000 1.429 +++ gdb.texinfo 15 Sep 2007 08:53:16 -0000 @@ -16418,20 +16418,24 @@ Formats}, for more information. @kindex printf -@item printf @var{string}, @var{expressions}@dots{} -Print the values of the @var{expressions} under the control of -@var{string}. The @var{expressions} are separated by commas and may be -either numbers or pointers. Their values are printed as specified by -@var{string}, exactly as if your program were to execute the C -subroutine -@c FIXME: the above implies that at least all ANSI C formats are -@c supported, but it isn't true: %E and %G don't work (or so it seems). -@c Either this is a bug, or the manual should document what formats are -@c supported. - -@smallexample -printf (@var{string}, @var{expressions}@dots{}); -@end smallexample +@item printf @var{template}, @var{expressions}@dots{} +Print the values of one or more @var{expressions} under the control of +the string @var{template}. To print several values, make +@var{expressions} be a comma-separated list of individual expressions, +which may be either numbers or pointers. Their values are printed as +specified by @var{template}, exactly as a C program would do by +executing the code below: + +@smallexample +printf (@var{template}, @var{expressions}@dots{}); +@end smallexample + +As in @code{C} @code{printf}, ordinary characters in @var{template} +are printed verbatim, while @dfn{conversion specification} introduced +by the @samp{%} character cause subsequent @var{expressions} to be +evaluated, their values converted and formatted according to type and +style information encoded in the conversion specifications, and then +printed. For example, you can print two values in hex like this: @@ -16439,9 +16443,44 @@ printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo @end smallexample -The only backslash-escape sequences that you can use in the format -string are the simple ones that consist of backslash followed by a -letter. +@code{printf} supports all the standard @code{C} conversion +specifications, including the flags and modifiers between the @samp{%} +character and the conversion letter, with the following exceptions: + +@itemize @bullet +@item +The argument-ordering modifiers, such as @samp{2$}, are not supported. + +@item +The modifier @samp{*} is not supported for specifying precision or +width. + +@item +The @samp{'} flag (for separation of digits into groups according to +@code{LC_NUMERIC'}) is not supported. + +@item +The type modifiers @samp{hh}, @samp{j}, @samp{t}, and @samp{z} are not +supported. + +@item +The conversion letter @samp{n} (as in @samp{%n}) is not supported. + +@item +The conversion letters @samp{a} and @samp{A} are not supported. +@end itemize + +@noindent +Note that the @samp{ll} type modifier is supported only if the +underlying @code{C} implementation used to build @value{GDBN} supports +the @code{long long int} type, and the @samp{L} type modifier is +supported only if @code{long double} type is available. + +As in @code{C}, @code{printf} supports simple backslash-escape +sequences, such as @code{\n}, @samp{\t}, @samp{\\}, @samp{\"}, +@samp{\a}, and @samp{\f}, that consist of backslash followed by a +single character. Octal and hexadecimal escape sequences are not +supported. @end table @node Interpreters