From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11417 invoked by alias); 28 Feb 2010 13:05:08 -0000 Received: (qmail 11319 invoked by uid 22791); 28 Feb 2010 13:05:07 -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; Sun, 28 Feb 2010 13:05:03 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 709FF6D42F5; Sun, 28 Feb 2010 14:05:00 +0100 (CET) Date: Sun, 28 Feb 2010 13:05:00 -0000 From: Corinna Vinschen To: gdb-patches@sourceware.org Subject: [RFA] defs.h: Define GDB_DEFAULT_TARGET_[WIDE_]CHARSET for Cygwin and MingW builds Message-ID: <20100228130500.GG5683@calimero.vinschen.de> Reply-To: gdb-patches@sourceware.org Mail-Followup-To: gdb-patches@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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-02/txt/msg00671.txt.bz2 Hi, today I tested the wide char printing in GDB for the furst time on a Cygwin build and it didn't work well. The reson was that the default for GDB_DEFAULT_TARGET_WIDE_CHARSET is UTF-32, which is bad for a system defining wchar_t to be UTF-16. That's Windows for you. So I applied the below patch, which makes GDB for Cygwin happy. I also set the GDB_DEFAULT_TARGET_CHARSET for Cygwin and Win32 to a more sane default for both systems. Ok to apply? Thanks, Corinna * defs.h (GDB_DEFAULT_TARGET_WIDE_CHARSET): Define as UTF-16 for Windows-based systems. (GDB_DEFAULT_TARGET_CHARSET): Set to UTF-8 for Cygwin and CP1252 for other Windows-based systems. Index: defs.h =================================================================== RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.265 diff -u -p -r1.265 defs.h --- defs.h 25 Feb 2010 20:30:58 -0000 1.265 +++ defs.h 28 Feb 2010 13:04:26 -0000 @@ -1192,6 +1192,22 @@ extern int use_windows; #define ISATTY(FP) (isatty (fileno (FP))) #endif +/* The default wide character charset is UTF-32, which is wrong for + Windows-based systems which use UTF-16. */ +#if defined (__CYGWIN__) || defined (_WIN32) +#define GDB_DEFAULT_TARGET_WIDE_CHARSET "UTF-16" +#endif + +/* The default output charset for Cygwin is UTF-8. The default output + charset for Win32 is the default ANSI codepage of the system, which + depends on the localization of the underlying Windows system. However, + CP1252 is a good default replacement for ISO-8859-1 at least. */ +#if defined (__CYGWIN__) +#define GDB_DEFAULT_TARGET_CHARSET "UTF-8" +#elif defined (_WIN32) +#define GDB_DEFAULT_TARGET_CHARSET "CP1252" +#endif + /* Ensure that V is aligned to an N byte boundary (B's assumed to be a power of 2). Round up/down when necessary. Examples of correct use include: -- Corinna Vinschen Cygwin Project Co-Leader Red Hat