Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew STUBBS <andrew.stubbs@st.com>
To: gdb-patches@sources.redhat.com
Subject: Re: [PATCH] Use search path for scripts
Date: Thu, 12 Jan 2006 00:09:00 -0000	[thread overview]
Message-ID: <43C5584C.3050708@st.com> (raw)
In-Reply-To: <437DE8F9.9030606@st.com>

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  <andrew.stubbs@st.com>
> 
> 	* 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 <fcntl.h>
> +
>  /* 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.


  parent reply	other threads:[~2006-01-12  0:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-16 19:36 Andrew STUBBS
2005-11-17  0:04 ` Eli Zaretskii
2005-11-17 12:41   ` Andrew STUBBS
2005-11-17 19:42     ` Eli Zaretskii
2005-11-18 13:23       ` Andrew STUBBS
2005-11-18 14:53         ` Eli Zaretskii
2005-11-18 15:54           ` Andrew STUBBS
2005-11-25 18:02             ` Andrew STUBBS
2005-11-25 18:12             ` Daniel Jacobowitz
2005-11-25 18:33               ` Andrew STUBBS
2005-11-25 18:39                 ` Daniel Jacobowitz
2005-11-25 20:12                   ` Andrew STUBBS
2005-11-25 21:26                     ` Daniel Jacobowitz
2005-11-25 22:33                   ` Eli Zaretskii
2005-11-28 19:34                     ` Andrew STUBBS
2005-11-25 21:56                 ` Eli Zaretskii
2005-11-25 21:43               ` Eli Zaretskii
2006-01-12  0:09             ` Andrew STUBBS [this message]
2006-01-22 20:40               ` Daniel Jacobowitz
2006-01-23 16:29                 ` Andrew STUBBS
2006-01-23 17:41                   ` Andrew STUBBS

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43C5584C.3050708@st.com \
    --to=andrew.stubbs@st.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox