aboutsummaryrefslogtreecommitdiff
path: root/gdb/infcmd.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2023-04-04 12:11:50 +0100
committerAndrew Burgess <aburgess@redhat.com>2023-04-28 22:50:46 +0100
commit598e87ecc064cd8ffc2af4bcde4186d30382f4d5 (patch)
tree960c83a38af1b0921616e8df0f0e709c9dc9977c /gdb/infcmd.c
parent94e6c5641234c4ced9cb3fa0ccc2aaaa6b7b62ea (diff)
downloadgdb-598e87ecc064cd8ffc2af4bcde4186d30382f4d5.zip
gdb-598e87ecc064cd8ffc2af4bcde4186d30382f4d5.tar.gz
gdb-598e87ecc064cd8ffc2af4bcde4186d30382f4d5.tar.bz2
gdb: make set/show inferior-tty work with $_gdb_setting_str
Like the previous two commits, this commit fixes set/show inferior-tty to work with $_gdb_setting_str. Instead of using a scratch variable which is then pushed into the current inferior from a set callback, move to the API that allows for getters and setters, and store the value directly within the current inferior. Update an existing test to check the inferior-tty setting. Reviewed-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r--gdb/infcmd.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 7b2db17..1ed7ced 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -66,11 +66,6 @@ static void step_1 (int, int, const char *);
#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
@@ -94,15 +89,24 @@ static bool finish_print = true;
+/* 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)
@@ -3136,14 +3140,14 @@ _initialize_infcmd ()
/* 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);