This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [doc RFA] Don't search $cdir in openp
On Tue, Apr 6, 2010 at 11:02 AM, Doug Evans <dje@google.com> wrote:
> Hi.
>
> I'd like to check this in if there are no objections.
>
> GDB uses the source search path for scripts, which includes $cdir.
> But GDB doesn't actually expand $cdir, it just leaves it as is,
> so if the user actually had a directory named $cdir it would get
> used. ?This means that $cdir means different things in different
> contexts (source file vs script file) and I think that's wrong.
> Therefore this patch causes openp to skip $cdir.
> This is ok for source files since it's handled at a higher level
> (and openp doesn't know what to substitute for $cdir anyway).
>
> I've tweaked the docs to clarify things.
> Can I get approval (or rewording) for the doc part of the patch?
>
Apologies for the followup. I decided I wasn't sufficiently happy
with the wording of the comment I added to source.c.
Here's a better version.
2010-04-06 Doug Evans <dje@google.com>
* source.c (openp): Skip $cdir in PATH.
doc/
* gdb.texinfo (Command Files): Document that gdb skips $cdir in
search path, and document that gdb only scans the search path if
the script's path doesn't specify a directory.
Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.108
diff -u -p -r1.108 source.c
--- source.c 10 Mar 2010 18:20:06 -0000 1.108
+++ source.c 6 Apr 2010 18:08:52 -0000
@@ -764,6 +764,16 @@ openp (const char *path, int opts, const
/* Normal file name in path -- just use it. */
strncpy (filename, p, len);
filename[len] = 0;
+
+ /* Don't search $cdir. It's also a magic path like $cwd, but we
+ don't have enough information to expand it. The user *could*
+ have an actual directory named '$cdir' but handling that would
+ be confusing, it would mean different things in different
+ contexts. If the user really has '$cdir' one can use './$cdir'.
+ We can get $cdir when loading scripts. When loading
source files
+ $cdir must have already been expanded to the correct value. */
+ if (strcmp (filename, "$cdir") == 0)
+ continue;
}
/* Remove trailing slashes */
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.696
diff -u -p -r1.696 gdb.texinfo
--- doc/gdb.texinfo 5 Apr 2010 17:14:57 -0000 1.696
+++ doc/gdb.texinfo 6 Apr 2010 18:08:52 -0000
@@ -19383,8 +19383,12 @@ unless the order of execution is changed
printed as they are executed. An error in any command terminates
execution of the command file and control is returned to the console.
-@value{GDBN} searches for @var{filename} in the current directory and then
-on the search path (specified with the @samp{directory} command).
+@value{GDBN} first searches for @var{filename} in the current directory.
+If the file is not found there, and @var{filename} does not specify a
+directory, then @value{GDBN} also looks for the file on the source search path
+(specified with the @samp{directory} command);
+except that @file{$cdir} is not searched, @file{$cdir} is meaningless
+in this context.
If @code{-v}, for verbose mode, is given then @value{GDBN} displays
each command as it is executed. The option must be given before