From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: brobecker@adacore.com
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] Fix typo in type of parameter "w" in print_wchar...
Date: Sat, 25 Apr 2009 08:50:00 -0000 [thread overview]
Message-ID: <200904250849.n3P8n5BU002469@brahms.sibelius.xs4all.nl> (raw)
In-Reply-To: <20090425003658.GA32745@adacore.com> (message from Joel Brobecker on Fri, 24 Apr 2009 17:36:58 -0700)
> Date: Fri, 24 Apr 2009 17:36:58 -0700
> From: Joel Brobecker <brobecker@adacore.com>
>
> I think this is the last issue I've found so far with character set
> conversions and printing...
>
> This one occurs on AIX while trying to print a simple ascii string.
> The output looks like this:
>
> (gdb) p __gnat_version
> $3 = "
>
> The problem turned out to be pretty straightforward, once I got to
> understand how things are supposed to work.
>
> Basically, for every character in our string, we call print_wchar
> to push the equivalent wchar on our itermediate wchar buffer.
> The issue is that we had the wrong type for the wchar (gdb_wint_t
> instead of gdb_wchar_t). gdb_wint_t is 4bytes long whereas gdb_wchar_t
> is 2 bytes long. So when we do the pushing:
>
> obstack_grow (output, &w, sizeof (gdb_wchar_t));
>
> We only push 2 bytes of the 4 bytes that w got accidently promoted to.
> On ppc-aix, it's big endian, so we end up always pushing zeros...
>
> 2009-04-24 Joel Brobecker <brobecker@adacore.com>
>
> * c-lang.c (print_wchar): Use the correct type for parameter "w".
>
> I'm currently testing the patch on x86_64-linux...
I think this is wrong. The type of a single wide character is wint_t
instead of wchar_t such that it can properly hold WEOF, much in the
same way as the "normal" character functions use int instead of char.
The proper/safer approach is probably to do the conversion to wchar_t
in print_wchar itself just before that obstack_grow() call.
> diff --git a/gdb/c-lang.c b/gdb/c-lang.c
> index 027e9b2..5fe04de 100644
> --- a/gdb/c-lang.c
> +++ b/gdb/c-lang.c
> @@ -156,7 +156,7 @@ append_string_as_wide (const char *string, struct obstack *output)
> escapes across calls. */
>
> static void
> -print_wchar (gdb_wint_t w, const gdb_byte *orig, int orig_len,
> +print_wchar (gdb_wchar_t w, const gdb_byte *orig, int orig_len,
> int width, struct obstack *output, int quoter,
> int *need_escapep)
> {
next prev parent reply other threads:[~2009-04-25 8:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-25 0:37 Joel Brobecker
2009-04-25 8:50 ` Mark Kettenis [this message]
2009-05-07 18:38 ` Joel Brobecker
2009-05-07 18:53 ` Mark Kettenis
2009-05-07 20:48 ` Joel Brobecker
2009-05-12 8:06 ` Joel Brobecker
2009-05-13 9:43 ` Joel Brobecker
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=200904250849.n3P8n5BU002469@brahms.sibelius.xs4all.nl \
--to=mark.kettenis@xs4all.nl \
--cc=brobecker@adacore.com \
--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