#define ERROR_NO_INFERIOR \
if (!target_has_execution ()) error (_("The program is not being run."));
-/* Scratch area where 'set inferior-tty' will store user-provided value.
- We'll immediate copy it into per-inferior storage. */
-
-static std::string inferior_io_terminal_scratch;
-
/* Pid of our debugged inferior, or 0 if no inferior now.
Since various parts of infrun.c test this to see whether there is a program
being debugged it should be nonzero (currently 3 is used) for remote
\f
+/* Store the new value passed to 'set inferior-tty'. */
+
static void
-set_inferior_tty_command (const char *args, int from_tty,
- struct cmd_list_element *c)
+set_tty_value (const std::string &tty)
{
- /* CLI has assigned the user-provided value to inferior_io_terminal_scratch.
- Now route it to current inferior. */
- current_inferior ()->set_tty (inferior_io_terminal_scratch);
+ current_inferior ()->set_tty (tty);
}
+/* Get the current 'inferior-tty' value. */
+
+static const std::string &
+get_tty_value ()
+{
+ return current_inferior ()->tty ();
+}
+
+/* Implement 'show inferior-tty' command. */
+
static void
show_inferior_tty_command (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
/* Add the filename of the terminal connected to inferior I/O. */
auto tty_set_show
- = add_setshow_optional_filename_cmd ("inferior-tty", class_run,
- &inferior_io_terminal_scratch, _("\
+ = add_setshow_optional_filename_cmd ("inferior-tty", class_run, _("\
Set terminal for future runs of program being debugged."), _(" \
Show terminal for future runs of program being debugged."), _(" \
Usage: set inferior-tty [TTY]\n\n \
If TTY is omitted, the default behavior of using the same terminal as GDB\n \
is restored."),
- set_inferior_tty_command,
+ set_tty_value,
+ get_tty_value,
show_inferior_tty_command,
&setlist, &showlist);
add_alias_cmd ("tty", tty_set_show.set, class_run, 0, &cmdlist);
gdb_test_no_output "set environment FOO foo"
gdb_test_no_output "set environment BAR bar"
gdb_test_no_output "set inferior-tty some_tty"
+ gdb_test {print $_gdb_setting_str("inferior-tty")} \
+ " = \"some_tty\""
}
# Check that properties of inferior 1 have been copied
gdb_test "show environment ENVVAR" "ENVVAR = var"
gdb_test "show inferior-tty" \
"Terminal for future runs of program being debugged is \"some_tty\"\."
+ gdb_test {print $_gdb_setting_str("inferior-tty")} \
+ " = \"some_tty\""
}
# Change this second inferior, to check that the next clone-inferior
gdb_test_no_output "set args foo"
gdb_test_no_output "set cwd /somewhere/else"
gdb_test_no_output "set environment FOO oof"
+ gdb_test_no_output "set inferior-tty another_tty"
+ gdb_test {print $_gdb_setting_str("inferior-tty")} \
+ " = \"another_tty\""
}
with_test_prefix "inferior 1" {
gdb_test "show environment ENVVAR" "ENVVAR = var"
gdb_test "show inferior-tty" \
"Terminal for future runs of program being debugged is \"some_tty\"\."
+ gdb_test {print $_gdb_setting_str("inferior-tty")} \
+ " = \"some_tty\""
}
# Tweak inferior 1 a bit more.
"switch to inferior ${inf} before set"
gdb_test_no_output "set args inf${inf}-args"
gdb_test_no_output "set cwd /inf${inf}-cwd"
+ gdb_test_no_output "set inferior-tty /inf${inf}-tty"
}
# Check settings are still correct for each inferior.
gdb_test "with cwd tmp-value -- print 1" " = 1"
gdb_test "show cwd" "/inf${inf}-cwd.*"
+ gdb_test "with inferior-tty tmp-value -- print 1" " = 1"
+ gdb_test "show inferior-tty" "/inf${inf}-tty.*"
+
# 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\""
+
+ gdb_test {print $_gdb_setting_str("inferior-tty")} \
+ "\"/inf${inf}-tty\""
+ gdb_test {print $_gdb_setting("inferior-tty")} \
+ "\"/inf${inf}-tty\""
}
# 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"
+ gdb_test "python print(gdb.parameter('inferior-tty'))" \
+ "/inf${inf}-tty"
}
# Check the settings can be read from Guile.
"inf${inf}-args"
gdb_test "guile (print (parameter-value \"cwd\"))" \
"/inf${inf}-cwd"
+ gdb_test "guile (print (parameter-value \"inferior-tty\"))" \
+ "/inf${inf}-tty"
}
}