aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorAndrew Stubbs <andrew.stubbs@st.com>2006-01-23 16:28:37 +0000
committerAndrew Stubbs <andrew.stubbs@st.com>2006-01-23 16:28:37 +0000
commit4b505b12693cdcd0b4e88aa8beedca359b8827a7 (patch)
tree51f064b2f090b6ed51a97cd18c02e785b5387ca5 /gdb/cli
parent721d14ba74f11a737711195f28de345a34073de2 (diff)
downloadgdb-4b505b12693cdcd0b4e88aa8beedca359b8827a7.zip
gdb-4b505b12693cdcd0b4e88aa8beedca359b8827a7.tar.gz
gdb-4b505b12693cdcd0b4e88aa8beedca359b8827a7.tar.bz2
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. 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.
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-cmds.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 0ecde68..88b4956 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -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);