From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7769 invoked by alias); 4 May 2010 19:43:43 -0000 Received: (qmail 7760 invoked by uid 22791); 4 May 2010 19:43:41 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from aussmtpmrkps320.us.dell.com (HELO aussmtpmrkps320.us.dell.com) (143.166.224.254) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 04 May 2010 19:43:31 +0000 X-Loopcount0: from 12.110.134.31 Received: from unknown (HELO M31.equallogic.com) ([12.110.134.31]) by aussmtpmrkps320.us.dell.com with SMTP; 04 May 2010 14:43:29 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <19424.30941.651367.946330@pkoning-laptop.equallogic.com> Date: Tue, 04 May 2010 19:43:00 -0000 From: Paul Koning To: gdb-patches@sourceware.org Subject: [RFC] Make string printing work on NetBSD (iconv issue) 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-05/txt/msg00074.txt.bz2 On NetBSD (and, from what I've heard, some other systems like Solaris also) a full version of iconv exists except that it doesn't have the codeset name "wchar_t". Currently GDB assumes without checking that this codeset exists. The result is that on NetBSD, any attempt to print a string fails with an uninformative error like "Error reading variable". The attached patch fixes this by having configure pick a suitable codeset name to use. "wchar_t" is used if available, otherwise ucs-2 or ucs-4 with the appropriate byte order suffix is used instead. Tested on i386 NetBSD and i386 Linux. I don't have write privs but I do have the paperwork in place. paul 2010-05-04 Paul Koning * configure.ac: Define ICONV_INTERMEDIATE_ENCODING as iconv codeset name for wchar_t data. * gdb_wchar.h: Use ICONV_INTERMEDIATE_ENCODING. * configure: Regenerate. * config.in: Regenerate. Index: gdb/config.in =================================================================== RCS file: /cvs/src/src/gdb/config.in,v retrieving revision 1.116 diff -u -p -r1.116 config.in --- gdb/config.in 10 Mar 2010 18:37:22 -0000 1.116 +++ gdb/config.in 4 May 2010 19:18:33 -0000 @@ -599,6 +599,9 @@ /* Define as const if the declaration of iconv() needs const. */ #undef ICONV_CONST +/* Codeset name that corresponds to wchar_t encoding. */ +#undef ICONV_INTERMEDIATE_ENCODING + /* Define if you want to use new multi-fd /proc interface (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */ #undef NEW_PROC_API Index: gdb/configure =================================================================== RCS file: /cvs/src/src/gdb/configure,v retrieving revision 1.302 diff -u -p -r1.302 configure --- gdb/configure 23 Apr 2010 18:07:27 -0000 1.302 +++ gdb/configure 4 May 2010 19:18:34 -0000 @@ -13325,6 +13325,40 @@ $as_echo "#define HAVE_PERSONALITY 1" >> fi +if test "x$am_cv_func_iconv" = "xyes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking iconv codeset for wchar_t" >&5 +$as_echo_n "checking iconv codeset for wchar_t... " >&6; } + if iconv -f ascii -t wchar_t /dev/null; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: wchar_t" >&5 +$as_echo "wchar_t" >&6; } + +$as_echo "#define ICONV_INTERMEDIATE_ENCODING \"wchar_t\"" >>confdefs.h + + else + if test "$ac_cv_c_bigendian" = "yes"; then + if test "$gl_cv_bitsizeof_wchar_t" = "32"; then + +$as_echo "#define ICONV_INTERMEDIATE_ENCODING \"ucs-4be\"" >>confdefs.h + + else + +$as_echo "#define ICONV_INTERMEDIATE_ENCODING \"ucs-2be\"" >>confdefs.h + + fi + else + if test "$gl_cv_bitsizeof_wchar_t" = "32"; then + +$as_echo "#define ICONV_INTERMEDIATE_ENCODING \"ucs-4le\"" >>confdefs.h + + else + +$as_echo "#define ICONV_INTERMEDIATE_ENCODING \"ucs-2le\"" >>confdefs.h + + fi + fi + fi +fi + target_sysroot_reloc=0 Index: gdb/configure.ac =================================================================== RCS file: /cvs/src/src/gdb/configure.ac,v retrieving revision 1.117 diff -u -p -r1.117 configure.ac --- gdb/configure.ac 23 Apr 2010 18:07:26 -0000 1.117 +++ gdb/configure.ac 4 May 2010 19:18:34 -0000 @@ -1480,6 +1480,34 @@ then [Define if you support the personality syscall.]) fi +dnl Check if iconv handles wchar_t, and if not, what to use instead. +if test "x$am_cv_func_iconv" = "xyes"; then + AC_MSG_CHECKING(iconv codeset for wchar_t) + if iconv -f ascii -t wchar_t /dev/null; then + AC_MSG_RESULT(wchar_t) + AC_DEFINE([ICONV_INTERMEDIATE_ENCODING],["wchar_t"], + [Codeset name that corresponds to wchar_t encoding.]) + else + if test "$ac_cv_c_bigendian" = "yes"; then + if test "$gl_cv_bitsizeof_wchar_t" = "32"; then + AC_DEFINE([ICONV_INTERMEDIATE_ENCODING],["ucs-4be"], + [Codeset name that corresponds to wchar_t encoding.]) + else + AC_DEFINE([ICONV_INTERMEDIATE_ENCODING],["ucs-2be"], + [Codeset name that corresponds to wchar_t encoding.]) + fi + else + if test "$gl_cv_bitsizeof_wchar_t" = "32"; then + AC_DEFINE([ICONV_INTERMEDIATE_ENCODING],["ucs-4le"], + [Codeset name that corresponds to wchar_t encoding.]) + else + AC_DEFINE([ICONV_INTERMEDIATE_ENCODING],["ucs-2le"], + [Codeset name that corresponds to wchar_t encoding.]) + fi + fi + fi +fi + dnl Handle optional features that can be enabled. target_sysroot_reloc=0 Index: gdb/gdb_wchar.h =================================================================== RCS file: /cvs/src/src/gdb/gdb_wchar.h,v retrieving revision 1.3 diff -u -p -r1.3 gdb_wchar.h --- gdb/gdb_wchar.h 1 Jan 2010 07:31:32 -0000 1.3 +++ gdb/gdb_wchar.h 4 May 2010 19:18:34 -0000 @@ -35,7 +35,7 @@ wrappers for the wchar_t functionality we use. */ -#define INTERMEDIATE_ENCODING "wchar_t" +#define INTERMEDIATE_ENCODING ICONV_INTERMEDIATE_ENCODING #if defined (HAVE_ICONV) #include