This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Make string printing work on NetBSD (iconv issue)


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  <paul_koning@dell.com>

	* 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 <iconv.h>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]