Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* pr 11067 patch
@ 2010-02-11  2:55 Chris Moller
  2010-02-11  9:30 ` Joel Brobecker
  0 siblings, 1 reply; 18+ messages in thread
From: Chris Moller @ 2010-02-11  2:55 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 240 bytes --]

Provides a little more info on enums for simple 'p <enum>' cases; keeps 
the old format for complex cases like structs and arrays:

(gdb) p e
$1 = Val1 = (enum E)56
(gdb) p ea
$2 = {Val1, Val2, Val1}
(gdb) p es
$3 = {v = 5, e = Val2}
(gdb)

[-- Attachment #2: pr11067.patch --]
[-- Type: text/plain, Size: 16123 bytes --]

Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.11340
diff -u -r1.11340 ChangeLog
--- gdb/ChangeLog	9 Feb 2010 15:52:57 -0000	1.11340
+++ gdb/ChangeLog	11 Feb 2010 02:44:21 -0000
@@ -1,3 +1,10 @@
+Wed Feb 10 17:13:44 2010  Chris Moller  <moller@mollerware.com>
+
+	PR gdb/11067
+	* c-valprint.c (c_val_print): In case TYPE_CODE_ENUM, add code to
+	print the numeric value of the enum and the enum tag for
+	top-level, non-summary "print enum"s.
+
 2010-02-09  Tristan Gingold  <gingold@adacore.com>
 
 	* machoread.c (macho_symfile_relocate): New function.
Index: gdb/c-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-valprint.c,v
retrieving revision 1.67
diff -u -r1.67 c-valprint.c
--- gdb/c-valprint.c	2 Feb 2010 16:45:16 -0000	1.67
+++ gdb/c-valprint.c	11 Feb 2010 02:44:22 -0000
@@ -412,9 +412,23 @@
 	    }
 	}
       if (i < len)
-	{
-	  fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
-	}
+	if (options->summary || recurse != 0)
+	  {
+	    fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
+	  }
+	else
+	  {
+	    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 = "<unknown>";
+	  
+	    fprintf_filtered (stream, "%s = (enum %s)%lld",
+			      TYPE_FIELD_NAME (type, i),
+			      enum_name,
+			      val);
+	  }
       else
 	{
 	  print_longest (stream, 'd', 0, val);
Index: gdb/testsuite/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/ChangeLog,v
retrieving revision 1.2128
diff -u -r1.2128 ChangeLog
--- gdb/testsuite/ChangeLog	9 Feb 2010 13:16:33 -0000	1.2128
+++ gdb/testsuite/ChangeLog	11 Feb 2010 02:44:39 -0000
@@ -1,3 +1,20 @@
+Wed Feb 10 17:18:17 2010  Chris Moller  <moller@mollerware.com>
+
+	PR gdb/11067
+	* gdb.base/pr11067.c: New file.
+	* gdb.base/pr11067.exp: New file.
+	* gdb.base/Makefile.in (EXECUTABLES): Added pr11067
+	* gdb.cp/classes.exp (multiple places):
+	* gdb.cp/m-data.exp (multiple places):
+	* gdb.cp/m-static.exp (multiple places):
+	* gdb.cp/namespace.exp (multiple places):
+	* gdb.mi/mi-var-display.exp (multiple places):
+	* gdb.mi/mi2-var-display.exp (multiple places):
+	* gdb.python/py-value.exp (multiple places):
+	* gdb.base/setvar.exp (multiple places): Updated expects to new
+	enum format.
+	
+
 2010-02-09  Joel Brobecker  <brobecker@adacore.com>
 
 	* gdb.ada/ptype_tagged_param: New testcase.
Index: gdb/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
--- gdb/testsuite/gdb.base/Makefile.in	15 Sep 2009 03:30:08 -0000	1.5
+++ gdb/testsuite/gdb.base/Makefile.in	11 Feb 2010 02:44:39 -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: gdb/testsuite/gdb.base/pr11067.c
===================================================================
RCS file: gdb/testsuite/gdb.base/pr11067.c
diff -N gdb/testsuite/gdb.base/pr11067.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gdb/testsuite/gdb.base/pr11067.c	11 Feb 2010 02:44:40 -0000
@@ -0,0 +1,37 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   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 <http://www.gnu.org/licenses/>.  */
+
+enum E {
+  Val1 = 56,
+  Val2
+};
+
+struct Es {
+  int v;
+  enum E e;
+};
+
+enum E e = Val1;
+
+enum E ea[] = { Val1, Val2, Val1 };
+
+struct Es es = { 5, Val2 };
+
+int main() {
+  return 0;
+}
+
Index: gdb/testsuite/gdb.base/pr11067.exp
===================================================================
RCS file: gdb/testsuite/gdb.base/pr11067.exp
diff -N gdb/testsuite/gdb.base/pr11067.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gdb/testsuite/gdb.base/pr11067.exp	11 Feb 2010 02:44:40 -0000
@@ -0,0 +1,48 @@
+# 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 <http://www.gnu.org/licenses/>.
+
+if { [skip_cplus_tests] } { continue }
+
+load_lib "cp-support.exp"
+
+set testfile "pr11067"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } {
+     untested pr11067.exp
+     return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+if ![runto_main] then {
+    perror "couldn't run to breakpoint"
+    continue
+}
+
+# set a breakpoint at the return stmt
+
+gdb_test "print e"  "Val1 = \\(enum E\\)56"
+
+gdb_test "print ea"  "{Val1, Val2, Val1}"
+
+gdb_test "print es"  "v = 5, e = Val2}"
+
+gdb_exit
+return 0
Index: gdb/testsuite/gdb.base/setvar.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/setvar.exp,v
retrieving revision 1.19
diff -u -r1.19 setvar.exp
--- gdb/testsuite/gdb.base/setvar.exp	29 Jan 2010 15:38:37 -0000	1.19
+++ gdb/testsuite/gdb.base/setvar.exp	11 Feb 2010 02:44:40 -0000
@@ -399,18 +399,22 @@
 # GNU C supports them, some other compilers don't.
 
 if {$gcc_compiled} then {
-    gdb_test "print sef.field=sm1" ".*.\[0-9\]* = sm1"
-    gdb_test "print sef.field" ".*.\[0-9\]* = sm1" "print sef.field (sm1)"
-    gdb_test "print sef.field=s1" ".*.\[0-9\]* = s1"
-    gdb_test "print sef.field" ".*.\[0-9\]* = s1" "print sef.field (s1)"
-    gdb_test "print uef.field=u2" ".*.\[0-9\]* = u2"
-    gdb_test "print uef.field" ".*.\[0-9\]* = u2" "print uef.field (u2)"
-    gdb_test "print uef.field=u1" ".*.\[0-9\]* = u1"
-    gdb_test "print uef.field" ".*.\[0-9\]* = u1" "print uef.field (u1)"
+    gdb_test "print sef.field=sm1" ".*.\[0-9\]* = sm1 = \\(enum senum\\)-1"
+    gdb_test "print sef.field" ".*.\[0-9\]* = sm1 = \\(enum senum\\)-1" \
+	"print sef.field (sm1)"
+    gdb_test "print sef.field=s1" ".*.\[0-9\]* = s1 = \\(enum senum\\)1"
+    gdb_test "print sef.field" ".*.\[0-9\]* = s1 = \\(enum senum\\)1" \
+	"print sef.field (s1)"
+    gdb_test "print uef.field=u2" ".*.\[0-9\]* = u2 = \\(enum uenum\\)2"
+    gdb_test "print uef.field" ".*.\[0-9\]* = u2 = \\(enum uenum\\)2" \
+	"print uef.field (u2)"
+    gdb_test "print uef.field=u1" ".*.\[0-9\]* = u1 = \\(enum uenum\\)1"
+    gdb_test "print uef.field" ".*.\[0-9\]* = u1 = \\(enum uenum\\)1" \
+	"print uef.field (u1)"
 
     # Test for truncation when assigning invalid values to bitfields.
     gdb_test "print sef.field=7" \
-	".*warning: Value does not fit in 2 bits.*\[0-9\]* = sm1"
+	".*warning: Value does not fit in 2 bits.*\[0-9\]* = sm1 = \\(enum senum\\)-1"
     gdb_test "print uef.field=6" \
-	".*warning: Value does not fit in 2 bits.*\[0-9\]* = u2"
+	".*warning: Value does not fit in 2 bits.*\[0-9\]* = u2 = \\(enum uenum\\)2"
 }
Index: gdb/testsuite/gdb.cp/classes.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/classes.exp,v
retrieving revision 1.24
diff -u -r1.24 classes.exp
--- gdb/testsuite/gdb.cp/classes.exp	1 Jan 2010 07:32:01 -0000	1.24
+++ gdb/testsuite/gdb.cp/classes.exp	11 Feb 2010 02:44:41 -0000
@@ -413,7 +413,7 @@
 
     # print the enum member
 
-    gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = (ClassWithEnum::)?green"
+    gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = (ClassWithEnum::)?green = \\(enum ClassWithEnum::PrivEnum\\)1"
 
     # ptype on the enum member
 
@@ -482,7 +482,7 @@
     }
 
     gdb_test_multiple "print ('ClassWithEnum::PrivEnum') 42" "print ('ClassWithEnum::PrivEnum') 42" {
-	-re "\\$\[0-9\]+ = (ClassWithEnum::)?yellow$nl$gdb_prompt $" {
+	-re "\\$\[0-9\]+ = (ClassWithEnum::)?yellow = \\(enum ClassWithEnum::PrivEnum\\)42$nl$gdb_prompt $" {
 	    # gcc 3.3.2 -gstabs+
 	    # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
 	    pass "print ('ClassWithEnum::PrivEnum') 42"
Index: gdb/testsuite/gdb.cp/m-data.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/m-data.exp,v
retrieving revision 1.7
diff -u -r1.7 m-data.exp
--- gdb/testsuite/gdb.cp/m-data.exp	1 Jan 2010 07:32:01 -0000	1.7
+++ gdb/testsuite/gdb.cp/m-data.exp	11 Feb 2010 02:44:41 -0000
@@ -71,7 +71,7 @@
 gdb_test "print test1.key2" "\\$\[0-9\]* = 4589" "simple object, long"
 
 # simple object, enum
-gdb_test "print test1.value" "\\$\[0-9\]* = egyptian" "simple object, enum"
+gdb_test "print test1.value" "\\$\[0-9\]* = egyptian = \\(enum region\\)1" "simple object, enum"
 
 # Two.
 
@@ -85,10 +85,10 @@
 gdb_test "print test2.key2" "\\$\[0-9\]* = 7" "derived template object, base long"
 
 # derived template object, base enum
-gdb_test "print test2.value" "\\$\[0-9\]* = oriental" "derived template object, base enum"
+gdb_test "print test2.value" "\\$\[0-9\]* = oriental = \\(enum region\\)0" "derived template object, base enum"
 
 # derived template object, enum
-gdb_test "print test2.value_derived" "\\$\[0-9\]* = roman" "derived template object, derived enum"
+gdb_test "print test2.value_derived" "\\$\[0-9\]* = roman = \\(enum region\\)4" "derived template object, derived enum"
 
 # Three.
 
@@ -102,10 +102,10 @@
 gdb_test "print test3.data.key2" "\\$\[0-9\]* = 7" "template object, long"
 
 # template object, derived template data member's base enum
-gdb_test "print test3.data.value" "\\$\[0-9\]* = oriental" "template object, base enum"
+gdb_test "print test3.data.value" "\\$\[0-9\]* = oriental = \\(enum region\\)0" "template object, base enum"
 
 # template object, derived template data member's enum
-gdb_test "print test3.data.value_derived" "\\$\[0-9]\* = etruscan" "template object, derived enum"
+gdb_test "print test3.data.value_derived" "\\$\[0-9]\* = etruscan = \\(enum region\\)3" "template object, derived enum"
 
 # Now some tests for shadowing (see PR gdb/804):
 
Index: gdb/testsuite/gdb.cp/m-static.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/m-static.exp,v
retrieving revision 1.9
diff -u -r1.9 m-static.exp
--- gdb/testsuite/gdb.cp/m-static.exp	1 Jan 2010 07:32:01 -0000	1.9
+++ gdb/testsuite/gdb.cp/m-static.exp	11 Feb 2010 02:44:41 -0000
@@ -82,7 +82,7 @@
 gdb_test "print test1.key2" "\\$\[0-9\]* = 77" "simple object, static long"
 
 # simple object, static enum
-gdb_test "print test1.value" "\\$\[0-9\]* = oriental" "simple object, static enum"
+gdb_test "print test1.value" "\\$\[0-9\]* = oriental = \\(enum region\\)0" "simple object, static enum"
 
 # Two.
 
@@ -96,10 +96,10 @@
 gdb_test "print test2.key2" "\\$\[0-9\]* = 77" "derived template object, base static long"
 
 # derived template object, base static enum
-gdb_test "print test2.value" "\\$\[0-9\].* = oriental" "derived template object, base static enum"
+gdb_test "print test2.value" "\\$\[0-9\].* = oriental = \\(enum region\\)0" "derived template object, base static enum"
 
 # derived template object, static enum
-gdb_test "print test2.value_derived" "\\$\[0-9\].* = etruscan" "derived template object, static enum"
+gdb_test "print test2.value_derived" "\\$\[0-9\].* = etruscan = \\(enum region\\)3" "derived template object, static enum"
 
 # Three.
 
@@ -113,10 +113,10 @@
 gdb_test "print test3.data.key2" "\\$\[0-9\].* = 77" "template object, static long"
 
 # template object, static derived template data member's base static enum
-gdb_test "print test3.data.value" "\\$\[0-9\].* = oriental" "template object, static enum"
+gdb_test "print test3.data.value" "\\$\[0-9\].* = oriental = \\(enum region\\)0" "template object, static enum"
 
 #  template object, static derived template data member's static enum
-gdb_test "print test3.data.value_derived" "\\$\[0-9\].* = etruscan" "template object, static derived enum"
+gdb_test "print test3.data.value_derived" "\\$\[0-9\].* = etruscan = \\(enum region\\)3" "template object, static derived enum"
 
 # 2002-08-16
 # Four.
Index: gdb/testsuite/gdb.cp/namespace.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/namespace.exp,v
retrieving revision 1.16
diff -u -r1.16 namespace.exp
--- gdb/testsuite/gdb.cp/namespace.exp	19 Jan 2010 18:11:19 -0000	1.16
+++ gdb/testsuite/gdb.cp/namespace.exp	11 Feb 2010 02:44:41 -0000
@@ -273,4 +273,4 @@
 gdb_test "print XOtherFile" "No symbol \"XOtherFile\" in current context."
 
 # Enum tests.
-gdb_test "print AAA::ALPHA" "\\$\[0-9\].* = AAA::ALPHA"
+gdb_test "print AAA::ALPHA" "\\$\[0-9\].* = AAA::ALPHA = \\(enum AAA::SomeEnum\\)0"
Index: gdb/testsuite/gdb.mi/mi-var-display.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-display.exp,v
retrieving revision 1.34
diff -u -r1.34 mi-var-display.exp
--- gdb/testsuite/gdb.mi/mi-var-display.exp	1 Jan 2010 07:32:03 -0000	1.34
+++ gdb/testsuite/gdb.mi/mi-var-display.exp	11 Feb 2010 02:44:42 -0000
@@ -568,7 +568,7 @@
 # Test: c_variable-7.61
 # Desc: value of anone
 mi_gdb_test "-var-evaluate-expression anone" \
-	"\\^done,value=\"A\"" \
+	"\\^done,value=\"A = \\(enum <unknown>\\)0\"" \
 	"eval variable anone"
 
 # Test: c_variable-7.70
Index: gdb/testsuite/gdb.mi/mi2-var-display.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-var-display.exp,v
retrieving revision 1.27
diff -u -r1.27 mi2-var-display.exp
--- gdb/testsuite/gdb.mi/mi2-var-display.exp	1 Jan 2010 07:32:03 -0000	1.27
+++ gdb/testsuite/gdb.mi/mi2-var-display.exp	11 Feb 2010 02:44:43 -0000
@@ -567,7 +567,7 @@
 # Test: c_variable-7.61
 # Desc: value of anone
 mi_gdb_test "-var-evaluate-expression anone" \
-	"\\^done,value=\"A\"" \
+	"\\^done,value=\"A = \\(enum <unknown>\\)0\"" \
 	"eval variable anone"
 
 # Test: c_variable-7.70
Index: gdb/testsuite/gdb.python/py-value.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-value.exp,v
retrieving revision 1.5
diff -u -r1.5 py-value.exp
--- gdb/testsuite/gdb.python/py-value.exp	14 Jan 2010 08:03:37 -0000	1.5
+++ gdb/testsuite/gdb.python/py-value.exp	11 Feb 2010 02:44:43 -0000
@@ -115,7 +115,7 @@
   gdb_test "python print 'result = ' + str(1.5+f)" " = 2.75" "add python float with double value"
 
   # Conversion test.
-  gdb_test "print evalue" " = TWO"
+  gdb_test "print evalue" " = TWO = \\(enum e\\)2"
   gdb_test "python evalue = gdb.history (0)" ""
   gdb_test "python print int (evalue)" "2"
 

[-- Attachment #3: pr11067-check.diff --]
[-- Type: text/plain, Size: 487 bytes --]

1c1
< Test Run By moller on Wed Feb 10 08:49:14 2010
---
> Test Run By moller on Wed Feb 10 21:27:30 2010
5648a5649,5652
> Running ../../../src/gdb/testsuite/gdb.base/pr11067.exp ...
> PASS: gdb.base/pr11067.exp: print e
> PASS: gdb.base/pr11067.exp: print ea
> PASS: gdb.base/pr11067.exp: print es
15512c15516
< PASS: gdb.threads/watchthreads.exp: disable 3
---
> PASS: gdb.threads/watchthreads.exp: disable 2
15716c15720
< # of expected passes		14910
---
> # of expected passes		14913

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-11  2:55 pr 11067 patch Chris Moller
@ 2010-02-11  9:30 ` Joel Brobecker
  2010-02-11 14:19   ` Chris Moller
  2010-02-11 19:50   ` Tom Tromey
  0 siblings, 2 replies; 18+ messages in thread
