* NEWS: Mention --with-iconv-bin.
authorDoug Evans <dje@google.com>
Mon, 9 May 2011 21:49:57 +0000 (21:49 +0000)
committerDoug Evans <dje@google.com>
Mon, 9 May 2011 21:49:57 +0000 (21:49 +0000)
* configure.ac: New option --with-iconv-bin.
* configure: Regenerate.
* config.in: Regenerate.
* defs.h (relocate_gdb_directory): Declare.
* main.c (relocate_gdb_directory): Renamed from relocate_directory,
removed progname parameter, and exported.  All callers updated.
* charset.c (find_charset_names): Use --with-iconv-bin if specified.

doc/
* gdb.texinfo (Requirements): Fix typo.  Mention --with-iconv-bin.

gdb/ChangeLog
gdb/NEWS
gdb/charset.c
gdb/config.in
gdb/configure
gdb/configure.ac
gdb/defs.h
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/main.c

index 580ce56..6a130b6 100644 (file)
@@ -1,5 +1,14 @@
 2011-05-09  Doug Evans  <dje@google.com>
 
+       * NEWS: Mention --with-iconv-bin.
+       * configure.ac: New option --with-iconv-bin.
+       * configure: Regenerate.
+       * config.in: Regenerate.
+       * defs.h (relocate_gdb_directory): Declare.
+       * main.c (relocate_gdb_directory): Renamed from relocate_directory,
+       removed progname parameter, and exported.  All callers updated.
+       * charset.c (find_charset_names): Use --with-iconv-bin if specified.
+
        * linux-nat.c (lin_lwp_attach_lwp): For !WIPSTOPPED case,
        adding missing call to restore_child_signals_mask.
 
index 9b59419..e735293 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,12 @@
 
 *** Changes since GDB 7.3
 
+* New configure option --with-iconv-bin.
+  When using the internationalization support like the one in the GNU C
+  library, GDB will invoke the "iconv" program to get a list of supported
+  character sets.  If this program lives in a non-standard location, one can
+  use this option to specify where to find it.
+
 * When natively debugging programs on PowerPC BookE processors running
   a Linux kernel version 2.6.34 or later, GDB supports masked hardware
   watchpoints, which specify a mask in addition to an address to watch.
index a84085a..b85758b 100644 (file)
@@ -799,7 +799,9 @@ find_charset_names (void)
   char *args[3];
   int err, status;
   int fail = 1;
+  int flags;
   struct gdb_environ *iconv_env;
+  char *iconv_program;
 
   /* Older iconvs, e.g. 2.2.2, don't omit the intro text if stdout is
      not a tty.  We need to recognize it and ignore it.  This text is
@@ -811,12 +813,26 @@ find_charset_names (void)
 
   child = pex_init (PEX_USE_PIPES, "iconv", NULL);
 
-  args[0] = "iconv";
+#ifdef ICONV_BIN
+  {
+    char *iconv_dir = relocate_gdb_directory (ICONV_BIN,
+                                             ICONV_BIN_RELOCATABLE);
+    iconv_program = concat (iconv_dir, SLASH_STRING, "iconv", NULL);
+    xfree (iconv_dir);
+  }
+#else
+  iconv_program = xstrdup ("iconv");
+#endif
+  args[0] = iconv_program;
   args[1] = "-l";
   args[2] = NULL;
+  flags = PEX_STDERR_TO_STDOUT;
+#ifndef ICONV_BIN
+  flags |= PEX_SEARCH;
+#endif
   /* Note that we simply ignore errors here.  */
