From 05779d57f9f4e7cbb6d4c79d8851d35a422bdd0d Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sat, 27 Jun 2020 14:56:05 +0100 Subject: Make {get,set}_inferior_io_terminal inferior methods This converts the get_inferior_io_terminal and set_inferior_io_terminal free functions to inferior methods. Since the related commands are called "tty", "{set,show} inferior-tty", and MI's "-inferior-tty-{set,show}", to make the connection between the commands and the code more obvious, the methods are named set_tty/tty instead of set_io_terminal/io_terminal. gdb/ChangeLog: * fork-child.c (prefork_hook): Adjust. * infcmd.c (set_inferior_io_terminal, get_inferior_io_terminal): Delete. (set_inferior_tty_command, show_inferior_tty_command): Adjust. * inferior.c (inferior::set_tty, inferior::tty): New methods. * inferior.h (set_inferior_io_terminal, get_inferior_io_terminal): Remove declarations. (struct inferior) : New methods. (struct inferior) : Rename to ... (struct inferior) : ... this and make private. * main.c (captured_main_1): Adjust. * mi/mi-cmd-env.c (mi_cmd_inferior_tty_set): Adjust. (mi_cmd_inferior_tty_show): Adjust. * nto-procfs.c (nto_procfs_target::create_inferior): Adjust. * windows-nat.c (windows_nat_target::create_inferior): Adjust. --- gdb/inferior.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'gdb/inferior.h') diff --git a/gdb/inferior.h b/gdb/inferior.h index 5002b0b..572c5f3 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -118,11 +118,6 @@ extern void set_sigint_trap (void); extern void clear_sigint_trap (void); -/* Set/get file name for default use for standard in/out in the inferior. */ - -extern void set_inferior_io_terminal (const char *terminal_name); -extern const char *get_inferior_io_terminal (void); - /* Collected pid, tid, etc. of the debugged inferior. When there's no inferior, inferior_ptid.pid () will be 0. */ @@ -411,6 +406,14 @@ public: inline safe_inf_threads_range threads_safe () { return safe_inf_threads_range (this->thread_list); } + /* Set/get file name for default use for standard in/out in the + inferior. On Unix systems, we try to make TERMINAL_NAME the + inferior's controlling terminal. If TERMINAL_NAME is nullptr or + the empty string, then the inferior inherits GDB's terminal (or + GDBserver's if spawning a remote process). */ + void set_tty (const char *terminal_name); + const char *tty (); + /* Convenient handle (GDB inferior id). Unique across all inferiors. */ int num = 0; @@ -456,9 +459,6 @@ public: this inferior. */ gdb::unique_xmalloc_ptr cwd; - /* The name of terminal device to use for I/O. */ - gdb::unique_xmalloc_ptr terminal; - /* The terminal state as set by the last target_terminal::terminal_* call. */ target_terminal_state terminal_state = target_terminal_state::is_ours; @@ -541,6 +541,9 @@ public: private: /* The inferior's target stack. */ target_stack m_target_stack; + + /* The name of terminal device to use for I/O. */ + gdb::unique_xmalloc_ptr m_terminal; }; /* Keep a registry of per-inferior data-pointers required by other GDB -- cgit v1.1