Fix for using named pipes on Windows
authorGuillaume LABARTHE <guillaume.labarthe@gmail.com>
Thu, 18 Jul 2019 16:20:04 +0000 (17:20 +0100)
committerPedro Alves <palves@redhat.com>
Thu, 18 Jul 2019 16:20:04 +0000 (17:20 +0100)
On Windows, passing a named pipe as terminal argument to the new-ui
command does not work.

The problem is that the new_ui_command function in top.c opens the
same tty three times, for stdin, stdout and stderr.  With Windows
named pipes, the second and third calls to open fail.

Opening the file only once and passing the same stream for stdin,
stdout and stderr makes it work.

Pedro says:

 I tried it on GNU/Linux and things still work.
 I ran all the MI tests with forced new-ui, with:

 $ make check TESTS="gdb.mi/*.exp" RUNTESTFLAGS="FORCE_MI_SEPARATE_UI=1"

 and saw no regressions.

gdb/ChangeLog:
2019-07-18  Guillaume LABARTHE  <guillaume.labarthe@gmail.com>

* top.c (new_ui_command): Open specified terminal just once.

gdb/ChangeLog
gdb/top.c

index fa669daa4b3825f2d35b751e72aef99d3ed794ef..d6fe9895a717f69a332d3f4d08d211b75f69dc10 100644 (file)
@@ -1,3 +1,7 @@
+2019-07-18  Guillaume LABARTHE  <guillaume.labarthe@gmail.com>
+
+       * top.c (new_ui_command): Open specified terminal just once.
+
 2019-07-18  Tom Tromey  <tromey@adacore.com>
 
        * symtab.c (main_name): Constify return type.
index 83a3604688b1c952d4d412ed454401b6485825bf..60f81b3bf85416c3f48201666095e40297d3effe 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -337,8 +337,6 @@ open_terminal_stream (const char *name)
 static void
 new_ui_command (const char *args, int from_tty)
 {
-  gdb_file_up stream[3];
-  int i;
   int argc;
   const char *interpreter_name;
   const char *tty_name;
@@ -357,13 +355,13 @@ new_ui_command (const char *args, int from_tty)
   {
     scoped_restore save_ui = make_scoped_restore (&current_ui);
 
-    /* Open specified terminal, once for each of
-       stdin/stdout/stderr.  */
-    for (i = 0; i < 3; i++)
-      stream[i] = open_terminal_stream (tty_name);
+    /* Open specified terminal.  Note: we used to open it three times,
+       once for each of stdin/stdout/stderr, but that does not work
+       with Windows named pipes.  */
+    gdb_file_up stream = open_terminal_stream (tty_name);
 
     std::unique_ptr<ui> ui
-      (new struct ui (stream[0].get (), stream[1].get (), stream[2].get ()));
+      (new struct ui (stream.get (), stream.get (), stream.get ()));
 
     ui->async = 1;
 
@@ -373,10 +371,8 @@ new_ui_command (const char *args, int from_tty)
 
     interp_pre_command_loop (top_level_interpreter ());
 
-    /* Make sure the files are not closed.  */
-    stream[0].release ();
-    stream[1].release ();
-    stream[2].release ();
+    /* Make sure the file is not closed.  */
+    stream.release ();
 
     ui.release ();
   }
This page took 0.029437 seconds and 4 git commands to generate.