Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: <gdb-patches@sourceware.org>
Subject: [RFC] Testsuite: Avoid \r\r\n problem of *-*-mingw* host
Date: Tue, 17 Sep 2013 23:14:00 -0000	[thread overview]
Message-ID: <006301ceb3fb$9bad1d60$d3075820$@muller@ics-cnrs.unistra.fr> (raw)

  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  <muller@sourceware.org>

	* 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.


             reply	other threads:[~2013-09-17 23:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-17 23:14 Pierre Muller [this message]
2013-09-18  2:11 ` Joel Brobecker
2013-09-18  7:20   ` Doug Evans
2013-09-18  7:33     ` Pierre Muller
2013-09-18 13:44       ` Joel Brobecker
2013-09-18 15:59         ` Pierre Muller
     [not found]         ` <5239cde9.0db6b40a.21be.fffff5f5SMTPIN_ADDED_BROKEN@mx.google.com>
2013-09-18 17:14           ` Doug Evans

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='006301ceb3fb$9bad1d60$d3075820$@muller@ics-cnrs.unistra.fr' \
    --to=pierre.muller@ics-cnrs.unistra.fr \
    --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