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/gdb/testsuite] Another way to avoid the windows native tty troubles


  Sometime ago, I proposed a patch that
was trying to cope with the tty problem
on windows cygwin and mingw targets.
  

The patch was for an individual test, gdb.base/fileio.exp
http://sourceware.org/ml/gdb-patches/2007-12/msg00045.html

  Several answers concerned the reasons of the tty problems,
but I was mainly interested in getting 
more reliable testsuite results for windows targets.
  Lots of tests fail simply because the programs think that
they are not on a terminal and thus use full buffering, which is
incompatible with the testsuite logic.

But, as Pedro said, individual files are not the right location to 
fix this.

  I finally came up with a different idea, that seems to work
now quite well.

  The idea is simply to add an object that call setbuf(stdout,NULL)
in a function that is added to the ctor section.
  The source
gdb.arch/cygwin-ctor.c is simply:
$ cat ../gdb.arch/cygwin-ctor.c

#include <stdio.h>

void
disableoutbuffer ()
{
  setbuf (stdout, 0);
}

asm (".section .ctor");
asm(" .long     _disableoutbuffer");

<<< End of cygwin-ctor.c file >>>
This file can be compile with gcc as cygwin-ctor.o
or with gcc -mno-cygwin as mingw-ctor.o (allowing to 
use it for mingw tests, even if those still have lots of other problems).

  Adding this object at link time is done in 
gdb_compile proc in lib/gdb.exp (see below).

  This allows me to get about 80 failures less and more than 100 passes more
for cygwin testsuite.
  The tty troubles are still visible in the three remaining
failure in gdb.base/fileio.exp (instead of 38 failures usually)
concerning istty tests for stdin stdout and stderr. 

  The gdb_compile procedure change is rather simple,
but it could probably be made more universal by converting this into
a target info property that would be set in site.exp file for instance.

setcurrtarget_info always_link 'mingw-ctor.o'
  In that case site.exp could also contain the code needed to compile
this object from the source.

  I tought about putting the object generation inside the gdb/testsuite
Makefile,
but this would mean that people using 'runtest' directly
inside the testsuite directory would get into troubles...

  I would like to know if such a testsuite change could be 
considered for inclusion in CVS tree, and in which direction
I should go regarding these questions:
1) Should the patch stay cygwin/mingw specific or is there any interest in
using the more universal target info approach that I tried to explain above?
2) How should I cope with the object generation?
3) There is one compilation failure that seems to be specific to my
patch and is related to a compilation using the -nodefaultlibs option    
in gdb.base/prelink.so.
  This probably means that cygwin is not linked in.
Note that the compilation also fails without my patch, but for
some other reason (probably because some of the linked object do
require cygwin).

All comments most welcome,


Pierre Muller
Pascal language support maintainer for GDB




  
$ cvs diff -up gdb.exp
Index: gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.102
diff -u -p -r1.102 gdb.exp
--- gdb.exp     4 May 2008 04:04:11 -0000       1.102
+++ gdb.exp     13 Jun 2008 23:49:55 -0000
@@ -1541,6 +1541,7 @@ proc gdb_compile {source dest type optio
     global gdb_wrapper_file;
     global gdb_wrapper_flags;
     global gdb_wrapper_initialized;
+    global objdir;

     set outdir [file dirname $dest]

@@ -1626,7 +1627,18 @@ proc gdb_compile {source dest type optio
        }
        set options [lreplace $options $nowarnings $nowarnings $flag]
     }
-
+    if { ($type == "executable") &&
+       ([istarget "*-*-mingw*"]
+        || [istarget *-*-cygwin*]
+        || [istarget *-*-pe*])} {
+      verbose "Adding ctor to avoid buffer flushing problems" 2
+      if [istarget "*-*-mingw*"] {
+        lappend options "additional_flags=${objdir}/mingw-ctor.o"
+      } else {
+        lappend options "additional_flags=${objdir}/cygwin-ctor.o"
+      }
+    }
+
     set result [target_compile $source $dest $type $options];

     # Prune uninteresting compiler (and linker) output.



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