Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA/commit] Set default target-wide-charset setting to "UTF-16" for x86_64-windows.
@ 2012-10-19 20:07 Joel Brobecker
  2012-10-19 20:48 ` Tom Tromey
  2012-10-19 22:19 ` Eli Zaretskii
  0 siblings, 2 replies; 5+ messages in thread
From: Joel Brobecker @ 2012-10-19 20:07 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Brobecker

GDB on x86_64-windows is having trouble printing wide characters.
For instance, from gdb.base/wchar.exp:

    wchar_t narrow = 97;  /* This is 'a' */

Without this patch, GDB prints narrow as:

    $1 = 97 L'\141'

This is because the default target wide charset is UTF-32, whereas
wchar_t is only 16bits long.

gdb/ChangeLog:

        * amd64-windows-tdep.c (amd64_windows_auto_wide_charset): New
        function.
        (amd64_windows_init_abi): Set auto_wide_charset gdbarch method
        to amd64_windows_auto_wide_charset.

Tested on x86_64-windows, using AdaCore's testsuite.  It seems to be
in line with what's done on x86-windows.

I'll commit in a few days unless there are objections.

---
 gdb/amd64-windows-tdep.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index 528fbb6..142e141 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -190,6 +190,14 @@ amd64_windows_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
   return destination;
 }
 
+/* Implement the "auto_wide_charset" gdbarch method.  */
+
+static const char *
+amd64_windows_auto_wide_charset (void)
+{
+  return "UTF-16";
+}
+
 static void
 amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
@@ -215,6 +223,8 @@ amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_gdbarch_iterate_over_objfiles_in_search_order
     (gdbarch, windows_iterate_over_objfiles_in_search_order);
 
+  set_gdbarch_auto_wide_charset (gdbarch, amd64_windows_auto_wide_charset);
+
   set_solib_ops (gdbarch, &solib_target_so_ops);
 }
 
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFA/commit] Set default target-wide-charset setting to "UTF-16" for x86_64-windows.
  2012-10-19 20:07 [RFA/commit] Set default target-wide-charset setting to "UTF-16" for x86_64-windows Joel Brobecker
@ 2012-10-19 20:48 ` Tom Tromey
  2012-10-23 15:38   ` checked in: " Joel Brobecker
  2012-10-19 22:19 ` Eli Zaretskii
  1 sibling, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2012-10-19 20:48 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel>         * amd64-windows-tdep.c (amd64_windows_auto_wide_charset): New
Joel>         function.
Joel>         (amd64_windows_init_abi): Set auto_wide_charset gdbarch method
Joel>         to amd64_windows_auto_wide_charset.

I think these are both fine, this is what the hook is for.

It makes me wonder though if we could defer guessing the default until a
spot where we know the size of the target wchar_t.

Tom


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFA/commit] Set default target-wide-charset setting to "UTF-16" for x86_64-windows.
  2012-10-19 20:07 [RFA/commit] Set default target-wide-charset setting to "UTF-16" for x86_64-windows Joel Brobecker
  2012-10-19 20:48 ` Tom Tromey
@ 2012-10-19 22:19 ` Eli Zaretskii
  2012-10-19 23:27   ` Joel Brobecker
  1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2012-10-19 22:19 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

> From: Joel Brobecker <brobecker@adacore.com>
> Cc: Joel Brobecker <brobecker@adacore.com>
> Date: Fri, 19 Oct 2012 13:06:59 -0700
> 
> +static const char *
> +amd64_windows_auto_wide_charset (void)
> +{
> +  return "UTF-16";
> +}

Shouldn't this be "UTF-16LE"?  Or is "LE" the default?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFA/commit] Set default target-wide-charset setting to "UTF-16" for x86_64-windows.
  2012-10-19 22:19 ` Eli Zaretskii
@ 2012-10-19 23:27   ` Joel Brobecker
  0 siblings, 0 replies; 5+ messages in thread
From: Joel Brobecker @ 2012-10-19 23:27 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

> Shouldn't this be "UTF-16LE"?  Or is "LE" the default?

Not in this case, because GDB takes care of adding the "LE" suffix
for us, based on the target endianness. I guess that might be useful
on platforms that can execute code following either endianness.

-- 
Joel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* checked in: [RFA/commit] Set default target-wide-charset setting to "UTF-16" for x86_64-windows.
  2012-10-19 20:48 ` Tom Tromey
@ 2012-10-23 15:38   ` Joel Brobecker
  0 siblings, 0 replies; 5+ messages in thread
From: Joel Brobecker @ 2012-10-23 15:38 UTC (permalink / raw)
  To: gdb-patches

> Joel>         * amd64-windows-tdep.c (amd64_windows_auto_wide_charset): New
> Joel>         function.
> Joel>         (amd64_windows_init_abi): Set auto_wide_charset gdbarch method
> Joel>         to amd64_windows_auto_wide_charset.
> 
> I think these are both fine, this is what the hook is for.

Thanks, Tom. Both checked in. (I will send a confirmation for the other
patch as well, just for paper-trail reasons).

-- 
Joel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-10-23 15:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-19 20:07 [RFA/commit] Set default target-wide-charset setting to "UTF-16" for x86_64-windows Joel Brobecker
2012-10-19 20:48 ` Tom Tromey
2012-10-23 15:38   ` checked in: " Joel Brobecker
2012-10-19 22:19 ` Eli Zaretskii
2012-10-19 23:27   ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox