public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH 3/3] Set stdin/stdout/stderr to binary mode in cygwin.
Date: Thu, 01 Aug 2013 08:10:00 -0000	[thread overview]
Message-ID: <51FA17C3.9070307@codesourcery.com> (raw)
In-Reply-To: <83r4ehxtey.fsf@gnu.org>

On 07/29/2013 11:44 PM, Eli Zaretskii wrote:
>> +      setmode (fileno (stdin), O_BINARY);
>> >+      setmode (fileno (stdout), O_BINARY);
>> >+      setmode (fileno (stderr), O_BINARY);
> Do you really need all 3 of the standard handles in binary mode?  I
> thought the problem was only with output?

Setting stdin in binary mode is for another purpose, should go to a
separated patch.  Sorry for the confusion.  Patch below is to only set
stdout and stderr in binary mode.

-- 
Yao (齐尧)

gdb:

2013-08-01  Pedro Alves  <pedro@codesourcery.com>
	    Daniel Jacobowitz  <dan@codesourcery.com>
	    Yao Qi  <yao@codesourcery.com>

	* main.c [__MINGW32__]: Include fcntl.h and windows.h.
	(captured_main) [__MINGW32__]: Set stdout and stderr to
	binary mode if GDB is using cygwin pty.
---
 gdb/main.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/gdb/main.c b/gdb/main.c
index 3a2fee6..6a79df9 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -47,6 +47,11 @@
 #include "filenames.h"
 #include "filestuff.h"
 
+#ifdef __MINGW32__
+#include <fcntl.h>
+#include <windows.h>
+#endif
+
 /* The selected interpreter.  This will be used as a set command
    variable, so it should always be malloc'ed - since
    do_setshow_command will free it.  */
@@ -384,6 +389,13 @@ captured_main (void *data)
 	 other operation is performed.  */
       setvbuf (stdout, NULL, _IONBF, BUFSIZ);
       setvbuf (stderr, NULL, _IONBF, BUFSIZ);
+
+      /* In textmode, a '\n' is automatically expanded into "\r\n".  This
+	 results in expect seeing "\r\r\n".  The tests aren't prepared
+	 currently for other forms of eol.  As a workaround, we force the
+	 output to binary mode.  */
+      setmode (fileno (stdout), O_BINARY);
+      setmode (fileno (stderr), O_BINARY);
     }
 #endif
 
-- 
1.7.7.6


  reply	other threads:[~2013-08-01  8:10 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-29  8:46 [PATCH 0/3 V3] Test mingw32 GDB " Yao Qi
2013-07-29  8:46 ` [PATCH 3/3] Set stdin/stdout/stderr to binary mode " Yao Qi
2013-07-29 15:44   ` Eli Zaretskii
2013-08-01  8:10     ` Yao Qi [this message]
2013-08-01 16:37       ` Eli Zaretskii
2013-07-29  8:46 ` [PATCH 2/3] Unbuffer stdout and stderr " Yao Qi
2013-07-29 15:42   ` Eli Zaretskii
2013-08-01  8:06     ` Yao Qi
2013-08-01 16:36       ` Eli Zaretskii
2013-08-02  0:40         ` Yao Qi
2013-07-29  8:46 ` [PATCH 1/3] Detect GDB is " Yao Qi
2013-07-29 15:38   ` Eli Zaretskii
2013-07-30  9:27     ` Yao Qi
2013-07-30 15:33       ` Eli Zaretskii
2013-08-01  7:52         ` Yao Qi
2013-08-01 16:33           ` Eli Zaretskii
2013-08-02  2:51             ` Yao Qi
2013-08-02  6:10               ` Eli Zaretskii
2013-08-03  4:55           ` Christopher Faylor
2013-08-04  8:45             ` Yao Qi
2013-08-05  4:41               ` Christopher Faylor
2013-08-05  6:23                 ` Yao Qi
2013-08-06  2:08                   ` Christopher Faylor
2013-08-06  3:05                     ` Yao Qi
2013-08-08  5:11                       ` Christopher Faylor
2013-08-08  7:24                         ` Yao Qi
2013-08-15 17:40                           ` Christopher Faylor
2013-08-15 18:58                             ` Tom Tromey
2013-08-15 19:14                               ` Eli Zaretskii
2013-08-16  0:06                                 ` Yao Qi
2013-08-16  2:01                                   ` Tom Tromey
2013-08-16  1:07                             ` Yao Qi
2013-08-16 16:37                               ` Christopher Faylor
2013-08-08  7:28                         ` Pierre Muller
2013-08-13  8:12                           ` Yao Qi
2013-08-13  8:23                             ` Pierre Muller
2013-07-29 14:03 ` [PATCH 0/3 V3] Test mingw32 GDB " Pierre Muller
2013-07-30  6:03   ` Yao Qi
2013-07-29 18:03 ` Tom Tromey
2013-07-29 18:43   ` Eli Zaretskii

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=51FA17C3.9070307@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=eliz@gnu.org \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).