This is the mail archive of the cygwin mailing list for the Cygwin 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]

some notes on debugging screen (long) (was: cygwin-1.5.6-1 Vim now broken)


>-----Original Message-----
>From: cygwin-owner@cygwin.com [mailto:cygwin-owner@cygwin.com] On Behalf Of Christopher Faylor
>Sent: Tuesday, January 20, 2004 9:11 AM
>To: cygwin@cygwin.com
>Subject: Re: cygwin-1.5.6-1 Vim now broken
>
[SNIP]
>>I guess it'd be a show stopper if screen were part of Cygwin.  Still, I
>>think it's more important than Vim, as there are a dozen editors but no
>>screen alternatives.
>
>That's truly amazing logic.
>
>1) Vim is probably the most popular editor in cygwin.
>
>2) It's a SEGV from cygwin.  It would be folly to ignore those.
>
>3) As you note, screen doesn't even ship with cygwin.
>
>>Anyway, I did what I could, reporting it before 1.5.6 -
>>http://www.cygwin.com/ml/cygwin/2003-12/msg00557.html .  I'm not
>>complaining.  I also reported it to the screen mailing-list today as
>>there are a few Cygwin users and one may be able to help you with it.
>
>"Help me with it".  Yeah.  That's one way to look at it.
>
>Why don't you help *us* with it by debugging the problem?  I don't
>really care about screen but if it's important to you then some
>hours with gdb might be in order.  That's what I do with problems
>that I care about.
>
>cgf

Agreed Chris :)

To anyone who wants to take up a gdb process in this noble cause, as I won't be able to work on it in the next few days at least,
following are some of my observations.

The problem:

In cygwin1.dlls post 1.5.5 screen windows are set at 80x25, first line of stty -a output:

speed 38400 baud; rows 25; columns 80; line = 0;

The problem of reattaching screens not working correctly is less urgent, but will be mentioned.

while screen believes the window size to be correct, which you can verify by looking CTRL+a+i

If you try to do something like:

stty rows 58 columns 133

You will get:

stty: standard input: Invalid argument

What this means is that TIOCSWINSZ (change win size) commands to the terminal result in an EINVAL (invalid argument).

FWIF, the code sending the EINVAL is around line 1105 in winsup/cygwin/fhandler_tty.cc:

    case TIOCSWINSZ:
      if (get_ttyp ()->winsize.ws_row != ((struct winsize *) arg)->ws_row
          || get_ttyp ()->winsize.ws_col != ((struct winsize *) arg)->ws_col)
        {
          if (!ioctl_request_event)
            get_ttyp ()->ioctl_retval = -EINVAL;
          else
            {
              get_ttyp ()->arg.winsize = *(struct winsize *) arg;
              SetEvent (ioctl_request_event);
              get_ttyp ()->winsize = *(struct winsize *) arg;
              killsys (-get_ttyp ()->getpgid (), SIGWINCH);
              if (ioctl_done_event)
                WaitForSingleObject (ioctl_done_event, INFINITE);
            }
        }
      break;

Commenting out the second if/else allows you to send TIOCSWINSZ commands to the terminal, making the screens the correct number of
lines and columns. After this you can see that screen works correctly. THIS IS NOT the problem though, just something I noticed.
Screens still start with the wrong size.

What you need:

Get and compile winsup from cvs. See the FAQ for instructions. You may also want to install a copy of "insight".

Get screen-4.0.2 from a GNU mirror, apply the tiny attached patch to build. You should be on an NT+ system with CYGWIN=ntsec.

If you want to look at the reattach bug, you may want to use my hacked up screen from here:
http://www.io.com/~rkitover/screen-3.9.13.tar.gz . This version, IIRC, doesn't require ntsec.

You will not be able to use gdb on a screen binary directly, as you will get a "must be connected to terminal" error, use something
like:

----
#!/bin/sh
echo gdb --pid=$$ --directory=/path-to-screen-source/screen-3.9.13/ \
  --se=/path-to-unstripped-screen-binary/screen.exe
read akey
/path-to-unstripped-screen-binary/screen.exe
----

then run the gdb command this script prints out in another terminal

You can also try using insight, the GUI version of GDB.

Make sure you "set follow-fork-mode child" in gdb, or parent, depending on which part of screen you're trying to follow.

Using symbol-file /install/bin/cygwin1.dll should let you step into the Cygwin dll. (cd to the appropriate source directory).

If you want to try debugging the reattach problem, see:
http://sources.redhat.com/ml/cygwin-patches/2003-q2/msg00203.html 

Although this was a dead end, it may help you find the appropriate direction.

Good luck!

-- 
Rafael

Attachment: screen-4.0.2-cygwin.patch
Description: Binary data

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

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