From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19571 invoked by alias); 26 Sep 2013 20:01:41 -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 19559 invoked by uid 89); 26 Sep 2013 20:01:41 -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; Thu, 26 Sep 2013 20:01:41 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.4 required=5.0 tests=AWL,BAYES_50,MSGID_MULTIPLE_AT,SPAM_SUBJECT 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 DFC35C0F44 for ; Thu, 26 Sep 2013 22:01:37 +0200 (CEST) Received: from mailhost.u-strasbg.fr (localhost [127.0.0.1]) by antivirus (Postfix) with ESMTP id C75EEC0FC3 for ; Thu, 26 Sep 2013 22:01:37 +0200 (CEST) Received: from md13.u-strasbg.fr (md13.u-strasbg.fr [130.79.200.248]) by mr3.u-strasbg.fr (Postfix) with ESMTP id B626AC0F44 for ; Thu, 26 Sep 2013 22:01:36 +0200 (CEST) Received: from ms11.u-strasbg.fr (ms11.u-strasbg.fr [130.79.204.111]) by md13.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id r8QK1ato006980 for ; Thu, 26 Sep 2013 22:01:36 +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 ms11.u-strasbg.fr (Postfix) with ESMTPSA id 515DF1FD90 for ; Thu, 26 Sep 2013 22:01:36 +0200 (CEST) From: "Pierre Muller" To: "'gdb-patches'" References: <002901cebaf2$35ec65a0$a1c530e0$@muller@ics-cnrs.unistra.fr> In-Reply-To: <002901cebaf2$35ec65a0$a1c530e0$@muller@ics-cnrs.unistra.fr> Subject: [RFC 3/6] mingw-hdep: Add "maint set testuite-mode on/off" command. Date: Thu, 26 Sep 2013 20:01:00 -0000 Message-ID: <003201cebaf3$338a8b60$9a9fa220$@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/msg00939.txt.bz2 This patch is to add maint set testsuite mode on/off command. Finally, thanks to Yao's patch about handling of flushing of stderr for mingw, it reduces to switching the stdout and stderr between binary and text mode. Setting the file handles to binary mode avoid all the trouble about double ^M that confuses DejaGnu so often when trying to run the testsuite with a mingw compiled GDB. Pierre Muller GDB pascal language maintainer 2013-09-26 Pierre Muller mingw-hdep.c (set_output_binary_mode): New function. (set_output_normal_mode) : New function. (maint_testsuite_mode): New static variable. (set_maint_testsuite_mode) : New function. (show_maint_testsuite_mode) : New function. (_initialize_mingw_hdep): Add "maint set testsuite-mode on/off" command. (gdb_call_async_signal_handler): (void): --- gdb/mingw-hdep.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-) diff --git a/gdb/mingw-hdep.c b/gdb/mingw-hdep.c index 976e9e8..330f46b 100644 --- a/gdb/mingw-hdep.c +++ b/gdb/mingw-hdep.c @@ -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" @@ -274,6 +276,50 @@ gdb_call_async_signal_handler (struct async_signal_handler *handler, 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; @@ -281,4 +327,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); + } -- 1.7.9