From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29830 invoked by alias); 17 Sep 2013 23:14:14 -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 29814 invoked by uid 89); 17 Sep 2013 23:14:13 -0000 Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.222.213) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Sep 2013 23:14:13 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=AWL,BAYES_20,MSGID_MULTIPLE_AT autolearn=no version=3.3.2 X-HELO: mailhost.u-strasbg.fr Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antispam (Postfix) with ESMTP id 58505C0508 for ; Wed, 18 Sep 2013 01:14:10 +0200 (CEST) Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antivirus (Postfix) with ESMTP id 48393C0AB7 for ; Wed, 18 Sep 2013 01:14:10 +0200 (CEST) Received: from md15.u-strasbg.fr (md15.u-strasbg.fr [130.79.200.204]) by mr3.u-strasbg.fr (Postfix) with ESMTP id 37B98C0508 for ; Wed, 18 Sep 2013 01:14:09 +0200 (CEST) Received: from ms17.u-strasbg.fr (ms17.u-strasbg.fr [130.79.204.117]) by md15.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id r8HNE95h018621 for ; Wed, 18 Sep 2013 01:14:09 +0200 (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (lec67-4-82-230-53-140.fbx.proxad.net [82.230.53.140]) (Authenticated sender: mullerp) by ms17.u-strasbg.fr (Postfix) with ESMTPSA id D49BB1FD95 for ; Wed, 18 Sep 2013 01:14:08 +0200 (CEST) From: "Pierre Muller" To: Subject: [RFC] Testsuite: Avoid \r\r\n problem of *-*-mingw* host Date: Tue, 17 Sep 2013 23:14:00 -0000 Message-ID: <006301ceb3fb$9bad1d60$d3075820$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-SW-Source: 2013-09/txt/msg00559.txt.bz2 Here is an alternate proposal to get rid of that double \r problem encountered when running the testsuite with mingw host GDB. maint set testsuite-mode on force stdout and stderr to use binary mode. maint set testsuite-mode off restores stdout and stderr "normal" text mode behavior. Comments welcome, Pierre Muller GDB pascal language maintainer 2013-09-18 Pierre Muller * mingw-hdep.c (set_output_binary_mode): New function. (set_output_normal_mode, set_maint_testsuite_mode): New functions. (show_maint_testsuite_mode): New function. (_initialize_mingw_hdep): Add new command, "maintenance set testsuite-mode on/off". testsuite/ChangeLog: * testsuite/lib/gdb.exp (*-*-mingw* hosts): Add "maint set testsuite-mode" and "set interacitve-mode on" startup command. Index: src/gdb/mingw-hdep.c =================================================================== RCS file: /cvs/src/src/gdb/mingw-hdep.c,v retrieving revision 1.16 diff -u -p -r1.16 mingw-hdep.c --- src/gdb/mingw-hdep.c 6 Apr 2013 06:52:06 -0000 1.16 +++ src/gdb/mingw-hdep.c 17 Sep 2013 23:00:49 -0000 @@ -21,6 +21,8 @@ #include "main.h" #include "serial.h" #include "event-loop.h" +#include "command.h" +#include "gdbcmd.h" #include "gdb_assert.h" #include "gdb_select.h" @@ -265,6 +267,50 @@ gdb_call_async_signal_handler (struct as SetEvent (sigint_event); } +/* Set stdout and stderr handles to binary unbuffered mode. */ + +static void +set_output_binary_mode (void) +{ + /* 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); +} + +/* Restore stdout and stderr handles to "normal" mode. */ + +static void +set_output_normal_mode (void) +{ + setmode (fileno (stdout), O_TEXT); + setmode (fileno (stderr), O_TEXT); +} + +static int maint_testsuite_mode = 0; + +/* Sets the maintenance testsuite mode using the static global + testuite_mode. */ + +static void +set_maint_testsuite_mode (char *args, int from_tty, + struct cmd_list_element *c) +{ + if (maint_testsuite_mode) + set_output_binary_mode (); + else + set_output_normal_mode (); +} + +static void +show_maint_testsuite_mode (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("Testsuite mode is %s.\n"), value); +} + /* -Wmissing-prototypes */ extern initialize_file_ftype _initialize_mingw_hdep; @@ -272,4 +318,16 @@ void _initialize_mingw_hdep (void) { sigint_event = CreateEvent (0, FALSE, FALSE, 0); + add_setshow_boolean_cmd ("testsuite-mode", class_maintenance, + &maint_testsuite_mode, _("\ +Set to adapt to dejagnu testsuite runs."), _("\ +Show whether GDB is adapted to run testsuite."), _("\ +Use \"on\" to enable, \"off\" to disable.\n\ +If enabled, stdout and stderr are set to binary mode,\n\ +to allow better testing."), + set_maint_testsuite_mode, + show_maint_testsuite_mode, + &maintenance_set_cmdlist, + &maintenance_show_cmdlist); + } Index: src/gdb/testsuite/lib/gdb.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v retrieving revision 1.245 diff -u -p -r1.245 gdb.exp --- src/gdb/testsuite/lib/gdb.exp 16 Sep 2013 23:59:02 -0000 1.245 +++ src/gdb/testsuite/lib/gdb.exp 17 Sep 2013 23:01:48 -0000 @@ -61,6 +61,10 @@ global INTERNAL_GDBFLAGS if ![info exists INTERNAL_GDBFLAGS] { set INTERNAL_GDBFLAGS "-nw -nx -data-directory $BUILD_DATA_DIRECTORY" } +if [ishost "*-*-mingw*"] { + verbose "mingw host, needs testsuite-mode" +# append INTERNAL_GDBFLAGS " -iex {maint set testsuite-mode on} -iex {set interactive-mode on}" +} # The variable gdb_prompt is a regexp which matches the gdb prompt. # Set it if it is not already set.