diff options
| -rw-r--r-- | lldb/include/lldb/Core/Event.h | 5 | ||||
| -rw-r--r-- | lldb/include/lldb/Host/Predicate.h | 17 | ||||
| -rw-r--r-- | lldb/source/Host/common/Host.cpp | 9 | ||||
| -rw-r--r-- | lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Target/Process.cpp | 5 |
5 files changed, 11 insertions, 27 deletions
diff --git a/lldb/include/lldb/Core/Event.h b/lldb/include/lldb/Core/Event.h index f4c7f4769a3..cad12f85373 100644 --- a/lldb/include/lldb/Core/Event.h +++ b/lldb/include/lldb/Core/Event.h @@ -122,9 +122,8 @@ public: const ConstString &GetFlavor() const override { return GetFlavorString(); } bool WaitForEventReceived( - const std::chrono::microseconds &abstime = std::chrono::microseconds(0), - bool *timed_out = nullptr) { - return m_predicate.WaitForValueEqualTo(true, abstime, timed_out); + const std::chrono::microseconds &abstime = std::chrono::microseconds(0)) { + return m_predicate.WaitForValueEqualTo(true, abstime); } private: diff --git a/lldb/include/lldb/Host/Predicate.h b/lldb/include/lldb/Host/Predicate.h index d8ab37933eb..73e7ba92fd2 100644 --- a/lldb/include/lldb/Host/Predicate.h +++ b/lldb/include/lldb/Host/Predicate.h @@ -138,17 +138,12 @@ public: /// If non-nullptr, the absolute time at which we should stop /// waiting, else wait an infinite amount of time. /// - /// @param[out] timed_out - /// If not null, set to true if we return because of a time out, - /// and false if the value was set. - /// /// @return /// @li \b true if the \a m_value is equal to \a value - /// @li \b false otherwise + /// @li \b false otherwise (timeout occurred) //------------------------------------------------------------------ bool WaitForValueEqualTo(T value, const std::chrono::microseconds &timeout = - std::chrono::microseconds(0), - bool *timed_out = nullptr) { + std::chrono::microseconds(0)) { // pthread_cond_timedwait() or pthread_cond_wait() will atomically unlock // the mutex and wait for the condition to be set. When either function // returns, they will re-lock the mutex. We use an auto lock/unlock class @@ -160,19 +155,13 @@ public: printf("%s (value = 0x%8.8x, timeout = %llu), m_value = 0x%8.8x\n", __FUNCTION__, value, timeout.count(), m_value); #endif - if (timed_out) - *timed_out = false; - while (m_value != value) { if (timeout == std::chrono::microseconds(0)) { m_condition.wait(lock); } else { std::cv_status result = m_condition.wait_for(lock, timeout); - if (result == std::cv_status::timeout) { - if (timed_out) - *timed_out = true; + if (result == std::cv_status::timeout) break; - } } } diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index ac4593484f3..49f1f045aab 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -536,18 +536,15 @@ Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir, error.SetErrorString("failed to get process ID"); if (error.Success()) { - bool timed_out = false; - shell_info_sp->process_reaped.WaitForValueEqualTo( - true, std::chrono::seconds(timeout_sec), &timed_out); - if (timed_out) { + if (!shell_info_sp->process_reaped.WaitForValueEqualTo( + true, std::chrono::seconds(timeout_sec))) { error.SetErrorString("timed out waiting for shell command to complete"); // Kill the process since it didn't complete within the timeout specified Kill(pid, SIGKILL); // Wait for the monitor callback to get the message - timed_out = false; shell_info_sp->process_reaped.WaitForValueEqualTo( - true, std::chrono::seconds(1), &timed_out); + true, std::chrono::seconds(1)); } else { if (status_ptr) *status_ptr = shell_info_sp->status; diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp index 463e5f583c5..d36f64a4903 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -175,7 +175,7 @@ bool CommunicationKDP::GetSequenceMutex( bool CommunicationKDP::WaitForNotRunningPrivate( const std::chrono::microseconds &timeout) { - return m_is_running.WaitForValueEqualTo(false, timeout, NULL); + return m_is_running.WaitForValueEqualTo(false, timeout); } size_t diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 1f223dfc444..bbad51a4f1e 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -3797,11 +3797,10 @@ void Process::ControlPrivateStateThread(uint32_t signal) { bool receipt_received = false; if (PrivateStateThreadIsValid()) { while (!receipt_received) { - bool timed_out = false; // Check for a receipt for 2 seconds and then check if the private // state thread is still around. - receipt_received = event_receipt_sp->WaitForEventReceived( - std::chrono::seconds(2), &timed_out); + receipt_received = + event_receipt_sp->WaitForEventReceived(std::chrono::seconds(2)); if (!receipt_received) { // Check if the private state thread is still around. If it isn't // then we are done waiting |

