This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] defs.h: Define GDB_DEFAULT_TARGET_[WIDE_]CHARSET for Cygwin and MingW builds
On Mar 2 15:55, Tom Tromey wrote:
> >>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
>
> Tom> I agree, we need a gdbarch method.
>
> Tom> I'll look into this today.
>
> Here's a patch, please let me know what you think.
>
> This patch nearly works -- it regresses on a Python test that looks at
> gdb.parameter('target-charset') directly and then gets confused by
> "auto". I think the only solution for this is to add a new Python API.
> (It would be easy enough to just hack the test case somehow -- but the
> libstdc++ printers use this same idiom, so a real solution is needed.)
>
> I wasn't sure where to put the Cygwin override; I took Daniel's
> suggestion of i386_cygwin_init_abi; but Corinna's earlier patches
> changed all Windows targets, not just Cygwin, and I didn't see a good
> place to do that.
Me neither. There seems to be no i386_windows_init_abi which would
allow to define this for all Windows targets.
Btw., in contrast to Cygwin, native Windows hosts don't have the
nl_langinfo function. Of course, this affects the default host charset.
ISO-8859-1 is no sensible default, even if it mostly works on western
language Windows systems since it's quite similar to CP1252. The most
sensible default host charset for a native Windows GDB is the codepage
returned by GetACP(), as Eli already pointed out for the target charset.
Maybe something along these lines would help (untested!):
--- charset.c 2010-03-03 11:09:43.000000000 +0100
+++ charset.c.new 2010-03-03 11:09:36.000000000 +0100
@@ -904,6 +904,10 @@ default_auto_wide_charset (void)
return GDB_DEFAULT_TARGET_WIDE_CHARSET;
}
+#ifdef _WIN32
+static w32_host_default_charset[16]; /* "CP + x<=5 digits + paranoia. */
+#endif
+
void
_initialize_charset (void)
{
@@ -927,6 +931,11 @@ _initialize_charset (void)
if (!strcmp (auto_host_charset_name, "646") || !*auto_host_charset_name)
auto_host_charset_name = "ASCII";
auto_target_charset_name = auto_host_charset_name;
+#elif defined (_WIN32)
+ snprintf (w32_host_default_charset, sizeof w32_host_default_charset,
+ "CP%d", GetACP());
+ auto_host_charset_name = w32_host_default_charset;
+ auto_target_charset_name = auto_host_charset_name;
#endif
#endif
Corinna
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat