This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mi tty commands


Sorry Daniel, this patch was old and I had already reformatted most of
the problems you noticed. I have been paying attention to the spacing
issues and wouldn't try to waste your time.

Here is an updated patch which should take into account all of the
problems. However, it is of course possible problems still exist.

On Sat, May 28, 2005 at 07:08:55PM -0400, Daniel Jacobowitz wrote:
> On Sun, May 22, 2005 at 05:00:40PM -0400, Bob Rossi wrote:
> > On Thu, Mar 10, 2005 at 09:26:44PM -0500, Bob Rossi wrote:
> > > Ping
> > 
> > Ping, and O yeah, I updated the patch the best I could to get the code
> > to conform with the GNU coding standards. I hope I'm getting this right.
> 
> Not quite, but I don't mind proofreading :-)
> 
> > +2005-05-22  Bob Rossi  <bob@brasko.net>
> > +
> > +	* fork-child.c (fork-inferior): Use accessor function for
> > +	inferior_io_terminal
> > +	* infcmd.c (inferior_io_terminal): make static
> 
> All ChangeLog entries should start with a capital letter, end with a
> period, and be generally sentencelike.  You've got the third bit down.

Done.

> > +	(set_inferior_io_terminal): Add accessor definition
> > +	(get_inferior_io_terminal): Add accessor definition
> > +	(tty_command): Use accessor function
> > +	(_initialize_infcmd): Add inferior_tty setshow variable
> > +	* inferior.h (set_inferior_io_terminal): Add accessor declaration
> > +	(get_inferior_io_terminal): Add accessor declaration
> > +	* nto-procfs (procfs_create_inferior): Use accessor function
> > +	* win32-nat.c (child_create_inferior): Use accessor function
> > +	* mi/mi-cmd-env.c (mi_cmd_inferior_tty_set): Add MI definition
> > +	(mi_cmd_inferior_tty_set): Add MI definition
> 
> Just "New function" is usually fine.

Done.

> > +	* mi/mi-cmds.c (mi_cmds): Add inferior-tty-set/inferior-tty-show
> 
> Please use "and" instead of /.
> 
> > +  const char *inferior_io_terminal = get_inferior_io_terminal();
> 
> That pesky space! :-)

Done.

> >    /* If no exec file handed to us, get it from the exec-file command
> >       -- with a good, common error message if none is specified.  */
> > @@ -261,7 +262,7 @@
> >  
> >    /* Tell the terminal handling subsystem what tty we plan to run on;
> >       it will just record the information for later.  */
> > -  new_tty_prefork (inferior_io_terminal);
> > +  new_tty_prefork ((char*)inferior_io_terminal);
> 
> Another pesky space; please use "char *".

Done.

> > +  if (inferior_io_terminal)
> > +    xfree ( inferior_io_terminal );
> 
> Some pesky anti-spaces.

Done.

> > +  /* add the filename of the terminal connected to inferior I/O */
> > +  add_setshow_string_noescape_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);
> > +  set_cmd_completer (c, filename_completer);
> > +
> 
> Ditto on the pesky spaces.  The Usage: bit is unnecessary.  There are
> no other set commands with underscores; inferior-tty would be better,
> but would just "tty" be OK?  That's even simpler.

I changed it to inferior-tty. If you insist on "tty", I'll change it.
However, I was thinking with MI, there might one day be console-tty.

> > -/* File name for default use for standard in/out in the inferior.  */
> > +/* Set/Get name for default use for standard in/out in the inferior.  */
> 
> Get doesn't need to be capitalized here.  Also, it's still a file name;
> could you leave that?

OK, done.

> > +Set terminal for future runs of program being debugged.
> 
> I think there's either one or two missing uses of "the" here; at least
> one before program.

Done.

> > +/* Set the inferior terminal device name */
> 
> Full sentence with a full stop at the end, please.

Done.

> > +    # test that the commands,
> > +    #   -inferior-tty-set
> > +    #   -inferior-tth-show
>
> Test that they what?  Or just "Test the commands:".

