gdb/configure.ac: Add option --with-additional-debug-dirs
Commit Message
If you want to install GDB in a custom prefix, have it look for debug info
in that prefix but also in the distro's default location (typically,
/usr/lib/debug) and run the GDB testsuite before doing "make install", you
have a bit of a problem:
Configuring GDB with '--prefix=$PREFIX' sets the GDB 'debug-file-directory'
parameter to $PREFIX/lib/debug. Unfortunately this precludes GDB from
looking for distro-installed debug info in /usr/lib/debug. For regular GDB
use you could set debug-file-directory to $PREFIX:/usr/lib/debug in
$PREFIX/etc/gdbinit so that GDB will look in both places, but if you want
to run the testsuite then that doesn't help because in that case GDB runs
with the '-nx' option.
There's the configure option '--with-separate-debug-dir' to set the default
value for 'debug-file-directory', but it accepts only one directory and not
a list. I considered modifying it to accept a list, but it's not obvious
how to do that because its value is also used by BFD, as well as processed
for "relocatability".
I thought it was simpler to add a new option to specify a list of
additional directories that will be appended to the debug-file-directory
setting.
---
gdb/config.in | 3 +++
gdb/configure | 19 +++++++++++++++++--
gdb/configure.ac | 6 ++++++
gdb/main.c | 5 +++++
gdb/top.c | 6 ++++++
5 files changed, 37 insertions(+), 2 deletions(-)
base-commit: d3f340763bab7c74838ebb481fd7ff93acd9f00c
Comments
Thiago Jung Bauermann <thiago.bauermann@linaro.org> writes:
> If you want to install GDB in a custom prefix, have it look for debug info
> in that prefix but also in the distro's default location (typically,
> /usr/lib/debug) and run the GDB testsuite before doing "make install", you
> have a bit of a problem:
>
> Configuring GDB with '--prefix=$PREFIX' sets the GDB 'debug-file-directory'
> parameter to $PREFIX/lib/debug. Unfortunately this precludes GDB from
> looking for distro-installed debug info in /usr/lib/debug. For regular GDB
> use you could set debug-file-directory to $PREFIX:/usr/lib/debug in
> $PREFIX/etc/gdbinit so that GDB will look in both places, but if you want
> to run the testsuite then that doesn't help because in that case GDB runs
> with the '-nx' option.
>
> There's the configure option '--with-separate-debug-dir' to set the default
> value for 'debug-file-directory', but it accepts only one directory and not
> a list. I considered modifying it to accept a list, but it's not obvious
> how to do that because its value is also used by BFD, as well as processed
> for "relocatability".
>
> I thought it was simpler to add a new option to specify a list of
> additional directories that will be appended to the debug-file-directory
> setting.
> ---
> gdb/config.in | 3 +++
> gdb/configure | 19 +++++++++++++++++--
> gdb/configure.ac | 6 ++++++
> gdb/main.c | 5 +++++
> gdb/top.c | 6 ++++++
> 5 files changed, 37 insertions(+), 2 deletions(-)
Ping.
>>>>> "Thiago" == Thiago Jung Bauermann via Gdb-patches <gdb-patches@sourceware.org> writes:
Thiago> If you want to install GDB in a custom prefix, have it look for debug info
Thiago> in that prefix but also in the distro's default location (typically,
Thiago> /usr/lib/debug) and run the GDB testsuite before doing "make install", you
Thiago> have a bit of a problem:
...
Thiago> I thought it was simpler to add a new option to specify a list of
Thiago> additional directories that will be appended to the debug-file-directory
Thiago> setting.
I don't think this was ever reviewed? Sorry about that.
Thiago> diff --git a/gdb/configure.ac b/gdb/configure.ac
Thiago> index fb43cd10d6c8..715001384177 100644
Thiago> --- a/gdb/configure.ac
Thiago> +++ b/gdb/configure.ac
Thiago> @@ -119,6 +119,12 @@ GDB_AC_WITH_DIR(DEBUGDIR, separate-debug-dir,
Thiago> [look for global separate debug info in this path @<:@LIBDIR/debug@:>@],
Thiago> [${libdir}/debug])
Thiago> +AC_ARG_WITH(additional-debug-dirs,
Thiago> +AS_HELP_STRING([--with-additional-debug-dirs=PATHs],
Thiago> + [list of additional directories to search for separate debug info]),
Thiago> +[AC_DEFINE_UNQUOTED(ADDITIONAL_DEBUG_DIRS, "${withval}",
Thiago> + Additional directories to look for separate debug info.)])
It's a nit but I think it's normal to indent the body of AC_ARG_WITH.
Thiago> +#ifdef ADDITIONAL_DEBUG_DIRS
Thiago> + debug_file_directory = debug_file_directory + DIRNAME_SEPARATOR
Thiago> + + ADDITIONAL_DEBUG_DIRS;
Thiago> +#endif
gdb style is to put parens around the RHS of the assignment in this
case, and indent the 2nd line to line up.
I think a new configure switch could use at least a NEWS entry.
I didn't see --with-separate-debug-dir in the docs, so there's maybe not
a natural place for this there.
Tom
Hello Tom,
Thank you for your review!
Tom Tromey <tom@tromey.com> writes:
>>>>>> "Thiago" == Thiago Jung Bauermann via Gdb-patches <gdb-patches@sourceware.org>
> writes:
>
> Thiago> If you want to install GDB in a custom prefix, have it look for debug info
> Thiago> in that prefix but also in the distro's default location (typically,
> Thiago> /usr/lib/debug) and run the GDB testsuite before doing "make install", you
> Thiago> have a bit of a problem:
>
> ...
> Thiago> I thought it was simpler to add a new option to specify a list of
> Thiago> additional directories that will be appended to the debug-file-directory
> Thiago> setting.
>
> I don't think this was ever reviewed? Sorry about that.
It wasn't. Not a big deal though. I've been applying the patch locally
in our CI in the meantime.
> Thiago> diff --git a/gdb/configure.ac b/gdb/configure.ac
> Thiago> index fb43cd10d6c8..715001384177 100644
> Thiago> --- a/gdb/configure.ac
> Thiago> +++ b/gdb/configure.ac
> Thiago> @@ -119,6 +119,12 @@ GDB_AC_WITH_DIR(DEBUGDIR, separate-debug-dir,
> Thiago> [look for global separate debug info in this path @<:@LIBDIR/debug@:>@],
> Thiago> [${libdir}/debug])
>
> Thiago> +AC_ARG_WITH(additional-debug-dirs,
> Thiago> +AS_HELP_STRING([--with-additional-debug-dirs=PATHs],
> Thiago> + [list of additional directories to search for separate debug info]),
> Thiago> +[AC_DEFINE_UNQUOTED(ADDITIONAL_DEBUG_DIRS, "${withval}",
> Thiago> + Additional directories to look for separate debug info.)])
>
> It's a nit but I think it's normal to indent the body of AC_ARG_WITH.
Ah, I hadn't noticed. Fixed.
> Thiago> +#ifdef ADDITIONAL_DEBUG_DIRS
> Thiago> + debug_file_directory = debug_file_directory + DIRNAME_SEPARATOR
> Thiago> + + ADDITIONAL_DEBUG_DIRS;
> Thiago> +#endif
>
> gdb style is to put parens around the RHS of the assignment in this
> case, and indent the 2nd line to line up.
That's true. Fixed.
> I think a new configure switch could use at least a NEWS entry.
Ah, I didn't know new configure options also got NEWS entries.
Added one.
> I didn't see --with-separate-debug-dir in the docs, so there's maybe not
> a natural place for this there.
I actually found a good spot for it, so I mentioned the new option
there.
I'm sending a v2 with these changes shortly.
@@ -3,6 +3,9 @@
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
+/* Additional directories to look for separate debug info. */
+#undef ADDITIONAL_DEBUG_DIRS
+
/* Directories from which to load auto-loaded scripts. */
#undef AUTO_LOAD_DIR
@@ -906,6 +906,7 @@ enable_fast_install
with_gnu_ld
enable_libtool_lock
with_separate_debug_dir
+with_additional_debug_dirs
with_gdb_datadir
with_relocated_sources
with_auto_load_dir
@@ -1660,6 +1661,9 @@ Optional Packages:
--with-separate-debug-dir=PATH
look for global separate debug info in this path
[LIBDIR/debug]
+ --with-additional-debug-dirs=PATHs
+ list of additional directories to search for
+ separate debug info
--with-gdb-datadir=PATH look for global separate data files in this path
[DATADIR/gdb]
--with-relocated-sources=PATH
@@ -11448,7 +11452,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11451 "configure"
+#line 11455 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11554,7 +11558,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11557 "configure"
+#line 11561 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -17830,6 +17834,17 @@ _ACEOF
+
+# Check whether --with-additional-debug-dirs was given.
+if test "${with_additional_debug_dirs+set}" = set; then :
+ withval=$with_additional_debug_dirs;
+cat >>confdefs.h <<_ACEOF
+#define ADDITIONAL_DEBUG_DIRS "${withval}"
+_ACEOF
+
+fi
+
+
# We can't pass paths as command line arguments.
# Mingw32 tries to be clever and will convert the paths for us.
# For example -DBINDIR="/usr/local/bin" passed on the command line may get
@@ -119,6 +119,12 @@ GDB_AC_WITH_DIR(DEBUGDIR, separate-debug-dir,
[look for global separate debug info in this path @<:@LIBDIR/debug@:>@],
[${libdir}/debug])
+AC_ARG_WITH(additional-debug-dirs,
+AS_HELP_STRING([--with-additional-debug-dirs=PATHs],
+ [list of additional directories to search for separate debug info]),
+[AC_DEFINE_UNQUOTED(ADDITIONAL_DEBUG_DIRS, "${withval}",
+ Additional directories to look for separate debug info.)])
+
# We can't pass paths as command line arguments.
# Mingw32 tries to be clever and will convert the paths for us.
# For example -DBINDIR="/usr/local/bin" passed on the command line may get
@@ -719,6 +719,11 @@ captured_main_1 (struct captured_main_args *context)
debug_file_directory
= relocate_gdb_directory (DEBUGDIR, DEBUGDIR_RELOCATABLE);
+#ifdef ADDITIONAL_DEBUG_DIRS
+ debug_file_directory = debug_file_directory + DIRNAME_SEPARATOR
+ + ADDITIONAL_DEBUG_DIRS;
+#endif
+
gdb_datadir = relocate_gdb_directory (GDB_DATADIR,
GDB_DATADIR_RELOCATABLE);
@@ -1581,6 +1581,12 @@ This GDB was configured as follows:\n\
--with-separate-debug-dir=%s%s\n\
"), DEBUGDIR, DEBUGDIR_RELOCATABLE ? " (relocatable)" : "");
+#ifdef ADDITIONAL_DEBUG_DIRS
+ gdb_printf (stream, _ ("\
+ --with-additional-debug-dirs=%s\n\
+"), ADDITIONAL_DEBUG_DIRS);
+#endif
+
if (TARGET_SYSTEM_ROOT[0])
gdb_printf (stream, _("\
--with-sysroot=%s%s\n\