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: [PATCH] Print references as /x correctly


On 2/26/06, Thomas Richter <thor@mail.math.tu-berlin.de> wrote:
> gdb 6.4 does not print references correctly with the type specifier /x. To reproduce, create
> a reference "a" to an int variable, then try to print its value by
>
> p /x a
>
> gdb will now incorrectly print the address of the variable a references, not its contents.

Hi, Thomas.  Thanks for the bug report --- it looks right to me.  I
want to run the regression test suite on it, though, to see if there
are tests that need to be updated.  We should probably have a
regression test for this problem as well.

By the way: in the future, you should use the 'diff' program to
generate patches that show the change you're suggesting.  Use the '-u'
or '-c' option, so that your patch shows the context of the change as
well as the modified lines themselves.  This is less ambiguous, easier
for others to try out (since they can use the 'patch' program to apply
the patch automatically), and should be less work for you.

For example, here's the output from diff -u for your change:

Index: printcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/printcmd.c,v
retrieving revision 1.97
diff -u -p -r1.97 printcmd.c
--- printcmd.c	2 Feb 2006 02:26:48 -0000	1.97
+++ printcmd.c	27 Feb 2006 05:57:49 -0000
@@ -326,7 +326,8 @@ print_formatted (struct value *val, int
 	  || TYPE_CODE (type) == TYPE_CODE_STRING
 	  || TYPE_CODE (type) == TYPE_CODE_STRUCT
 	  || TYPE_CODE (type) == TYPE_CODE_UNION
-	  || TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
+	  || TYPE_CODE (type) == TYPE_CODE_NAMESPACE
+          || TYPE_CODE (type) == TYPE_CODE_REF)
 	/* If format is 0, use the 'natural' format for
 	 * that type of value.  If the type is non-scalar,
 	 * we have to use language rules to print it as


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