From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78349 invoked by alias); 30 May 2016 22:41:19 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 78337 invoked by uid 89); 30 May 2016 22:41:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=strace, cgf, H*MI:sk:e29d08b, H*f:sk:e29d08b X-HELO: limerock01.mail.cornell.edu Received: from limerock01.mail.cornell.edu (HELO limerock01.mail.cornell.edu) (128.84.13.241) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 May 2016 22:41:08 +0000 X-CornellRouted: This message has been Routed already. Received: from authusersmtp.mail.cornell.edu (granite3.serverfarm.cornell.edu [10.16.197.8]) by limerock01.mail.cornell.edu (8.14.4/8.14.4_cu) with ESMTP id u4UMf6Oh015691 for ; Mon, 30 May 2016 18:41:06 -0400 Received: from [192.168.1.3] (mta-68-175-148-36.twcny.rr.com [68.175.148.36] (may be forged)) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id u4UMf4Nr024489 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Mon, 30 May 2016 18:41:05 -0400 Subject: Re: gdb pty problem [Was: emacs gud-interface is not updated after gdb command execution (maybe because of incomplete output from gdb)] To: cygwin@cygwin.com References: <466943424.37628.394d161a-7219-415d-a659-0f774811ad2d.open-xchange@email.1und1.de> <44459aa0-4381-2368-ab63-5dffc26f3344@cornell.edu> From: Ken Brown Message-ID: Date: Tue, 31 May 2016 09:35:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------4DDC1BC81CDB88093C067D02" X-PMX-Cornell-Gauge: Gauge=XXXXX X-IsSubscribed: yes X-SW-Source: 2016-05/txt/msg00416.txt.bz2 --------------4DDC1BC81CDB88093C067D02 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2149 On 5/30/2016 4:02 PM, Ken Brown wrote: > On 5/26/2016 8:31 AM, Ken Brown wrote: >> This looks like a bug I reported several years ago; it actually has >> nothing to do with emacs: >> >> https://www.cygwin.com/ml/cygwin/2011-10/msg00445.html >> >> It was fixed but then reappeared some months later: >> >> https://www.cygwin.com/ml/cygwin/2012-05/msg00049.html >> >> It was fixed again but apparently is back. The test case from the >> original report still exhibits the problem. > > I've tracked down the commits that fixed this bug in the past. The first fix was > > commit 31d2bedc585420092eb53895c5f5646651f13215 > Author: Christopher Faylor > Date: Sun Oct 23 19:01:47 2011 +0000 > > * fhandler_tty.cc (fhandler_pty_slave::read): Use consistent way for testing > ReadFile return. > * pipe.cc (fhandler_pipe::create_selectable): Open the write side of the pipe > in message-mode to force writing as "chunks". Explain why. > > The second was > > commit fb9d631817cc2b5d83c2a6ff928851d201c992bf > Author: Christopher Faylor > Date: Fri May 4 03:00:43 2012 +0000 > > * DevNotes: Add entry cgf-000002. > * fhandler_tty.cc (bytes_available): Revert to previous Oct-2011 behavior where > a dummy buffer is used to determine how many bytes will be read. > (fhandler_pty_master::ioctl): Correct coercion in assignment. > > A few weeks later the code was simplified: > > commit bd8afa5eb160b56715b805befe850a5ba2131d28 > Author: Christopher Faylor > Date: Wed May 16 01:56:41 2012 +0000 > > * DevNotes: Add entry cgf-000008. > * fhandler_tty.cc (bytes_available): Simplify by returning the number of bytes > available in the message unless that is zero. > > I've looked at the current code in the vicinity of these changes, and nothing jumps out at me as obviously breaking the previous fixes; but that doesn't mean much. FWIW, if I take my original test case, as modified by cgf, and uncomment the line "sleep (1);", then the program finishes successfully. I don't know if that provides a clue. For convenience, I'm attaching the modified test case. Ken --------------4DDC1BC81CDB88093C067D02 Content-Type: text/plain; charset=UTF-8; name="gdbstc.cc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gdbstc.cc" Content-length: 1712 #include #include #include #include #include #include void get_output (int fd); int main (int argc, const char **argv) { int master; pid_t pid; if ((pid = forkpty (&master, NULL, NULL, NULL)) < 0) { perror ("forkpty"); exit (1); } /* child */ if (pid == 0) { const char *av[100]; // putenv ("HOME=/tmp"); int i = 0; #ifdef STRACE_GDB av[i++] = "strace"; av[i++] = "-o"; av[i++] = "/tmp/strace.out"; #ifdef __CYGWIN__ av[i++] = "--mask=all+paranoid"; #endif #endif av[i++] = argv[1] ?: "gdb"; fprintf (stderr, "*** using %s\n", av[0]); av[i++] = "-i=mi"; av[i] = NULL; execvp (av[0], (char * const *) av); /* shouldn't get here */ exit (1); } /* parent */ const char *input[20]; int i = 0; input[i++] = "1-inferior-tty-set /dev/pty3\n"; input[i++] = "2-gdb-set height 0\n"; input[i++] = "3-gdb-set non-stop 1\n"; input[i++] = "4-file-list-exec-source-files\n"; input[i++] = "5-file-list-exec-source-file\n"; input[i++] = "6-gdb-show prompt\n"; input[i++] = "7-stack-info-frame\n"; input[i++] = "8-thread-info\n"; input[i++] = "9-break-list\n"; input[i++] = "q\n"; input[i] = NULL; for (int i = 0; input[i]; ++i) { write (master, input[i], strlen (input[i])); sleep (1); } get_output (master); wait (NULL); } void get_output (int fd) { char buf[4096]; while (1) { int nread = read (fd, buf, sizeof (buf)); if (nread > 0) write (STDOUT_FILENO, buf, nread); else { printf ("No more output. nread %d\n", nread); break; } } } --------------4DDC1BC81CDB88093C067D02 Content-Type: text/plain; charset=us-ascii Content-length: 218 -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple --------------4DDC1BC81CDB88093C067D02--