-  if (!pex_run_in_environment (child, PEX_SEARCH | PEX_STDERR_TO_STDOUT,
-                              "iconv", args, environ_vector (iconv_env),
+  if (!pex_run_in_environment (child, flags,
+                              args[0], args, environ_vector (iconv_env),
                               NULL, NULL, &err))
     {
       FILE *in = pex_read_output (child, 0);
@@ -888,6 +904,7 @@ find_charset_names (void)
 
     }
 
+  xfree (iconv_program);
   pex_free (child);
   free_environ (iconv_env);
 
index 01ba750..db00195 100644 (file)
 /* Define to 1 if you have the `_mcleanup' function. */
 #undef HAVE__MCLEANUP
 
+/* Path of directory of iconv program. */
+#undef ICONV_BIN
+
+/* Define if the iconv directory should be relocated when GDB is moved. */
+#undef ICONV_BIN_RELOCATABLE
+
 /* Define as const if the declaration of iconv() needs const. */
 #undef ICONV_CONST
 
index 92818a0..bf6ac01 100755 (executable)
@@ -961,6 +961,7 @@ with_pkgversion
 with_bugurl
 with_zlib
 with_libiconv_prefix
+with_iconv_bin
 with_system_readline
 with_expat
 with_gnu_ld
@@ -1660,6 +1661,7 @@ Optional Packages:
   --with-zlib             include zlib support (auto/yes/no) default=auto
   --with-libiconv-prefix=DIR
                           search for libiconv in DIR/include and DIR/lib
+  --with-iconv-bin=PATH   specify where to find the iconv program
   --with-system-readline  use installed readline library
   --with-expat            include expat support (auto/yes/no)
   --with-gnu-ld           assume the C compiler uses GNU ld default=no
@@ -9523,6 +9525,57 @@ _ACEOF
   fi
 
 
+# GDB may fork/exec the iconv program to get the list of supported character
+# sets.  Allow the user to specify where to find it.
+# There are several factors affecting the choice of option name:
+# - There is already --with-libiconv-prefix but we can't use it, it specifies
+#   the build-time location of libiconv files.
+# - The program we need to find is iconv, which comes with glibc.  The user
+#   doesn't necessarily have libiconv installed.  Therefore naming this
+#   --with-libiconv-foo feels wrong.
+# - We want the path to be relocatable, but GDB_AC_DEFINE_RELOCATABLE is
+#   defined to work on directories not files (though it really doesn't know
+#   the difference).
+# - Calling this --with-iconv-prefix is perceived to cause too much confusion
+#   with --with-libiconv-prefix.
+# Putting these together is why the option name is --with-iconv-bin.
+
+
+# Check whether --with-iconv-bin was given.
+if test "${with_iconv_bin+set}" = set; then :
+  withval=$with_iconv_bin; iconv_bin="${withval}"
+
+cat >>confdefs.h <<_ACEOF
+#define ICONV_BIN "${iconv_bin}"
+_ACEOF
+
+
+  if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
+     if test "x$prefix" = xNONE; then
+       test_prefix=/usr/local
+     else
+       test_prefix=$prefix
+     fi
+  else
+     test_prefix=$exec_prefix
+  fi
+  value=0
+  case ${iconv_bin} in
+     "${test_prefix}"|"${test_prefix}/"*|\
+       '${exec_prefix}'|'${exec_prefix}/'*)
+     value=1
+     ;;
+  esac
+
+cat >>confdefs.h <<_ACEOF
+#define ICONV_BIN_RELOCATABLE $value
+_ACEOF
+
+
+
+fi
+
+
 # On alpha-osf, it appears that libtermcap and libcurses are not compatible.
 # There is a very specific comment in /usr/include/curses.h explaining that
 # termcap routines built into libcurses must not be used.
index 96e0a7b..a42ce27 100644 (file)
@@ -433,6 +433,29 @@ AC_SEARCH_LIBS(dlgetmodinfo, [dl xpdl])
 
 AM_ICONV
 
+# GDB may fork/exec the iconv program to get the list of supported character
+# sets.  Allow the user to specify where to find it.
+# There are several factors affecting the choice of option name:
+# - There is already --with-libiconv-prefix but we can't use it, it specifies
+#   the build-time location of libiconv files.
+# - The program we need to find is iconv, which comes with glibc.  The user
+#   doesn't necessarily have libiconv installed.  Therefore naming this
+#   --with-libiconv-foo feels wrong.
+# - We want the path to be relocatable, but GDB_AC_DEFINE_RELOCATABLE is
+#   defined to work on directories not files (though it really doesn't know
+#   the difference).
+# - Calling this --with-iconv-prefix is perceived to cause too much confusion
+#   with --with-libiconv-prefix.
+# Putting these together is why the option name is --with-iconv-bin.
+
+AC_ARG_WITH(iconv-bin,
+AS_HELP_STRING([--with-iconv-bin=PATH], [specify where to find the iconv program]),
+[iconv_bin="${withval}"
+ AC_DEFINE_UNQUOTED([ICONV_BIN], ["${iconv_bin}"],
+                    [Path of directory of iconv program.])
+ GDB_AC_DEFINE_RELOCATABLE(ICONV_BIN, iconv, ${iconv_bin})
+])
+
 # On alpha-osf, it appears that libtermcap and libcurses are not compatible.
 # There is a very specific comment in /usr/include/curses.h explaining that
 # termcap routines built into libcurses must not be used.
index 089631c..4df2a3e 100644 (file)
@@ -282,6 +282,12 @@ struct breakpoint;
 struct frame_info;
 struct gdbarch;
 
+/* From main.c.  */
+
+/* This really belong in utils.c (path-utils.c?), but it references some
+   globals that are currently only available to main.c.  */
+extern char *relocate_gdb_directory (const char *initial, int flag);
+
 /* From utils.c */
 
 extern void initialize_utils (void);
index 2eacb32..e9990c2 100644 (file)
@@ -1,3 +1,7 @@
+2011-05-09  Doug Evans  <dje@google.com>
+
+       * gdb.texinfo (Requirements): Fix typo.  Mention --with-iconv-bin.
+
 2011-05-06  Sergio Durigan Junior  <sergiodj@linux.vnet.ibm.com>
            Thiago Jung Bauermann  <bauerman@br.ibm.com>
 
index 3618b70..65172b5 100644 (file)
@@ -31214,7 +31214,12 @@ Sets}) require a functioning @code{iconv} implementation.  If you are
 on a GNU system, then this is provided by the GNU C Library.  Some
 other systems also provide a working @code{iconv}.
 
