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] --with-iconv-path


Hi.

We have one environment where the iconv binary comes from a non-standard
location.  This patch lets one tell gdb where to find it.

Before I write docs/NEWS, can anyone think of any problems with this approach?

One alternative that I don't like is requiring the user to set $PATH
to find the right iconv - that is an internal implementation detail
the user shouldn't have to deal with.

[Ideally one could query some iconv_*() function at runtime: It knows where
its going to find its .so files, and iconv is typically at a fixed path
relative to that.  But I couldn't find such an interface.
Another alternative would be to have an iconv_*() function that returned
a list of all the charsets: that's all gdb uses the iconv program for.
And I realize some environments have iconvlist.
Alas one also has to work with the glibcs that are out there.]

TIA

2011-05-05  Doug Evans  <dje@google.com>

	* configure.ac: New configure option --with-iconv-path.
	* configure: Regenerate.
	* config.in: Regenerate.
	* charset.c (find_charset_names): Use ICONV_PATH if defined.

Index: charset.c
===================================================================
RCS file: /cvs/src/src/gdb/charset.c,v
retrieving revision 1.44
diff -u -p -r1.44 charset.c
--- charset.c	21 Apr 2011 14:26:38 -0000	1.44
+++ charset.c	6 May 2011 00:14:37 -0000
@@ -799,6 +799,7 @@ find_charset_names (void)
   char *args[3];
   int err, status;
   int fail = 1;
+  int flags;
   struct gdb_environ *iconv_env;
 
   /* Older iconvs, e.g. 2.2.2, don't omit the intro text if stdout is
@@ -811,12 +812,20 @@ find_charset_names (void)
 
   child = pex_init (PEX_USE_PIPES, "iconv", NULL);
 
+#ifdef ICONV_PATH
+  args[0] = ICONV_PATH;
+#else
   args[0] = "iconv";
+#endif
   args[1] = "-l";
   args[2] = NULL;
+  flags = PEX_STDERR_TO_STDOUT;
+#ifndef ICONV_PATH
+  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);
Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/configure.ac,v
retrieving revision 1.144
diff -u -p -r1.144 configure.ac
--- configure.ac	17 Mar 2011 13:19:10 -0000	1.144
+++ configure.ac	6 May 2011 00:14:37 -0000
@@ -433,6 +433,16 @@ AC_SEARCH_LIBS(dlgetmodinfo, [dl xpdl])
 
 AM_ICONV
 
+# GDB may invoke iconv to get the list of supported character sets.
+# Allow the user to specify where to find it.
+
+AC_ARG_WITH(iconv-path,
+AS_HELP_STRING([--with-iconv-path=PATH], [specify where to find the iconv program]),
+[iconv_path="${withval}"
+ AC_DEFINE_UNQUOTED([ICONV_PATH], ["${iconv_path}"],
+                    [Path of iconv program.])
+])
+
 # 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]