[Lldb-commits] [lldb] r353675 - [lldb] [MainLoop] Initialize empty sigset_t correctly

Michal Gorny via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 11 01:18:46 PST 2019


Author: mgorny
Date: Mon Feb 11 01:18:46 2019
New Revision: 353675

URL: http://llvm.org/viewvc/llvm-project?rev=353675&view=rev
Log:
[lldb] [MainLoop] Initialize empty sigset_t correctly

Fix MainLoop::RunImpl::get_sigmask() to correctly return empty sigset_t
when SIGNAL_POLLING_UNSUPPORTED is true.  On NetBSD (and probably
on some other platforms), integers are not implicitly convertible to
sigset_t, so 'return 0' is erraneous.  Instead, sigset_t should be reset
through sigemptyset().

While at it, move common parts out of the #ifdef.

Differential Revision: https://reviews.llvm.org/D57959

Modified:
    lldb/trunk/source/Host/common/MainLoop.cpp

Modified: lldb/trunk/source/Host/common/MainLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/MainLoop.cpp?rev=353675&r1=353674&r2=353675&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/MainLoop.cpp (original)
+++ lldb/trunk/source/Host/common/MainLoop.cpp Mon Feb 11 01:18:46 2019
@@ -137,18 +137,20 @@ MainLoop::RunImpl::RunImpl(MainLoop &loo
 }
 
 sigset_t MainLoop::RunImpl::get_sigmask() {
-#if SIGNAL_POLLING_UNSUPPORTED
-  return 0;
-#else
   sigset_t sigmask;
+#if defined(_WIN32)
+  sigmask = 0;
+#elif SIGNAL_POLLING_UNSUPPORTED
+  sigemptyset(&sigmask);
+#else
   int ret = pthread_sigmask(SIG_SETMASK, nullptr, &sigmask);
   assert(ret == 0);
   (void) ret;
 
   for (const auto &sig : loop.m_signals)
     sigdelset(&sigmask, sig.first);
-  return sigmask;
 #endif
+  return sigmask;
 }
 
 #ifdef __ANDROID__




More information about the lldb-commits mailing list