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]

[patch] Fix: Regression for gdb.trace/unavailable.exp [Re: [5/5] reimplement 'set print vtbl on']


On Tue, 20 Mar 2012 08:20:48 +0100, Jan Kratochvil wrote:
> On Thu, 15 Mar 2012 16:49:19 +0100, Tom Tromey wrote:
> > 2012-03-15  Tom Tromey  <tromey@redhat.com>
> > 
> > 	* cp-valprint.c (cp_print_value_fields): Use
> > 	print_function_pointer_address for vtable slot.
[...]
> cdfae53fa67f5576d6a15500bba8ea3fb7e5aa71 is the first bad commit
[...]
> On {x86_64,x86_64-m32,i686}-fedora17-linux-gnu in gdbserver non-extended mode,
> (Probably on any platform in gdbserver non-extended mode.)
> 
> -PASS: gdb.trace/unavailable.exp: collect globals: print object on: print derived_unavail
> -PASS: gdb.trace/unavailable.exp: collect globals: print object on: print derived_partial
> -PASS: gdb.trace/unavailable.exp: collect globals: print object on: print derived_whole
> +FAIL: gdb.trace/unavailable.exp: collect globals: print object on: print derived_unavail
> +FAIL: gdb.trace/unavailable.exp: collect globals: print object on: print derived_partial
> +FAIL: gdb.trace/unavailable.exp: collect globals: print object on: print derived_whole
> -PASS: gdb.trace/unavailable.exp: collect globals: print object off: print derived_unavail
> -PASS: gdb.trace/unavailable.exp: collect globals: print object off: print derived_partial
> -PASS: gdb.trace/unavailable.exp: collect globals: print object off: print derived_whole
> -PASS: gdb.trace/unavailable.exp: collect globals: print virtual_partial
> +FAIL: gdb.trace/unavailable.exp: collect globals: print object off: print derived_unavail
> +FAIL: gdb.trace/unavailable.exp: collect globals: print object off: print derived_partial
> +FAIL: gdb.trace/unavailable.exp: collect globals: print object off: print derived_whole
> +FAIL: gdb.trace/unavailable.exp: collect globals: print virtual_partial

-$41 = {<Middle> = <unavailable>, _vptr.Derived = 0, z = <unavailable>}^M
-(gdb) FAIL: gdb.trace/unavailable.exp: collect globals: print object on: print derived_unavail
+$41 = {<Middle> = <unavailable>, _vptr.Derived = <unavailable>, z = <unavailable>}^M
+(gdb) PASS: gdb.trace/unavailable.exp: collect globals: print object on: print derived_unavail
 - the code fix part.

 $43 = (Derived) {<Middle> = {<Base> = {x = 2}, _vptr.Middle = 0x401158, y = 3}, _vptr.Derived = 0x401140 <vtable for Derived+32>, z = 4}^M
-(gdb) FAIL: gdb.trace/unavailable.exp: collect globals: print object on: print derived_whole
+(gdb) PASS: gdb.trace/unavailable.exp: collect globals: print object on: print derived_whole
 - just missing testcase expected output update

No regressions on {x86_64,x86_64-m32,i686}-fedora17-linux-gnu.

I will check it in.


Thanks,
Jan


gdb/
2012-03-31  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* cp-valprint.c (cp_print_value_fields): Check valprint_check_validity
	for TYPE_VPTR_FIELDNO.
	* valprint.c (valprint_check_validity): Make it global, move the
	function comment ...
	* value.h (valprint_check_validity): ... to this new declaration.

gdb/testsuite/
2012-03-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.trace/unavailable.exp
	(collect globals: print object on: print derived_partial)
	(collect globals: print object on: print derived_whole)
	(collect globals: print object off: print derived_partial)
	(collect globals: print object off: print derived_whole): Update
	expected output.

--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -360,14 +360,18 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 		}
 	      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);
+		  int i_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8;
+		  struct type *i_type = TYPE_FIELD_TYPE (type, i);
+
+		  if (valprint_check_validity (stream, i_type, i_offset, val))
+		    {
+		      CORE_ADDR addr;
+		      
+		      addr = extract_typed_address (valaddr + i_offset, i_type);
+		      print_function_pointer_address (get_type_arch (type),
+						      addr, stream,
+						      options->addressprint);
+		    }
 		}
 	      else
 		{
--- a/gdb/testsuite/gdb.trace/unavailable.exp
+++ b/gdb/testsuite/gdb.trace/unavailable.exp
@@ -542,11 +542,11 @@ proc gdb_collect_globals_test { } { with_test_prefix "collect globals" {
 
 	# vtable pointer available, but nothing else
 	gdb_test "print derived_partial" \
-	    " = \\(Derived\\) {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex, z = <unavailable>}"
+	    " = \\(Derived\\) {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex <vtable for Derived.*>, z = <unavailable>}"
 
 	# whole object available
 	gdb_test "print derived_whole" \
-	    " = \\(Derived\\) {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex, z = 4}"
+	    " = \\(Derived\\) {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex <vtable for Derived.*>, z = 4}"
     }
 
     gdb_test_no_output "set print object off"
@@ -560,11 +560,11 @@ proc gdb_collect_globals_test { } { with_test_prefix "collect globals" {
 
 	# vtable pointer available, but nothing else
 	gdb_test "print derived_partial" \
-	    " = {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex, z = <unavailable>}"
+	    " = {<Middle> = {<Base> = <unavailable>, _vptr.Middle = <unavailable>, y = <unavailable>}, _vptr.Derived = $hex <vtable for Derived.*>, z = <unavailable>}"
 
 	# whole object available
 	gdb_test "print derived_whole" \
-	    " = {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex, z = 4}"
+	    " = {<Middle> = {<Base> = {x = 2}, _vptr.Middle = $hex, y = 3}, _vptr.Derived = $hex <vtable for Derived.*>, z = 4}"
     }
 
     # An instance of a virtual class where we collected everything but
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -248,17 +248,9 @@ scalar_type_p (struct type *type)
     }
 }
 
-/* Helper function to check the validity of some bits of a value.
+/* See its definition in value.h.  */
 
-   If TYPE represents some aggregate type (e.g., a structure), return 1.
-   
-   Otherwise, any of the bytes starting at OFFSET and extending for
-   TYPE_LENGTH(TYPE) bytes are invalid, print a message to STREAM and
-   return 0.  The checking is done using FUNCS.
-   
-   Otherwise, return 1.  */
-
-static int
+int
 valprint_check_validity (struct ui_file *stream,
 			 struct type *type,
 			 int embedded_offset,
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -213,6 +213,20 @@ extern struct value *allocate_computed_value (struct type *type,
 					      const struct lval_funcs *funcs,
 					      void *closure);
 
+/* Helper function to check the validity of some bits of a value.
+
+   If TYPE represents some aggregate type (e.g., a structure), return 1.
+   
+   Otherwise, any of the bytes starting at OFFSET and extending for
+   TYPE_LENGTH(TYPE) bytes are invalid, print a message to STREAM and
+   return 0.  The checking is done using FUNCS.
+   
+   Otherwise, return 1.  */
+
+extern int valprint_check_validity (struct ui_file *stream, struct type *type,
+				    int embedded_offset,
+				    const struct value *val);
+
 extern struct value *allocate_optimized_out_value (struct type *type);
 
 /* If VALUE is lval_computed, return its lval_funcs structure.  */


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