[PATCH] Add printf format specifier for printing enumerator

Eli Zaretskii eliz@gnu.org
Fri Feb 5 14:53:00 GMT 2016


> From: Simon Marchi <simon.marchi@polymtl.ca>
> Cc: Simon Marchi <simon.marchi@polymtl.ca>
> Date: Fri,  5 Feb 2016 09:17:56 -0500
> 
> This patch adds a format specifier to gdb's printf command, to print the
> enumerator (the text label) of an enum value.  It's currently possible
> to display that value using the print command, but not as part of a
> formatted string.
> 
> For example, assuming we have the following enum definition:
> 
>   enum NodeType {
>     ...
>     NODE_INTEGER,
>     ...
>   };
> 
>   enum NodeType node = NODE_INTEGER;
> 
> we can display it this way:
> 
>   (gdb) printf "Visiting node of type %q\n", node
>   Visiting node of type NODE_INTEGER
> 
> All the letters of "enum" are already used as format specifiers.

What about upper-case letters?

> +@code{printf} supports the @samp{q} conversion letter to print the textual
> +label (enumerator) of a C enumeration value.

This sentence will look awkward because it starts with a lower-case
letter.  How about starting with "Also, "?

I think an example here will be good, as the text does not make it
crystal clear what will be printed.

Other than that, the documentation parts look good to me, thanks.



More information about the Gdb-patches mailing list