This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] native mingw32 gdb, eol format
- From: Yao Qi <yao at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Tue, 16 Jul 2013 09:06:07 +0800
- Subject: [PATCH] native mingw32 gdb, eol format
Hello,
I see the following fail on a remote windows host for mingw32 native
gdb,
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 through the PTY, the '\n' is being expanded to "\r\n",
hence "\r\r\n".
This patch, which was written by Pedro, is to force stdout/stderr to
binary mode prevents that expansion. This patch gets much
improvement on the test result of mingw native gdb. Is it OK?
=== gdb Summary ===
-# of expected passes 11845
-# of unexpected failures 2931
-# of expected failures 22
-# of unknown successes 1
-# of known failures 20
-# of unresolved testcases 911
-# of untested testcases 131
-# of unsupported tests 84
+# of expected passes 14613
+# of unexpected failures 780
+# of unexpected successes 1
+# of expected failures 37
+# of known failures 35
+# of unresolved testcases 23
+# of untested testcases 130
+# of unsupported tests 94
gdb:
2013-07-16 Pedro Alves <pedro@codesourcery.com>
Yao Qi <yao@codesourcery.com>
* mingw-hdep.c (_initialize_mingw_hdep): If stdout and stderr
are pipes, set them to binary mode.
---
gdb/mingw-hdep.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/gdb/mingw-hdep.c b/gdb/mingw-hdep.c
index efc9848..3b29495 100644
--- a/gdb/mingw-hdep.c
+++ b/gdb/mingw-hdep.c
@@ -271,5 +271,24 @@ extern initialize_file_ftype _initialize_mingw_hdep;
void
_initialize_mingw_hdep (void)
{
+ int out = fileno (stdout);
+ int err = fileno (stderr);
+ HANDLE hout = (HANDLE) _get_osfhandle (out);
+ HANDLE herr = (HANDLE) _get_osfhandle (err);
+
+ /* 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 (hout) == FILE_TYPE_PIPE
+ && GetFileType (herr) == FILE_TYPE_PIPE)
+ {
+ setmode (out, O_BINARY);
+ setmode (err, O_BINARY);
+ }
+
sigint_event = CreateEvent (0, FALSE, FALSE, 0);
}
--
1.7.7.6