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]

Re: [PATCH 2/3] Unbuffer stdout and stderr in cygwin


On 07/29/2013 11:42 PM, Eli Zaretskii wrote:
> I would suggest to call the function using_cygwin_pty or some such.
> "is_in_cygwin" is IMO too ambiguous.
> 

OK, fixed in patch 1/3.

>> >+      setvbuf (stdout, NULL, _IONBF, BUFSIZ);
>> >+      setvbuf (stderr, NULL, _IONBF, BUFSIZ);
> How about using line buffering instead on both streams?  Or at least
> leave stdout line-buffered?  Did you try that, and if so, did that
> have the same problems that triggered these patches?

I tried line-buffering for stdout, but get some regressions in python
related testing,

FAIL: gdb.python/py-explore-cc.exp: explore int_ptr_ref (timeout)
FAIL: gdb.python/py-explore-cc.exp: explore b (timeout)
FAIL: gdb.python/py-explore-cc.exp: explore B (timeout)

FAIL: gdb.python/py-explore.exp: explore ss_ptr (timeout)
FAIL: gdb.python/py-explore.exp: explore darray_ref (timeout)
FAIL: gdb.python/py-explore.exp: explore su (timeout)
FAIL: gdb.python/py-explore.exp: explore cs (timeout)
FAIL: gdb.python/py-explore.exp: explore cu (timeout)

however, I don't triage these fails yet.
> 
> You see, the way your patch works, using GDB from a Cygwin shell
> window will always do the above, even when not running the test
> suite.  Users might be unhappy that their standard output suddenly
> becomes much less efficient.

Yes, I get your point.  GDB would be less efficient on output.  How
about this patch? still unbuffering stdout and stderr, due to these
regression?

-- 
Yao (éå)

gdb:

2013-08-01  Joseph Myers  <joseph@codesourcery.com>
	    Yao Qi  <yao@codesourcery.com>

	* main.c (captured_main) [__MINGW32__]: Set stdout
	and stderr unbuffered if GDB is using Cygwin pty.
---
 gdb/main.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/gdb/main.c b/gdb/main.c
index 677f587..3a2fee6 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -375,6 +375,18 @@ captured_main (void *data)
   saved_command_line[0] = '\0';
   instream = stdin;
 
+#ifdef __MINGW32__
+  if (using_cygwin_pty ())
+    {
+      /* A Cygwin session may not look like a terminal to the Windows
+	 runtime; ensure stdout and stderr is unbuffered.  Note that
+	 setvbuf may be used after the file is opened but before any
+	 other operation is performed.  */
+      setvbuf (stdout, NULL, _IONBF, BUFSIZ);
+      setvbuf (stderr, NULL, _IONBF, BUFSIZ);
+    }
+#endif
+
   gdb_stdout = stdio_fileopen (stdout);
   gdb_stderr = stdio_fileopen (stderr);
   gdb_stdlog = gdb_stderr;	/* for moment */
-- 
1.7.7.6


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