This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Iconv / Solaris
>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
Tom> I can write a patch tomorrow.
Please try the appended. You will have to re-run autoheader and
autoconf.
I took the opportunity to add more text to the comment in gdb_wchar.h,
in the hopes that this would make it more clear.
If this works for you, I will check it in.
Tom
2009-08-28 Tom Tromey <tromey@redhat.com>
* gdb_wchar.h: Update comments. Use DISABLE_ICONV.
* configure, config.in: Rebuild.
* configure.ac (DISABLE_ICONV): Define when needed.
* configure.host: Set gdb_host_wchar_iconv.
Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/configure.ac,v
retrieving revision 1.105
diff -u -r1.105 configure.ac
--- configure.ac 22 Aug 2009 17:08:09 -0000 1.105
+++ configure.ac 28 Aug 2009 16:15:22 -0000
@@ -788,6 +788,12 @@
ttrace wborder setlocale iconvlist libiconvlist btowc])
AM_LANGINFO_CODESET
+# An additional check for whether iconv is ok for us to use.
+if test "$gdb_host_wchar_iconv" = no; then
+ AC_DEFINE([DISABLE_ICONV], 1,
+ [Define if host iconv is unsuitable for use by gdb])
+fi
+
# Check the return and argument types of ptrace. No canned test for
# this, so roll our own.
gdb_ptrace_headers='
Index: configure.host
===================================================================
RCS file: /cvs/src/src/gdb/configure.host,v
retrieving revision 1.103
diff -u -r1.103 configure.host
--- configure.host 11 Jan 2009 13:15:56 -0000 1.103
+++ configure.host 28 Aug 2009 16:15:22 -0000
@@ -8,6 +8,8 @@
# gdb_host_double_format host's double floatformat, or 0
# gdb_host_long_double_format host's long double floatformat, or 0
# gdb_host_obs host-specific .o files to include
+# gdb_host_wchar_iconv "no" if iconv_open will not accept
+# "wchar_t" as an argument.
# Map host cpu into the config cpu subdirectory name.
# The default is $host_cpu.
@@ -207,3 +209,15 @@
gdb_host_long_double_format=0
;;
esac
+
+
+# Per-host iconv setting.
+
+# Default to "yes".
+gdb_host_wchar_iconv=yes
+
+case "${host}" in
+*-*-solaris*)
+ gdb_host_wchar_iconv=no
+ ;;
+esac
Index: gdb_wchar.h
===================================================================
RCS file: /cvs/src/src/gdb/gdb_wchar.h,v
retrieving revision 1.2
diff -u -r1.2 gdb_wchar.h
--- gdb_wchar.h 15 Apr 2009 22:20:31 -0000 1.2
+++ gdb_wchar.h 28 Aug 2009 16:15:22 -0000
@@ -21,18 +21,33 @@
/* We handle three different modes here.
- Capable systems have the full suite: wchar_t support and iconv
+ 1. Capable systems have the full suite: wchar_t support and iconv
(perhaps via GNU libiconv). On these machines, full functionality
- is available.
+ is available. In this case, the intermediate character set is
+ "wchar_t".
- DJGPP is known to have libiconv but not wchar_t support. On
+ 2. DJGPP is known to have libiconv but not wchar_t support. On
systems like this, we use the narrow character functions. The full
functionality is available to the user, but many characters (those
- outside the narrow range) will be displayed as escapes.
+ outside the narrow range) will be displayed as escapes. In this
+ case, the intermediate character set uses the host encoding.
- Finally, some systems do not have iconv. Here we provide a phony
- iconv which only handles a single character set, and we provide
- wrappers for the wchar_t functionality we use. */
+ We also end up in this scenario if the host iconv is not fully
+ suitable. Solaris falls into this category both because iconv_open
+ does not accept "wchar_t" as an argument, but also because wchar_t
+ does not have a fixed encoding.
+
+ 3. Finally, some systems do not have iconv. Here we provide a
+ phony iconv which only handles a single character set, and we
+ provide wrappers for the wchar_t functionality we use. This is
+ what the "PHONY_ICONV" define means, below. In this case, the
+ intermediate character set uses the host encoding, and limited
+ functionality is available to the user.
+
+ It is possible that you may run into a system that does not support
+ "wchar_t" as an argument to iconv_open, but where
+ __STDC_ISO_10646__ is defined. If you have such a system, we can
+ add a fourth case where we fix the intermediate encoding. */
#define INTERMEDIATE_ENCODING "wchar_t"
@@ -40,14 +55,17 @@
#if defined (HAVE_ICONV)
#include <iconv.h>
#else
-/* This define is used elsewhere so we don't need to duplicate the
- same checking logic in multiple places. */
+/* Case 3. This define is used elsewhere so we don't need to
+ duplicate the same checking logic in multiple places. */
#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)
+#if defined (HAVE_ICONV) && defined (HAVE_WCHAR_H) && defined (HAVE_BTOWC) \
+ && !defined (DISABLE_ICONV)
+
+/* Case 1. */
#include <wchar.h>
#include <wctype.h>
@@ -65,6 +83,8 @@
#else
+/* Case 2 and case 3, depending on whether PHONY_ICONV is defined. */
+
typedef char gdb_wchar_t;
typedef int gdb_wint_t;