public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: cygwin@cygwin.com
Subject: Re: gdb pty problem [Was: emacs gud-interface is not updated after gdb command execution (maybe because of incomplete output from gdb)]
Date: Wed, 01 Jun 2016 12:51:00 -0000	[thread overview]
Message-ID: <34c9cf10-4930-a017-92fc-fd56171671b1@cornell.edu> (raw)
In-Reply-To: <20160531094115.GE24015@calimero.vinschen.de>

[-- Attachment #1: Type: text/plain, Size: 1856 bytes --]

On 5/31/2016 5:41 AM, Corinna Vinschen wrote:
> Any chance you could bisect Cygwin to help finding the culprit?

The culprit is

commit 252a07b0ad3353abcd0fcd9b1b65ff977acd679e
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Fri Apr 3 13:07:35 2015 +0900

    Cygwin hangs up if several keys are typed during outputting a lot of texts.

        * fhandler_tty.cc (fhandler_pty_slave::read): Change calculation of
        "readlen" not to use "bytes_in_pipe" value directly.


Reverting that commit fixes the problem.  To test, compile and run the attached file.

$ gcc gdbstc.cc

$ ./a
1-inferior-tty-set /dev/pty3
2-gdb-set height 0
3-gdb-set non-stop 1
4-file-list-exec-source-files
5-file-list-exec-source-file
6-gdb-show prompt
7-stack-info-frame
8-thread-info
9-break-list
q
*** using gdb
=thread-group-added,id="i1"
~"GNU gdb (GDB) (Cygwin 7.10.1-1) 7.10.1\n"
~"Copyright (C) 2015 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
~"This GDB was configured as \"i686-pc-cygwin\".\nType \"show configuration\" for configuration details."
~"\nFor bug reporting instructions, please see:\n"
~"<http://www.gnu.org/software/gdb/bugs/>.\n"
~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
~"For help, type \"help\".\n"
~"Type \"apropos word\" to search for commands related to \"word\".\n"
=cmd-param-changed,param="auto-load safe-path",value="/"
(gdb)
...

In bad cases (bug present), the program hangs and doesn't complete until the gdb process is killed from a different terminal.  In good cases it runs to completion.

Ken

[-- Attachment #2: gdbstc.cc --]
[-- Type: text/plain, Size: 1714 bytes --]

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pty.h>
#include <string.h>
#include <sys/wait.h>

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;
	}
    }
}



[-- Attachment #3: Type: text/plain, Size: 218 bytes --]

--
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

  reply	other threads:[~2016-06-01 12:51 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-26 12:32 emacs gud-interface is not updated after gdb command execution (maybe because of incomplete output from gdb) Tobias Zawada
2016-05-26 15:48 ` William M. (Mike) Miller
2016-05-26 17:48 ` Ken Brown
2016-05-26 18:00   ` Tobias Zawada
2016-05-26 18:01     ` Ken Brown
2016-05-31  1:47   ` gdb pty problem [Was: emacs gud-interface is not updated after gdb command execution (maybe because of incomplete output from gdb)] Ken Brown
2016-05-31  9:35     ` Ken Brown
2016-05-31 22:41       ` Corinna Vinschen
2016-06-01 12:51         ` Ken Brown [this message]
2016-06-01 13:02           ` Ken Brown
2016-06-01 14:28             ` Corinna Vinschen
2016-06-01 14:29               ` Corinna Vinschen
2016-06-01 14:33               ` Ken Brown
2016-06-01 15:22                 ` Ken Brown
2016-06-01 18:29                   ` Corinna Vinschen
2016-06-01 19:05                     ` Ken Brown
2016-06-01 19:54                       ` Corinna Vinschen
2016-06-01 20:01                         ` Ken Brown
2016-06-01 21:05                           ` [GOLDSTAR] " Corinna Vinschen
2016-06-02  2:09                             ` Andrew Schulman
2016-06-01 14:18           ` Corinna Vinschen
2016-06-06 10:12             ` Takashi Yano
2016-06-06 13:16               ` Corinna Vinschen
2016-06-07 13:14                 ` Takashi Yano
2016-06-07 16:11                   ` Corinna Vinschen
2016-06-06 14:01               ` Ken Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34c9cf10-4930-a017-92fc-fd56171671b1@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).