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

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