From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16610 invoked by alias); 25 Jul 2013 05:10:21 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 16573 invoked by uid 89); 25 Jul 2013 05:10:21 -0000 X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_50,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RDNS_NONE,TW_SF,TW_TV,TW_VB autolearn=no version=3.3.1 Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 25 Jul 2013 05:10:20 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1V2Dob-00038D-47 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Wed, 24 Jul 2013 22:10:13 -0700 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Wed, 24 Jul 2013 22:10:12 -0700 Received: from qiyao.dyndns.org.dyndns.org (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Wed, 24 Jul 2013 22:10:12 -0700 From: Yao Qi To: Subject: [PATCH 3/3] native mingw32 gdb, eol format Date: Thu, 25 Jul 2013 05:10:00 -0000 Message-ID: <1374728963-25187-4-git-send-email-yao@codesourcery.com> In-Reply-To: <1374728963-25187-1-git-send-email-yao@codesourcery.com> References: <1374728963-25187-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-07/txt/msg00591.txt.bz2 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 Daniel Jacobowitz Yao Qi * 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 +#include +#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