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

Simon Marchi
2016-07-02T01:29:22Z

[-- Attachment #1: Type: text/plain, Size: 565 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-resetting-an-empty-inferior-tty.patch --]
[-- Type: text/x-diff; name=0001-Allow-resetting-an-empty-inferior-tty.patch, Size: 1786 bytes --]

From 139d8e7ccc24e0efaa84ad9424f318d55dfe9eea Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@polymtl.ca>
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