Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: LABARTHE Guillaume <guillaume.labarthe@gmail.com>
To: gdb-patches@sourceware.org
Subject: [RFC][PATCH] new-ui command under windows using NamedPipe
Date: Wed, 17 Jul 2019 18:41:00 -0000	[thread overview]
Message-ID: <CAE8umTY7-xAwTgxBrF1kVMFHURhLqbX84rPYb8=Wtw6=ve+9fQ@mail.gmail.com> (raw)

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

Hello,

I am currently working on a front-end for gdb on windows, and trying
to use the new-ui command passing as tty name the name of a named pipe
without luck.

Then I decided to dig into it so I cloned gdb's repo and started
debugging. After some investigation I found out that the problem was
that the function new_ui_command in top.c opens the same tty three
times (for stdin, sdout and stderr). With windows named pipes the
second and third calls to open fail. I then patched the function to
open the file only once and pass the same stream for stdin stdout and
stderr and that made it work.

I don't know the implication of my patch on other operating systems or
what would be the way to make it specific to windows.

Can you please advise on the best way to make this patch portable.
You will find in the attachments my patch so far.

Best regards

[-- Attachment #2: 0001-First-fix-for-using-named-pipes-on-windows.patch --]
[-- Type: application/octet-stream, Size: 1498 bytes --]

From 7592ffa1d242253ff764a4914056649065aaa959 Mon Sep 17 00:00:00 2001
From: Guillaume LABARTHE <guillaume.labarthe@gmail.com>
Date: Wed, 17 Jul 2019 20:25:04 +0200
Subject: [PATCH] First fix for using named pipes on windows


diff --git a/gdb/top.c b/gdb/top.c
index c5fc94f829..405526d92b 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -340,8 +340,7 @@ open_terminal_stream (const char *name)
 static void
 new_ui_command (const char *args, int from_tty)
 {
-  gdb_file_up stream[3];
-  int i;
+  gdb_file_up stream;
   int argc;
   const char *interpreter_name;
   const char *tty_name;
@@ -360,13 +359,11 @@ 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 */
+    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;
 
@@ -377,10 +374,7 @@ 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 ();
-
+    stream.release ();
     ui.release ();
   }
 
-- 
2.11.0


             reply	other threads:[~2019-07-17 18:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-17 18:41 LABARTHE Guillaume [this message]
2019-07-18 16:24 ` Pedro Alves
2019-07-19  8:50   ` Andrew Burgess
2019-07-19  8:54     ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAE8umTY7-xAwTgxBrF1kVMFHURhLqbX84rPYb8=Wtw6=ve+9fQ@mail.gmail.com' \
    --to=guillaume.labarthe@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox