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


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

Re: [5/5] reimplement 'set print vtbl on'


Pedro> We could consider making that unconditional?

Tom> Yeah, I think I will do that.

Tom> I can leave the old code around on the off chance it is useful to
Tom> somebody with GCC 2.95.  I'm not sure this is really worthwhile, but it
Tom> does have the virtue of making the patch more obviously ok.

Pedro> Would it be hard to make "set print vtbl on" do with newer binaries what
Pedro> it supposedly does with older compiler built binaries, given the code
Pedro> you've written for "info vtable"?

Tom> I think it is doable.  I will look at it.

I went with a much simpler patch, appended.  I am going to check it in.

I looked into making 'set print vtbl on' work for newer ABIs, but I
couldn't convince myself that it was useful -- it would be very verbose,
I couldn't picture using it aside from enable-print-disable, and for
that "info vtbl $" is simpler.

Tom

2012-03-15  Tom Tromey  <tromey@redhat.com>

	* cp-valprint.c (cp_print_value_fields): Use
	print_function_pointer_address for vtable slot.

2012-03-15  Tom Tromey  <tromey@redhat.com>

	* gdb.cp/virtfunc2.exp: Update expected output.
	* gdb.cp/pr9631.exp: Update expected output.
	* gdb.cp/member-ptr.exp: Update expected output.
	* gdb.cp/inherit.exp (test_print_mvi_classes): Update expected
	output.
	* gdb.cp/casts.exp: Update expected output.

Index: cp-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-valprint.c,v
retrieving revision 1.81
diff -u -r1.81 cp-valprint.c
--- cp-valprint.c	7 Feb 2012 04:48:18 -0000	1.81
+++ cp-valprint.c	15 Mar 2012 15:48:36 -0000
@@ -358,6 +358,17 @@
 					   v, stream, recurse + 1,
 					   options);
 		}
+	      else if (i == TYPE_VPTR_FIELDNO (type))
+		{
+		  CORE_ADDR addr
+		    = extract_typed_address (valaddr + offset
+					     + TYPE_FIELD_BITSIZE (type, i) / 8,
+					     TYPE_FIELD_TYPE (type, i));
+
+		  print_function_pointer_address (get_type_arch (type),
+						  addr, stream,
+						  options->addressprint);
+		}
 	      else
 		{
 		  struct value_print_options opts = *options;
Index: testsuite/gdb.cp/casts.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/casts.exp,v
retrieving revision 1.14
diff -u -r1.14 casts.exp
--- testsuite/gdb.cp/casts.exp	16 Jan 2012 16:21:45 -0000	1.14
+++ testsuite/gdb.cp/casts.exp	15 Mar 2012 15:48:39 -0000
@@ -137,7 +137,7 @@
     "dynamic_cast upcast to unique base"
 
 gdb_test "print dynamic_cast<Alpha &> (derived)" \
-    " = \\(Alpha \\&\\) @$nonzero_hex: {.* = $nonzero_hex}" \
+    " = \\(Alpha \\&\\) @$nonzero_hex: {.* = ${nonzero_hex}( <vtable for Derived.*>)?}" \
     "dynamic_cast simple upcast to reference"
 
 gdb_test "print dynamic_cast<Derived *> (ad)" \
Index: testsuite/gdb.cp/inherit.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/inherit.exp,v
retrieving revision 1.23
diff -u -r1.23 inherit.exp
--- testsuite/gdb.cp/inherit.exp	16 Jan 2012 16:21:45 -0000	1.23
+++ testsuite/gdb.cp/inherit.exp	15 Mar 2012 15:48:39 -0000
@@ -670,7 +670,7 @@
 	    # gcc 2.95.3 -gstabs+
 	    pass $name
 	}
-	-re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_3_vB = $hex, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_3_vC = $hex, vc = 23, vx = 24\}, $re_vbptr_3_vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" {
+	-re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_3_vB = ${hex}( <vtable for vD.*>)?, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_3_vC = ${hex}( <vtable for vC.*>)?, vc = 23, vx = 24\}, $re_vbptr_3_vD = ${hex}( <vtable for vD.*>)?, vd = 25, vx = 26\}$nl$gdb_prompt $" {
 	    # gcc 3.3.2 -gdwarf-2
 	    # gcc HEAD 2004-01-21 -gdwarf-2
 	    # gcc HEAD 2004-01-21 -gstabs+
@@ -691,7 +691,7 @@
 	    # gcc 2.95.3 -gstabs+
 	    pass $name
 	}
