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]

Re: Add --with-relocated-sources configure option


On Tue, 21 Apr 2009, Eli Zaretskii wrote:

> > Date: Mon, 20 Apr 2009 20:26:08 +0000 (UTC)
> > From: "Joseph S. Myers" <joseph@codesourcery.com>
> > 
> > gdb/doc:
> > 2009-04-20  Joseph Myers  <joseph@codesourcery.com>
> > 
> > 	* gdb.texinfo (Source Path): Document --with-relocated-sources.
> 
> This part is okay (assuming that the code is approved), with a few
> comments:

How does the documentation in this revised version of the patch seem?  
I've also updated the configure support to use AC_HELP_STRING as requested 
by Tom.

> Second, the second part of the last sentence above, the one which
> starts with "and paths", got me confused.  Let's see if I understood
> your intent.  Assuming I configured GDB like this:
> 
>   ./configure --prefix=/some/dir --with-relocated-sources=/some/dir/bar
> 
> then, even if the GDB tree is moved to /elsewhere/foo, GDB will
> automagically find its sources in /elsewhere/foo/bar.  Is that true?

Yes.

> >            This is useful if @value{GDBN}, libraries or executables
> > +with debug information and corresponding source code are being
> > +distributed together. 
> 
> Don't you mean that this is useful if they are also _moved_ to a
> different location together?

Yes; I was thinking moved via being distributed (packaged on one system, 
unpacked on another).

gdb:
2009-04-20  Joseph Myers  <joseph@codesourcery.com>

	* 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:
2009-04-20  Joseph Myers  <joseph@codesourcery.com>

	* gdb.texinfo (Source Path): Document --with-relocated-sources.

Index: gdb/configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/configure.ac,v
retrieving revision 1.93
diff -u -r1.93 configure.ac
--- gdb/configure.ac	17 Apr 2009 17:44:04 -0000	1.93
+++ gdb/configure.ac	20 Apr 2009 23:10:35 -0000
@@ -118,6 +118,13 @@
   ;;
 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
Index: gdb/main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.73
diff -u -r1.73 main.c
--- gdb/main.c	28 Jan 2009 15:01:00 -0000	1.73
+++ gdb/main.c	20 Apr 2009 23:10:35 -0000
@@ -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 @@
 
   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 
Index: gdb/source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.96
diff -u -r1.96 source.c
--- gdb/source.c	13 Mar 2009 02:34:13 -0000	1.96
+++ gdb/source.c	20 Apr 2009 23:10:35 -0000
@@ -1746,7 +1746,7 @@
 /* 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;
Index: gdb/source.h
===================================================================
RCS file: /cvs/src/src/gdb/source.h,v
retrieving revision 1.10
diff -u -r1.10 source.h
--- gdb/source.h	3 Jan 2009 05:57:53 -0000	1.10
+++ gdb/source.h	20 Apr 2009 23:10:35 -0000
@@ -66,4 +66,7 @@
 
 /* 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
Index: gdb/doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.580
diff -u -r1.580 gdb.texinfo
--- gdb/doc/gdb.texinfo	15 Apr 2009 22:20:32 -0000	1.580
+++ gdb/doc/gdb.texinfo	20 Apr 2009 23:10:44 -0000
@@ -5809,6 +5809,19 @@
 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{}

-- 
Joseph S. Myers
joseph@codesourcery.com


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