2006-01-23 Andrew Stubbs <andrew.stubbs@st.com>
authorAndrew Stubbs <andrew.stubbs@st.com>
Mon, 23 Jan 2006 16:28:37 +0000 (16:28 +0000)
committerAndrew Stubbs <andrew.stubbs@st.com>
Mon, 23 Jan 2006 16:28:37 +0000 (16:28 +0000)
* cli/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.

gdb/ChangeLog
gdb/cli/cli-cmds.c
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo

index b8c504f7b9ebe73bfe89886b8e1b331943e606ed..5f3106a08ecdd5b6b622b4f112744b4fd9461705 100644 (file)
@@ -1,3 +1,8 @@
+2006-01-23  Andrew Stubbs  <andrew.stubbs@st.com>
+
+       * cli/cli-cmds.c: Include fcntl.h.
+       (source_command): Use the GDB search path to find script files.
+
 2006-01-22  Daniel Jacobowitz  <dan@codesourcery.com>
 
        PR tdep/2029
index 0ecde68e98877de0e2594b73bc54b977ee5a6fd4..88b495641ee798c1f9fbcaf84c63dd69759ec5a3 100644 (file)
@@ -51,6 +51,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);
@@ -427,6 +429,8 @@ source_command (char *args, int from_tty)
   FILE *stream;
   struct cleanup *old_cleanups;
   char *file = args;
+  char *full_pathname = NULL;
+  int fd;
 
   if (file == NULL)
     {
@@ -436,8 +440,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)
     {
       if (from_tty)
        perror_with_name (file);
@@ -445,6 +459,7 @@ source_command (char *args, int from_tty)
        return;
     }
 
+  stream = fdopen (fd, FOPEN_RT);
   script_from_file (stream, file);
 
   do_cleanups (old_cleanups);
index d9aac344d5b1692911d22602c10439bc4c9ab5ee..c0400466d2dabf686cf03308735d98e1410a6061 100644 (file)
@@ -1,3 +1,10 @@
+2006-01-23  Andrew Stubbs  <andrew.stubbs@st.com>
+
+       * gdb.texinfo (Choosing files): Mention that -directory is used
+       for script files.
+       (Specifying source directories): Likewise.
+       (Command files): Explain how script files are found.
+
 2006-01-21  Eli Zaretskii  <eliz@gnu.org>
 
        * gdb.texinfo (Backtrace): Describe how to get backtrace of all
index c17520a103f8fd0b7ea2af91e806eaa40bf27105..fd1a7ed245930635de9a52f4fe1c7e51fbf563e0 100644 (file)
@@ -950,7 +950,7 @@ also be interleaved with @samp{-command} as required.
 @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
@@ -5018,6 +5018,9 @@ When you start @value{GDBN}, its source path includes only @samp{cdir}
 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{}
@@ -16210,6 +16213,9 @@ 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).
+
 Commands that would ask for confirmation if used interactively proceed
 without asking when used in a command file.  Many @value{GDBN} commands that
 normally print messages to say what they are doing omit the messages
This page took 0.045677 seconds and 4 git commands to generate.