From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30598 invoked by alias); 17 Aug 2010 18:06:45 -0000 Received: (qmail 30590 invoked by uid 22791); 17 Aug 2010 18:06:44 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 Aug 2010 18:06:36 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7HI6QKd024063 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 17 Aug 2010 14:06:26 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7HI6Ql5030762; Tue, 17 Aug 2010 14:06:26 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o7HI6PJW019474; Tue, 17 Aug 2010 14:06:25 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 899D9378196; Tue, 17 Aug 2010 12:06:23 -0600 (MDT) From: Tom Tromey To: kazu@codesourcery.com (Kazu Hirata) Cc: gdb-patches@sourceware.org Subject: Re: Your INTERMEDIATE_ENCODING patch for Solaris References: <20100731162500.32FAE5664F4@henry1.codesourcery.com> Date: Tue, 17 Aug 2010 18:06:00 -0000 In-Reply-To: (Tom Tromey's message of "Thu, 05 Aug 2010 12:40:35 -0600") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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-08/txt/msg00263.txt.bz2 >>>>> "Tom" == Tom Tromey writes: Kazu> As Andrew replied to your message above, __STDC_ISO_10646__ is not Kazu> defined on Solaris. Could we use __sun__ instead? Tom> I am not a Solaris expert, but some digging through the online Tom> OpenSolaris libc sources a few months ago convinced me that the Solaris Tom> wchar_t is in fact not UCS-4. Tom> If that is true, then this patch would be incorrect. While looking at this more today, I found: http://defect.opensolaris.org/bz/show_bug.cgi?id=11076 Some of the comments make it clear that wchar_t != UCS-4 for Solaris. Tom> This particular problem has come up multiple times. I am not completely Tom> sure what to do about it, but my current inclination is to change gdb so Tom> that most hosts fall back to PHONY_ICONV, with exceptions for libiconv Tom> and for Linux. This will at least have gdb default to working, and is Tom> also attractive because I have some hope of actually testing it. Daniel> Sounds good to me. Here is what I am testing. If someone can try it out on Solaris, I would appreciate that. Tom b/gdb/ChangeLog: 2010-08-17 Tom Tromey * gdb_wchar.h: Check HAVE_LIBICONV, __STDC_ISO_10646__. Change how INTERMEDIATE_ENCODING is defined. * configure, config.in: Rebuild. * acinclude.m4 (AM_ICONV): Define HAVE_LIBICONV. diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4 index 1942ef4..082a9bc 100644 --- a/gdb/acinclude.m4 +++ b/gdb/acinclude.m4 @@ -256,6 +256,7 @@ AC_DEFUN([AM_ICONV], LIBICONV= if test "$am_cv_lib_iconv" = yes; then LIBICONV="-liconv" + AC_DEFINE(HAVE_LIBICONV, 1, [Define if using libiconv.]) else LIBICONV_LIBDIR= LIBICONV_INCLUDE= diff --git a/gdb/config.in b/gdb/config.in index 7659181..35272a2 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -214,6 +214,9 @@ /* Define if you have the expat library. */ #undef HAVE_LIBEXPAT +/* Define if using libiconv. */ +#undef HAVE_LIBICONV + /* Define to 1 if you have the `libiconvlist' function. */ #undef HAVE_LIBICONVLIST diff --git a/gdb/configure b/gdb/configure index 485c904..852c5c1 100755 --- a/gdb/configure +++ b/gdb/configure @@ -9450,6 +9450,9 @@ $as_echo "$am_cv_func_iconv" >&6; } LIBICONV= if test "$am_cv_lib_iconv" = yes; then LIBICONV="-liconv" + +$as_echo "#define HAVE_LIBICONV 1" >>confdefs.h + else LIBICONV_LIBDIR= LIBICONV_INCLUDE= diff --git a/gdb/gdb_wchar.h b/gdb/gdb_wchar.h index fca3fe4..1ff7a1c 100644 --- a/gdb/gdb_wchar.h +++ b/gdb/gdb_wchar.h @@ -23,7 +23,11 @@ Capable systems have the full suite: wchar_t support and iconv (perhaps via GNU libiconv). On these machines, full functionality - is available. + is available. Note that full functionality is dependent on us + being able to convert from an arbitrary encoding to wchar_t. In + practice this means we look for __STDC_ISO_10646__ (where we know + the name of the wchar_t encoding) or GNU libiconv, where we can use + "wchar_t". DJGPP is known to have libiconv but not wchar_t support. On systems like this, we use the narrow character functions. The full @@ -35,8 +39,6 @@ wrappers for the wchar_t functionality we use. */ -#define INTERMEDIATE_ENCODING "wchar_t" - #if defined (HAVE_ICONV) #include #else @@ -45,9 +47,11 @@ #define PHONY_ICONV #endif -/* We use "btowc" as a sentinel to detect functioning wchar_t - support. */ -#if defined (HAVE_ICONV) && defined (HAVE_WCHAR_H) && defined (HAVE_BTOWC) +/* We use "btowc" as a sentinel to detect functioning wchar_t support. + We check for either __STDC_ISO_10646__ or libiconv in order to + ensure we can convert to and from wchar_t. */ +#if defined (HAVE_ICONV) && defined (HAVE_WCHAR_H) && defined (HAVE_BTOWC) \ + && (defined (__STDC_ISO_10646__) || defined (HAVE_LIBICONV)) #include #include @@ -63,6 +67,25 @@ typedef wint_t gdb_wint_t; #define LCST(X) L ## X +/* If __STDC_ISO_10646__ is defined, then the host wchar_t is UCS-4. + We exploit this fact in the hope that there are hosts that define + this but which do not support "wchar_t" as an encoding argument to + iconv_open. We put the endianness into the encoding name to avoid + hosts that emit a BOM when the unadorned name is used. */ +#if defined (__STDC_ISO_10646__) +#if WORDS_BIGENDIAN +#define INTERMEDIATE_ENCODING "UCS-4BE" +#else +#define INTERMEDIATE_ENCODING "UCS-4LE" +#endif +#elif defined (HAVE_LIBICONV) +#define INTERMEDIATE_ENCODING "wchar_t" +#else +/* This shouldn't happen, because the earlier #if should have filtered + out this case. */ +#error "Neither __STDC_ISO_10646__ nor HAVE_LIBICONV defined" +#endif + #else typedef char gdb_wchar_t;