-On systems with @code{iconv}, you can install GNU Libiconv.  If you
+If @value{GDBN} is using the @code{iconv} program which is installed
+in a non-standard place, you will need to tell @value{GDBN} where to find it.
+This is done with @option{--with-iconv-bin} which specifies the
+directory that contains the @code{iconv} program.
+
+On systems without @code{iconv}, you can install GNU Libiconv.  If you
 have previously installed Libiconv, you can use the
 @option{--with-libiconv-prefix} option to configure.
 
index ff305a1..73ce4c8 100644 (file)
@@ -104,6 +104,7 @@ extern char *external_editor_command;
    file or directory.  FLAG is true if the value is relocatable, false
    otherwise.  Returns a newly allocated string; this may return NULL
    under the same conditions as make_relative_prefix.  */
+
 static char *
 relocate_path (const char *progname, const char *initial, int flag)
 {
@@ -117,12 +118,13 @@ relocate_path (const char *progname, const char *initial, int flag)
    the result is a directory, it is used; otherwise, INITIAL is used.
    The chosen directory is then canonicalized using lrealpath.  This
    function always returns a newly-allocated string.  */
-static char *
-relocate_directory (const char *progname, const char *initial, int flag)
+
+char *
+relocate_gdb_directory (const char *initial, int flag)
 {
   char *dir;
 
-  dir = relocate_path (progname, initial, flag);
+  dir = relocate_path (gdb_program_name, initial, flag);
   if (dir)
     {
       struct stat s;
@@ -342,22 +344,21 @@ captured_main (void *data)
   current_directory = gdb_dirbuf;
 
   /* Set the sysroot path.  */
-  gdb_sysroot = relocate_directory (argv[0], TARGET_SYSTEM_ROOT,
-                                   TARGET_SYSTEM_ROOT_RELOCATABLE);
+  gdb_sysroot = relocate_gdb_directory (TARGET_SYSTEM_ROOT,
+                                       TARGET_SYSTEM_ROOT_RELOCATABLE);
 
-  debug_file_directory = relocate_directory (argv[0], DEBUGDIR,
-                                            DEBUGDIR_RELOCATABLE);
+  debug_file_directory = relocate_gdb_directory (DEBUGDIR,
+                                                DEBUGDIR_RELOCATABLE);
 
-  gdb_datadir = relocate_directory (argv[0], GDB_DATADIR,
-                                   GDB_DATADIR_RELOCATABLE);
+  gdb_datadir = relocate_gdb_directory (GDB_DATADIR,
+                                       GDB_DATADIR_RELOCATABLE);
 
 #ifdef WITH_PYTHON_PATH
   {
     /* For later use in helping Python find itself.  */
     char *tmp = concat (WITH_PYTHON_PATH, SLASH_STRING, "lib", NULL);
 
-    python_libdir = relocate_directory (argv[0], tmp,
-                                       PYTHON_PATH_RELOCATABLE);
+    python_libdir = relocate_gdb_directory (tmp, PYTHON_PATH_RELOCATABLE);
     xfree (tmp);
   }
 #endif