Hmm, I must have feel asleep ..., I'm over worked and under payed :)

> I tried to point out one example of each of the formatting problems;
> that wasn't an exhaustive list, but you can probably see all the others
> now.

Thanks for doing this. I should be capable of getting this mostly
correct from now on. I wouldn't expect to see to many spacing errors.

Thanks,
Bob Rossi

Index: src/gdb/ChangeLog
+	* 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.
+	* inferior.h (set_inferior_io_terminal): New prototype.
+	(get_inferior_io_terminal): Ditto.
+	* nto-procfs (procfs_create_inferior): Use accessor function.
+	* 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: src/gdb/doc/ChangeLog
+	* gdb.texinfo (GDB/MI Miscellaneous Commands): Add -inferior-tty-set.
+	(GDB/MI Miscellaneous Commands): Add -inferior-tty-show.

Index: src/gdb/fork-child.c
===================================================================
RCS file: /cvs/src/src/gdb/fork-child.c,v
retrieving revision 1.26
diff -w -u -r1.26 fork-child.c
--- src/gdb/fork-child.c	12 May 2005 20:21:17 -0000	1.26
+++ src/gdb/fork-child.c	29 May 2005 23:09:28 -0000
@@ -138,6 +138,7 @@
   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.  */
@@ -261,7 +262,7 @@
 
   /* Tell the terminal handling subsystem what tty we plan to run on;
      it will just record the information for later.  */
-  new_tty_prefork (inferior_io_terminal);
+  new_tty_prefork ((char *)inferior_io_terminal);
 
   /* It is generally good practice to flush any possible pending stdio
      output prior to doing a fork, to avoid the possibility of both
Index: src/gdb/infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.138
diff -w -u -r1.138 infcmd.c
--- src/gdb/infcmd.c	22 May 2005 14:53:34 -0000	1.138
+++ src/gdb/infcmd.c	29 May 2005 23:09:29 -0000
@@ -136,7 +136,7 @@
 
 /* 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 @@
 
 /* Accessor routines. */
 
+void 
+set_inferior_io_terminal (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 @@
   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
@@ -1994,6 +2012,14 @@
 	       _("Set terminal for future runs of program being debugged."));
   set_cmd_completer (c, filename_completer);
 
