public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Andrew Burgess <aburgess@redhat.com>
Cc: tom@tromey.com, gdb-patches@sourceware.org
Subject: Re: [PATCHv2] gdb: add support for %V to printf command
Date: Fri, 28 Apr 2023 18:34:17 +0300	[thread overview]
Message-ID: <83r0s4qava.fsf@gnu.org> (raw)
In-Reply-To: <878recb13p.fsf@redhat.com> (message from Andrew Burgess on Fri, 28 Apr 2023 14:14:18 +0100)

> From: Andrew Burgess <aburgess@redhat.com>
> Date: Fri, 28 Apr 2023 14:14:18 +0100
> 
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -67,6 +67,15 @@
>      break foo thread 1 task 1
>      watch var thread 2 task 3
>  
> +* The printf command now accepts a '%V' output format which will
> +  format an expression just as the 'print' command would.  Print
> +  options can be placed withing '[...]' after the '%V' to modify how
> +  the value is printed.  E.g:
> +    printf "%V", some_array
> +    printf "%V[-array-indexes on]", some_array
> +  will print the array without, or with array indexes included, just
> +  as the array would be printed by the 'print' command.

Should this mention the effect on dprintf?

>  @kindex dprintf-style gdb
> -Handle the output using the @value{GDBN} @code{printf} command.
> +Handle the output using the @value{GDBN} @code{printf} command.  When
> +using this style it is possible to use the @samp{%V} format specifier
                   ^
A comma missing there.

> +Most of @value{GDB}'s format specifiers align with those supported by
> +the @code{printf} function, however, @value{GDB}'s @samp{%V} format
> +specifier extension is not supported by @code{printf}.  When using
> +@samp{call} style dprintf care should be taken to ensure that only
                            ^
Comma missing.

> +format specifiers supported by the output function are used otherwise
                                                              ^
And another one.

> +@anchor{%V Format Specifier}
> +Additionally, @code{printf} supports a special @samp{%V} output format.
> +This format prints the string representation of an expression just as
> +@value{GDBN} would produce with the standard @kbd{print} command
> +(@pxref{Data, ,Examining Data}):
> +
> +@smallexample
> +(@value{GDBP}) print array
> +$1 = @{0, 1, 2, 3, 4, 5@}
> +(@value{GDBP}) printf "Array is: %V\n", array
> +Array is: @{0, 1, 2, 3, 4, 5@}
> +@end smallexample
> +
> +Additionally, it is possible to include print options with the
> +@samp{%V} format by placing them in @samp{[...]} immediately after the
> +@samp{%V}, like this:

There are two "additionally" here, and I wonder whether replacing one
of tyhem with "also" would read better.

> +If you need to print a literal @samp{[} directly after a @samp{%V} then
                                                                     ^
Comma missing.

Thanks.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>

  reply	other threads:[~2023-04-28 15:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30 12:22 [PATCH] " Andrew Burgess
2023-03-30 14:20 ` Eli Zaretskii
2023-04-11 12:34   ` Andrew Burgess
2023-04-17 15:47 ` Tom Tromey
2023-04-28 13:14   ` [PATCHv2] " Andrew Burgess
2023-04-28 15:34     ` Eli Zaretskii [this message]
2023-05-12 13:01     ` [PATCHv3] " Andrew Burgess
2023-05-12 13:47       ` Simon Marchi
2023-05-26 20:44       ` Tom Tromey
2023-05-30 20:56         ` Andrew Burgess

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=83r0s4qava.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).