From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9660 invoked by alias); 12 Jan 2006 00:09:11 -0000 Received: (qmail 9964 invoked by uid 22791); 11 Jan 2006 19:24:30 -0000 X-Spam-Check-By: sourceware.org Received: from lon-del-01.spheriq.net (HELO lon-del-01.spheriq.net) (195.46.50.97) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 11 Jan 2006 19:24:26 +0000 Received: from lon-out-02.spheriq.net ([195.46.50.130]) by lon-del-01.spheriq.net with ESMTP id k0BJGMFl009230 for ; Wed, 11 Jan 2006 19:24:22 GMT Received: from lon-cus-01.spheriq.net (lon-cus-01.spheriq.net [195.46.50.37]) by lon-out-02.spheriq.net with ESMTP id k0BJD8hI013807 for ; Wed, 11 Jan 2006 19:13:08 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by lon-cus-01.spheriq.net with ESMTP id k0BJD89p018675 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK) for ; Wed, 11 Jan 2006 19:13:08 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B706FDA41 for ; Wed, 11 Jan 2006 19:13:07 +0000 (GMT) Received: by zeta.dmz-eu.st.com (STMicroelectronics, from userid 60012) id E2B334760C; Wed, 11 Jan 2006 19:16:32 +0000 (GMT) Received: from zeta.dmz-eu.st.com (localhost [127.0.0.1]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B800F75994 for ; Wed, 11 Jan 2006 19:16:32 +0000 (UTC) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 51EDC4760B for ; Wed, 11 Jan 2006 19:16:32 +0000 (GMT) Received: from [164.129.15.13] (terrorhawk.bri.st.com [164.129.15.13]) by mail1.bri.st.com (MOS 3.5.8-GR) with ESMTP id CHD00711 (AUTH stubbsa); Wed, 11 Jan 2006 19:13:05 GMT Message-ID: <43C5584C.3050708@st.com> Date: Thu, 12 Jan 2006 00:09:00 -0000 From: Andrew STUBBS User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: Re: [PATCH] Use search path for scripts References: <437B6718.7070300@st.com> <437C6D69.1030209@st.com> <437DC94B.7060601@st.com> <437DE8F9.9030606@st.com> In-Reply-To: <437DE8F9.9030606@st.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-O-Spoofed: Not Scanned X-O-General-Status: No X-O-Spam1-Status: Not Scanned X-O-Spam2-Status: Not Scanned X-O-URL-Status: Not Scanned X-O-Virus1-Status: No X-O-Virus2-Status: Not Scanned X-O-Virus3-Status: No X-O-Virus4-Status: No X-O-Virus5-Status: Not Scanned X-O-Image-Status: Not Scanned X-O-Attach-Status: Not Scanned X-SpheriQ-Ver: 4.2.0 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-01/txt/msg00115.txt.bz2 Hi, This one has been on hold for some time now. IIRC, Daniel wasn't happy about it sharing the same search path and Eli didn't want yet another one. I am happy to go either way, as long as it works. Which should it be? May I check it in as it is or add another search path with another command and option to go with it? Thanks Andrew Andrew Stubbs wrote: > Eli Zaretskii wrote: > >>> + stream = fdopen (fd, "r"); >> >> >> ^^^ >> Shouldn't this be FOPEN_RT, like what was used in the call to fopen in >> the original code? > > > Quite so. I don't know where that came from. > > Update attached. > > Andrew Stubbs > > > ------------------------------------------------------------------------ > > 2005-11-17 Andrew Stubbs > > * cli-cmds.c: Include fcntl.h. > (source_command): Use the GDB search path to find script files. > > doc/ > * gdb.texinfo (Choosing files): Mention that -directory is used > for script files. > (Specifying source directories): Likewise. > (Command files): Explain how script files are found. > > > Index: src/gdb/cli/cli-cmds.c > =================================================================== > --- src.orig/gdb/cli/cli-cmds.c 2005-11-18 11:22:08.000000000 +0000 > +++ src/gdb/cli/cli-cmds.c 2005-11-18 14:43:08.000000000 +0000 > @@ -50,6 +50,8 @@ > #include "tui/tui.h" /* For tui_active et.al. */ > #endif > > +#include > + > /* Prototypes for local command functions */ > > static void complete_command (char *, int); > @@ -433,6 +435,8 @@ source_command (char *args, int from_tty > char *file = args; > char *minusv=NULL; > int old_source_verbose = source_verbose; > + char *full_pathname = NULL; > + int fd; > > /* -v causes the source command to run in verbose mode. > We still have to be able to handle filenames with spaces. */ > @@ -486,8 +490,18 @@ source_command (char *args, int from_tty > file = tilde_expand (file); > old_cleanups = make_cleanup (xfree, file); > > - stream = fopen (file, FOPEN_RT); > - if (!stream) > + /* Search for and open 'file' on the search path used for source > + files. Put the full location in 'full_pathname'. */ > + fd = openp (source_path, OPF_TRY_CWD_FIRST, > + file, O_RDONLY, 0, &full_pathname); > + > + /* Use the full path name, if it is found. */ > + if (full_pathname != NULL && fd != -1) > + { > + file = full_pathname; > + } > + > + if (fd == -1) > { > source_verbose = old_source_verbose; > if (from_tty) > @@ -496,6 +510,7 @@ source_command (char *args, int from_tty > return; > } > > + stream = fdopen (fd, FOPEN_RT); > script_from_file (stream, file); > > do_cleanups (old_cleanups); > Index: src/gdb/doc/gdb.texinfo > =================================================================== > --- src.orig/gdb/doc/gdb.texinfo 2005-11-18 11:22:09.000000000 +0000 > +++ src/gdb/doc/gdb.texinfo 2005-11-18 12:31:33.000000000 +0000 > @@ -951,7 +951,7 @@ also be interleaved with @samp{-command} > @itemx -d @var{directory} > @cindex @code{--directory} > @cindex @code{-d} > -Add @var{directory} to the path to search for source files. > +Add @var{directory} to the path to search for source and script files. > > @item -r > @itemx -readnow > @@ -4830,6 +4830,9 @@ When you start @value{GDBN}, its source > and @samp{cwd}, in that order. > To add other directories, use the @code{directory} command. > > +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). > + > @table @code > @item directory @var{dirname} @dots{} > @item dir @var{dirname} @dots{} > @@ -15997,6 +16000,9 @@ The lines in a command file are executed > 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). > + > If @code{-v}, for verbose mode, is given then each command will > be displayed as it is executed. The option may be given before or after > @var{filename}, but will be interpreted as part of the filename anywhere else.