+  /* add the filename of the terminal connected to inferior I/O */
+  add_setshow_string_noescape_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);
+  set_cmd_completer (c, filename_completer);
+
   add_setshow_optional_filename_cmd ("args", class_run,
 				     &inferior_args, _("\
 Set argument list to give program being debugged when it is started."), _("\
Index: src/gdb/inferior.h
===================================================================
RCS file: /cvs/src/src/gdb/inferior.h,v
retrieving revision 1.71
diff -w -u -r1.71 inferior.h
--- src/gdb/inferior.h	14 May 2005 06:07:42 -0000	1.71
+++ src/gdb/inferior.h	29 May 2005 23:09:30 -0000
@@ -103,9 +103,10 @@
 
 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 (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. */
Index: src/gdb/nto-procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/nto-procfs.c,v
retrieving revision 1.13
diff -w -u -r1.13 nto-procfs.c
--- src/gdb/nto-procfs.c	15 Feb 2005 15:49:14 -0000	1.13
+++ src/gdb/nto-procfs.c	29 May 2005 23:09:30 -0000
@@ -984,6 +984,7 @@
   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));
@@ -1010,11 +1011,11 @@
   if (inferior_io_terminal)
     {
       if (!in[0])
-	in = inferior_io_terminal;
+	in = (char*)inferior_io_terminal;
       if (!out[0])
-	out = inferior_io_terminal;
+	out = (char*)inferior_io_terminal;
       if (!err[0])
-	err = inferior_io_terminal;
+	err = (char*)inferior_io_terminal;
     }
 
   if (in[0])
Index: src/gdb/win32-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/win32-nat.c,v
retrieving revision 1.111
diff -w -u -r1.111 win32-nat.c
--- src/gdb/win32-nat.c	23 May 2005 19:32:27 -0000	1.111
+++ src/gdb/win32-nat.c	29 May 2005 23:09:31 -0000
@@ -1735,6 +1735,7 @@
   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'."));
Index: src/gdb/doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.257
diff -w -u -r1.257 gdb.texinfo
--- src/gdb/doc/gdb.texinfo	26 May 2005 19:28:23 -0000	1.257
+++ src/gdb/doc/gdb.texinfo	29 May 2005 23:09:47 -0000
@@ -19092,6 +19092,57 @@
 (@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
Index: src/gdb/mi/mi-cmd-env.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmd-env.c,v
retrieving revision 1.8
diff -w -u -r1.8 mi-cmd-env.c
--- src/gdb/mi/mi-cmd-env.c	11 Feb 2005 04:06:11 -0000	1.8
+++ src/gdb/mi/mi-cmd-env.c	29 May 2005 23:09:47 -0000
@@ -244,6 +244,30 @@
   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)
 {
Index: src/gdb/mi/mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.16
diff -w -u -r1.16 mi-cmds.c
--- src/gdb/mi/mi-cmds.c	11 Feb 2005 18:13:55 -0000	1.16
+++ src/gdb/mi/mi-cmds.c	29 May 2005 23:09:47 -0000
@@ -153,6 +153,8 @@
   { "trace-save", { NULL, 0 }, NULL, NULL },
   { "trace-start", { NULL, 0 }, NULL, NULL },
   { "trace-stop", { NULL, 0 }, NULL, NULL },
+  { "inferior-tty-set", { NULL, 0 }, NULL, mi_cmd_inferior_tty_set},
+  { "inferior-tty-show", { NULL, 0 }, NULL, mi_cmd_inferior_tty_show},
   { "var-assign", { NULL, 0 }, 0, mi_cmd_var_assign},
   { "var-create", { NULL, 0 }, 0, mi_cmd_var_create},
   { "var-delete", { NULL, 0 }, 0, mi_cmd_var_delete},
Index: src/gdb/mi/mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.15
diff -w -u -r1.15 mi-cmds.h
--- src/gdb/mi/mi-cmds.h	13 Jan 2005 22:08:27 -0000	1.15
+++ src/gdb/mi/mi-cmds.h	29 May 2005 23:09:47 -0000
@@ -96,6 +96,8 @@
 extern mi_cmd_args_ftype mi_cmd_target_select;
 extern mi_cmd_argv_ftype mi_cmd_thread_list_ids;
 extern mi_cmd_argv_ftype mi_cmd_thread_select;
+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_var_assign;
 extern mi_cmd_argv_ftype mi_cmd_var_create;
 extern mi_cmd_argv_ftype mi_cmd_var_delete;
Index: src/gdb/testsuite/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/ChangeLog,v
retrieving revision 1.1119
diff -w -u -r1.1119 ChangeLog
--- src/gdb/testsuite/ChangeLog	29 May 2005 01:58:53 -0000	1.1119
+++ src/gdb/testsuite/ChangeLog	29 May 2005 23:09:55 -0000
@@ -1,3 +1,8 @@
+2005-05-28  Bob Rossi  <bob@brasko.net>
+
+	* gdb.mi/mi-basics.exp (test_setshow_inferior_tty): Test MI tty
+	command.
+
 2005-05-29  Joel Brobecker  <brobecker@adacore.com>
 
 	* gdb.arch/alpha-step.c: New file.
Index: src/gdb/testsuite/gdb.mi/mi-basics.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
retrieving revision 1.9
diff -w -u -r1.9 mi-basics.exp
--- src/gdb/testsuite/gdb.mi/mi-basics.exp	9 Aug 2004 16:32:44 -0000	1.9
+++ src/gdb/testsuite/gdb.mi/mi-basics.exp	29 May 2005 23:09:56 -0000
@@ -236,12 +236,42 @@
 
 } 
 
+proc test_setshow_inferior_tty {} {
+    global mi_gdb_prompt
+
+    # Test that the commands,
+    #   -inferior-tty-set
+    #   -inferior-tth-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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]