Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [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

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