[PATCH 3/8] Introduce gdb-specific %p format suffixes
Pedro Alves
palves@redhat.com
Mon Sep 30 14:06:00 GMT 2019
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
More information about the Gdb-patches
mailing list