Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 3/8] Introduce gdb-specific %p format suffixes
Date: Mon, 30 Sep 2019 14:06:00 -0000	[thread overview]
Message-ID: <a2a3a746-a26a-ddbe-34cc-56799b14edff@redhat.com> (raw)
In-Reply-To: <20190927212520.20073-4-tom@tromey.com>

Hi,

I noticed a coupled typos while reading this, probably mine...

On 9/27/19 10:25 PM, Tom Tromey wrote:
> +/* The possible kinds of fields.  */
> +enum class field_kind
> +  {
> +    SIGNED,
> +    STRING,
> +  };
> +
> +/* An int field, to be passed to %pF in format strings.  */

This should read something like:

/* The base type of all fields.  */

> +
> +struct base_field_s
> +{
> +  const char *name;
> +  field_kind kind;
> +};
> +
> +/* An int field, to be passed to %pF in format strings.  */

This used to be called int_field_s, before the
'uiout->field_int -> uiout->field_signed' rename.

Should now read:

/* A signed integer field, to be passed to %pF in format strings.  */

> +
> +struct signed_field_s : base_field_s
> +{
> +  LONGEST val;
> +};
> +
> +/* Construct a temporary signed_field_s on the caller's stack and
> +   return a pointer to the constructed object.  We use this because
> +   it's not possible to pass a reference via va_args.  */
> +
> +static inline signed_field_s *
> +signed_field (const char *name, LONGEST val,
> +	      signed_field_s &&tmp = {})
> +{
> +  tmp.name = name;
> +  tmp.kind = field_kind::SIGNED;
> +  tmp.val = val;
> +  return &tmp;
> +}
> +
> +/* A string field, to be passed to %pF in format strings.  */
> +
> +struct string_field_s : base_field_s
> +{
> +  const char *str;
> +};
> +
> +/* Construct a temporary string_field_s on the caller's stack and
> +   return a pointer to the constructed object.  We use this because
> +   it's not possible to pass a reference via va_args.  */
> +
> +static inline string_field_s *
> +string_field (const char *name, const char *str,
> +	      string_field_s &&tmp = {})
> +{
> +  tmp.name = name;
> +  tmp.kind = field_kind::STRING;
> +  tmp.str = str;
> +  return &tmp;
> +}
> +
> +/* A styled string.  */
> +
> +struct styled_string_s
> +{
> +  /* The style.  */
> +  ui_file_style style;
> +
> +  /* The string.  */
> +  const char *str;
> +};
> +
> +/* Construct a temporary styled_string_s on the caller's stack and
> +   return a pointer to the constructed object.  We use this because
> +   it's not possible to pass a reference via va_args.  */
> +
> +static inline styled_string_s *
> +styled_string (const ui_file_style &style, const char *str,
> +	       styled_string_s &&tmp = {})
> +{
> +  tmp.style = style;
> +  tmp.str = str;
> +  return &tmp;
> +}
> +
>  class ui_out
>  {
>   public:
> @@ -110,7 +197,55 @@ class ui_out
>  
>    void spaces (int numspaces);
>    void text (const char *string);
> +
> +  /* Output a printf-style formatted string.  In addition to the usual
> +     printf format specs, this supports a few GDB-specific
> +     formatters:
> +
> +     - '%pF' - output a field.
> +
> +       The argument is a field, wrapped in any of the base_field_s
> +       subclasses.  signed_field for integer fields, styled_field for

styled_field -> string_field

> +       string fields.  This is preferred over separate
> +       uiout->field_int(), uiout_>field_string() etc. calls when the

field_int -> field_signed

> +       formatted message is translatable.  E.g.:
> +

Thanks,
Pedro Alves


  reply	other threads:[~2019-09-30 14:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27 21:25 [PATCH 0/8] More gdb styling improvements Tom Tromey
2019-09-27 21:25 ` [PATCH 2/8] Don't create empty literal pieces Tom Tromey
2019-09-27 21:25 ` [PATCH 3/8] Introduce gdb-specific %p format suffixes Tom Tromey
2019-09-30 14:06   ` Pedro Alves [this message]
2021-08-18  9:02   ` Andreas Schwab
2021-08-27 20:17     ` Tom Tromey
2019-09-27 21:25 ` [PATCH 5/8] Style "pwd" output Tom Tromey
2019-09-27 21:25 ` [PATCH 7/8] Use styled_string in more places Tom Tromey
2019-09-27 21:25 ` [PATCH 6/8] Introduce metadata style Tom Tromey
2019-09-30 14:07   ` Pedro Alves
2019-09-27 21:25 ` [PATCH 4/8] Use new %p format suffixes in gdb Tom Tromey
2019-09-30 14:05   ` Pedro Alves
2019-09-27 21:25 ` [PATCH 8/8] Use styled_string for "show logging filename" Tom Tromey
2019-09-27 21:25 ` [PATCH 1/8] Remove the ui_out_style_kind enum Tom Tromey
2019-09-30 14:09 ` [PATCH 0/8] More gdb styling improvements Pedro Alves
2019-10-01 21:11   ` Tom Tromey

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=a2a3a746-a26a-ddbe-34cc-56799b14edff@redhat.com \
    --to=palves@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