[Lldb-commits] [lldb] r278500 - Fix-up r278299 for windows

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 12 04:20:21 PDT 2016


Author: labath
Date: Fri Aug 12 06:20:21 2016
New Revision: 278500

URL: http://llvm.org/viewvc/llvm-project?rev=278500&view=rev
Log:
Fix-up r278299 for windows

FD_SETSIZE on windows limits the number of file descriptors, rather than their individual
magnitude (the underlying implementation uses an array rather than a bitset). This meant that the
assert in the SelectHelper was incorrect, and failing all the time. Fix that.

I am not sure whether this should be #ifdef MSVC, or #ifdef WINDOWS, but my feeling is that a
more posix-conforming implementation on windows would choose the bitset implementation, so I'm
sticking with the former.

Modified:
    lldb/trunk/source/Utility/SelectHelper.cpp

Modified: lldb/trunk/source/Utility/SelectHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/SelectHelper.cpp?rev=278500&r1=278499&r2=278500&view=diff
==============================================================================
--- lldb/trunk/source/Utility/SelectHelper.cpp (original)
+++ lldb/trunk/source/Utility/SelectHelper.cpp Fri Aug 12 06:20:21 2016
@@ -100,6 +100,12 @@ lldb_private::Error
 SelectHelper::Select()
 {
     lldb_private::Error error;
+#ifdef _MSC_VER
+    // On windows FD_SETSIZE limits the number of file descriptors, not their numeric value.
+    lldbassert(m_fd_map.size() <= FD_SETSIZE);
+    if (m_fd_map.size() > FD_SETSIZE)
+        return lldb_private::Error("Too many file descriptors for select()");
+#endif
 
     int max_read_fd = -1;
     int max_write_fd = -1;
@@ -109,7 +115,7 @@ SelectHelper::Select()
     {
         pair.second.PrepareForSelect();
         const int fd = pair.first;
-#if !defined(__APPLE__)
+#if !defined(__APPLE__) && !defined(_MSC_VER)
         lldbassert(fd < FD_SETSIZE);
         if (fd >= FD_SETSIZE)
         {




More information about the lldb-commits mailing list