Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] New substitute-path commands
Date: Mon, 10 Jul 2006 05:40:00 -0000	[thread overview]
Message-ID: <20060710054027.GF971@adacore.com> (raw)
In-Reply-To: <uhd1sp9uv.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1538 bytes --]

Hi Eli,

I incorporated all your comments in the this new version.

> > +directory between compilation and debugging.  @value{GDBN} does a simple
> > +string replacement of the first occurrence of @var{from} with @var{to}
> > +in the directory part of the source file name, and uses the result
> > +instead of the original file name to look up the sources.
> 
> I suggested to have this text after the command description.  In that
> context, @var{from} and @var{to} refer to the command's arguments.
> But you moved the description higher in the text, which made those
> reference dangling.  So this needs to be reworded in some way.

You're right. It didn't work that way at all. You'll see my attempt
at fixing it in this version of the patch.

2006-07-07  Joel Brobecker  <brobecker@adacore.com

        * source.c (substitute_path_from): New static variable.
        (substitute_path_to): Likewise.
        (xrewrite_source_path): New function.
        (find_and_open_source): Add source path rewriting support.
        (show_substitute_path_command): New function.
        (unset_substitute_path_command): New function.
        (set_substitute_path_command): New function.
        (_initialize_source): Add new substitute-path commands.

Patch not re-sent, since identical to previous iteration.
See http://sources.redhat.com/ml/gdb-patches/2006-07/msg00062.html.

2006-07-09  Joel Brobecker  <brobecker@adacore.com

        * gdb.texinfo (Source Path): Add documentation for new
        substitute-path commands.

Thanks,
-- 
Joel

[-- Attachment #2: subst-doc.diff --]
[-- Type: text/plain, Size: 3994 bytes --]

Index: gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.340
diff -u -p -r1.340 gdb.texinfo
--- gdb.texinfo	21 Jun 2006 13:57:21 -0000	1.340
+++ gdb.texinfo	10 Jul 2006 05:36:05 -0000
@@ -5033,6 +5033,44 @@ To add other directories, use the @code{
 The search path is used to find both program source files and @value{GDBN}
 script files (read using the @samp{-command} option and @samp{source} command).
 
+In addition to the source path, @value{GDBN} provides a set of commands
+that manage a source path substitution rule.  A @dfn{substitution rule}
+specifies how to rewrite source directories stored in the program's
+debug information in case the sources were moved to a different
+directory between compilation and debugging.  The rule is made of
+two strings, the first specifying what needs to be rewritten in
+the path, and the second specifying how it should be rewritten.
+In the @ref{set substitute-path} command description, these two
+parts are named respectively @var{from} and @var{to}.  @value{GDBN}
+does a simple string replacement of the first occurrence of @var{from}
+with @var{to} in the directory part of the source file name, and uses
+the result instead of the original file name to look up the sources.
+
+Using the previous example, suppose the @file{foo-1.0} tree has been
+moved from @file{/usr/src} to @file{/mnt/cross}, then you can tell
+GDB to replace @file{/usr/src} in all source path names with
+@file{/mnt/cross}.  The first lookup will then be
+@file{/mnt/cross/foo-1.0/lib/foo.c} in place of the original location
+of @file{/usr/src/foo-1.0/lib/foo.c}.  To define a source path
+substitution rule, use the @ref{set substitute-path} command.
+
+In many cases, you can achieve the same result using the @code{directory}
+command.  However, @code{set substitute-path} can be more efficient in
+the case where the sources are organized in a complex tree with multiple
+subdirectories.  With the @code{directory} command, you need to add each
+subdirectory of your project.  If you moved the entire tree while
+preserving its internal organization, then @code{set substitute-path}
+allows you to direct the debugger to all the sources with one single
+command.
+
+@code{set substitute-path} is also more than just a shortcut command.
+The source path is only used if the file at the original location no
+longer exists.  On the other hand, @code{set substitute-path} modifies
+the debugger behavior to look at the rewritten location instead.  So, if
+for any reason a source file that is not relevant to your executable is
+located at the original location, the substitution rule is the only
+method available to point GDB at the new location.
+
 @table @code
 @item directory @var{dirname} @dots{}
 @item dir @var{dirname} @dots{}
@@ -5068,6 +5106,34 @@ Reset the source path to its default val
 @item show directories
 @kindex show directories
 Print the source path: show which directories it contains.
+
+@anchor{set substitute-path}
+@item set substitute-path @var{from} @var{to}
+@kindex set substitute-path
+Define a source path substitution rule.  The new substitution rule
+replaces any rule previously defined.
+
+For example, if the file @file{/foo/bar/baz.c} was moved to
+@file{/mnt/cross/baz.c}, then the command
+
+@smallexample
+(@value{GDBP}) set substitute-path /usr/src /mnt/cross
+@end smallexample
+
+@noindent
+will tell @value{GDBN} to replace @samp{/usr/src} with
+@samp{/mnt/cross}, which will allow @value{GDBN} to find the file
+@file{baz.c} even though it was moved.
+
+@item unset substitute-path
+@kindex unset substitute-path
+If a source path substitution rule is active, then cancel it.
+This command has no effect otherwise.
+
+@item show substitute-path
+@kindex show substitute-path
+Print the source path substitution rule if defined.
+
 @end table
 
 If your source path is cluttered with directories that are no longer of

  reply	other threads:[~2006-07-10  5:40 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-05 21:58 Joel Brobecker
2006-07-05 22:49 ` Andreas Schwab
2006-07-05 23:01 ` Daniel Jacobowitz
2006-07-06  4:47   ` Joel Brobecker
2006-07-06 16:07     ` PAUL GILLIAM
2006-07-06 16:30       ` Daniel Jacobowitz
2006-07-06 21:28         ` Joel Brobecker
2006-07-07  5:22         ` Joel Brobecker
2006-07-07  9:40           ` Eli Zaretskii
2006-07-07 19:12             ` Joel Brobecker
2006-07-08 12:19               ` Eli Zaretskii
2006-07-10  5:40                 ` Joel Brobecker [this message]
2006-07-10 19:53                   ` Eli Zaretskii
2006-07-10 21:47                     ` Joel Brobecker
2006-07-10 21:51                       ` Daniel Jacobowitz
2006-07-10 21:56                         ` Joel Brobecker
2006-07-10 21:58                           ` Daniel Jacobowitz
2006-07-11  3:24                       ` Eli Zaretskii
2006-07-07 10:39           ` Andrew STUBBS
2006-07-07 16:12             ` Joel Brobecker
2006-07-07 16:45               ` Andrew STUBBS
2006-07-07 17:20                 ` Joel Brobecker
2006-07-11 12:47           ` Daniel Jacobowitz
2006-07-11 20:30             ` Joel Brobecker
2006-07-11 20:33               ` Daniel Jacobowitz
2006-07-11 20:45                 ` Joel Brobecker
2006-07-11 22:25             ` Joel Brobecker
2006-07-11 22:31               ` Christopher Faylor
2006-07-11 22:50               ` Daniel Jacobowitz
2006-07-11 23:00                 ` Joel Brobecker
2006-07-12  3:22                 ` Eli Zaretskii
2006-07-12  3:47                   ` Daniel Jacobowitz
2006-07-12  4:50                     ` Joel Brobecker
2006-07-12 14:09                       ` Daniel Jacobowitz
2006-07-06  3:31 ` Eli Zaretskii
2006-07-06  4:46   ` Joel Brobecker
2006-07-06  9:36 ` Andrew STUBBS
2006-07-06 21:19 ` Jason Molenda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060710054027.GF971@adacore.com \
    --to=brobecker@adacore.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox