From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19130 invoked by alias); 6 Apr 2010 18:12:58 -0000 Received: (qmail 19119 invoked by uid 22791); 6 Apr 2010 18:12:55 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SARE_MSGID_LONG45,SPF_HELO_PASS,TW_CP,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 06 Apr 2010 18:12:51 +0000 Received: from hpaq7.eem.corp.google.com (hpaq7.eem.corp.google.com [10.3.21.7]) by smtp-out.google.com with ESMTP id o36ICmOa000542 for ; Tue, 6 Apr 2010 11:12:49 -0700 Received: from pvd12 (pvd12.prod.google.com [10.241.209.204]) by hpaq7.eem.corp.google.com with ESMTP id o36ICKDX024983 for ; Tue, 6 Apr 2010 20:12:47 +0200 Received: by pvd12 with SMTP id 12so132818pvd.3 for ; Tue, 06 Apr 2010 11:12:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.141.124.12 with HTTP; Tue, 6 Apr 2010 11:12:46 -0700 (PDT) In-Reply-To: <20100406180226.A185884397@ruffy.mtv.corp.google.com> References: <20100406180226.A185884397@ruffy.mtv.corp.google.com> Date: Tue, 06 Apr 2010 18:12:00 -0000 Received: by 10.141.23.20 with SMTP id a20mr5873696rvj.49.1270577566307; Tue, 06 Apr 2010 11:12:46 -0700 (PDT) Message-ID: Subject: Re: [doc RFA] Don't search $cdir in openp From: Doug Evans To: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-04/txt/msg00101.txt.bz2 On Tue, Apr 6, 2010 at 11:02 AM, Doug Evans 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. =A0This 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 * 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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] =3D 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") =3D=3D 0) + continue; } /* Remove trailing slashes */ Index: doc/gdb.texinfo =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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