From 29b0e8a24aad93899d3d81d9e43493adfa83c930 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 21 Apr 2009 10:13:05 +0000 Subject: [PATCH] gdb: * configure.ac (--with-relocated-sources): New. * configure, config.in: Regenerate. * source.c (add_substitute_path_rule): Remove static. * source.h (add_substitute_path_rule): Declare. * main.c: Include "source.h". (captured_main): Add substitution rule if RELOC_SRCDIR. gdb/doc: * gdb.texinfo (Source Path): Document --with-relocated-sources. --- gdb/ChangeLog | 9 +++++++++ gdb/config.in | 3 +++ gdb/configure | 21 +++++++++++++++++++++ gdb/configure.ac | 7 +++++++ gdb/doc/ChangeLog | 4 ++++ gdb/doc/gdb.texinfo | 13 +++++++++++++ gdb/main.c | 8 ++++++++ gdb/source.c | 2 +- gdb/source.h | 3 +++ 9 files changed, 69 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index dc41f711190..7252cdb1ad6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2009-04-21 Joseph Myers + + * configure.ac (--with-relocated-sources): New. + * configure, config.in: Regenerate. + * source.c (add_substitute_path_rule): Remove static. + * source.h (add_substitute_path_rule): Declare. + * main.c: Include "source.h". + (captured_main): Add substitution rule if RELOC_SRCDIR. + 2009-04-21 Pierre Muller * gnu-nat.h (proc_debug): Add missing continuation line in macro. diff --git a/gdb/config.in b/gdb/config.in index ab0c84019f6..1bfd8375c30 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -630,6 +630,9 @@ 'ptrdiff_t'. */ #undef PTRDIFF_T_SUFFIX +/* Relocated directory for source files. */ +#undef RELOC_SRCDIR + /* Bug reporting address */ #undef REPORT_BUGS_TO diff --git a/gdb/configure b/gdb/configure index 0ba6d2c5d0f..d37c4f2eb93 100755 --- a/gdb/configure +++ b/gdb/configure @@ -882,6 +882,8 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-separate-debug-dir=path Look for global separate debug info in this path LIBDIR/debug + --with-relocated-sources=PATH + Automatically relocate this path for source files --with-libunwind Use libunwind frame unwinding support --with-curses use the curses library instead of the termcap library @@ -7133,6 +7135,25 @@ _ACEOF esac +# Check whether --with-relocated-sources or --without-relocated-sources was given. +if test "${with_relocated_sources+set}" = set; then + withval="$with_relocated_sources" + reloc_srcdir="${withval}" + + test "x$prefix" = xNONE && prefix="$ac_default_prefix" + test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + ac_define_dir=`eval echo $reloc_srcdir` + ac_define_dir=`eval echo $ac_define_dir` + +cat >>confdefs.h <<_ACEOF +#define RELOC_SRCDIR "$ac_define_dir" +_ACEOF + + + +fi; + + subdirs="$subdirs doc testsuite" diff --git a/gdb/configure.ac b/gdb/configure.ac index b8555c83893..68c8e4a2a07 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -118,6 +118,13 @@ case ${debugdir} in ;; esac +AC_ARG_WITH(relocated-sources, +AC_HELP_STRING([--with-relocated-sources=PATH], [Automatically relocate this path for source files]), +[reloc_srcdir="${withval}" + AC_DEFINE_DIR(RELOC_SRCDIR, reloc_srcdir, + [Relocated directory for source files. ]) +]) + AC_CONFIG_SUBDIRS(doc testsuite) # Check whether to support alternative target configurations diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 428da00b8f5..b0f803bb405 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2009-04-21 Joseph Myers + + * gdb.texinfo (Source Path): Document --with-relocated-sources. + 2009-04-18 Carlos O'Donell Joseph Myers diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index ebba32fc2b7..50949e059e4 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -5809,6 +5809,19 @@ for any reason a source file that is not relevant to your executable is located at the original location, a substitution rule is the only method available to point @value{GDBN} at the new location. +@cindex @samp{--with-relocated-sources} +@cindex default source path substitution +You can configure a default source path substitution rule by +configuring @value{GDBN} with the +@samp{--with-relocated-sources=@var{dir}} option. The @var{dir} +should be the name of a directory under @value{GDBN}'s configured +prefix (set with @samp{--prefix} or @samp{--exec-prefix}), and +directory names in debug information under @var{dir} will be adjusted +automatically if the installed @value{GDBN} is moved to a new +location. This is useful if @value{GDBN}, libraries or executables +with debug information and corresponding source code are being moved +together. + @table @code @item directory @var{dirname} @dots{} @item dir @var{dirname} @dots{} diff --git a/gdb/main.c b/gdb/main.c index 5d4640b37f2..86607d3241e 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -40,6 +40,8 @@ #include "interps.h" #include "main.h" +#include "source.h" + /* If nonzero, display time usage both at startup and for each command. */ int display_time; @@ -359,6 +361,12 @@ captured_main (void *data) get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit); +#ifdef RELOC_SRCDIR + add_substitute_path_rule (RELOC_SRCDIR, + make_relative_prefix (argv[0], BINDIR, + RELOC_SRCDIR)); +#endif + /* There will always be an interpreter. Either the one passed into this captured main, or one specified by the user at start up, or the console. Initialize the interpreter to the one requested by diff --git a/gdb/source.c b/gdb/source.c index 43df92ff83b..50f3510f130 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1746,7 +1746,7 @@ find_substitute_path_rule (const char *from) /* Add a new substitute-path rule at the end of the current list of rules. The new rule will replace FROM into TO. */ -static void +void add_substitute_path_rule (char *from, char *to) { struct substitute_path_rule *rule; diff --git a/gdb/source.h b/gdb/source.h index 47968f0f599..72271fef801 100644 --- a/gdb/source.h +++ b/gdb/source.h @@ -66,4 +66,7 @@ extern struct symtab_and_line set_current_source_symtab_and_line (const struct s /* Reset any information stored about a default file and line to print. */ extern void clear_current_source_symtab_and_line (void); + +/* Add a source path substitution rule. */ +extern void add_substitute_path_rule (char *, char *); #endif -- 2.39.2