#define ERROR_NO_INFERIOR \
if (!target_has_execution ()) error (_("The program is not being run."));
-/* Scratch area where the new cwd will be stored by 'set cwd'. */
-
-static std::string inferior_cwd_scratch;
-
/* Scratch area where 'set inferior-tty' will store user-provided value.
We'll immediate copy it into per-inferior storage. */
return current_inferior ()->cwd ();
}
-/* Handle the 'set cwd' command. */
+/* Store the new value passed to 'set cwd'. */
static void
-set_cwd_command (const char *args, int from_tty, struct cmd_list_element *c)
+set_cwd_value (const std::string &args)
{
- current_inferior ()->set_cwd (inferior_cwd_scratch);
+ current_inferior ()->set_cwd (args);
}
/* Handle the 'show cwd' command. */
set_cmd_completer (args_set_show.set, filename_completer);
auto cwd_set_show
- = add_setshow_string_noescape_cmd ("cwd", class_run,
- &inferior_cwd_scratch, _("\
+ = add_setshow_string_noescape_cmd ("cwd", class_run, _("\
Set the current working directory to be used when the inferior is started.\n \
Changing this setting does not have any effect on inferiors that are\n \
already running."),
Use this command to change the current working directory that will be used\n\
when the inferior is started. This setting does not affect GDB's current\n\
working directory."),
- set_cwd_command,
+ set_cwd_value, get_inferior_cwd,
show_cwd_command,
&setlist, &showlist);
set_cmd_completer (cwd_set_show.set, filename_completer);
gdb_test "inferior ${inf}" "Switching to inferior ${inf}.*" \
"switch to inferior ${inf} before set"
gdb_test_no_output "set args inf${inf}-args"
+ gdb_test_no_output "set cwd /inf${inf}-cwd"
}
# Check settings are still correct for each inferior.
gdb_test "with args tmp-value -- print 1" " = 1"
gdb_test "show args" "inf${inf}-args.*"
+ gdb_test "with cwd tmp-value -- print 1" " = 1"
+ gdb_test "show cwd" "/inf${inf}-cwd.*"
+
# If the inferiors are running check $_gdb_setting_str and
# $_gdb_setting return the correct values.
if { $run } {
gdb_test {print $_gdb_setting_str("args")} "\"inf${inf}-args\""
gdb_test {print $_gdb_setting("args")} "\"inf${inf}-args\""
+ gdb_test {print $_gdb_setting_str("cwd")} "\"/inf${inf}-cwd\""
+ gdb_test {print $_gdb_setting("cwd")} "\"/inf${inf}-cwd\""
}
# Check the settings can be read from Python.
if { $run_python_tests } {
gdb_test "python print(gdb.parameter('args'))" "inf${inf}-args"
+ gdb_test "python print(gdb.parameter('cwd'))" "/inf${inf}-cwd"
}
# Check the settings can be read from Guile.
if { $run_guile_tests } {
gdb_test "guile (print (parameter-value \"args\"))" \
"inf${inf}-args"
+ gdb_test "guile (print (parameter-value \"cwd\"))" \
+ "/inf${inf}-cwd"
}
}