From: Joel Brobecker @ 2010-02-11  9:30 UTC (permalink / raw)
  To: Chris Moller; +Cc: gdb-patches

> Provides a little more info on enums for simple 'p <enum>' cases;
> keeps the old format for complex cases like structs and arrays:

I feel really bad about this, and I really apologize - I am just only
suddenly wondering why this is considered a good idea, was that discussed?
Please understand that this is not an objection, but I just had a look
at the PR, and I happen to disagree with the reporter. According to me,
he said:

  1. If I print 'e', GDB prints 'Val1' and that's OK.
  2. If I print 'Val1', GDB prints also prints 'Val1' and he says
     that, instead, GDB should print its numerical value.

I disagree on (2) because, if he wanted the numerical value, he should
have told GDB. For instance:

  (gdb) p GREEN
  $1 = GREEN
  (gdb) p /d GREEN
  $2 = 1

If people still think that this suggestion is a good one, I looked at
the patch (the least I could do)...

> +Wed Feb 10 17:13:44 2010  Chris Moller  <moller@mollerware.com>
> +
> +	PR gdb/11067
> +	* c-valprint.c (c_val_print): In case TYPE_CODE_ENUM, add code to
> +	print the numeric value of the enum and the enum tag for
> +	top-level, non-summary "print enum"s.



> +	if (options->summary || recurse != 0)
> +	  {
> +	    fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
> +	  }

We do not use the curly braces in this case, when the block only contains
one statement.

