static void source_info (char *, int);
-static void show_directories (char *, int);
-
/* Path of directories to search for source files.
Same format as the PATH environment variable's value. */
error (_("Can't find a default source file"));
}
\f
+/* Handler for "set directories path-list" command.
+ "set dir mumble" doesn't prepend paths, it resets the entire
+ path list. The theory is that set(show(dir)) should be a no-op. */
+
+static void
+set_directories_command (char *args, int from_tty, struct cmd_list_element *c)
+{
+ /* This is the value that was set.
+ It needs to be processed to maintain $cdir:$cwd and remove dups. */
+ char *set_path = source_path;
+
+ /* We preserve the invariant that $cdir:$cwd begins life at the end of
+ the list by calling init_source_path. If they appear earlier in
+ SET_PATH then mod_path will move them appropriately.
+ mod_path will also remove duplicates. */
+ init_source_path ();
+ if (*set_path != '\0')
+ mod_path (set_path, &source_path);
+
+ xfree (set_path);
+}
+
+/* Print the list of source directories.
+ This is used by the "ld" command, so it has the signature of a command
+ function. */
+
static void
-show_directories (char *ignore, int from_tty)
+show_directories_1 (char *ignore, int from_tty)
{
puts_filtered ("Source directories searched: ");
puts_filtered (source_path);
puts_filtered ("\n");
}
+/* Handler for "show directories" command. */
+
+static void
+show_directories_command (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ show_directories_1 (NULL, from_tty);
+}
+
/* Forget what we learned about line positions in source files, and
which directories contain them; must check again now since files
may be found in a different directory now. */
forget_cached_source_info ();
}
if (from_tty)
- show_directories ((char *) 0, from_tty);
+ show_directories_1 ((char *) 0, from_tty);
}
/* Add a path given with the -d command line switch.
set_cmd_completer (c, filename_completer);
- add_cmd ("directories", no_class, show_directories, _("\
-Current search path for finding source files.\n\
+ add_setshow_optional_filename_cmd ("directories",
+ class_files,
+ &source_path,
+ _("\
+Set the search path for finding source files."),
+ _("\
+Show the search path for finding source files."),
+ _("\
$cwd in the path means the current working directory.\n\
-$cdir in the path means the compilation directory of the source file."),
- &showlist);
+$cdir in the path means the compilation directory of the source file.\n\
+GDB ensures the search path always ends with $cdir:$cwd by\n\
+appending these directories if necessary.\n\
+Setting the value to an empty string sets it to $cdir:$cwd, the default."),
+ set_directories_command,
+ show_directories_command,
+ &setlist, &showlist);
if (xdb_commands)
{
add_com_alias ("D", "directory", class_files, 0);
- add_cmd ("ld", no_class, show_directories, _("\
+ add_cmd ("ld", no_class, show_directories_1, _("\
Current search path for finding source files.\n\
$cwd in the path means the current working directory.\n\
$cdir in the path means the compilation directory of the source file."),
--- /dev/null
+# Copyright (C) 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite. It tests gdb.parameter.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+load_lib gdb-python.exp
+
+# Start with a fresh gdb.
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+# Skip all tests if Python scripting is not enabled.
+if { [skip_python_tests] } { continue }
+
+# We use "." here instead of ":" so that this works on win32 too.
+gdb_test "python print gdb.parameter ('directories')" "$srcdir/$subdir.\\\$cdir.\\\$cwd"