From: Thomas Richter <thor@mail.math.tu-berlin.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] Print references as /x correctly
Date: Sun, 26 Feb 2006 23:42:00 -0000 [thread overview]
Message-ID: <200602262248.k1QMmjlB009999@mersenne.math.TU-Berlin.DE> (raw)
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
next reply other threads:[~2006-02-26 22:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-26 23:42 Thomas Richter [this message]
2006-02-27 6:16 ` Jim Blandy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200602262248.k1QMmjlB009999@mersenne.math.TU-Berlin.DE \
--to=thor@mail.math.tu-berlin.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox