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

dawn at burble.org dawn at burble.org
Fri Nov 21 18:57:39 PST 2014


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

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


More information about the lldb-commits mailing list