> +	else
> +	  {
> +	    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 = "<unknown>";

Can you place each statement on their own line? I am guessing that
GNU indent will fix that anyway, and I also think that this is harder
to read.

Rather than "unknown", I wonder if we shouldn't be using "<anonymous>".

> +	    fprintf_filtered (stream, "%s = (enum %s)%lld",
> +			      TYPE_FIELD_NAME (type, i),
> +			      enum_name,
> +			      val);

Just a gotcha, here: val is a LONGEST, which is not necessarily
a long long. Use plongest to format your value into a string.

Also, would you mind adding a short comment explaining why you are
doing all this (we want to be concise if printing this enum as part
of a larger data structure or while in summary mode).

> +	* gdb.cp/classes.exp (multiple places):
> +	* gdb.cp/m-data.exp (multiple places):
> +	* gdb.cp/m-static.exp (multiple places):
> +	* gdb.cp/namespace.exp (multiple places):
> +	* gdb.mi/mi-var-display.exp (multiple places):
> +	* gdb.mi/mi2-var-display.exp (multiple places):
> +	* gdb.python/py-value.exp (multiple places):
> +	* gdb.base/setvar.exp (multiple places): Updated expects to new
> +	enum format.

Hmmm, I don't think you need the "multiple places".  IIRC, the GCS allow
you to just say:
        
        * gdb.base/setvar.exp: Update throughout to match new enum format.

> +enum E e = Val1;
> +
> +enum E ea[] = { Val1, Val2, Val1 };
> +
> +struct Es es = { 5, Val2 };
> +
> +int main() {
> +  return 0;
> +}

I can see some linkers optimizing away your global variables, causing
the testcase to fail... The AIX linker, for instance, does that.
You have a look at exprs.c, or grep for AIX in gdb.base/*.c for some
ideas on how to deceive the linker and prevent this unwanted optimization.

> +if { [skip_cplus_tests] } { continue }
> +
> +load_lib "cp-support.exp"

I don't think this is right, is it? Since this is a C test, I don't
understand why that would be needed...

> +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } {
> +     untested pr11067.exp
> +     return -1

Same here, you're doing a C++ build for a C program.

Have a look at http://sourceware.org/gdb/wiki/GDBTestcaseCookbook.
If I were you, I'd just do the following to build your program:

        set testfile template
        set srcfile ${testfile}.c
        if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
            return -1
        }

The above also includes the calls to gdb_exit/gdb_start/etc, so they
can also go.

> +# set a breakpoint at the return stmt

Superfluous comment :).

> +gdb_exit
> +return 0

Also superfluous...

-- 
Joel


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-11  9:30 ` Joel Brobecker
@ 2010-02-11 14:19   ` Chris Moller
  2010-02-11 19:50   ` Tom Tromey
  1 sibling, 0 replies; 18+ messages in thread
From: Chris Moller @ 2010-02-11 14:19 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On 02/11/10 04:29, Joel Brobecker wrote:
>> Provides a little more info on enums for simple 'p<enum>' cases;
>> keeps the old format for complex cases like structs and arrays:
>>      
>
> I feel really bad about this, and I really apologize - I am just only
> suddenly wondering why this is considered a good idea, was that discussed?
> Please understand that this is not an objection, but I just had a look
> at the PR, and I happen to disagree with the reporter. According to me,
> he said:
>
>    1. If I print 'e', GDB prints 'Val1' and that's OK.
>    2. If I print 'Val1', GDB prints also prints 'Val1' and he says
>       that, instead, GDB should print its numerical value.
>
> I disagree on (2) because, if he wanted the numerical value, he should
> have told GDB. For instance:
>
>    (gdb) p GREEN
>    $1 = GREEN
>    (gdb) p /d GREEN
>    $2 = 1
>
> If people still think that this suggestion is a good one, I looked at
> the patch (the least I could do)...
>    

I personally don't have much of an opinion either way about whether the 
patch is a good idea--it was on the bug list, they told me to shoot 
bugs, so I did.

But for such a trivial thing, it sure has wasted a lot of bandwidth...


I'll fold in your comments below, thx.



>    
>> +Wed Feb 10 17:13:44 2010  Chris Moller<moller@mollerware.com>
>> +
>> +	PR gdb/11067
>> +	* c-valprint.c (c_val_print): In case TYPE_CODE_ENUM, add code to
>> +	print the numeric value of the enum and the enum tag for
>> +	top-level, non-summary "print enum"s.
>>      
>
>
>
>    
>> +	if (options->summary || recurse != 0)
>> +	  {
>> +	    fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
>> +	  }
>>      
>
> We do not use the curly braces in this case, when the block only contains
> one statement.
>
>    


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-11  9:30 ` Joel Brobecker
  2010-02-11 14:19   ` Chris Moller
@ 2010-02-11 19:50   ` Tom Tromey
  2010-02-12  4:11     ` Joel Brobecker
  1 sibling, 1 reply; 18+ messages in thread
From: Tom Tromey @ 2010-02-11 19:50 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Chris Moller, gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

>> Provides a little more info on enums for simple 'p <enum>' cases;
>> keeps the old format for complex cases like structs and arrays:

Joel> I feel really bad about this, and I really apologize - I am just
Joel> only suddenly wondering why this is considered a good idea, was
Joel> that discussed?

A little bit on the archer list, but not really directly.

Joel>   1. If I print 'e', GDB prints 'Val1' and that's OK.
Joel>   2. If I print 'Val1', GDB prints also prints 'Val1' and he says
Joel>      that, instead, GDB should print its numerical value.

Joel> I disagree on (2) because, if he wanted the numerical value, he should
Joel> have told GDB. For instance:

Joel>   (gdb) p GREEN
Joel>   $1 = GREEN
Joel>   (gdb) p /d GREEN
Joel>   $2 = 1

Joel> If people still think that this suggestion is a good one, I looked at
Joel> the patch (the least I could do)...

I asked Chris to work on this because I run into this with some
frequency.  I often will print some enum-typed value and get a symbolic
answer.  Then I have to type another command to get the numeric answer.

It seems mildly friendlier to simply always print it, at least at the
top level.  (In stack traces and in structures it may wind up being too
verbose, hence that decision.)

Differentiating cases 1 and 2 above is not really practical because the
evaluation and printing code are kept separate.

If you disagree strongly, then we could just close the PR and drop it, I
suppose.  I am not very intent on this, I just thought it would be a
nice, if minor, enhancement.  I didn't see a real downside.

Joel> Can you place each statement on their own line? I am guessing that
Joel> GNU indent will fix that anyway, and I also think that this is harder
Joel> to read.

I think we've abandoned any hope of using GNU indent.

Thanks for reviewing this.

Tom


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-11 19:50   ` Tom Tromey
@ 2010-02-12  4:11     ` Joel Brobecker
  2010-02-12 15:48       ` Chris Moller
  0 siblings, 1 reply; 18+ messages in thread
From: Joel Brobecker @ 2010-02-12  4:11 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Chris Moller, gdb-patches

> If you disagree strongly, then we could just close the PR and drop it, I
> suppose.  I am not very intent on this, I just thought it would be a
> nice, if minor, enhancement.  I didn't see a real downside.

Not at all, I cannot say I like the idea, but if it's useful to others,
this is all that really matters. Let's go ahead, then.

Regarding GNU indent - I know. But I try to keep formatting the code
the way GNU indent would do it in sane situations, as it helps keeping
some uniformity to our code.  There are some rules I don't like (ahem,
ask me about spaces and tabs), but I think that uniformity is more
important...

I'm happy I contributed just a little bit towards this patch - I really
felt bad reacting to it so so late in the game.

-- 
Joel


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-12  4:11     ` Joel Brobecker
@ 2010-02-12 15:48       ` Chris Moller
  2010-02-13 11:49         ` Jan Kratochvil
  0 siblings, 1 reply; 18+ messages in thread
From: Chris Moller @ 2010-02-12 15:48 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

Herewith, if anyone is interested, is what I expect is the final version 
of this patch, incorporating Joel's comments.  Absent any objections, I 
expect I'll commit it Monday (just to give people time to object :-) ).

[Joel, thanks for the link to the GDBTestcaseCookbook--extracting 
coherence from lots of oral tradition and examples dating from the mists 
of the distant past wasn't working well.]

On 02/11/10 23:11, Joel Brobecker wrote:
>> If you disagree strongly, then we could just close the PR and drop it, I
>> suppose.  I am not very intent on this, I just thought it would be a
>> nice, if minor, enhancement.  I didn't see a real downside.
>>      
>
> Not at all, I cannot say I like the idea, but if it's useful to others,
> this is all that really matters. Let's go ahead, then.
>
> Regarding GNU indent - I know. But I try to keep formatting the code
> the way GNU indent would do it in sane situations, as it helps keeping
> some uniformity to our code.  There are some rules I don't like (ahem,
> ask me about spaces and tabs), but I think that uniformity is more
> important...
>
> I'm happy I contributed just a little bit towards this patch - I really
> felt bad reacting to it so so late in the game.
>
>    


[-- Attachment #2: pr11067.patch --]
[-- Type: text/plain, Size: 16075 bytes --]

Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.11340
diff -u -r1.11340 ChangeLog
--- gdb/ChangeLog	9 Feb 2010 15:52:57 -0000	1.11340
+++ gdb/ChangeLog	12 Feb 2010 15:37:46 -0000
@@ -1,3 +1,10 @@
+Wed Feb 10 17:13:44 2010  Chris Moller  <moller@mollerware.com>
+
+	PR gdb/11067
+	* c-valprint.c (c_val_print): In case TYPE_CODE_ENUM, add code to
+	print the numeric value of the enum and the enum tag for
+	top-level, non-summary "print enum"s.
+
 2010-02-09  Tristan Gingold  <gingold@adacore.com>
 
 	* machoread.c (macho_symfile_relocate): New function.
Index: gdb/c-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-valprint.c,v
retrieving revision 1.67
diff -u -r1.67 c-valprint.c
--- gdb/c-valprint.c	2 Feb 2010 16:45:16 -0000	1.67
+++ gdb/c-valprint.c	12 Feb 2010 15:37:47 -0000
@@ -412,9 +412,30 @@
 	    }
 	}
       if (i < len)
-	{
+	/*
+	  When printing a simple enum value, the following code includes, in
+	  addition to the symbolic value, the numeric value and the enum tag.
+	  Under other-than-simple circumstances--in structs, arrays, etc.--
+	  it does what's always done and prints just the symbolic value.
+	*/
+	if (options->summary || recurse != 0)
 	  fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
-	}
+	else
+	  {
+	    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 = "<anonymous>";
+	  
+	    fprintf_filtered (stream, "%s = (enum %s)%s",
+			      TYPE_FIELD_NAME (type, i),
+			      enum_name,
+			      plongest (val));
+	  }
       else
 	{
 	  print_longest (stream, 'd', 0, val);
Index: gdb/testsuite/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/ChangeLog,v
retrieving revision 1.2128
diff -u -r1.2128 ChangeLog
--- gdb/testsuite/ChangeLog	9 Feb 2010 13:16:33 -0000	1.2128
+++ gdb/testsuite/ChangeLog	12 Feb 2010 15:38:04 -0000
@@ -1,3 +1,19 @@
+Wed Feb 10 17:18:17 2010  Chris Moller  <moller@mollerware.com>
+
+	PR gdb/11067
+	* gdb.base/pr11067.c: New file.
+	* gdb.base/pr11067.exp: New file.
+	* gdb.base/Makefile.in (EXECUTABLES): Added pr11067
+	* gdb.cp/classes.exp:
+	* gdb.cp/m-data.exp:
+	* gdb.cp/m-static.exp:
+	* gdb.cp/namespace.exp:
+	* gdb.mi/mi-var-display.exp:
+	* gdb.mi/mi2-var-display.exp:
+	* gdb.python/py-value.exp:
+	* gdb.base/setvar.exp: Updated expects to the new enum format.
+	
+
 2010-02-09  Joel Brobecker  <brobecker@adacore.com>
 
 	* gdb.ada/ptype_tagged_param: New testcase.
Index: gdb/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
--- gdb/testsuite/gdb.base/Makefile.in	15 Sep 2009 03:30:08 -0000	1.5
+++ gdb/testsuite/gdb.base/Makefile.in	12 Feb 2010 15:38:04 -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: gdb/testsuite/gdb.base/pr11067.c
===================================================================
RCS file: gdb/testsuite/gdb.base/pr11067.c
diff -N gdb/testsuite/gdb.base/pr11067.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gdb/testsuite/gdb.base/pr11067.c	12 Feb 2010 15:38:05 -0000
@@ -0,0 +1,48 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   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 <http://www.gnu.org/licenses/>.  */
+
+enum E {
+  Val1 = 56,
+  Val2
+};
+
+struct Es {
+  int v;
+  enum E e;
+};
+
+enum E e = Val1;
+
+enum E ea[] = { Val1, Val2, Val1 };
+
+struct Es es = { 5, Val2 };
+
+int main() {
+  /*
+    The following is a fake-out for linkers (such as, apparently, the AIX
+    linker) that optimises out unreference variables.
+  */
+  
+  e = Val2;
+
+  ea[0] = Val2;
+
+  es.v = 99;
+  
+  return 0;
+}
+
Index: gdb/testsuite/gdb.base/pr11067.exp
===================================================================
RCS file: gdb/testsuite/gdb.base/pr11067.exp
diff -N gdb/testsuite/gdb.base/pr11067.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gdb/testsuite/gdb.base/pr11067.exp	12 Feb 2010 15:38:05 -0000
@@ -0,0 +1,31 @@
+# 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 <http://www.gnu.org/licenses/>.
+
+set testfile "pr11067"
+set srcfile ${testfile}.c
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
+    return -1
+}
+
+if ![runto_main] {
+    return -1
+}
+
+gdb_test "print e"  "Val1 = \\(enum E\\)56"
+
+gdb_test "print ea"  "{Val1, Val2, Val1}"
+
+gdb_test "print es"  "v = 5, e = Val2}"
Index: gdb/testsuite/gdb.base/setvar.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/setvar.exp,v
retrieving revision 1.19
diff -u -r1.19 setvar.exp
--- gdb/testsuite/gdb.base/setvar.exp	29 Jan 2010 15:38:37 -0000	1.19
+++ gdb/testsuite/gdb.base/setvar.exp	12 Feb 2010 15:38:05 -0000
@@ -399,18 +399,22 @@
 # GNU C supports them, some other compilers don't.
 
 if {$gcc_compiled} then {
-    gdb_test "print sef.field=sm1" ".*.\[0-9\]* = sm1"
-    gdb_test "print sef.field" ".*.\[0-9\]* = sm1" "print sef.field (sm1)"
-    gdb_test "print sef.field=s1" ".*.\[0-9\]* = s1"
-    gdb_test "print sef.field" ".*.\[0-9\]* = s1" "print sef.field (s1)"
-    gdb_test "print uef.field=u2" ".*.\[0-9\]* = u2"
-    gdb_test "print uef.field" ".*.\[0-9\]* = u2" "print uef.field (u2)"
-    gdb_test "print uef.field=u1" ".*.\[0-9\]* = u1"
-    gdb_test "print uef.field" ".*.\[0-9\]* = u1" "print uef.field (u1)"
+    gdb_test "print sef.field=sm1" ".*.\[0-9\]* = sm1 = \\(enum senum\\)-1"
+    gdb_test "print sef.field" ".*.\[0-9\]* = sm1 = \\(enum senum\\)-1" \
+	"print sef.field (sm1)"
+    gdb_test "print sef.field=s1" ".*.\[0-9\]* = s1 = \\(enum senum\\)1"
+    gdb_test "print sef.field" ".*.\[0-9\]* = s1 = \\(enum senum\\)1" \
+	"print sef.field (s1)"
+    gdb_test "print uef.field=u2" ".*.\[0-9\]* = u2 = \\(enum uenum\\)2"
+    gdb_test "print uef.field" ".*.\[0-9\]* = u2 = \\(enum uenum\\)2" \
+	"print uef.field (u2)"
+    gdb_test "print uef.field=u1" ".*.\[0-9\]* = u1 = \\(enum uenum\\)1"
+    gdb_test "print uef.field" ".*.\[0-9\]* = u1 = \\(enum uenum\\)1" \
+	"print uef.field (u1)"
 
     # Test for truncation when assigning invalid values to bitfields.
     gdb_test "print sef.field=7" \
-	".*warning: Value does not fit in 2 bits.*\[0-9\]* = sm1"
+	".*warning: Value does not fit in 2 bits.*\[0-9\]* = sm1 = \\(enum senum\\)-1"
     gdb_test "print uef.field=6" \
-	".*warning: Value does not fit in 2 bits.*\[0-9\]* = u2"
+	".*warning: Value does not fit in 2 bits.*\[0-9\]* = u2 = \\(enum uenum\\)2"
 }
