From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25941 invoked by alias); 3 Mar 2010 10:16:09 -0000 Received: (qmail 25922 invoked by uid 22791); 3 Mar 2010 10:16:08 -0000 X-Spam-Check-By: sourceware.org Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.83/v0.83-20-g38e4449) with ESMTP; Wed, 03 Mar 2010 10:16:04 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 47E016D42F5; Wed, 3 Mar 2010 11:16:01 +0100 (CET) Date: Wed, 03 Mar 2010 10:16:00 -0000 From: Corinna Vinschen To: gdb-patches@sourceware.org Subject: Re: [RFA] defs.h: Define GDB_DEFAULT_TARGET_[WIDE_]CHARSET for Cygwin and MingW builds Message-ID: <20100303101601.GH17293@calimero.vinschen.de> Reply-To: gdb-patches@sourceware.org Mail-Followup-To: gdb-patches@sourceware.org References: <20100228184749.GA17375@caradoc.them.org> <20100228192159.GP5683@calimero.vinschen.de> <20100228222702.GC29360@caradoc.them.org> <20100301103125.GB9730@calimero.vinschen.de> <20100301173054.GD5683@calimero.vinschen.de> <20100301193126.GA9416@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00094.txt.bz2 On Mar 2 15:55, Tom Tromey wrote: > >>>>> "Tom" == Tom Tromey 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