From 080017175b5248f1e5b0d48a55a06634244db459 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Thu, 8 Apr 2010 21:08:40 +0000 Subject: [PATCH] * 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. --- gdb/ChangeLog | 4 ++++ gdb/doc/ChangeLog | 6 ++++++ gdb/doc/gdb.texinfo | 8 ++++++-- gdb/source.c | 10 ++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 05cfec64ab5..0bed4e420b8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2010-04-08 Doug Evans + + * source.c (openp): Skip $cdir in PATH. + 2010-04-08 Phil Muldoon PR python/11417 diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index a85e56a2583..16264af8756 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,9 @@ +2010-04-08 Doug Evans + + * 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. + 2010-04-05 Doug Evans * gdb.texinfo (maint show python auto-load): Fix typo. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index fd8b0bc34d9..039287d7bc1 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -19383,8 +19383,12 @@ unless the order of execution is changed by one of the 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 because the compilation directory +is not relevant to scripts. If @code{-v}, for verbose mode, is given then @value{GDBN} displays each command as it is executed. The option must be given before diff --git a/gdb/source.c b/gdb/source.c index dda5d1bb6d0..e9893ba566b 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -764,6 +764,16 @@ openp (const char *path, int opts, const char *string, /* 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 */ -- 2.30.2