summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Rossi <bob@brasko.net>2005-07-06 14:54:37 +0000
committerBob Rossi <bob@brasko.net>2005-07-06 14:54:37 +0000
commit3721ef102785c6b5d706219407eeaed1902add3d (patch)
tree874878ac7035c2847ac224bb8b7f082aa2abaefc
parentf7b75da3eb30217d8b4d3ccb9749119ebf499b75 (diff)
downloadgdb-3721ef102785c6b5d706219407eeaed1902add3d.tar.gz
Index: gdb/ChangeLog
+2005-07-06 Bob Rossi <bob@brasko.net> + + * fork-child.c (fork-inferior): Use accessor function for + inferior_io_terminal. + * infcmd.c (inferior_io_terminal): Make static. + (set_inferior_io_terminal): New function. + (get_inferior_io_terminal): Ditto. + (tty_command): Use accessor function. + (_initialize_infcmd): Add inferior_tty setshow variable. + (_initialize_infcmd): Remove tty command. + (_initialize_infcmd): Add a tty command that is an alias. + * inferior.h (set_inferior_io_terminal): New prototype. + (get_inferior_io_terminal): Ditto. + (new_tty_prefork): Add const qualifier to parameter. + * inflow.c (inferior_thisrun_terminal): Add const qualifier. + (new_tty_prefork): Add const qualifier to parameter. + * nto-procfs (procfs_create_inferior): Use accessor function. + (procfs_create_inferior): Add const qualifier to locals. + * win32-nat.c (child_create_inferior): Ditto. + * mi/mi-cmd-env.c (mi_cmd_inferior_tty_set): New function. + (mi_cmd_inferior_tty_set): Ditto. + * mi/mi-cmds.c (mi_cmds): Add inferior-tty-set and inferior-tty-show + * mi/mi-cmds.h (mi_cmd_inferior_tty_set): Add prototype. + (mi_cmd_inferior_tty_show): Ditto. Index: gdb/doc/ChangeLog +2005-07-06 Bob Rossi <bob@brasko.net> + + * gdb.texinfo (GDB/MI Miscellaneous Commands): Add -inferior-tty-set + and -inferior-tty-show. + (Input/Output): Document "set/show inferior-tty" and tty alias. Index: gdb/testsuite/ChangeLog +2005-07-06 Bob Rossi <bob@brasko.net> + + * gdb.mi/mi-basics.exp (test_setshow_inferior_tty): Test MI tty + command. + (Copyright): Update copyright.
-rw-r--r--gdb/ChangeLog25
-rw-r--r--gdb/doc/ChangeLog6
-rw-r--r--gdb/doc/gdb.texinfo70
-rw-r--r--gdb/fork-child.c1
-rw-r--r--gdb/infcmd.c36
-rw-r--r--gdb/inferior.h7
-rw-r--r--gdb/inflow.c4
-rw-r--r--gdb/mi/mi-cmd-env.c24
-rw-r--r--gdb/mi/mi-cmds.c2
-rw-r--r--gdb/mi/mi-cmds.h2
-rw-r--r--gdb/nto-procfs.c3
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.mi/mi-basics.exp32
-rw-r--r--gdb/win32-nat.c1
14 files changed, 204 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 85ba233991b..30352b501e2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,28 @@
+2005-07-06 Bob Rossi <bob@brasko.net>
+
+ * fork-child.c (fork-inferior): Use accessor function for
+ inferior_io_terminal.
+ * infcmd.c (inferior_io_terminal): Make static.
+ (set_inferior_io_terminal): New function.
+ (get_inferior_io_terminal): Ditto.
+ (tty_command): Use accessor function.
+ (_initialize_infcmd): Add inferior_tty setshow variable.
+ (_initialize_infcmd): Remove tty command.
+ (_initialize_infcmd): Add a tty command that is an alias.
+ * inferior.h (set_inferior_io_terminal): New prototype.
+ (get_inferior_io_terminal): Ditto.
+ (new_tty_prefork): Add const qualifier to parameter.
+ * inflow.c (inferior_thisrun_terminal): Add const qualifier.
+ (new_tty_prefork): Add const qualifier to parameter.
+ * nto-procfs (procfs_create_inferior): Use accessor function.
+ (procfs_create_inferior): Add const qualifier to locals.
+ * win32-nat.c (child_create_inferior): Ditto.
+ * mi/mi-cmd-env.c (mi_cmd_inferior_tty_set): New function.
+ (mi_cmd_inferior_tty_set): Ditto.
+ * mi/mi-cmds.c (mi_cmds): Add inferior-tty-set and inferior-tty-show
+ * mi/mi-cmds.h (mi_cmd_inferior_tty_set): Add prototype.
+ (mi_cmd_inferior_tty_show): Ditto.
+
2005-07-06 Wu Zhou <woodzltc@cn.ibm.com>
* tui/tui-win.c (parse_scrolling_args): Fix SEGV error with invalid
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 3d712e79360..b1929b78d3d 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,9 @@
+2005-07-06 Bob Rossi <bob@brasko.net>
+
+ * gdb.texinfo (GDB/MI Miscellaneous Commands): Add -inferior-tty-set
+ and -inferior-tty-show.
+ (Input/Output): Document "set/show inferior-tty" and tty alias.
+
2005-07-02 Nathan J. Williams <nathanw@wasabisystems.com>
* gdb.texinfo (Packets): Change description of 'D' packet to note
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 84281725313..580df9d3f76 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -2095,7 +2095,24 @@ terminal.
When you use the @code{tty} command or redirect input in the @code{run}
command, only the input @emph{for your program} is affected. The input
-for @value{GDBN} still comes from your terminal.
+for @value{GDBN} still comes from your terminal. @code{tty} is an alias
+for @code{set inferior-tty}.
+
+@cindex inferior tty
+@cindex set inferior controlling terminal
+You can use the @code{show inferior-tty} command to tell @value{GDBN} to
+display the name of the terminal that will be used for future runs of your
+program.
+
+@table @code
+@item set inferior-tty /dev/ttyb
+@kindex set inferior-tty
+Set the tty for the program being debugged to /dev/ttyb.
+
+@item show inferior-tty
+@kindex show inferior-tty
+Show the current tty for the program being debugged.
+@end table
@node Attach
@section Debugging an already-running process
@@ -19181,6 +19198,57 @@ The corresponding @value{GDBN} command is @samp{interpreter-exec}.
(@value{GDBP})
@end smallexample
+@subheading The @code{-inferior-tty-set} Command
+@findex -inferior-tty-set
+
+@subheading Synopsis
+
+@smallexample
+-inferior-tty-set /dev/pts/1
+@end smallexample
+
+Set terminal for future runs of the program being debugged.
+
+@subheading @value{GDBN} Command
+
+The corresponding @value{GDBN} command is @samp{set inferior-tty /dev/pts/1}.
+
+@subheading Example
+
+@smallexample
+(@value{GDBP})
+-inferior-tty-set /dev/pts/1
+^done
+(@value{GDBP})
+@end smallexample
+
+@subheading The @code{-inferior-tty-show} Command
+@findex -inferior-tty-show
+
+@subheading Synopsis
+
+@smallexample
+-inferior-tty-show
+@end smallexample
+
+Show terminal for future runs of program being debugged.
+
+@subheading @value{GDBN} Command
+
+The corresponding @value{GDBN} command is @samp{show inferior-tty /dev/pts/1}.
+
+@subheading Example
+
+@smallexample
+(@value{GDBP})
+-inferior-tty-set /dev/pts/1
+^done
+(@value{GDBP})
+-inferior-tty-show
+^done,inferior_tty_terminal="/dev/pts/1"
+(@value{GDBP})
+@end smallexample
+
@ignore
@c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@node GDB/MI Kod Commands
diff --git a/gdb/fork-child.c b/gdb/fork-child.c
index f2691661d71..5cf5e493d3f 100644
--- a/gdb/fork-child.c
+++ b/gdb/fork-child.c
@@ -138,6 +138,7 @@ fork_inferior (char *exec_file_arg, char *allargs, char **env,
char **save_our_env;
int shell = 0;
static char **argv;
+ const char *inferior_io_terminal = get_inferior_io_terminal ();
/* If no exec file handed to us, get it from the exec-file command
-- with a good, common error message if none is specified. */
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 86e8d9d778a..dff889f9cc1 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -136,7 +136,7 @@ static char **inferior_argv;
/* File name for default use for standard in/out in the inferior. */
-char *inferior_io_terminal;
+static char *inferior_io_terminal;
/* 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
@@ -203,6 +203,24 @@ struct gdb_environ *inferior_environ;
/* Accessor routines. */
+void
+set_inferior_io_terminal (const char *terminal_name)
+{
+ if (inferior_io_terminal)
+ xfree (inferior_io_terminal);
+
+ if (!terminal_name)
+ inferior_io_terminal = NULL;
+ else
+ inferior_io_terminal = savestring (terminal_name, strlen (terminal_name));
+}
+
+const char *
+get_inferior_io_terminal (void)
+{
+ return inferior_io_terminal;
+}
+
char *
get_inferior_args (void)
{
@@ -376,7 +394,7 @@ tty_command (char *file, int from_tty)
if (file == 0)
error_no_arg (_("terminal name for running target process"));
- inferior_io_terminal = savestring (file, strlen (file));
+ set_inferior_io_terminal (file);
}
/* Kill the inferior if already running. This function is designed
@@ -1988,11 +2006,15 @@ unset_command (char *args, int from_tty)
void
_initialize_infcmd (void)
{
- struct cmd_list_element *c;
-
- c = add_com ("tty", class_run, tty_command,
- _("Set terminal for future runs of program being debugged."));
- set_cmd_completer (c, filename_completer);
+ struct cmd_list_element *c = NULL;
+
+ /* add the filename of the terminal connected to inferior I/O */
+ add_setshow_filename_cmd ("inferior-tty", class_run,
+ &inferior_io_terminal, _("\
+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"), NULL, NULL, &setlist, &showlist);
+ add_com_alias ("tty", "set inferior-tty", class_alias, 0);
add_setshow_optional_filename_cmd ("args", class_run,
&inferior_args, _("\
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 4fbfcdef4ca..435bf7ee87e 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -103,9 +103,10 @@ extern void set_sigio_trap (void);
extern void clear_sigio_trap (void);
-/* File name for default use for standard in/out in the inferior. */
+/* Set/get file name for default use for standard in/out in the inferior. */
-extern char *inferior_io_terminal;
+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, PIDGET (inferior_ptid) will be 0. */
@@ -264,7 +265,7 @@ extern char *construct_inferior_arguments (struct gdbarch *, int, char **);
/* From inflow.c */
-extern void new_tty_prefork (char *);
+extern void new_tty_prefork (const char *);
extern int gdb_has_a_terminal (void);
diff --git a/gdb/inflow.c b/gdb/inflow.c
index 2961a3928e1..b88e3038b13 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -94,7 +94,7 @@ static void (*sigquit_ours) ();
/* The name of the tty (from the `tty' command) that we gave to the inferior
when it was last started. */
-static char *inferior_thisrun_terminal;
+static const char *inferior_thisrun_terminal;
/* Nonzero if our terminal settings are in effect. Zero if the
inferior's settings are in effect. Ignored if !gdb_has_a_terminal
@@ -509,7 +509,7 @@ child_terminal_info (char *args, int from_tty)
the terminal specified in the NEW_TTY_PREFORK call. */
void
-new_tty_prefork (char *ttyname)
+new_tty_prefork (const char *ttyname)
{
/* Save the name for later, for determining whether we and the child
are sharing a tty. */
diff --git a/gdb/mi/mi-cmd-env.c b/gdb/mi/mi-cmd-env.c
index 61fa7f8b098..b6e7fd7da1d 100644
--- a/gdb/mi/mi-cmd-env.c
+++ b/gdb/mi/mi-cmd-env.c
@@ -244,6 +244,30 @@ mi_cmd_env_dir (char *command, char **argv, int argc)
return MI_CMD_DONE;
}
+/* Set the inferior terminal device name. */
+enum mi_cmd_result
+mi_cmd_inferior_tty_set (char *command, char **argv, int argc)
+{
+ set_inferior_io_terminal (argv[0]);
+
+ return MI_CMD_DONE;
+}
+
+/* Print the inferior terminal device name */
+enum mi_cmd_result
+mi_cmd_inferior_tty_show (char *command, char **argv, int argc)
+{
+ const char *inferior_io_terminal = get_inferior_io_terminal ();
+
+ if ( !mi_valid_noargs ("mi_cmd_inferior_tty_show", argc, argv))
+ error (_("mi_cmd_inferior_tty_show: Usage: No args"));
+
+ if (inferior_io_terminal)
+ ui_out_field_string (uiout, "inferior_tty_terminal", inferior_io_terminal);
+
+ return MI_CMD_DONE;
+}
+
void
_initialize_mi_cmd_env (void)
{
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index 6655d0581ab..c2a3ecac685 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -91,6 +91,8 @@ struct mi_cmd mi_cmds[] =
{ "gdb-show", { "show", 1 }, NULL, NULL },
{ "gdb-source", { NULL, 0 }, NULL, NULL },
{ "gdb-version", { "show version", 0 }, 0 },
+ { "inferior-tty-set", { NULL, 0 }, NULL, mi_cmd_inferior_tty_set},
+ { "inferior-tty-show", { NULL, 0 }, NULL, mi_cmd_inferior_tty_show},
{ "interpreter-exec", { NULL, 0 }, 0, mi_cmd_interpreter_exec},
{ "kod-info", { NULL, 0 }, NULL, NULL },
{ "kod-list", { NULL, 0 }, NULL, NULL },
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index 560963c40e9..0712608d13f 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -85,6 +85,8 @@ extern mi_cmd_args_ftype mi_cmd_exec_interrupt;
extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_file;
extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_files;
extern mi_cmd_argv_ftype mi_cmd_gdb_exit;
+extern mi_cmd_argv_ftype mi_cmd_inferior_tty_set;
+extern mi_cmd_argv_ftype mi_cmd_inferior_tty_show;
extern mi_cmd_argv_ftype mi_cmd_interpreter_exec;
extern mi_cmd_argv_ftype mi_cmd_stack_info_depth;
extern mi_cmd_argv_ftype mi_cmd_stack_info_frame;
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index e65dfc275e4..c7aac005b14 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -981,9 +981,10 @@ procfs_create_inferior (char *exec_file, char *allargs, char **env,
pid_t pid;
int flags, errn;
char **argv, *args;
- char *in = "", *out = "", *err = "";
+ const char *in = "", *out = "", *err = "";
int fd, fds[3];
sigset_t set;
+ const char *inferior_io_terminal = get_inferior_io_terminal ();
argv = xmalloc (((strlen (allargs) + 1) / (unsigned) 2 + 2) *
sizeof (*argv));
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index bc57d7fb0bd..3b60675cc8e 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2005-07-06 Bob Rossi <bob@brasko.net>
+
+ * gdb.mi/mi-basics.exp (test_setshow_inferior_tty): Test MI tty
+ command.
+ (Copyright): Update copyright.
+
2005-07-06 Wu Zhou <woodzltc@cn.ibm.com>
* gdb.fortran/exprs.exp (test_arithmetic_expressions): Add five
diff --git a/gdb/testsuite/gdb.mi/mi-basics.exp b/gdb/testsuite/gdb.mi/mi-basics.exp
index 39a08736910..0d2b06ee98d 100644
--- a/gdb/testsuite/gdb.mi/mi-basics.exp
+++ b/gdb/testsuite/gdb.mi/mi-basics.exp
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2003, 2005 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
@@ -236,12 +236,42 @@ proc test_path_specification {} {
}
+proc test_setshow_inferior_tty {} {
+ global mi_gdb_prompt
+
+ # Test that the commands,
+ # -inferior-tty-set
+ # -inferior-tty-show
+ # are setting/getting the same data in GDB.
+
+ mi_gdb_test "301-inferior-tty-show" \
+ "301\\\^done" \
+ "initial tty is empty"
+
+ mi_gdb_test "302-inferior-tty-set /dev/pts/1" \
+ "302\\\^done" \
+ "set tty to /dev/pts/1"
+
+ mi_gdb_test "303-inferior-tty-show" \
+ "303\\\^done,inferior_tty_terminal=\"/dev/pts/1\"" \
+ "tty was set correctly"
+
+ mi_gdb_test "304-inferior-tty-set" \
+ "304\\\^done" \
+ "set tty to the empty string"
+
+ mi_gdb_test "305-inferior-tty-show" \
+ "305\\\^done" \
+ "final tty is empty"
+}
+
if [test_mi_interpreter_selection] {
test_exec_and_symbol_mi_operatons
test_breakpoints_deletion
test_dir_specification
test_cwd_specification
test_path_specification
+ test_setshow_inferior_tty
}
mi_gdb_exit
diff --git a/gdb/win32-nat.c b/gdb/win32-nat.c
index bd775ad6b27..d9525727479 100644
--- a/gdb/win32-nat.c
+++ b/gdb/win32-nat.c
@@ -1735,6 +1735,7 @@ child_create_inferior (char *exec_file, char *allargs, char **env,
const char *sh;
int tty;
int ostdin, ostdout, ostderr;
+ const char *inferior_io_terminal = get_inferior_io_terminal ();
if (!exec_file)
error (_("No executable specified, use `target exec'."));