Index: printcmd.c =================================================================== RCS file: /cvs/src/src/gdb/printcmd.c,v retrieving revision 1.173 diff -u -r1.173 printcmd.c --- printcmd.c 5 Mar 2010 20:18:14 -0000 1.173 +++ printcmd.c 11 Mar 2010 15:20:44 -0000 @@ -373,6 +373,46 @@ current_language); return; } + + if (TYPE_CODE (type) == TYPE_CODE_ENUM + && options->format == 'f') + { + unsigned flen, i; + LONGEST val; + + flen = TYPE_NFIELDS (type); + val = unpack_long (type, valaddr); + + for (i = 0; i < flen; i++) + { + if (val == TYPE_FIELD_BITPOS (type, i)) + { + break; + } + } + if (i < flen) + { + char *enum_name; + + if (TYPE_NAME (type)) + enum_name = TYPE_NAME (type); + else if (TYPE_TAG_NAME(type)) + enum_name = TYPE_TAG_NAME(type); + else + enum_name = ""; + + fprintf_filtered (stream, "%s = (enum %s)%s", + TYPE_FIELD_NAME (type, i), + enum_name, + plongest (val)); + } + else + { + warning (_("Enum fancy formatting failed, using simple format.")); + print_longest (stream, 'd', 0, val); + } + return; + } if (len > sizeof(LONGEST) && (TYPE_CODE (type) == TYPE_CODE_INT Index: testsuite/gdb.base/Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/Makefile.in,v retrieving revision 1.5 diff -u -r1.5 Makefile.in --- testsuite/gdb.base/Makefile.in 15 Sep 2009 03:30:08 -0000 1.5 +++ testsuite/gdb.base/Makefile.in 11 Mar 2010 15:20:45 -0000 @@ -12,7 +12,8 @@ scope section_command setshow setvar shmain sigall signals \ solib solib_sl so-impl-ld so-indr-cl \ step-line step-test structs structs2 \ - twice-tmp varargs vforked-prog watchpoint whatis catch-syscall + twice-tmp varargs vforked-prog watchpoint whatis catch-syscall \ + pr11067 MISCELLANEOUS = coremmap.data ../foobar.baz \ shr1.sl shr2.sl solib_sl.sl solib1.sl solib2.sl Index: testsuite/gdb.base/pr11067.c =================================================================== RCS file: testsuite/gdb.base/pr11067.c diff -N testsuite/gdb.base/pr11067.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.base/pr11067.c 11 Mar 2010 15:20:45 -0000 @@ -0,0 +1,18 @@ +#include + +typedef enum { E0, E1, E2 } ex_e; +ex_e ef = E2; + +enum tt { + T0, + T1, + T2 +}; + +enum tt tf = T1; + +int +main() +{ + return 0; +} Index: testsuite/gdb.base/pr11067.exp =================================================================== RCS file: testsuite/gdb.base/pr11067.exp diff -N testsuite/gdb.base/pr11067.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.base/pr11067.exp 11 Mar 2010 15:20:45 -0000 @@ -0,0 +1,28 @@ +# Copyright 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set testfile pr11067 +set srcfile ${testfile}.c +if [prepare_for_testing $testfile.exp $testfile $srcfile {debug}] { + return -1 +} + +if ![runto_main] then { + fail "Can't run to main" + return +} + +gdb_test "p /f tf" "T1 = \\(enum tt\\)1.*" +gdb_test "p /f ef" "E2 = \\(enum \\)2.*"