Index: gdb/testsuite/gdb.cp/classes.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/classes.exp,v
retrieving revision 1.24
diff -u -r1.24 classes.exp
--- gdb/testsuite/gdb.cp/classes.exp	1 Jan 2010 07:32:01 -0000	1.24
+++ gdb/testsuite/gdb.cp/classes.exp	12 Feb 2010 15:38:06 -0000
@@ -413,7 +413,7 @@
 
     # print the enum member
 
-    gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = (ClassWithEnum::)?green"
+    gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = (ClassWithEnum::)?green = \\(enum ClassWithEnum::PrivEnum\\)1"
 
     # ptype on the enum member
 
@@ -482,7 +482,7 @@
     }
 
     gdb_test_multiple "print ('ClassWithEnum::PrivEnum') 42" "print ('ClassWithEnum::PrivEnum') 42" {
-	-re "\\$\[0-9\]+ = (ClassWithEnum::)?yellow$nl$gdb_prompt $" {
+	-re "\\$\[0-9\]+ = (ClassWithEnum::)?yellow = \\(enum ClassWithEnum::PrivEnum\\)42$nl$gdb_prompt $" {
 	    # gcc 3.3.2 -gstabs+
 	    # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
 	    pass "print ('ClassWithEnum::PrivEnum') 42"
Index: gdb/testsuite/gdb.cp/m-data.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/m-data.exp,v
retrieving revision 1.7
diff -u -r1.7 m-data.exp
--- gdb/testsuite/gdb.cp/m-data.exp	1 Jan 2010 07:32:01 -0000	1.7
+++ gdb/testsuite/gdb.cp/m-data.exp	12 Feb 2010 15:38:06 -0000
@@ -71,7 +71,7 @@
 gdb_test "print test1.key2" "\\$\[0-9\]* = 4589" "simple object, long"
 
 # simple object, enum
-gdb_test "print test1.value" "\\$\[0-9\]* = egyptian" "simple object, enum"
+gdb_test "print test1.value" "\\$\[0-9\]* = egyptian = \\(enum region\\)1" "simple object, enum"
 
 # Two.
 
@@ -85,10 +85,10 @@
 gdb_test "print test2.key2" "\\$\[0-9\]* = 7" "derived template object, base long"
 
 # derived template object, base enum
-gdb_test "print test2.value" "\\$\[0-9\]* = oriental" "derived template object, base enum"
+gdb_test "print test2.value" "\\$\[0-9\]* = oriental = \\(enum region\\)0" "derived template object, base enum"
 
 # derived template object, enum
-gdb_test "print test2.value_derived" "\\$\[0-9\]* = roman" "derived template object, derived enum"
+gdb_test "print test2.value_derived" "\\$\[0-9\]* = roman = \\(enum region\\)4" "derived template object, derived enum"
 
 # Three.
 
@@ -102,10 +102,10 @@
 gdb_test "print test3.data.key2" "\\$\[0-9\]* = 7" "template object, long"
 
 # template object, derived template data member's base enum
-gdb_test "print test3.data.value" "\\$\[0-9\]* = oriental" "template object, base enum"
+gdb_test "print test3.data.value" "\\$\[0-9\]* = oriental = \\(enum region\\)0" "template object, base enum"
 
 # template object, derived template data member's enum
-gdb_test "print test3.data.value_derived" "\\$\[0-9]\* = etruscan" "template object, derived enum"
+gdb_test "print test3.data.value_derived" "\\$\[0-9]\* = etruscan = \\(enum region\\)3" "template object, derived enum"
 
 # Now some tests for shadowing (see PR gdb/804):
 
Index: gdb/testsuite/gdb.cp/m-static.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/m-static.exp,v
retrieving revision 1.9
diff -u -r1.9 m-static.exp
--- gdb/testsuite/gdb.cp/m-static.exp	1 Jan 2010 07:32:01 -0000	1.9
+++ gdb/testsuite/gdb.cp/m-static.exp	12 Feb 2010 15:38:06 -0000
@@ -82,7 +82,7 @@
 gdb_test "print test1.key2" "\\$\[0-9\]* = 77" "simple object, static long"
 
 # simple object, static enum
-gdb_test "print test1.value" "\\$\[0-9\]* = oriental" "simple object, static enum"
+gdb_test "print test1.value" "\\$\[0-9\]* = oriental = \\(enum region\\)0" "simple object, static enum"
 
 # Two.
 
@@ -96,10 +96,10 @@
 gdb_test "print test2.key2" "\\$\[0-9\]* = 77" "derived template object, base static long"
 
 # derived template object, base static enum
-gdb_test "print test2.value" "\\$\[0-9\].* = oriental" "derived template object, base static enum"
+gdb_test "print test2.value" "\\$\[0-9\].* = oriental = \\(enum region\\)0" "derived template object, base static enum"
 
 # derived template object, static enum
-gdb_test "print test2.value_derived" "\\$\[0-9\].* = etruscan" "derived template object, static enum"
+gdb_test "print test2.value_derived" "\\$\[0-9\].* = etruscan = \\(enum region\\)3" "derived template object, static enum"
 
 # Three.
 
@@ -113,10 +113,10 @@
 gdb_test "print test3.data.key2" "\\$\[0-9\].* = 77" "template object, static long"
 
 # template object, static derived template data member's base static enum
-gdb_test "print test3.data.value" "\\$\[0-9\].* = oriental" "template object, static enum"
+gdb_test "print test3.data.value" "\\$\[0-9\].* = oriental = \\(enum region\\)0" "template object, static enum"
 
 #  template object, static derived template data member's static enum
-gdb_test "print test3.data.value_derived" "\\$\[0-9\].* = etruscan" "template object, static derived enum"
+gdb_test "print test3.data.value_derived" "\\$\[0-9\].* = etruscan = \\(enum region\\)3" "template object, static derived enum"
 
 # 2002-08-16
 # Four.
Index: gdb/testsuite/gdb.cp/namespace.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/namespace.exp,v
retrieving revision 1.16
diff -u -r1.16 namespace.exp
--- gdb/testsuite/gdb.cp/namespace.exp	19 Jan 2010 18:11:19 -0000	1.16
+++ gdb/testsuite/gdb.cp/namespace.exp	12 Feb 2010 15:38:06 -0000
@@ -273,4 +273,4 @@
 gdb_test "print XOtherFile" "No symbol \"XOtherFile\" in current context."
 
 # Enum tests.
-gdb_test "print AAA::ALPHA" "\\$\[0-9\].* = AAA::ALPHA"
+gdb_test "print AAA::ALPHA" "\\$\[0-9\].* = AAA::ALPHA = \\(enum AAA::SomeEnum\\)0"
Index: gdb/testsuite/gdb.mi/mi-var-display.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-display.exp,v
retrieving revision 1.34
diff -u -r1.34 mi-var-display.exp
--- gdb/testsuite/gdb.mi/mi-var-display.exp	1 Jan 2010 07:32:03 -0000	1.34
+++ gdb/testsuite/gdb.mi/mi-var-display.exp	12 Feb 2010 15:38:07 -0000
@@ -568,7 +568,7 @@
 # Test: c_variable-7.61
 # Desc: value of anone
 mi_gdb_test "-var-evaluate-expression anone" \
-	"\\^done,value=\"A\"" \
+	"\\^done,value=\"A = \\(enum <anonymous>\\)0\"" \
 	"eval variable anone"
 
 # Test: c_variable-7.70
Index: gdb/testsuite/gdb.mi/mi2-var-display.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-var-display.exp,v
retrieving revision 1.27
diff -u -r1.27 mi2-var-display.exp
--- gdb/testsuite/gdb.mi/mi2-var-display.exp	1 Jan 2010 07:32:03 -0000	1.27
+++ gdb/testsuite/gdb.mi/mi2-var-display.exp	12 Feb 2010 15:38:08 -0000
@@ -567,7 +567,7 @@
 # Test: c_variable-7.61
 # Desc: value of anone
 mi_gdb_test "-var-evaluate-expression anone" \
-	"\\^done,value=\"A\"" \
+	"\\^done,value=\"A = \\(enum <anonymous>\\)0\"" \
 	"eval variable anone"
 
 # Test: c_variable-7.70
Index: gdb/testsuite/gdb.python/py-value.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-value.exp,v
retrieving revision 1.5
diff -u -r1.5 py-value.exp
--- gdb/testsuite/gdb.python/py-value.exp	14 Jan 2010 08:03:37 -0000	1.5
+++ gdb/testsuite/gdb.python/py-value.exp	12 Feb 2010 15:38:08 -0000
@@ -115,7 +115,7 @@
   gdb_test "python print 'result = ' + str(1.5+f)" " = 2.75" "add python float with double value"
 
   # Conversion test.
-  gdb_test "print evalue" " = TWO"
+  gdb_test "print evalue" " = TWO = \\(enum e\\)2"
   gdb_test "python evalue = gdb.history (0)" ""
   gdb_test "python print int (evalue)" "2"
 

[-- Attachment #3: pr11067-check.diff --]
[-- Type: text/plain, Size: 1917 bytes --]

--- gdb-virgin.sum	2010-02-10 08:57:04.980039916 -0500
+++ gdb-patched.sum	2010-02-12 10:36:03.075165127 -0500
@@ -1,4 +1,4 @@
-Test Run By moller on Wed Feb 10 08:49:14 2010
+Test Run By moller on Fri Feb 12 10:27:31 2010
 Native configuration is i686-pc-linux-gnu
 
 		=== gdb tests ===
@@ -5646,6 +5646,10 @@
 PASS: gdb.base/pr11022.exp: breakpoint hit 2
 PASS: gdb.base/pr11022.exp: set var x = 1
 PASS: gdb.base/pr11022.exp: watchpoint hit 2
+Running ../../../src/gdb/testsuite/gdb.base/pr11067.exp ...
+PASS: gdb.base/pr11067.exp: print e
+PASS: gdb.base/pr11067.exp: print ea
+PASS: gdb.base/pr11067.exp: print es
 Running ../../../src/gdb/testsuite/gdb.base/prelink.exp ...
 PASS: gdb.base/prelink.exp: prelink
 Running ../../../src/gdb/testsuite/gdb.base/printcmds.exp ...
@@ -12669,6 +12673,7 @@
 PASS: gdb.mi/mi-simplerun.exp: step at main
 PASS: gdb.mi/mi-simplerun.exp: step to callee4
 PASS: gdb.mi/mi-simplerun.exp: exec-finish
+FAIL: gdb.mi/mi-simplerun.exp: continue to end (failed to resume)
 PASS: gdb.mi/mi-simplerun.exp: continue to end
 Running ../../../src/gdb/testsuite/gdb.mi/mi-stack.exp ...
 PASS: gdb.mi/mi-stack.exp: breakpoint at callee4
@@ -15509,7 +15514,7 @@
 PASS: gdb.threads/watchthreads.exp: successfully compiled posix threads test case
 PASS: gdb.threads/watchthreads.exp: watch args[0]
 PASS: gdb.threads/watchthreads.exp: watch args[1]
-PASS: gdb.threads/watchthreads.exp: disable 3
+PASS: gdb.threads/watchthreads.exp: disable 2
 PASS: gdb.threads/watchthreads.exp: threaded watch loop
 PASS: gdb.threads/watchthreads.exp: first watchpoint on args[0] hit
 PASS: gdb.threads/watchthreads.exp: first watchpoint on args[1] hit
@@ -15713,8 +15718,8 @@
 
 		=== gdb Summary ===
 
-# of expected passes		14910
-# of unexpected failures	22
+# of expected passes		14913
+# of unexpected failures	23
 # of expected failures		41
 # of untested testcases		3
 # of unsupported tests		64

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-12 15:48       ` Chris Moller
@ 2010-02-13 11:49         ` Jan Kratochvil
  2010-02-13 18:56           ` Chris Moller
  0 siblings, 1 reply; 18+ messages in thread
From: Jan Kratochvil @ 2010-02-13 11:49 UTC (permalink / raw)
  To: Chris Moller; +Cc: gdb-patches

Hi Chris,

On Fri, 12 Feb 2010 16:48:13 +0100, Chris Moller wrote:
> --- gdb/testsuite/gdb.mi/mi-var-display.exp	1 Jan 2010 07:32:03 -0000	1.34
> +++ gdb/testsuite/gdb.mi/mi-var-display.exp	12 Feb 2010 15:38:07 -0000
>  mi_gdb_test "-var-evaluate-expression anone" \
> -	"\\^done,value=\"A\"" \
> +	"\\^done,value=\"A = \\(enum <anonymous>\\)0\"" \
>  	"eval variable anone"

While it works with Eclipse should this format be used even for MI?
MI doc says:
	returns its value as a string.

It is true it may be the same what `print' doc says:
	By default, GDB prints a value according to its data type.

Still IMO the representation "A = (enum <anonymous>)0" is not suitable for MI
as it is not the intended type of a C expression.

But in practice for Eclipse it works and it brings better user experience - as
in CLI.


Some GNU Coding Standard nitpicks:


> Index: gdb/ChangeLog$
> +Wed Feb 10 17:13:44 2010  Chris Moller  <moller@mollerware.com>

timestamp line does not follow GCS.


> +	/*
> +	  When printing a simple enum value, the following code includes, in
> +	  addition to the symbolic value, the numeric value and the enum tag.
> +	  Under other-than-simple circumstances--in structs, arrays, etc.--
> +	  it does what's always done and prints just the symbolic value.
> +	*/

GCS comment should be formatted:
 /* text...
    text.  */


> +	    else if (TYPE_TAG_NAME(type))
> +	      enum_name = TYPE_TAG_NAME(type);

GCS spacing: -> "TYPE_TAG_NAME (type)"

> +	    else
> +	      enum_name = "<anonymous>";
> +	  
= +^I  $

git diff --check says:
gdb/c-valprint.c:433: trailing whitespace.

(but unaware how to check an already axisting .patch file)

> +	    fprintf_filtered (stream, "%s = (enum %s)%s",
->
# +	    fprintf_filtered (stream, "%s = (enum %s) %s",

while PR 11067 shows it that way GCS 5.3 suggests a whitespace there:
     foo = (char *) malloc (sizeof *foo);


> +++ gdb/testsuite/gdb.base/pr11067.c	12 Feb 2010 15:38:05 -0000
> @@ -0,0 +1,48 @@
> +enum E {
> +  Val1 = 56,
> +  Val2
> +};

According to GNU indent it should be:

enum E
{
  Val1 = 56,
  Val2
};


> +struct Es {

ditto

> +int main() {

GCS:
int
main ()
{


> +  /*
> +    The following is a fake-out for linkers (such as, apparently, the AIX
> +    linker) that optimises out unreference variables.
> +  */

Comment -> GCS.

> +  return 0;
> +}
> +

trailing whitespace line.


> +++ gdb/testsuite/gdb.base/pr11067.exp	12 Feb 2010 15:38:05 -0000
> +gdb_test "print e"  "Val1 = \\(enum E\\)56"
> +
> +gdb_test "print ea"  "{Val1, Val2, Val1}"
> +

Two spaces.

GDB testscases use more a practice to expect also leading " = ":
gdb_test "print e" " = Val1 = \\(enum E\\)56"
gdb_test "print ea" " = {Val1, Val2, Val1}"

> +gdb_test "print es"  "v = 5, e = Val2}"

+ IMO missing opening bracket.

gdb_test "print es" " = {v = 5, e = Val2}"



Regards,
Jan


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-13 11:49         ` Jan Kratochvil
@ 2010-02-13 18:56           ` Chris Moller
  2010-02-19 14:28             ` Joel Brobecker
  0 siblings, 1 reply; 18+ messages in thread
From: Chris Moller @ 2010-02-13 18:56 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

On 02/13/10 06:49, Jan Kratochvil wrote:
> Hi Chris,
>
> On Fri, 12 Feb 2010 16:48:13 +0100, Chris Moller wrote:
>    
>> --- gdb/testsuite/gdb.mi/mi-var-display.exp	1 Jan 2010 07:32:03 -0000	1.34
>> +++ gdb/testsuite/gdb.mi/mi-var-display.exp	12 Feb 2010 15:38:07 -0000
>>   mi_gdb_test "-var-evaluate-expression anone" \
>> -	"\\^done,value=\"A\"" \
>> +	"\\^done,value=\"A = \\(enum<anonymous>\\)0\"" \
>>   	"eval variable anone"
>>      
>
> While it works with Eclipse should this format be used even for MI?
> MI doc says:
> 	returns its value as a string.
>
> It is true it may be the same what `print' doc says:
> 	By default, GDB prints a value according to its data type.
>
> Still IMO the representation "A = (enum<anonymous>)0" is not suitable for MI
> as it is not the intended type of a C expression.

Yeah, as I said last week, I've never been a fan of breaking historical 
behaviour, something my original patch was designed to avoid.

This has gone way past ridiculous--it's time this whole thing was 
resolved as WONTFIX and closed.

cm


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-13 18:56           ` Chris Moller
@ 2010-02-19 14:28             ` Joel Brobecker
  2010-02-19 14:36               ` Jan Kratochvil
  0 siblings, 1 reply; 18+ messages in thread
From: Joel Brobecker @ 2010-02-19 14:28 UTC (permalink / raw)
  To: Chris Moller; +Cc: Jan Kratochvil, gdb-patches

Hi Chris,

I finally had a bit of time to look at your last patch. I agree with
Jan's comments on the patch (formatting issues, mostly, right?), and
I have no other comments. The C code in the testsuite doesn't necessarily
need to follow the GCS, I think, but it's probably not much trouble
fixing it.  

> This has gone way past ridiculous--it's time this whole thing was
> resolved as WONTFIX and closed.

I respect either decision you might take. Again, I feel guilty about
jumping in the discussion really late. However, I should say that I am OK
with your latest version with the little tweaks suggested by Jan, if
you want to commit that. Jan's question, IMO (Jan, please correct me if
I am wrong), were meant as a discussion starter, rather than an objection.

-- 
Joel


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-19 14:28             ` Joel Brobecker
@ 2010-02-19 14:36               ` Jan Kratochvil
  2010-02-19 14:45                 ` Joel Brobecker
  2010-02-19 14:54                 ` Chris Moller
  0 siblings, 2 replies; 18+ messages in thread
From: Jan Kratochvil @ 2010-02-19 14:36 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Chris Moller, gdb-patches

Hi Chris,

On Fri, 19 Feb 2010 15:28:46 +0100, Joel Brobecker wrote:
> Jan's question, IMO (Jan, please correct me if I am wrong), were meant as
> a discussion starter, rather than an objection.

yes.  As I said in practice it is an improvement even for MI (at least for
Eclipse CDT (CDI)) but formally I do not find it right for MI (as such diplay
feature should be done by MI frontend and not the MI backend IMO).

IMHO I would do the change for CLI but not for the MI.  But besides no
approval rights I am even not a regular MI/frontend user.  So just my $0.02.


Regards,
Jan


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-19 14:36               ` Jan Kratochvil
@ 2010-02-19 14:45                 ` Joel Brobecker
  2010-02-19 14:54                 ` Chris Moller
  1 sibling, 0 replies; 18+ messages in thread
From: Joel Brobecker @ 2010-02-19 14:45 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Chris Moller, gdb-patches

> IMHO I would do the change for CLI but not for the MI.  But besides no
> approval rights I am even not a regular MI/frontend user.  So just my $0.02.

If I'm sensing things right, I don't think that Chris actually disagrees
with you, it's just that we've been um'ing and am'ing back and forth
a little too much and discouraged him as a result. I'm ready to bet that
Chris would be happy letting anyone take his patch over and improve it.

(I tend to agree with you on your comment, btw)

-- 
Joel


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-19 14:36               ` Jan Kratochvil
  2010-02-19 14:45                 ` Joel Brobecker
@ 2010-02-19 14:54                 ` Chris Moller
  2010-02-19 18:50                   ` Jan Kratochvil
  1 sibling, 1 reply; 18+ messages in thread
From: Chris Moller @ 2010-02-19 14:54 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Joel Brobecker, gdb-patches

On 02/19/10 09:36, Jan Kratochvil wrote:
> Hi Chris,
>
> On Fri, 19 Feb 2010 15:28:46 +0100, Joel Brobecker wrote:
>    
>> Jan's question, IMO (Jan, please correct me if I am wrong), were meant as
>> a discussion starter, rather than an objection.
>>      
>
> yes.  As I said in practice it is an improvement even for MI (at least for
> Eclipse CDT (CDI)) but formally I do not find it right for MI (as such diplay
> feature should be done by MI frontend and not the MI backend IMO).
>
> IMHO I would do the change for CLI but not for the MI.

The problem is that I don't know any way to change the enum formatting 
for CLI but leave it alone for MI-.  That's one of the reasons I 
proposed the "set enum-fmt" solution to, avoid breaking historical 
default behaviour but still giving users who wanted it the option to use 
a more informative format.

I'll be glad to dust the patch off--I haven't deleted either version--if 
people want it, and I'll even look around for some way to distinguish 
between running under CLI vs. MI if that's the right thing to do.  It 
had just gotten to the point where making a really trivial change was 
taking way more effort than it was worth.

Chris

>   But besides no
> approval rights I am even not a regular MI/frontend user.  So just my $0.02.
>
>
> Regards,
> Jan
>    


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-19 14:54                 ` Chris Moller
@ 2010-02-19 18:50                   ` Jan Kratochvil
  2010-02-19 19:52                     ` Chris Moller
  0 siblings, 1 reply; 18+ messages in thread
From: Jan Kratochvil @ 2010-02-19 18:50 UTC (permalink / raw)
  To: Chris Moller; +Cc: Joel Brobecker, gdb-patches

On Fri, 19 Feb 2010 15:53:45 +0100, Chris Moller wrote:
> The problem is that I don't know any way to change the enum
> formatting for CLI but leave it alone for MI-.
...
> some way to distinguish between running under CLI vs. MI if that's the right
> thing to do.

After I wrote the patch below according to Tom Tromey the Python pretty
printing applies even to the MI protocol values, therefore IMO it should also
apply to this new enum printing which is also some form of pretty printing.

Therefore my MI / CLI suggestion has been already rejected by the Python
pretty printing precedence and the patch below should be dropped.


Thanks,
Jan


ChangeLogged only changes to the patch:

gdb/
	* c-valprint.c (c_val_print) <TYPE_CODE_ENUM>: Add conditional
	!ENUM_NUMERIC_PRINT.
	* mi/mi-main.c (mi_cmd_data_evaluate_expression): Clear
	ENUM_NUMERIC_PRINT.
	* valprint.c (user_print_options) <enum_numeric_print>: New.
	(get_raw_print_options): Clear ENUM_NUMERIC_PRINT.
	(show_enum_numeric_print): New.
	(_initialize_valprint): Call add_setshow_boolean_cmd for
	"enum-numeric-print"..
	* valprint.h (struct value_print_options) <enum_numeric_print>: New.
	* varobj.c (value_get_print_value): Clear OPTS.ENUM_NUMERIC_PRINT.

Gdb/testsuite/
	* gdb.mi/basics.c (E): New.
	* gdb.mi/mi2-eval.exp (eval E): New.

--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -412,9 +412,30 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 	    }
 	}
       if (i < len)
-	{
+	/*
+	  When printing a simple enum value, the following code includes, in
+	  addition to the symbolic value, the numeric value and the enum tag.
+	  Under other-than-simple circumstances--in structs, arrays, etc.--
+	  it does what's always done and prints just the symbolic value.
+	*/
+	if (!options->enum_numeric_print || options->summary || recurse != 0)
 	  fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
-	}
+	else
+	  {
+	    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 = "<anonymous>";
+	  
+	    fprintf_filtered (stream, "%s = (enum %s)%s",
+			      TYPE_FIELD_NAME (type, i),
+			      enum_name,
+			      plongest (val));
+	  }
       else
 	{
 	  print_longest (stream, 'd', 0, val);
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1122,6 +1122,7 @@ mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
   /* Print the result of the expression evaluation.  */
   get_user_print_options (&opts);
   opts.deref_ref = 0;
+  opts.enum_numeric_print = 0;
   val_print (value_type (val), value_contents (val),
 	     value_embedded_offset (val), value_address (val),
 	     stb->stream, 0, &opts, current_language);
--- a/gdb/testsuite/gdb.base/Makefile.in
+++ b/gdb/testsuite/gdb.base/Makefile.in
@@ -12,7 +12,8 @@ EXECUTABLES = all-types annota1 bitfields break \
 	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
--- /dev/null
+++ b/gdb/testsuite/gdb.base/pr11067.c
@@ -0,0 +1,48 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   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 <http://www.gnu.org/licenses/>.  */
+
+enum E {
+  Val1 = 56,
+  Val2
+};
+
+struct Es {
+  int v;
+  enum E e;
+};
+
+enum E e = Val1;
+
+enum E ea[] = { Val1, Val2, Val1 };
+
+struct Es es = { 5, Val2 };
+
+int main() {
+  /*
+    The following is a fake-out for linkers (such as, apparently, the AIX
+    linker) that optimises out unreference variables.
+  */
+  
+  e = Val2;
+
+  ea[0] = Val2;
+
+  es.v = 99;
+  
+  return 0;
+}
+
--- /dev/null
+++ b/gdb/testsuite/gdb.base/pr11067.exp
@@ -0,0 +1,31 @@
+# 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 <http://www.gnu.org/licenses/>.
+
+set testfile "pr11067"
+set srcfile ${testfile}.c
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
+    return -1
+}
+
+if ![runto_main] {
+    return -1
+}
+
+gdb_test "print e"  "Val1 = \\(enum E\\)56"
+
+gdb_test "print ea"  "{Val1, Val2, Val1}"
+
+gdb_test "print es"  "v = 5, e = Val2}"
--- a/gdb/testsuite/gdb.base/setvar.exp
+++ b/gdb/testsuite/gdb.base/setvar.exp
@@ -399,18 +399,22 @@ set timeout $prev_timeout
 # GNU C supports them, some other compilers don't.
 
 if {$gcc_compiled} then {
-    gdb_test "print sef.field=sm1" ".*.\[0-9\]* = sm1"
-    gdb_test "print sef.field" ".*.\[0-9\]* = sm1" "print sef.field (sm1)"
-    gdb_test "print sef.field=s1" ".*.\[0-9\]* = s1"
-    gdb_test "print sef.field" ".*.\[0-9\]* = s1" "print sef.field (s1)"
-    gdb_test "print uef.field=u2" ".*.\[0-9\]* = u2"
-    gdb_test "print uef.field" ".*.\[0-9\]* = u2" "print uef.field (u2)"
-    gdb_test "print uef.field=u1" ".*.\[0-9\]* = u1"
-    gdb_test "print uef.field" ".*.\[0-9\]* = u1" "print uef.field (u1)"
+    gdb_test "print sef.field=sm1" ".*.\[0-9\]* = sm1 = \\(enum senum\\)-1"
+    gdb_test "print sef.field" ".*.\[0-9\]* = sm1 = \\(enum senum\\)-1" \
+	"print sef.field (sm1)"
+    gdb_test "print sef.field=s1" ".*.\[0-9\]* = s1 = \\(enum senum\\)1"
+    gdb_test "print sef.field" ".*.\[0-9\]* = s1 = \\(enum senum\\)1" \
+	"print sef.field (s1)"
+    gdb_test "print uef.field=u2" ".*.\[0-9\]* = u2 = \\(enum uenum\\)2"
+    gdb_test "print uef.field" ".*.\[0-9\]* = u2 = \\(enum uenum\\)2" \
+	"print uef.field (u2)"
+    gdb_test "print uef.field=u1" ".*.\[0-9\]* = u1 = \\(enum uenum\\)1"
+    gdb_test "print uef.field" ".*.\[0-9\]* = u1 = \\(enum uenum\\)1" \
+	"print uef.field (u1)"
 
     # Test for truncation when assigning invalid values to bitfields.
     gdb_test "print sef.field=7" \
-	".*warning: Value does not fit in 2 bits.*\[0-9\]* = sm1"
+	".*warning: Value does not fit in 2 bits.*\[0-9\]* = sm1 = \\(enum senum\\)-1"
     gdb_test "print uef.field=6" \
-	".*warning: Value does not fit in 2 bits.*\[0-9\]* = u2"
+	".*warning: Value does not fit in 2 bits.*\[0-9\]* = u2 = \\(enum uenum\\)2"
 }
--- a/gdb/testsuite/gdb.cp/classes.exp
+++ b/gdb/testsuite/gdb.cp/classes.exp
@@ -413,7 +413,7 @@ proc test_enums {} {
 
     # print the enum member
 
-    gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = (ClassWithEnum::)?green"
+    gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = (ClassWithEnum::)?green = \\(enum ClassWithEnum::PrivEnum\\)1"
 
     # ptype on the enum member
 
@@ -482,7 +482,7 @@ proc test_enums {} {
     }
 
     gdb_test_multiple "print ('ClassWithEnum::PrivEnum') 42" "print ('ClassWithEnum::PrivEnum') 42" {
-	-re "\\$\[0-9\]+ = (ClassWithEnum::)?yellow$nl$gdb_prompt $" {
+	-re "\\$\[0-9\]+ = (ClassWithEnum::)?yellow = \\(enum ClassWithEnum::PrivEnum\\)42$nl$gdb_prompt $" {
 	    # gcc 3.3.2 -gstabs+
 	    # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
 	    pass "print ('ClassWithEnum::PrivEnum') 42"
--- a/gdb/testsuite/gdb.cp/m-data.exp
+++ b/gdb/testsuite/gdb.cp/m-data.exp
@@ -71,7 +71,7 @@ gdb_test "print test1.key1" "\\$\[0-9\]* = 5" "simple object, const int"
 gdb_test "print test1.key2" "\\$\[0-9\]* = 4589" "simple object, long"
 
 # simple object, enum
-gdb_test "print test1.value" "\\$\[0-9\]* = egyptian" "simple object, enum"
+gdb_test "print test1.value" "\\$\[0-9\]* = egyptian = \\(enum region\\)1" "simple object, enum"
 
 # Two.
 
@@ -85,10 +85,10 @@ gdb_test "print test2.key1" "\\$\[0-9\]* = 5" "derived template object, base con
 gdb_test "print test2.key2" "\\$\[0-9\]* = 7" "derived template object, base long"
 
 # derived template object, base enum
-gdb_test "print test2.value" "\\$\[0-9\]* = oriental" "derived template object, base enum"
+gdb_test "print test2.value" "\\$\[0-9\]* = oriental = \\(enum region\\)0" "derived template object, base enum"
 
 # derived template object, enum
-gdb_test "print test2.value_derived" "\\$\[0-9\]* = roman" "derived template object, derived enum"
+gdb_test "print test2.value_derived" "\\$\[0-9\]* = roman = \\(enum region\\)4" "derived template object, derived enum"
 
 # Three.
 
@@ -102,10 +102,10 @@ gdb_test "print test3.data.key1" "\\$\[0-9\]* = 5" "template object, const int"
 gdb_test "print test3.data.key2" "\\$\[0-9\]* = 7" "template object, long"
 
 # template object, derived template data member's base enum
-gdb_test "print test3.data.value" "\\$\[0-9\]* = oriental" "template object, base enum"
+gdb_test "print test3.data.value" "\\$\[0-9\]* = oriental = \\(enum region\\)0" "template object, base enum"
 
 # template object, derived template data member's enum
-gdb_test "print test3.data.value_derived" "\\$\[0-9]\* = etruscan" "template object, derived enum"
+gdb_test "print test3.data.value_derived" "\\$\[0-9]\* = etruscan = \\(enum region\\)3" "template object, derived enum"
 
 # Now some tests for shadowing (see PR gdb/804):
 
--- a/gdb/testsuite/gdb.cp/m-static.exp
+++ b/gdb/testsuite/gdb.cp/m-static.exp
@@ -82,7 +82,7 @@ gdb_test "print test1.key1" "\\$\[0-9\]* = 5" "simple object, static const int"
 gdb_test "print test1.key2" "\\$\[0-9\]* = 77" "simple object, static long"
 
 # simple object, static enum
-gdb_test "print test1.value" "\\$\[0-9\]* = oriental" "simple object, static enum"
+gdb_test "print test1.value" "\\$\[0-9\]* = oriental = \\(enum region\\)0" "simple object, static enum"
 
 # Two.
 
@@ -96,10 +96,10 @@ gdb_test "print test2.key1" "\\$\[0-9\]* = 5" "derived template object, base sta
 gdb_test "print test2.key2" "\\$\[0-9\]* = 77" "derived template object, base static long"
 
 # derived template object, base static enum
-gdb_test "print test2.value" "\\$\[0-9\].* = oriental" "derived template object, base static enum"
+gdb_test "print test2.value" "\\$\[0-9\].* = oriental = \\(enum region\\)0" "derived template object, base static enum"
 
 # derived template object, static enum
-gdb_test "print test2.value_derived" "\\$\[0-9\].* = etruscan" "derived template object, static enum"
+gdb_test "print test2.value_derived" "\\$\[0-9\].* = etruscan = \\(enum region\\)3" "derived template object, static enum"
 
 # Three.
 
@@ -113,10 +113,10 @@ gdb_test "print test3.data.key1" "\\$\[0-9\].* = 5" "template object, static con
 gdb_test "print test3.data.key2" "\\$\[0-9\].* = 77" "template object, static long"
 
 # template object, static derived template data member's base static enum
-gdb_test "print test3.data.value" "\\$\[0-9\].* = oriental" "template object, static enum"
+gdb_test "print test3.data.value" "\\$\[0-9\].* = oriental = \\(enum region\\)0" "template object, static enum"
 
 #  template object, static derived template data member's static enum
-gdb_test "print test3.data.value_derived" "\\$\[0-9\].* = etruscan" "template object, static derived enum"
+gdb_test "print test3.data.value_derived" "\\$\[0-9\].* = etruscan = \\(enum region\\)3" "template object, static derived enum"
 
 # 2002-08-16
 # Four.
--- a/gdb/testsuite/gdb.cp/namespace.exp
+++ b/gdb/testsuite/gdb.cp/namespace.exp
@@ -273,4 +273,4 @@ gdb_test "print cXOtherFile" "No symbol \"cXOtherFile\" in current context."
 gdb_test "print XOtherFile" "No symbol \"XOtherFile\" in current context."
 
 # Enum tests.
-gdb_test "print AAA::ALPHA" "\\$\[0-9\].* = AAA::ALPHA"
+gdb_test "print AAA::ALPHA" "\\$\[0-9\].* = AAA::ALPHA = \\(enum AAA::SomeEnum\\)0"
--- a/gdb/testsuite/gdb.mi/basics.c
+++ b/gdb/testsuite/gdb.mi/basics.c
@@ -24,6 +24,8 @@ Free Software Foundation, Inc.
 #include <stdio.h>
 #include <unistd.h>
 
+static enum enum_name { enumerator } E = enumerator;
+
 int callee4 (void)
 {
   int A=1;
--- a/gdb/testsuite/gdb.mi/mi2-eval.exp
+++ b/gdb/testsuite/gdb.mi/mi2-eval.exp
@@ -58,6 +58,8 @@ mi_gdb_test "411-data-evaluate-expression A+3" "411\\^done,value=\"4\"" "eval A+
 
 mi_gdb_test "511-data-evaluate-expression \"A + 3\"" "511\\^done,value=\"4\"" "eval A + 3"
 
+mi_gdb_test "611-data-evaluate-expression \"E\"" "611\\^done,value=\"enumerator\"" "eval E"
+
 
 mi_gdb_exit
 return 0
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -115,7 +115,7 @@ proc test_value_numeric_ops {} {
   gdb_test "python print 'result = ' + str(1.5+f)" " = 2.75" "add python float with double value"
 
   # Conversion test.
-  gdb_test "print evalue" " = TWO"
+  gdb_test "print evalue" " = TWO = \\(enum e\\)2"
   gdb_test "python evalue = gdb.history (0)" ""
   gdb_test "python print int (evalue)" "2"
 
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -83,7 +83,8 @@ struct value_print_options user_print_options =
   1,				/* static_field_print */
   1,				/* pascal_static_field_print */
   0,				/* raw */
-  0				/* summary */
+  0,				/* summary */
+  1				/* enum_numeric_print */
 };
 
 /* Initialize *OPTS to be a copy of the user print options.  */
@@ -100,6 +101,7 @@ get_raw_print_options (struct value_print_options *opts)
 {  
   *opts = user_print_options;
   opts->pretty = Val_no_prettyprint;
+  opts->enum_numeric_print = 0;
 }
 
 /* Initialize *OPTS to be a copy of the user print options, but using
@@ -154,6 +156,17 @@ show_print_array_indexes (struct ui_file *file, int from_tty,
   fprintf_filtered (file, _("Printing of array indexes is %s.\n"), value);
 }
 
+/* If nonzero print also the numeric value of enum elements.  */
+
+static void
+show_enum_numeric_print (struct ui_file *file, int from_tty,
+			 struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file, _("\
+Printing of enum values with their numerical values is %s.\n"),
+		    value);
+}
+
 /* Print repeat counts if there are more than this many repetitions of an
    element in an array.  Referenced by the low level language dependent
    print routines. */
@@ -1734,4 +1747,12 @@ Use 'show input-radix' or 'show output-radix' to independently show each."),
 Set printing of array indexes."), _("\
 Show printing of array indexes"), NULL, NULL, show_print_array_indexes,
                            &setprintlist, &showprintlist);
+
+  add_setshow_boolean_cmd ("enum-numeric-print", class_support,
+			   &user_print_options.enum_numeric_print, _("\
+Set printing of enum values with their numerical values."), _("\
+Show printing of enum values with their numerical values."), NULL,
+			   NULL,
+			   show_enum_numeric_print,
+			   &setprintlist, &showprintlist);
 }
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -90,6 +90,9 @@ struct value_print_options
 
   /* If nonzero, print the value in "summary" form.  */
   int summary;
+
+  /* If nonzero print also the numeric value of enum elements.  */
+  int enum_numeric_print;
 };
 
 /* The global print options set by the user.  In general this should
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2544,6 +2544,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
   get_formatted_print_options (&opts, format_code[(int) format]);
   opts.deref_ref = 0;
   opts.raw = 1;
+  opts.enum_numeric_print = 0;
   if (thevalue)
     {
       make_cleanup (xfree, thevalue);


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-19 18:50                   ` Jan Kratochvil
@ 2010-02-19 19:52                     ` Chris Moller
  2010-02-19 20:11                       ` Jan Kratochvil
  0 siblings, 1 reply; 18+ messages in thread
From: Chris Moller @ 2010-02-19 19:52 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Joel Brobecker, gdb-patches

On 02/19/10 13:50, Jan Kratochvil wrote:
> On Fri, 19 Feb 2010 15:53:45 +0100, Chris Moller wrote:
>    
>> The problem is that I don't know any way to change the enum
>> formatting for CLI but leave it alone for MI-.
>>      
> ...
>    
>> some way to distinguish between running under CLI vs. MI if that's the right
>> thing to do.
>>      
>
> After I wrote the patch below according to Tom Tromey the Python pretty
> printing applies even to the MI protocol values, therefore IMO it should also
> apply to this new enum printing which is also some form of pretty printing.
>
> Therefore my MI / CLI suggestion has been already rejected by the Python
> pretty printing precedence and the patch below should be dropped.
>    

How about this:  The existing patch contains a test

      if (options->summary || recurse != 0)
          fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
    else {
       /* new formatting stuff */
    }

That limited the format change to unsummarised top-level "p <enum 
thingy>" circumstances.  If I make that test

      if (options->summary || recurse != 0 ||
                 ui_out_is_mi_like_p (interp_ui_out
    (top_level_interpreter ())))

i.e., checking if the print is to an MI whatever-it-is, the MI tests 
that failed under the original patch (mi-var-display and 
mi2-var-display) run okay as they originally were, which suggests to me 
that MI will go on getting enums formatted the way it expects them.  
Will that work?

Chris


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-19 19:52                     ` Chris Moller
@ 2010-02-19 20:11                       ` Jan Kratochvil
  2010-02-22  9:22                         ` Vladimir Prus
  2010-02-23 23:55                         ` Tom Tromey
  0 siblings, 2 replies; 18+ messages in thread
From: Jan Kratochvil @ 2010-02-19 20:11 UTC (permalink / raw)
  To: Vladimir Prus; +Cc: Joel Brobecker, gdb-patches, Chris Moller

On Fri, 19 Feb 2010 20:51:36 +0100, Chris Moller wrote:
> That limited the format change to unsummarised top-level "p <enum
> thingy>" circumstances.  If I make that test
> 
>      if (options->summary || recurse != 0 ||
>                 ui_out_is_mi_like_p (interp_ui_out
>    (top_level_interpreter ())))
> 
> i.e., checking if the print is to an MI whatever-it-is, the MI tests
> that failed under the original patch (mi-var-display and
> mi2-var-display) run okay as they originally were, which suggests to
> me that MI will go on getting enums formatted the way it expects
> them.  Will that work?

I would prefer the value_print_options way but rather:


Vladimir, if CLI start print instead of
	(gdb) p enum_var
	$1 = enumerator2
now:
	(gdb) p enum_var
	$1 = enumerator2 = (enum uenum) 2

should MI also print this "pretty printed" enum syntax or should it stick with
the original one? Therefore should be made this change?

 mi_gdb_test "-var-evaluate-expression anone" \
-       "\\^done,value=\"A\"" \
+       "\\^done,value=\"A = \\(enum <anonymous>\\)0\"" \
        "eval variable anone"


Thanks,
Jan


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-19 20:11                       ` Jan Kratochvil
@ 2010-02-22  9:22                         ` Vladimir Prus
  2010-02-23 23:55                         ` Tom Tromey
  1 sibling, 0 replies; 18+ messages in thread
From: Vladimir Prus @ 2010-02-22  9:22 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Joel Brobecker, gdb-patches, Chris Moller

On Friday 19 February 2010 23:11:05 Jan Kratochvil wrote:

> On Fri, 19 Feb 2010 20:51:36 +0100, Chris Moller wrote:
> > That limited the format change to unsummarised top-level "p <enum
> > thingy>" circumstances.  If I make that test
> > 
> >      if (options->summary || recurse != 0 ||
> >                 ui_out_is_mi_like_p (interp_ui_out
> >    (top_level_interpreter ())))
> > 
> > i.e., checking if the print is to an MI whatever-it-is, the MI tests
> > that failed under the original patch (mi-var-display and
> > mi2-var-display) run okay as they originally were, which suggests to
> > me that MI will go on getting enums formatted the way it expects
> > them.  Will that work?
> 
> I would prefer the value_print_options way but rather:
> 
> 
> Vladimir, if CLI start print instead of
> 	(gdb) p enum_var
> 	$1 = enumerator2
> now:
> 	(gdb) p enum_var
> 	$1 = enumerator2 = (enum uenum) 2
> 
> should MI also print this "pretty printed" enum syntax or should it stick with
> the original one? Therefore should be made this change?
> 
>  mi_gdb_test "-var-evaluate-expression anone" \
> -       "\\^done,value=\"A\"" \
> +       "\\^done,value=\"A = \\(enum <anonymous>\\)0\"" \
>         "eval variable anone"

Hi Jan,

I am not 100% sure but I am concerned about the above output having 'enum uenum' --
which is essentially the type of the variable. And MI already reports type separately.
I recall I've made some changed before to specifically stop GDB from including the 
type of variable inside value field when the type is function. So, I suggest that
this output is not included for MI. It might be OK to output a separate
field, e.g. "enum_integer_value" -- with the integer value as printed above -- but
I don't have a feeling if frontends really need that at this point.

Thanks,

-- 
Vladimir Prus
CodeSourcery
vladimir@codesourcery.com
(650) 331-3385 x722


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch
  2010-02-19 20:11                       ` Jan Kratochvil
  2010-02-22  9:22                         ` Vladimir Prus
@ 2010-02-23 23:55                         ` Tom Tromey
  2010-03-11 15:44                           ` pr 11067 patch resurrected from the dead Chris Moller
  1 sibling, 1 reply; 18+ messages in thread
From: Tom Tromey @ 2010-02-23 23:55 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Vladimir Prus, Joel Brobecker, gdb-patches, Chris Moller

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Finally catching up on this thread...

Jan> I would prefer the value_print_options way but rather:

Yes, I think value_print_options is preferable to checking
ui_out_is_mi_like_p.  My reason is that getting the ui-out object
involves looking at some global state, whereas value_print_options is
local to the call hierarchy.  This means that it is simpler to reason
about and modify.

Tom


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: pr 11067 patch resurrected from the dead
  2010-02-23 23:55                         ` Tom Tromey
@ 2010-03-11 15:44                           ` Chris Moller
  0 siblings, 0 replies; 18+ messages in thread
From: Chris Moller @ 2010-03-11 15:44 UTC (permalink / raw)
  To: tromey; +Cc: Jan Kratochvil, Vladimir Prus, Joel Brobecker, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1520 bytes --]

On 02/23/10 18:54, Tom Tromey wrote:
>>>>>> "Jan" == Jan Kratochvil<jan.kratochvil@redhat.com>  writes:
>>>>>>              
>
> Finally catching up on this thread...
>
> Jan>  I would prefer the value_print_options way but rather:
>    

Okay, folks, I dusted this off and spun another simple patch using 
value_print_options.  Given an enum:

    enum tt {
       T0,
       T1,
       T2
    };

    enum tt tf = T1;

If you do

    p /f tf

you'll get

    $1 = T1 = (enum tt)1

of instead of the

    $2 = T1

you'd get without the /f flag.  (It's "/f" because 'f' isn't otherwise 
used for enums--'f' for "fancy" or something like that.)

It also doesn't differentiate between printing single enums and enums in 
more complex things like arrays.  Given

    enum tt ta[] = { T1, T0, T2 };

The result would be:

    p /f ta
    $3 = {T1 = (enum tt)1, T0 = (enum tt)0, T2 = (enum tt)2}

As an alternative, maybe it could print something like

    $2 = (enum tt)1 <T1>

which kind looks like the result of printing a character.

As you can see in the attached check summary diff, this patch doesn't do 
a thing to MI or anything else.

If people like this, great.  Otherwise, I'll leave it dead and buried.

> Yes, I think value_print_options is preferable to checking
> ui_out_is_mi_like_p.  My reason is that getting the ui-out object
> involves looking at some global state, whereas value_print_options is
> local to the call hierarchy.  This means that it is simpler to reason
> about and modify.
>
> Tom
>    


[-- Attachment #2: pr11067.patch --]
[-- Type: text/x-patch, Size: 3815 bytes --]

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 = "<anonymous>";
+
+	  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 <stdio.h>
+
+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 <http://www.gnu.org/licenses/>.
+
+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 <anonymous>\\)2.*"

[-- Attachment #3: pr11067-check.diff --]
[-- Type: text/x-patch, Size: 1475 bytes --]

--- ../../../gdb-virgin.sum	2010-03-09 21:36:05.994326240 -0500
+++ gdb.sum	2010-03-11 10:26:51.188200869 -0500
@@ -1,4 +1,4 @@
-Test Run By moller on Tue Mar  9 19:14:09 2010
+Test Run By moller on Thu Mar 11 10:18:45 2010
 Native configuration is i686-pc-linux-gnu
 
 		=== gdb tests ===
@@ -5703,6 +5703,9 @@
 PASS: gdb.base/pr11022.exp: breakpoint hit 2
 PASS: gdb.base/pr11022.exp: set var x = 1
 PASS: gdb.base/pr11022.exp: watchpoint hit 2
+Running ../../../src/gdb/testsuite/gdb.base/pr11067.exp ...
+PASS: gdb.base/pr11067.exp: p /f tf
+PASS: gdb.base/pr11067.exp: p /f ef
 Running ../../../src/gdb/testsuite/gdb.base/prelink.exp ...
 PASS: gdb.base/prelink.exp: set verbose on
 PASS: gdb.base/prelink.exp: prelink
@@ -16058,7 +16061,7 @@
 PASS: gdb.threads/watchthreads2.exp: all threads started
 PASS: gdb.threads/watchthreads2.exp: watch x
 PASS: gdb.threads/watchthreads2.exp: set var test_ready = 1
-PASS: gdb.threads/watchthreads2.exp: all threads incremented x
+KFAIL: gdb.threads/watchthreads2.exp: gdb can drop watchpoints in multithreaded app (PRMS: gdb/10116)
 Running ../../../src/gdb/testsuite/gdb.trace/actions.exp ...
 PASS: gdb.trace/actions.exp: 5.1a: set three tracepoints, no actions
 PASS: gdb.trace/actions.exp: 5.1b: set actions for first tracepoint
@@ -16259,7 +16262,7 @@
 
 		=== gdb Summary ===
 
-# of expected passes		15452
+# of expected passes		15453
 # of unexpected failures	16
 # of expected failures		43
 # of untested testcases		3

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2010-03-11 15:44 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-11  2:55 pr 11067 patch Chris Moller
2010-02-11  9:30 ` Joel Brobecker
2010-02-11 14:19   ` Chris Moller
2010-02-11 19:50   ` Tom Tromey
2010-02-12  4:11     ` Joel Brobecker
2010-02-12 15:48       ` Chris Moller
2010-02-13 11:49         ` Jan Kratochvil
2010-02-13 18:56           ` Chris Moller
2010-02-19 14:28             ` Joel Brobecker
2010-02-19 14:36               ` Jan Kratochvil
2010-02-19 14:45                 ` Joel Brobecker
2010-02-19 14:54                 ` Chris Moller
2010-02-19 18:50                   ` Jan Kratochvil
2010-02-19 19:52                     ` Chris Moller
2010-02-19 20:11                       ` Jan Kratochvil
2010-02-22  9:22                         ` Vladimir Prus
2010-02-23 23:55                         ` Tom Tromey
2010-03-11 15:44                           ` pr 11067 patch resurrected from the dead Chris Moller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox