Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [doc RFA] Don't search $cdir in openp
@ 2010-04-06 18:02 Doug Evans
  2010-04-06 18:12 ` Doug Evans
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Doug Evans @ 2010-04-06 18:02 UTC (permalink / raw)
  To: gdb-patches

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?

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 17:40:05 -0000
@@ -764,6 +764,15 @@ 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'.  */
+	  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:00:45 -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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [doc RFA] Don't search $cdir in openp
  2010-04-06 18:02 [doc RFA] Don't search $cdir in openp Doug Evans
@ 2010-04-06 18:12 ` Doug Evans
  2010-04-06 18:32 ` Eli Zaretskii
  2010-04-07 20:03 ` Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Doug Evans @ 2010-04-06 18:12 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [doc RFA] Don't search $cdir in openp
  2010-04-06 18:02 [doc RFA] Don't search $cdir in openp Doug Evans
  2010-04-06 18:12 ` Doug Evans
@ 2010-04-06 18:32 ` Eli Zaretskii
  2010-04-07 20:03 ` Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2010-04-06 18:32 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

> Date: Tue,  6 Apr 2010 11:02:26 -0700 (PDT)
> From: dje@google.com (Doug Evans)
> 
> I've tweaked the docs to clarify things.
> Can I get approval (or rewording) for the doc part of the patch?

Yes, you can.

> +except that @file{$cdir} is not searched, @file{$cdir} is meaningless
> +in this context.

I would remove the part beginning with the comma.  If you think it is
necessary to explain this behavior, I would replace it with something
like

   because compilation directory is not relevant to scripts.

Thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [doc RFA] Don't search $cdir in openp
  2010-04-06 18:02 [doc RFA] Don't search $cdir in openp Doug Evans
  2010-04-06 18:12 ` Doug Evans
  2010-04-06 18:32 ` Eli Zaretskii
@ 2010-04-07 20:03 ` Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2010-04-07 20:03 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

>>>>> "Doug" == Doug Evans <dje@google.com> writes:

Doug> I'd like to check this in if there are no objections.

It seems like a good idea to me.

BTW this may be http://sourceware.org/bugzilla/show_bug.cgi?id=8852

Tom


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-04-07 20:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-06 18:02 [doc RFA] Don't search $cdir in openp Doug Evans
2010-04-06 18:12 ` Doug Evans
2010-04-06 18:32 ` Eli Zaretskii
2010-04-07 20:03 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox