aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2016-08-24 13:10:08 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2016-08-24 13:10:08 -0400
commit0a1ddfa6b67201bb06f51fb47b56096e81bec5c0 (patch)
tree1e26eec2dfe35fc59fe4709b33e059a153178960 /gdb
parentbdd78711b4c1ae26dbc8c2a64f28abec3486ae6c (diff)
downloadgdb-0a1ddfa6b67201bb06f51fb47b56096e81bec5c0.zip
gdb-0a1ddfa6b67201bb06f51fb47b56096e81bec5c0.tar.gz
gdb-0a1ddfa6b67201bb06f51fb47b56096e81bec5c0.tar.bz2
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. This is already supported in MI (and tested in gdb.mi/mi-basics.exp). I added a new test, set-inferior-tty.exp, where I test only the setting and unsetting of the parameter. It would be nice to actually test that the inferior output properly goes to the separate tty, but that will be for another day. gdb/ChangeLog: * infcmd.c (set_inferior_io_terminal): Set inferior terminal to NULL if terminal_name is an empty string. (_initialize_infcmd): Make the argument of "set inferior-tty" optional, mention it in the help doc. gdb/doc/ChangeLog: * gdb.texinfo (Input/Output): Mention possibility to unset inferior-tty. gdb/testsuite/ChangeLog: * gdb.base/set-inferior-tty.exp: New file. * gdb.base/set-inferior-tty.c: New file.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/doc/ChangeLog5
-rw-r--r--gdb/doc/gdb.texinfo6
-rw-r--r--gdb/infcmd.c20
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/set-inferior-tty.c24
-rw-r--r--gdb/testsuite/gdb.base/set-inferior-tty.exp40
7 files changed, 98 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 229a62b..0d875c8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2016-08-24 Simon Marchi <simon.marchi@ericsson.com>
+
+ * infcmd.c (set_inferior_io_terminal): Set inferior terminal to
+ NULL if terminal_name is an empty string.
+ (_initialize_infcmd): Make the argument of "set inferior-tty"
+ optional, mention it in the help doc.
+
2016-08-24 Carl Love <cel@us.ibm.com>
* rs6000-tdep.c (rs6000_gdbarch_init): Remove call
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index cc9bc70..c6fe47c 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-24 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdb.texinfo (Input/Output): Mention possibility to unset
+ inferior-tty.
+
2016-07-25 Tim Wiederhake <tim.wiederhake@intel.com>
* gdb.texinfo: Resume btrace on reconnect.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index f5dde61..d1a5e7c 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -2499,9 +2499,11 @@ display the name of the terminal that will be used for future runs of your
program.
@table @code
-@item set inferior-tty /dev/ttyb
+@item set inferior-tty [ @var{tty} ]
@kindex set inferior-tty
-Set the tty for the program being debugged to /dev/ttyb.
+Set the tty for the program being debugged to @var{tty}. Omitting @var{tty}
+restores the default behavior, which is to use the same terminal as
+@value{GDBN}.
@item show inferior-tty
@kindex show inferior-tty
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 58ba1cb..44a1fd1 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 && *terminal_name != '\0')
+ current_inferior ()->terminal = xstrdup (terminal_name);
+ else
+ current_inferior ()->terminal = NULL;
}
const char *
@@ -3224,14 +3228,16 @@ _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);
+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,
+ show_inferior_tty_command,
+ &setlist, &showlist);
add_com_alias ("tty", "set inferior-tty", class_alias, 0);
cmd_name = "args";
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 26ce978..f400a7b 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-24 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdb.base/set-inferior-tty.exp: New file.
+ * gdb.base/set-inferior-tty.c: New file.
+
2016-08-23 Pedro Alves <palves@redhat.com>
PR gdb/20494
diff --git a/gdb/testsuite/gdb.base/set-inferior-tty.c b/gdb/testsuite/gdb.base/set-inferior-tty.c
new file mode 100644
index 0000000..863fa99
--- /dev/null
+++ b/gdb/testsuite/gdb.base/set-inferior-tty.c
@@ -0,0 +1,24 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2016 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/set-inferior-tty.exp b/gdb/testsuite/gdb.base/set-inferior-tty.exp
new file mode 100644
index 0000000..1a5f49c
--- /dev/null
+++ b/gdb/testsuite/gdb.base/set-inferior-tty.exp
@@ -0,0 +1,40 @@
+# Copyright 2016 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile
+
+set compile_options "debug"
+if {[build_executable $testfile.exp $testfile ${srcfile} ${compile_options}] == -1} {
+ untested "failed to compile $testfile"
+ return -1
+}
+
+proc test_set_inferior_tty { } {
+ global binfile
+
+ clean_restart ${binfile}
+
+ gdb_test_no_output "set inferior-tty hello" "set inferior-tty to hello"
+ gdb_test "show inferior-tty" \
+ "Terminal for future runs of program being debugged is \"hello\"." \
+ "show inferior-tty shows hello"
+
+ gdb_test_no_output "set inferior-tty" "set inferior-tty to empty"
+ gdb_test "show inferior-tty" \
+ "Terminal for future runs of program being debugged is \"\"." \
+ "show inferior-tty shows empty"
+}
+
+test_set_inferior_tty