* [PATCH] Print references as /x correctly
@ 2006-02-26 23:42 Thomas Richter
2006-02-27 6:16 ` Jim Blandy
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Richter @ 2006-02-26 23:42 UTC (permalink / raw)
To: gdb-patches
Hi Folks,
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.
To fix this problem, edit print_formatted() in printcmd.c, the "default:" case of the
big switch in lines 323 of printcmd.c as follows:
default:
if (format == 0 /* FIX THOR: Print references also by this */
|| TYPE_CODE (type) == TYPE_CODE_ARRAY
|| TYPE_CODE (type) == TYPE_CODE_STRING
|| TYPE_CODE (type) == TYPE_CODE_STRUCT
|| TYPE_CODE (type) == TYPE_CODE_UNION
|| TYPE_CODE (type) == TYPE_CODE_REF
|| TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
/* 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
* a series of scalars.
*/
value_print (val, stream, format, Val_pretty_default);
Thus, include the type code TYPE_CODE_REF in the default printing style.
So long,
Thomas
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Print references as /x correctly
2006-02-26 23:42 [PATCH] Print references as /x correctly Thomas Richter
@ 2006-02-27 6:16 ` Jim Blandy
0 siblings, 0 replies; 2+ messages in thread
From: Jim Blandy @ 2006-02-27 6:16 UTC (permalink / raw)
To: Thomas Richter; +Cc: gdb-patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-27 5:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-26 23:42 [PATCH] Print references as /x correctly Thomas Richter
2006-02-27 6:16 ` Jim Blandy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox