From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 3/3] native mingw32 gdb, eol format
Date: Thu, 25 Jul 2013 05:10:00 -0000 [thread overview]
Message-ID: <1374728963-25187-4-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1374728963-25187-1-git-send-email-yao@codesourcery.com>
Hello,
I see the following fail on a remote windows host,
info tracepoints^M
Num Type Disp Enb Address What^M^M
1 tracepoint keep y 0x0040143f in gdb_c_test at actions.c:74^M^M
not installed on target^M^M
2 tracepoint keep y 0x00401687 in gdb_asm_test at actions.c:121^M^M
not installed on target^M^M
3 tracepoint keep y 0x004013d2 in gdb_recursion_test at actions.c:61^M^M
not installed on target^M^M
(gdb) FAIL: gdb.trace/deltrace.exp: 3.1a: set three tracepoints
this fail is caused by an extra '\r' at end of each line.
on Windows, when a file is opened in text mode, a "\n" is always
expanded to "\r\n", so gdb on Windows is outputting "\r\n", and when
that goes throught the PTY, the '\n' is being expanded to "\r\n",
hence "\r\r\n".
This patch is to force stdin/stdout/stderr to binary mode prevents that
expansion.
gdb:
2013-07-25 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__]: If stdout, stdin and stderr
are pipes, set them to binary mode.
---
gdb/main.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/gdb/main.c b/gdb/main.c
index 4777286..3b871ee 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. */
@@ -753,12 +758,33 @@ captured_main (void *data)
#ifdef __MINGW32__
if (cygwin_tty)
{
+ int in = fileno (stdin);
+ int out = fileno (stdout);
+ int err = fileno (stderr);
+ HANDLE hin = (HANDLE) _get_osfhandle (in);
+ HANDLE hout = (HANDLE) _get_osfhandle (out);
+ HANDLE herr = (HANDLE) _get_osfhandle (err);
+
/* A Cygwin session may not look like a terminal to the Windows
runtime; ensure unbuffered output. Note that setvbuf may be
used after the file is opened but before any other operation
is performed. */
setvbuf (stdout, NULL, _IONBF, BUFSIZ);
setvbuf (stderr, NULL, _IONBF, BUFSIZ);
+
+ /* In textmode, a '\n' is automatically expanded into "\r\n". When
+ driving the testsuite from a linux host, the '\n' is also
+ 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. Do this only if
+ the files are pipes (cygwin ttys are Windows pipes behind the
+ scenes). */
+ if (GetFileType (hin) == FILE_TYPE_PIPE)
+ setmode (in, O_BINARY);
+ if (GetFileType (hout) == FILE_TYPE_PIPE)
+ setmode (out, O_BINARY);
+ if (GetFileType (herr) == FILE_TYPE_PIPE)
+ setmode (err, O_BINARY);
}
#endif
--
1.7.7.6
next prev parent reply other threads:[~2013-07-25 5:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-25 5:10 [PATCH 0/3] Test mingw32 GDB in cygwin Yao Qi
2013-07-25 5:10 ` [PATCH 1/3] New option --cygwin-tty Yao Qi
2013-07-25 7:34 ` Corinna Vinschen
2013-07-25 7:37 ` Pierre Muller
2013-07-25 7:55 ` Yao Qi
2013-07-25 8:18 ` Corinna Vinschen
2013-07-25 8:26 ` Corinna Vinschen
2013-07-25 9:05 ` Yao Qi
2013-07-25 10:20 ` Corinna Vinschen
2013-07-25 12:08 ` Yao Qi
2013-07-25 15:21 ` Corinna Vinschen
2013-07-26 19:40 ` Doug Evans
2013-07-25 5:10 ` Yao Qi [this message]
2013-07-25 5:10 ` [PATCH 2/3] Unbuffer stdout and stderr on windows Yao Qi
2013-07-25 7:31 ` [PATCH 0/3] Test mingw32 GDB in cygwin Pierre Muller
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=1374728963-25187-4-git-send-email-yao@codesourcery.com \
--to=yao@codesourcery.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