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]

Add --with-relocated-sources configure option


This patch adds a configure option --with-relocated-sources to build
GDB with a default substitute-path.  The use of this option is for
distributing binaries of GDB, libraries and source code for those
libraries together, as explained in the documentation added for it:

    @cindex @samp{--with-relocated-sources}
    You can configure a default source path substitution rule by
    configuring @value{GDBN} with the
    @samp{--with-relocated-sources=@var{path}} option.  The @var{path}
    should be the name of a directory under @value{GDBN}'s configured
    binary prefix (set with @samp{--prefix} or @samp{--exec-prefix}), and
    paths in debug information under @var{path} will be relocated
    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
    distributed together.

OK to commit?

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 20:17:52 -0000
@@ -118,6 +118,13 @@
   ;;
 esac
 
+AC_ARG_WITH(relocated-sources,
+[  --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 20:17:53 -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 20:17:53 -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 20:17:53 -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 20:18:00 -0000
@@ -5809,6 +5809,18 @@
 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}
+You can configure a default source path substitution rule by
+configuring @value{GDBN} with the
+@samp{--with-relocated-sources=@var{path}} option.  The @var{path}
+should be the name of a directory under @value{GDBN}'s configured
+binary prefix (set with @samp{--prefix} or @samp{--exec-prefix}), and
+paths in debug information under @var{path} will be relocated
+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
+distributed 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]