This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Iconv / Solaris
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 27 Aug 2009 11:00:41 -0600
- Subject: Re: Iconv / Solaris
- References: <20090827020639.GA13935@caradoc.them.org>
- Reply-to: Tom Tromey <tromey at redhat dot com>
>>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes:
Daniel> Just confirming what I said on IRC: __STDC_ISO_10646__ is not defined
Daniel> anywhere, but with __sun__ your patch from here:
Daniel> http://sourceware.org/ml/gdb-patches/2009-07/msg00434.html
Daniel> fixes an otherwise broken GDB on Solaris. I think UCS-4 is right, but
Daniel> the Solaris documentation isn't clear; maybe it would be clear if I
Daniel> understood wide characters better.
Daniel> Actually, poking around the internet, it looks like wchar_t's contents
Daniel> may be locale-dependent...
Yeah :-(
I did a little digging on various sun.com sites, and all I could find is
that wchar_t will be UCS-4 if the current locale is using UTF-8. That
is not a very strong guarantee -- it means that GDB might work for some
users but not others, if there are locales where wchar_t is not UCS-4.
The very safest thing to do is disable use of wchar_t on a platform like
this. E.g., the appended hack can be used to try it. This will provide
a user experience similar to GDB 6.8.
Alternatively, you could try using the __sun__ variant and running gdb
in a non-UTF-8 locale. If it works we could go with (a variant of) this
approach.
Finally, I looked at libiconv-1.13. It also supports converting to the
"wchar_t" encoding using mbrtowc, if that is available. I guess it must
perform an intermediate conversion. Maybe using libiconv on Solaris
would provide a better experience for your users.
Tom
*** gdb_wchar.h.~1.2.~ 2009-04-15 15:59:05.000000000 -0600
--- gdb_wchar.h 2009-08-27 10:31:01.000000000 -0600
***************
*** 47,53 ****
/* We use "btowc" as a sentinel to detect functioning wchar_t
support. */
! #if defined (HAVE_ICONV) && defined (HAVE_WCHAR_H) && defined (HAVE_BTOWC)
#include <wchar.h>
#include <wctype.h>
--- 47,53 ----
/* We use "btowc" as a sentinel to detect functioning wchar_t
support. */
! #if defined (HAVE_ICONV) && defined (HAVE_WCHAR_H) && defined (HAVE_BTOWC) && !defined (__sun__)
#include <wchar.h>
#include <wctype.h>