-	-re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = $hex, vc = 0, vx = 0\}, $re_vbptr_3_vD = $hex, vd = 0, vx = 0\}, $re_vbptr_3_vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" {
+	-re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = ${hex}( <vtable for vE.*>)?, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = ${hex}( <vtable for vE.*>)?, vc = 0, vx = 0\}, $re_vbptr_3_vD = ${hex}( <vtable for vE.*>)?, vd = 0, vx = 0\}, $re_vbptr_3_vE = ${hex}( <vtable for vE.*>)?, ve = 27, vx = 28\}$nl$gdb_prompt $" {
 	    # gcc 3.3.4 -gdwarf-2
 	    # gcc 3.3.4 -gstabs+
 	    # gcc 3.4.1 -gdwarf-2
Index: testsuite/gdb.cp/member-ptr.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/member-ptr.exp,v
retrieving revision 1.17
diff -u -r1.17 member-ptr.exp
--- testsuite/gdb.cp/member-ptr.exp	16 Jan 2012 16:21:45 -0000	1.17
+++ testsuite/gdb.cp/member-ptr.exp	15 Mar 2012 15:48:39 -0000
@@ -257,7 +257,7 @@
     -re "$vhn = \{c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10, Virtual table at $hex\}\r\n$gdb_prompt $" {
 	pass $name
     }
-    -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" {
+    -re "$vhn = \{(_vptr.A|_vptr\\$) = ${hex}( <vtable for A.*>)?, c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" {
 	pass $name
     }
     -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 121, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" {
@@ -305,7 +305,7 @@
     -re "$vhn = \{c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10, Virtual table at $hex\}\r\n$gdb_prompt $" {
 	pass $name
     }
-    -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" {
+    -re "$vhn = \{(_vptr.A|_vptr\\$) = ${hex}( <vtable for A.*>), c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" {
 	pass $name
     }
     -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 121, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" {
Index: testsuite/gdb.cp/pr9631.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/pr9631.exp,v
retrieving revision 1.4
diff -u -r1.4 pr9631.exp
--- testsuite/gdb.cp/pr9631.exp	4 Jan 2012 08:17:47 -0000	1.4
+++ testsuite/gdb.cp/pr9631.exp	15 Mar 2012 15:48:39 -0000
@@ -45,4 +45,4 @@
 
 gdb_test \
   "print tender" \
-  "\\\$1 = {<foo::vbase> = {_vptr.vbase = $hex}, <empty_base> = {<No data fields>}, <No data fields>}"
+  "\\\$1 = {<foo::vbase> = {_vptr.vbase = ${hex}( <vtable for bar.*>)?}, <empty_base> = {<No data fields>}, <No data fields>}"
Index: testsuite/gdb.cp/virtbase.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/virtbase.exp,v
retrieving revision 1.8
diff -u -r1.8 virtbase.exp
--- testsuite/gdb.cp/virtbase.exp	4 Jan 2012 08:17:47 -0000	1.8
+++ testsuite/gdb.cp/virtbase.exp	15 Mar 2012 15:48:39 -0000
@@ -78,5 +78,5 @@
     " = \\(Virtual \\*\\) $hex" \
     "print same pointer from history value"
 gdb_test "print *$$" \
-    " = \\(Virtual\\) {<VirtualMiddleA> = {<VirtualBase> = {_vptr.VirtualBase = $hex, x = 0}, _vptr.VirtualMiddleA = $hex, y = \\{0 <repeats 300 times>\\}}, <VirtualMiddleB> = {_vptr.VirtualMiddleB = $hex, y = 0}, _vptr.Virtual = $hex, z = 0}" \
+    " = \\(Virtual\\) {<VirtualMiddleA> = {<VirtualBase> = {_vptr.VirtualBase = ${hex}( <vtable for Virtual.*>)?, x = 0}, _vptr.VirtualMiddleA = ${hex}( <vtable for Virtual.*>)?, y = \\{0 <repeats 300 times>\\}}, <VirtualMiddleB> = {_vptr.VirtualMiddleB = ${hex}( <vtable for Virtual.*>)?, y = 0}, _vptr.Virtual = ${hex}( <vtable for Virtual.*>)?, z = 0}" \
     "print whole pointed-to object, starting from the virtual base pointer"
Index: testsuite/gdb.cp/virtfunc2.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/virtfunc2.exp,v
retrieving revision 1.4
diff -u -r1.4 virtfunc2.exp
--- testsuite/gdb.cp/virtfunc2.exp	4 Jan 2012 08:17:47 -0000	1.4
+++ testsuite/gdb.cp/virtfunc2.exp	15 Mar 2012 15:48:39 -0000
@@ -53,6 +53,7 @@
 gdb_test "print o2.do_print2()"  "\\$\[0-9\]+ = 654321"
 gdb_test "print o2.do_print3()"  "\\$\[0-9\]+ = 111111"
 
+gdb_test "print o" " = {<interface> = {.*_vptr.interface = $hex <vtable for Obj.*>}, <No data fields>}"
 
 gdb_exit
 return 0


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