[Lldb-commits] [PATCH] fix lldb-mi hang on OSX

Abid, Hafiz Hafiz_Abid at mentor.com
Fri Nov 28 02:02:33 PST 2014


Hi Dawn,
I looked at the patch a bit. It looks ok to use select to check if the input is available before blocking on fgets. But I am still wondering why you need extra "return" in case of -exec-run. It seems to work ok on Linux. Where is it blocking in OSX? Btw, if the problem is only with gdb-exit then an extra check for it where we check for "quit" will work too.

Regards,
Abid

> -----Original Message-----
> From: dawn at burble.org [mailto:dawn at burble.org]
> Sent: 26 November 2014 00:13
> To: Abid, Hafiz; colin at codeplay.com; deepak at codeplay.com; lldb-
> commits at cs.uiuc.edu
> Subject: Re: [Lldb-commits] [PATCH] fix lldb-mi hang on OSX
> 
> Hi guys,
> 
> Please help me resolve this blocking issue with lldb-mi on OSX.  The patch
> sent in the original e-mail (and included below) solves the problem by
> enabling the ioctl code in CMICmnStreamStdinLinux::InputAvailable.
> Attached is an alternate patch which uses select, but requires additional
> code to handle -gdb-exit.
> Without either of these patches, lldb-mi hangs on OSX after -exec-run, and -
> gdb-exit doesn't terminate.
> 
> Please apply one of these, or tell me how you would prefer to resolve this?
> 
> Thanks,
> -Dawn
> 
> On Fri, Nov 21, 2014 at 06:57:39PM -0800, dawn at burble.org wrote:
> > This patch fixes the initial hang when starting up lldb-mi in
> > interpreter mode on OSX.  Without this, an additional "return" is
> > required in order for lldb-mi to proceed after "-exec-run" and "-gdb-exit" is
> also not handled properly.
> >
> > The patch enables code which was commented out.  Was there a reason
> for this?
> > If the code is not desired, would it be OK to enable it for OSX only?
> > Or would you prefer a command-line option for this?  This code is
> > definately needed on OSX to get past the hang.  If OK as is, please commit?
> >
> > Thanks,
> > -Dawn
> >
> 
> > Index: tools/lldb-mi/MICmnStreamStdinLinux.cpp
> >
> ================================================================
> ===
> > --- tools/lldb-mi/MICmnStreamStdinLinux.cpp	(revision 222598)
> > +++ tools/lldb-mi/MICmnStreamStdinLinux.cpp	(working copy)
> > @@ -22,6 +22,7 @@
> >  // Third Party Headers:
> >  #if !defined(_MSC_VER)
> >  #include <sys/select.h>
> > +#include <sys/ioctl.h>
> >  #include <termios.h>
> >  #endif              // !defined( _MSC_VER )
> >  #include <string.h> // For std::strerror() @@ -153,30 +154,27 @@
> > bool  CMICmnStreamStdinLinux::InputAvailable(bool &vwbAvail)  {
> > -    /* AD: Not used ATM but could come in handy just in case we need to
> do
> > -           this, poll for input
> > +#if !defined(_MSC_VER)
> > +    // poll for input
> > +    static const int STDIN = 0;
> > +    static bool bInitialized = false;
> >
> > -            static const int STDIN = 0;
> > -        static bool bInitialized = false;
> > +    if (!bInitialized)
> > +    {
> > +        // Use termios to turn off line buffering
> > +        ::termios term;
> > +        ::tcgetattr(STDIN, &term);
> > +        term.c_lflag &= ~ICANON;
> > +        ::tcsetattr(STDIN, TCSANOW, &term);
> > +        ::setbuf(stdin, NULL);
> > +        bInitialized = true;
> > +    }
> >
> > -        if( !bInitialized )
> > -            {
> > -            // Use termios to turn off line buffering
> > -            ::termios term;
> > -            ::tcgetattr( STDIN, &term );
> > -            ::term.c_lflag &= ~ICANON;
> > -            ::tcsetattr( STDIN, TCSANOW, &term );
> > -            ::setbuf( stdin, NULL );
> > -            bInitialized = true;
> > -        }
> > +    int nBytesWaiting;
> > +    ::ioctl(STDIN, FIONREAD, &nBytesWaiting);
> > +    vwbAvail = (nBytesWaiting > 0);
> > +#endif // !defined(_MSC_VER)
> >
> > -        int nBytesWaiting;
> > -        ::ioctl( STDIN, FIONREAD, &nBytesWaiting );
> > -        vwbAvail = (nBytesWaiting > 0);
> > -
> > -            return MIstatus::success;
> > -    */
> > -
> >      return MIstatus::success;
> >  }
> >
> 
> > _______________________________________________
> > lldb-commits mailing list
> > lldb-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits





More information about the lldb-commits mailing list