bokenness of nested pretty printers

Tom Tromey tromey@redhat.com
Thu Oct 16 19:17:00 GMT 2008


>>>>> "Paul" == Paul Pluzhnikov <ppluzhnikov@google.com> writes:

Paul> I think fixing this requires either that we pass down 'value' itself,
Paul> or at least 'value->offset'.

Thanks.  Nice analysis.

Paul> Comments?

I notice c-valprint.c does:

  return val_print (type, value_contents_all (val),
		    value_embedded_offset (val),
		    VALUE_ADDRESS (val) + value_offset (val),

That last line seems to indicate the answer.

Strangely, many calls to val_print do not do this.

I wonder why VALUE_ADDRESS does not do this addition itself.

The appended fixes this particular instance of the problem for me.
Of course, we'd have to audit all the calls to make sure the problem
is fully fixed.

What do you think of this approach?

Tom

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 3aa6d49..805f0e3 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -314,7 +314,8 @@ common_val_print (struct value *val, struct ui_file *stream, int format,
     return 0;
 
   return val_print (value_type (val), value_contents_all (val),
-		    value_embedded_offset (val), VALUE_ADDRESS (val),
+		    value_embedded_offset (val),
+		    VALUE_ADDRESS (val) + value_offset (val),
 		    stream, format, deref_ref, recurse, pretty,
 		    language);
 }



More information about the Archer mailing list