This is the mail archive of the 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]

[RFA] Fix typo in type of parameter "w" in print_wchar...

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  <>

        * c-lang.c (print_wchar): Use the correct type for parameter "w".

I'm currently testing the patch on x86_64-linux...

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)

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