Re: Is there a way to unset inferior-tty?

Simon Marchi <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
On 2016-07-01 14:51, Pedro Alves wrote:
> I think this should just be fixed to work.
> 
> The fix should be very similar to this:
> 
> 
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=811a659a779fdf93293fe1105d99e9db171a8b68
> 
> Thanks,
> Pedro Alves

Hi Marc,

Here's a patch.  If you like it I'll submit it to gdb-patches with 
ChangeLog and all.

That made me realize there is an alias for this, you can use "tty 
/dev/pts/X", which is equivalent to "set inferior-tty /dev/pts/X".  
There, I just saved you about 1 hour of typing per day :).

Simon
0001-Allow-resetting-an-empty-inferior-tty.patch (text/x-diff, 1.7 KB)
From 139d8e7ccc24e0efaa84ad9424f318d55dfe9eea Mon Sep 17 00:00:00 2001
From: Simon Marchi <[email protected]>
Date: Fri, 1 Jul 2016 21:23:28 -0400
Subject: [PATCH] Allow resetting an empty inferior-tty

This patch allows the user to set the inferior-tty to "empty", in order
to come back to the default behaviour of using the same tty as gdb is
using.
---
 gdb/infcmd.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 58ba1cb..97a1e35 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -151,7 +151,11 @@ void
 set_inferior_io_terminal (const char *terminal_name)
 {
   xfree (current_inferior ()->terminal);
-  current_inferior ()->terminal = terminal_name ? xstrdup (terminal_name) : 0;
+
+  if (terminal_name != NULL && strlen (terminal_name) > 0)
+    current_inferior ()->terminal = xstrdup (terminal_name);
+  else
+    current_inferior ()->terminal = NULL;
 }
 
 const char *
@@ -3224,14 +3228,14 @@ _initialize_infcmd (void)
   const char *cmd_name;
 
   /* Add the filename of the terminal connected to inferior I/O.  */
-  add_setshow_filename_cmd ("inferior-tty", class_run,
-			    &inferior_io_terminal_scratch, _("\
+  add_setshow_optional_filename_cmd ("inferior-tty", class_run,
+				     &inferior_io_terminal_scratch, _("\
 Set terminal for future runs of program being debugged."), _("\
 Show terminal for future runs of program being debugged."), _("\
 Usage: set inferior-tty /dev/pts/1"),
-			    set_inferior_tty_command,
-			    show_inferior_tty_command,
-			    &setlist, &showlist);
+				     set_inferior_tty_command,
+				     show_inferior_tty_command,
+				     &setlist, &showlist);
   add_com_alias ("tty", "set inferior-tty", class_alias, 0);
 
   cmd_name = "args";
-- 
2.9.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.