This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC 3/6] mingw-hdep: Add "maint set testuite-mode on/off" command.


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

 	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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]