This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PR11067 patch


The attached patch fixes bug 11067 "p <enum constant> should print the constant's value" by providing a means of setting a format string to be used in printing enums. The string is set with

set enum-fmt <string>

show enum-fmt returns the current format string.

Here's the description from the relevant add_setshow_string_cmd()

   (gdb) help set enum-fmt
   Set enum display format.
   Allows a printf-style format string to be specified to control the
   display
   of enum values.  The string will be printed verbatim when enum
   values are
   displayed except that:
        %v directives will be expanded to the numeric value of the enum,
        %s directives will be expanded to the symbolic value of the
   enum, and
        %t directives will be expanded to the enum tag.
   The default format is equivalent to "%s" and the default will be used if
   no argument is provided to the set operation.
   (gdb)

This allows the user to print the value in any useful way.

   $1 = Val1
   $2 = Val1=(enum E)56
   $3 = Val2=(enum E)57
   $4 = Val1 = (enum E)56
   $5 = Val2 = (enum E)57
   $6 = 56 "Val1"
   $7 = 57 "Val2"

or whatever:

Patch attached, as is a diff of before-and-after gdb.sum


Attachment: pr11067.patch
Description: Text document

Attachment: pr11067-check.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]