RE: [RFC] Improve testsuite for poor expect behavior

Pierre Muller
2009-06-17T22:54:21Z

> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de 'Daniel Jacobowitz'
> Envoyé : Thursday, June 18, 2009 12:43 AM
> À : Pierre Muller
> Cc : 'Joel Brobecker'; gdb-patches@sourceware.org
> Objet : Re: [RFC] Improve testsuite for poor expect behavior
>
> On Thu, Jun 18, 2009 at 12:37:14AM +0200, Pierre Muller wrote:
> > > +#ifdef _WIN32
> > > + /* A Cygwin ssh session may not look like a terminal to the
> Windows
> > > + runtime; ensure unbuffered output. */
> > > + setvbuf (stdout, NULL, _IONBF, BUFSIZ);
> > > + setvbuf (stderr, NULL, _IONBF, BUFSIZ);
> > > +#endif
> > > +
> >
> > Could we use something that would also work for Win64 compilation?
>
> Sure, if you tell us what it is - I figured _WIN32 still worked.
Sorry, I also have no idea here :(

> > > +#ifdef __MINGW32__
> > > + /* In textmode, a '\n' is automatically expanded into "\r\n".
> When
> > > + driving the testsuite from a linux host, the '\n' is also
> > > + expanded into "\r\n". This results in expect seing "\r\r\n".
> > > + The tests aren't prepared currently for other forms of eol.
> As a
> > > + workaround, we force the output to binary mode. Do this only
> if
> > > + the files are pipes (cygwin ttys are Windows pipes behind the
> > > + scenes). */
> > > + {
> > > + int in = fileno (stdin);
> > > + int out = fileno (stdout);
> > > + int err = fileno (stderr);
> > > + HANDLE hin = (HANDLE) _get_osfhandle (in);
> > > + HANDLE hout = (HANDLE) _get_osfhandle (out);
> > > + HANDLE herr = (HANDLE) _get_osfhandle (err);
> > > + if (GetFileType (hin) == FILE_TYPE_PIPE)
> > > + setmode (in, O_BINARY);
> > > + if (GetFileType (hout) == FILE_TYPE_PIPE)
> > > + setmode (out, O_BINARY);
> > > + if (GetFileType (herr) == FILE_TYPE_PIPE)
> > > + setmode (err, O_BINARY);
> > > + }
> > > +#endif
> > > +
> > > gdb_stdout = stdio_fileopen (stdout);
> > > gdb_stderr = stdio_fileopen (stderr);
> > > gdb_stdlog = gdb_stderr; /* for moment */
> > >
> >
> > Wouldn't it be better to move all this into
> > mingw-hdep.c file in the _initialize_mingw_hdep function,
> > the conditional can then be completely removed, no?
>
> IIRC you can't do that because you must setmode before anything writes
> to the file.

Yes, of course you are right,
I thought captured_main was called after
initialize_all_files, but it’s the reverse.
Is attribute (constructor) is
allowed in GDB code?

Pierre