X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-0.2 required=5.0 tests=AWL,BAYES_50,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org X-Yahoo-SMTP: jenXL62swBAWhMTL3wnej93oaS0ClBQOAKs8jbEbx_o- Date: Sun, 23 Oct 2011 15:04:15 -0400 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: gdb problem Message-ID: <20111023190414.GB13536@ednor.casa.cgf.cx> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <4EA329A3 DOT 30800 AT cornell DOT edu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ZGiS0Q5IWpPtfppv" Content-Disposition: inline In-Reply-To: <4EA329A3.30800@cornell.edu> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --ZGiS0Q5IWpPtfppv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Oct 22, 2011 at 04:37:55PM -0400, Ken Brown wrote: >The attached testcase illustrates a problem with `gdb -i=mi'. I've >tested both gdb 7.3.50-1 and 7.3.50-2, with cygwin 1.7.9 as well as with >several recent snapshots (including 2011-10-22). > >Under some circumstances, if gdb -i=mi is started and given several >input lines at once, it only prints part of the output before stopping. > I've been able to reproduce this once in a while while working >interactively (by copying and pasting the whole bunch of input lines); >in this case one can press Return to get the rest of the output. But >the problem happens consistently with the attached test case, which runs >gdb in a subprocess. One has to kill the gdb process before the main >program exits. > >The STC runs as expected on Linux. Thanks for the STC. I had to tweak it to actually see how it was supposed to work on Linux since only a limited number of lines from the pty were being output. I've included the revised test case below. I made a simple change to Cygwin which will probably cause subtle problems somewhere down the line. At least for now it seems to make gdb operate as expected. I'm building a new snapshot now. cgf --ZGiS0Q5IWpPtfppv Content-Type: text/x-c; charset=us-ascii Content-Disposition: attachment; filename="gdbstc.cc" #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; } } } --ZGiS0Q5IWpPtfppv Content-Type: text/plain; charset=us-ascii -- 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 --ZGiS0Q5IWpPtfppv--