[lldb-dev] [Lldb-commits] [lldb] r277011 - Clean up vestigial remnants of locking primitives

Todd Fiala via lldb-dev lldb-dev at lists.llvm.org
Thu Jul 28 10:49:46 PDT 2016


Hi Saleem,

It looks like you're missing Condition.cpp from your checkin @277011?  Can
you add it?

-Todd

On Thu, Jul 28, 2016 at 10:32 AM, Saleem Abdulrasool via lldb-commits <
lldb-commits at lists.llvm.org> wrote:

> Author: compnerd
> Date: Thu Jul 28 12:32:20 2016
> New Revision: 277011
>
> URL: http://llvm.org/viewvc/llvm-project?rev=277011&view=rev
> Log:
> Clean up vestigial remnants of locking primitives
>
> This finally removes the use of the Mutex and Condition classes. This is an
> intricate patch as the Mutex and Condition classes were tied together.
> Furthermore, many places had slightly differing uses of time values.
> Convert
> timeout values to relative everywhere to permit the use of
> std::chrono::duration, which is required for the use of
> std::condition_variable's timeout. Adjust all Condition and related Mutex
> classes over to std::{,recursive_}mutex and std::condition_variable.
>
> This change primarily comes at the cost of breaking the TracingMutex which
> was
> based around the Mutex class. It would be possible to write a wrapper to
> provide similar functionality, but that is beyond the scope of this change.
>
> Removed:
>     lldb/trunk/include/lldb/Host/Condition.h
>     lldb/trunk/include/lldb/Host/Mutex.h
>     lldb/trunk/source/Host/common/Condition.cpp
>     lldb/trunk/source/Host/common/Mutex.cpp
>     lldb/trunk/source/Host/windows/Condition.cpp
>     lldb/trunk/source/Host/windows/Mutex.cpp
> Modified:
>     lldb/trunk/include/lldb/Core/Event.h
>     lldb/trunk/include/lldb/Core/Listener.h
>     lldb/trunk/include/lldb/Core/ThreadSafeDenseMap.h
>     lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h
>     lldb/trunk/include/lldb/Host/Editline.h
>     lldb/trunk/include/lldb/Host/Predicate.h
>     lldb/trunk/include/lldb/Host/ProcessRunLock.h
>     lldb/trunk/include/lldb/Target/Process.h
>     lldb/trunk/source/API/SBListener.cpp
>     lldb/trunk/source/Core/Communication.cpp
>     lldb/trunk/source/Core/Debugger.cpp
>     lldb/trunk/source/Core/Listener.cpp
>     lldb/trunk/source/Host/CMakeLists.txt
>     lldb/trunk/source/Host/common/Host.cpp
>     lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp
>
> lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
>     lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
>     lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
>     lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
>     lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
>     lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
>     lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
>
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
>
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
>
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
>     lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
>     lldb/trunk/source/Target/Process.cpp
>     lldb/trunk/source/Target/Target.cpp
>
> Modified: lldb/trunk/include/lldb/Core/Event.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Event.h?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Core/Event.h (original)
> +++ lldb/trunk/include/lldb/Core/Event.h Thu Jul 28 12:32:20 2016
> @@ -12,6 +12,7 @@
>
>  // C Includes
>  // C++ Includes
> +#include <chrono>
>  #include <memory>
>  #include <string>
>
> @@ -141,7 +142,8 @@ public:
>      }
>
>      bool
> -    WaitForEventReceived (const TimeValue *abstime = nullptr, bool
> *timed_out = nullptr)
> +    WaitForEventReceived(const std::chrono::microseconds &abstime =
> std::chrono::microseconds(0),
> +                         bool *timed_out = nullptr)
>      {
>          return m_predicate.WaitForValueEqualTo(true, abstime, timed_out);
>      }
>
> Modified: lldb/trunk/include/lldb/Core/Listener.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Listener.h?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Core/Listener.h (original)
> +++ lldb/trunk/include/lldb/Core/Listener.h Thu Jul 28 12:32:20 2016
> @@ -12,6 +12,7 @@
>
>  // C Includes
>  // C++ Includes
> +#include <chrono>
>  #include <list>
>  #include <map>
>  #include <mutex>
> @@ -21,8 +22,6 @@
>  // Other libraries and framework includes
>  // Project includes
>  #include "lldb/lldb-private.h"
> -#include "lldb/Core/Broadcaster.h"
> -#include "lldb/Host/Condition.h"
>  #include "lldb/Core/Event.h"
>
>  namespace lldb_private {
> @@ -87,19 +86,15 @@ public:
>
>      // Returns true if an event was received, false if we timed out.
>      bool
> -    WaitForEvent (const TimeValue *timeout,
> -                  lldb::EventSP &event_sp);
> +    WaitForEvent(const std::chrono::microseconds &timeout, lldb::EventSP
> &event_sp);
>
>      bool
> -    WaitForEventForBroadcaster (const TimeValue *timeout,
> -                                Broadcaster *broadcaster,
> -                                lldb::EventSP &event_sp);
> +    WaitForEventForBroadcaster(const std::chrono::microseconds &timeout,
> Broadcaster *broadcaster,
> +                               lldb::EventSP &event_sp);
>
>      bool
> -    WaitForEventForBroadcasterWithType (const TimeValue *timeout,
> -                                        Broadcaster *broadcaster,
> -                                        uint32_t event_type_mask,
> -                                        lldb::EventSP &event_sp);
> +    WaitForEventForBroadcasterWithType(const std::chrono::microseconds
> &timeout, Broadcaster *broadcaster,
> +                                       uint32_t event_type_mask,
> lldb::EventSP &event_sp);
>
>      Event *
>      PeekAtNextEvent ();
> @@ -151,13 +146,10 @@ private:
>      typedef std::vector<lldb::BroadcasterManagerWP>
> broadcaster_manager_collection;
>
>      bool
> -    FindNextEventInternal(Mutex::Locker& lock,
> +    FindNextEventInternal(std::unique_lock<std::mutex> &lock,
>                            Broadcaster *broadcaster,   // nullptr for any
> broadcaster
>                            const ConstString *sources, // nullptr for any
> event
> -                          uint32_t num_sources,
> -                          uint32_t event_type_mask,
> -                          lldb::EventSP &event_sp,
> -                          bool remove);
> +                          uint32_t num_sources, uint32_t event_type_mask,
> lldb::EventSP &event_sp, bool remove);
>
>      bool
>      GetNextEventInternal(Broadcaster *broadcaster,   // nullptr for any
> broadcaster
> @@ -167,19 +159,17 @@ private:
>                           lldb::EventSP &event_sp);
>
>      bool
> -    WaitForEventsInternal(const TimeValue *timeout,
> +    WaitForEventsInternal(const std::chrono::microseconds &timeout,
>                            Broadcaster *broadcaster,   // nullptr for any
> broadcaster
>                            const ConstString *sources, // nullptr for any
> event
> -                          uint32_t num_sources,
> -                          uint32_t event_type_mask,
> -                          lldb::EventSP &event_sp);
> +                          uint32_t num_sources, uint32_t event_type_mask,
> lldb::EventSP &event_sp);
>
>      std::string m_name;
>      broadcaster_collection m_broadcasters;
>      std::recursive_mutex m_broadcasters_mutex; // Protects m_broadcasters
>      event_collection m_events;
> -    Mutex m_events_mutex; // Protects m_broadcasters and m_events
> -    Condition m_events_condition;
> +    std::mutex m_events_mutex; // Protects m_broadcasters and m_events
> +    std::condition_variable m_events_condition;
>      broadcaster_manager_collection m_broadcaster_managers;
>
>      void
>
> Modified: lldb/trunk/include/lldb/Core/ThreadSafeDenseMap.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeDenseMap.h?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Core/ThreadSafeDenseMap.h (original)
> +++ lldb/trunk/include/lldb/Core/ThreadSafeDenseMap.h Thu Jul 28 12:32:20
> 2016
> @@ -12,46 +12,41 @@
>
>  // C Includes
>  // C++ Includes
> +#include <mutex>
>
>  // Other libraries and framework includes
>  #include "llvm/ADT/DenseMap.h"
>
>  // Project includes
> -#include "lldb/Host/Mutex.h"
>
>  namespace lldb_private {
>
> -template <typename _KeyType, typename _ValueType>
> +template <typename _KeyType, typename _ValueType, typename _MutexType =
> std::mutex>
>  class ThreadSafeDenseMap
>  {
>  public:
>      typedef llvm::DenseMap<_KeyType,_ValueType> LLVMMapType;
> -
> -    ThreadSafeDenseMap(unsigned map_initial_capacity = 0,
> -                       Mutex::Type mutex_type = Mutex::eMutexTypeNormal) :
> -        m_map(map_initial_capacity),
> -        m_mutex(mutex_type)
> -    {
> -    }
> -
> +
> +    ThreadSafeDenseMap(unsigned map_initial_capacity = 0) :
> m_map(map_initial_capacity), m_mutex() {}
> +
>      void
>      Insert (_KeyType k, _ValueType v)
>      {
> -        Mutex::Locker locker(m_mutex);
> +        std::lock_guard<_MutexType> guard(m_mutex);
>          m_map.insert(std::make_pair(k,v));
>      }
>
>      void
>      Erase (_KeyType k)
>      {
> -        Mutex::Locker locker(m_mutex);
> +        std::lock_guard<_MutexType> guard(m_mutex);
>          m_map.erase(k);
>      }
>
>      _ValueType
>      Lookup (_KeyType k)
>      {
> -        Mutex::Locker locker(m_mutex);
> +        std::lock_guard<_MutexType> guard(m_mutex);
>          return m_map.lookup(k);
>      }
>
> @@ -59,7 +54,7 @@ public:
>      Lookup (_KeyType k,
>              _ValueType& v)
>      {
> -        Mutex::Locker locker(m_mutex);
> +        std::lock_guard<_MutexType> guard(m_mutex);
>          auto iter = m_map.find(k),
>               end = m_map.end();
>          if (iter == end)
> @@ -71,13 +66,13 @@ public:
>      void
>      Clear ()
>      {
> -        Mutex::Locker locker(m_mutex);
> +        std::lock_guard<_MutexType> guard(m_mutex);
>          m_map.clear();
>      }
>
>  protected:
>      LLVMMapType m_map;
> -    Mutex m_mutex;
> +    _MutexType m_mutex;
>  };
>
>  } // namespace lldb_private
>
> Modified: lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h (original)
> +++ lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h Thu Jul 28 12:32:20
> 2016
> @@ -12,61 +12,56 @@
>
>  // C Includes
>  // C++ Includes
> +#include <mutex>
>
>  // Other libraries and framework includes
>  #include "llvm/ADT/DenseSet.h"
>
>  // Project includes
> -#include "lldb/Host/Mutex.h"
>
>  namespace lldb_private {
> -
> -    template <typename _ElementType>
> -    class ThreadSafeDenseSet
> +
> +template <typename _ElementType, typename _MutexType = std::mutex>
> +class ThreadSafeDenseSet
> +{
> +public:
> +    typedef llvm::DenseSet<_ElementType> LLVMSetType;
> +
> +    ThreadSafeDenseSet(unsigned set_initial_capacity = 0) :
> m_set(set_initial_capacity), m_mutex() {}
> +
> +    void
> +    Insert(_ElementType e)
>      {
> -    public:
> -        typedef llvm::DenseSet<_ElementType> LLVMSetType;
> -
> -        ThreadSafeDenseSet(unsigned set_initial_capacity = 0,
> -                           Mutex::Type mutex_type =
> Mutex::eMutexTypeNormal) :
> -        m_set(set_initial_capacity),
> -        m_mutex(mutex_type)
> -        {
> -        }
> -
> -        void
> -        Insert (_ElementType e)
> -        {
> -            Mutex::Locker locker(m_mutex);
> -            m_set.insert(e);
> -        }
> -
> -        void
> -        Erase (_ElementType e)
> -        {
> -            Mutex::Locker locker(m_mutex);
> -            m_set.erase(e);
> -        }
> -
> -        bool
> -        Lookup (_ElementType e)
> -        {
> -            Mutex::Locker locker(m_mutex);
> -            return (m_set.count(e) > 0);
> -        }
> -
> -        void
> -        Clear ()
> -        {
> -            Mutex::Locker locker(m_mutex);
> -            m_set.clear();
> -        }
> -
> -    protected:
> -        LLVMSetType m_set;
> -        Mutex m_mutex;
> -    };
> -
> +        std::lock_guard<_MutexType> guard(m_mutex);
> +        m_set.insert(e);
> +    }
> +
> +    void
> +    Erase(_ElementType e)
> +    {
> +        std::lock_guard<_MutexType> guard(m_mutex);
> +        m_set.erase(e);
> +    }
> +
> +    bool
> +    Lookup(_ElementType e)
> +    {
> +        std::lock_guard<_MutexType> guard(m_mutex);
> +        return (m_set.count(e) > 0);
> +    }
> +
> +    void
> +    Clear()
> +    {
> +        stds::lock_guard<_MutexType> guard(m_mutex);
> +        m_set.clear();
> +    }
> +
> +protected:
> +    LLVMSetType m_set;
> +    _MutexType m_mutex;
> +};
> +
>  } // namespace lldb_private
>
>  #endif  // liblldb_ThreadSafeDenseSet_h_
>
> Removed: lldb/trunk/include/lldb/Host/Condition.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Condition.h?rev=277010&view=auto
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Host/Condition.h (original)
> +++ lldb/trunk/include/lldb/Host/Condition.h (removed)
> @@ -1,123 +0,0 @@
> -//===-- Condition.h ---------------------------------------------*- C++
> -*-===//
> -//
> -//                     The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
>
> -//===----------------------------------------------------------------------===//
> -
> -#ifndef liblldb_Condition_h_
> -#define liblldb_Condition_h_
> -
> -// C Includes
> -// C++ Includes
> -// Other libraries and framework includes
> -// Project includes
> -#include "lldb/lldb-types.h"
> -#include "lldb/Host/Mutex.h"
> -
> -namespace lldb_private {
> -
> -class TimeValue;
> -
> -//----------------------------------------------------------------------
> -/// @class Condition Condition.h "lldb/Host/Condition.h"
> -/// @brief A C++ wrapper class for pthread condition variables.
> -///
> -/// A class that wraps up a pthread condition (pthread_cond_t). The
> -/// class will create a pthread condition when an instance is
> -/// constructed, and destroy it when it is destructed. It also provides
> -/// access to the standard pthread condition calls.
> -//----------------------------------------------------------------------
> -class Condition
> -{
> -public:
> -    //------------------------------------------------------------------
> -    /// Default constructor
> -    ///
> -    /// The default constructor will initialize a new pthread condition
> -    /// and maintain the condition in the object state.
> -    //------------------------------------------------------------------
> -    Condition ();
> -
> -    //------------------------------------------------------------------
> -    /// Destructor
> -    ///
> -    /// Destroys the pthread condition that the object owns.
> -    //------------------------------------------------------------------
> -    ~Condition ();
> -
> -    //------------------------------------------------------------------
> -    /// Unblock all threads waiting for a condition variable
> -    ///
> -    /// @return
> -    ///     The return value from \c pthread_cond_broadcast()
> -    //------------------------------------------------------------------
> -    int
> -    Broadcast ();
> -
> -    //------------------------------------------------------------------
> -    /// Unblocks one thread waiting for the condition variable
> -    ///
> -    /// @return
> -    ///     The return value from \c pthread_cond_signal()
> -    //------------------------------------------------------------------
> -    int
> -    Signal ();
> -
> -    //------------------------------------------------------------------
> -    /// Wait for the condition variable to be signaled.
> -    ///
> -    /// The Wait() function atomically blocks the current thread
> -    /// waiting on this object's condition variable, and unblocks
> -    /// \a mutex. The waiting thread unblocks only after another thread
> -    /// signals or broadcasts this object's condition variable.
> -    ///
> -    /// If \a abstime is non-nullptr, this function will return when the
> -    /// system time reaches the time specified in \a abstime if the
> -    /// condition variable doesn't get unblocked. If \a abstime is nullptr
> -    /// this function will wait for an infinite amount of time for the
> -    /// condition variable to be unblocked.
> -    ///
> -    /// The current thread re-acquires the lock on \a mutex following
> -    /// the wait.
> -    ///
> -    /// @param[in] mutex
> -    ///     The mutex to use in the \c pthread_cond_timedwait() or
> -    ///     \c pthread_cond_wait() calls.
> -    ///
> -    /// @param[in] abstime
> -    ///     An absolute time at which to stop waiting if non-nullptr, else
> -    ///     wait an infinite amount of time for the condition variable
> -    ///     toget signaled.
> -    ///
> -    /// @param[out] timed_out
> -    ///     If not nullptr, will be set to true if the wait timed out, and
> -    //      false otherwise.
> -    ///
> -    /// @see Condition::Broadcast()
> -    /// @see Condition::Signal()
> -    //------------------------------------------------------------------
> -    int
> -    Wait(Mutex &mutex, const TimeValue *abstime = nullptr, bool
> *timed_out = nullptr);
> -
> -protected:
> -    //------------------------------------------------------------------
> -    // Member variables
> -    //------------------------------------------------------------------
> -    lldb::condition_t m_condition; ///< The condition variable.
> -
> -    //------------------------------------------------------------------
> -    /// Get accessor to the pthread condition object.
> -    ///
> -    /// @return
> -    ///     A pointer to the condition variable owned by this object.
> -    //------------------------------------------------------------------
> -    lldb::condition_t *
> -    GetCondition ();
> -};
> -
> -} // namespace lldb_private
> -
> -#endif // liblldb_Condition_h_
>
> Modified: lldb/trunk/include/lldb/Host/Editline.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Editline.h?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Host/Editline.h (original)
> +++ lldb/trunk/include/lldb/Host/Editline.h Thu Jul 28 12:32:20 2016
> @@ -54,7 +54,6 @@
>  #include <string>
>  #include <vector>
>
> -#include "lldb/Host/Condition.h"
>  #include "lldb/Host/ConnectionFileDescriptor.h"
>  #include "lldb/Host/FileSpec.h"
>  #include "lldb/Host/Predicate.h"
>
> Removed: lldb/trunk/include/lldb/Host/Mutex.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Mutex.h?rev=277010&view=auto
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Host/Mutex.h (original)
> +++ lldb/trunk/include/lldb/Host/Mutex.h (removed)
> @@ -1,313 +0,0 @@
> -//===-- Mutex.h -------------------------------------------------*- C++
> -*-===//
> -//
> -//                     The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
>
> -//===----------------------------------------------------------------------===//
> -
> -#ifndef liblldb_Mutex_h_
> -#define liblldb_Mutex_h_
> -
> -// C Includes
> -// C++ Includes
> -#ifdef LLDB_CONFIGURATION_DEBUG
> -#include <string>
> -#endif
> -
> -// Other libraries and framework includes
> -// Project includes
> -#include "lldb/lldb-types.h"
> -
> -namespace lldb_private {
> -
> -//----------------------------------------------------------------------
> -/// @class Mutex Mutex.h "lldb/Host/Mutex.h"
> -/// @brief A C++ wrapper class for pthread mutexes.
> -//----------------------------------------------------------------------
> -class Mutex
> -{
> -public:
> -    friend class Locker;
> -    friend class Condition;
> -
> -    enum Type
> -    {
> -        eMutexTypeNormal,       ///< Mutex that can't recursively entered
> by the same thread
> -        eMutexTypeRecursive     ///< Mutex can be recursively entered by
> the same thread
> -    };
> -
> -    //------------------------------------------------------------------
> -    /// @class Mutex::Locker
> -    ///
> -    /// A scoped locking class that allows a variety of pthread mutex
> -    /// objects to have a mutex locked when an Mutex::Locker
> -    /// object is created, and unlocked when it goes out of scope or
> -    /// when the Mutex::Locker::Reset(pthread_mutex_t *)
> -    /// is called. This provides an exception safe way to lock a mutex
> -    /// in a scope.
> -    //------------------------------------------------------------------
> -    class Locker
> -    {
> -    public:
> -        //--------------------------------------------------------------
> -        /// Default constructor.
> -        ///
> -        /// This will create a scoped mutex locking object that doesn't
> -        /// have a mutex to lock. One will need to be provided using the
> -        /// Mutex::Locker::Reset(pthread_mutex_t *) method.
> -        ///
> -        /// @see Mutex::Locker::Reset(pthread_mutex_t *)
> -        //--------------------------------------------------------------
> -        Locker();
> -
> -        //--------------------------------------------------------------
> -        /// Constructor with a Mutex object.
> -        ///
> -        /// This will create a scoped mutex locking object that extracts
> -        /// the mutex owned by \a m and locks it.
> -        ///
> -        /// @param[in] m
> -        ///     An instance of a Mutex object that contains a
> -        ///     valid mutex object.
> -        //--------------------------------------------------------------
> -        Locker(Mutex& m);
> -
> -        //--------------------------------------------------------------
> -        /// Constructor with a Mutex object pointer.
> -        ///
> -        /// This will create a scoped mutex locking object that extracts
> -        /// the mutex owned by a m and locks it.
> -        ///
> -        /// @param[in] m
> -        ///     A pointer to instance of a Mutex object that
> -        ///     contains a valid mutex object.
> -        //--------------------------------------------------------------
> -        Locker(Mutex* m);
> -
> -        //--------------------------------------------------------------
> -        /// Destructor
> -        ///
> -        /// Unlocks any valid pthread_mutex_t that this object may
> -        /// contain.
> -        //--------------------------------------------------------------
> -        ~Locker();
> -
> -        //--------------------------------------------------------------
> -        /// Change the contained mutex.
> -        ///
> -        /// Unlock the current mutex in this object (if it contains a
> -        /// valid mutex) and lock the new \a mutex object if it is
> -        /// non-nullptr.
> -        //--------------------------------------------------------------
> -        void
> -        Lock (Mutex &mutex);
> -
> -        void
> -        Lock (Mutex *mutex)
> -        {
> -            if (mutex)
> -                Lock(*mutex);
> -        }
> -
> -        //--------------------------------------------------------------
> -        /// Change the contained mutex only if the mutex can be locked.
> -        ///
> -        /// Unlock the current mutex in this object (if it contains a
> -        /// valid mutex) and try to lock \a mutex. If \a mutex can be
> -        /// locked this object will take ownership of the lock and will
> -        /// unlock it when it goes out of scope or Reset or TryLock are
> -        /// called again. If the mutex is already locked, this object
> -        /// will not take ownership of the mutex.
> -        ///
> -        /// @return
> -        ///     Returns \b true if the lock was acquired and the this
> -        ///     object will unlock the mutex when it goes out of scope,
> -        ///     returns \b false otherwise.
> -        //--------------------------------------------------------------
> -        bool
> -        TryLock(Mutex &mutex, const char *failure_message = nullptr);
> -
> -        bool
> -        TryLock(Mutex *mutex, const char *failure_message = nullptr)
> -        {
> -            if (mutex)
> -                return TryLock(*mutex, failure_message);
> -            else
> -                return false;
> -        }
> -
> -        void
> -        Unlock ();
> -
> -    protected:
> -        //--------------------------------------------------------------
> -        /// Member variables
> -        //--------------------------------------------------------------
> -        Mutex *m_mutex_ptr;
> -
> -    private:
> -        Locker(const Locker&);
> -        const Locker& operator=(const Locker&);
> -    };
> -
> -    //------------------------------------------------------------------
> -    /// Default constructor.
> -    ///
> -    /// Creates a pthread mutex with no attributes.
> -    //------------------------------------------------------------------
> -    Mutex();
> -
> -    //------------------------------------------------------------------
> -    /// Default constructor.
> -    ///
> -    /// Creates a pthread mutex with \a type as the mutex type.
> -    /// Valid values for \a type include:
> -    ///     @li Mutex::Type::eMutexTypeNormal
> -    ///     @li Mutex::Type::eMutexTypeRecursive
> -    ///
> -    /// @param[in] type
> -    ///     The type of the mutex.
> -    ///
> -    /// @see ::pthread_mutexattr_settype()
> -    //------------------------------------------------------------------
> -    Mutex(Mutex::Type type);
> -
> -    //------------------------------------------------------------------
> -    /// Destructor.
> -    ///
> -    /// Destroys the mutex owned by this object.
> -    //------------------------------------------------------------------
> -#ifdef LLDB_CONFIGURATION_DEBUG
> -    virtual
> -#endif
> -    ~Mutex();
> -
> -    //------------------------------------------------------------------
> -    /// Lock the mutex.
> -    ///
> -    /// Locks the mutex owned by this object. If the mutex is already
> -    /// locked, the calling thread will block until the mutex becomes
> -    /// available.
> -    ///
> -    /// @return
> -    ///     The error code from \c pthread_mutex_lock().
> -    //------------------------------------------------------------------
> -#ifdef LLDB_CONFIGURATION_DEBUG
> -    virtual
> -#endif
> -    int
> -    Lock();
> -
> -    //------------------------------------------------------------------
> -    /// Try to lock the mutex.
> -    ///
> -    /// Attempts to lock the mutex owned by this object without blocking.
> -    /// If the mutex is already locked, TryLock() will not block waiting
> -    /// for the mutex, but will return an error condition.
> -    ///
> -    /// @return
> -    ///     The error code from \c pthread_mutex_trylock().
> -    //------------------------------------------------------------------
> -#ifdef LLDB_CONFIGURATION_DEBUG
> -    virtual
> -#endif
> -    int
> -    TryLock(const char *failure_message = nullptr);
> -
> -    //------------------------------------------------------------------
> -    /// Unlock the mutex.
> -    ///
> -    /// If the current thread holds the lock on the owned mutex, then
> -    /// Unlock() will unlock the mutex. Calling Unlock() on this object
> -    /// when the calling thread does not hold the lock will result in
> -    /// undefined behavior.
> -    ///
> -    /// @return
> -    ///     The error code from \c pthread_mutex_unlock().
> -    //------------------------------------------------------------------
> -#ifdef LLDB_CONFIGURATION_DEBUG
> -    virtual
> -#endif
> -    int
> -    Unlock();
> -
> -protected:
> -    //------------------------------------------------------------------
> -    // Member variables
> -    //------------------------------------------------------------------
> -    // TODO: Hide the mutex in the implementation file in case we ever
> need to port to an
> -    // architecture that doesn't have pthread mutexes.
> -    lldb::mutex_t m_mutex; ///< The OS mutex object.
> -
> -private:
> -    //------------------------------------------------------------------
> -    /// Mutex get accessor.
> -    ///
> -    /// @return
> -    ///     A pointer to the pthread mutex object owned by this object.
> -    //------------------------------------------------------------------
> -    lldb::mutex_t *
> -    GetMutex();
> -
> -    Mutex(const Mutex&);
> -    const Mutex& operator=(const Mutex&);
> -};
> -
> -#ifdef LLDB_CONFIGURATION_DEBUG
> -class TrackingMutex : public Mutex
> -{
> -public:
> -    TrackingMutex() : Mutex()  {}
> -    TrackingMutex(Mutex::Type type) : Mutex (type) {}
> -
> -    virtual
> -    ~TrackingMutex() = default;
> -
> -    virtual int
> -    Unlock ();
> -
> -    virtual int
> -    TryLock(const char *failure_message = nullptr)
> -    {
> -        int return_value = Mutex::TryLock();
> -        if (return_value != 0 && failure_message != nullptr)
> -        {
> -            m_failure_message.assign(failure_message);
> -            m_thread_that_tried = pthread_self();
> -        }
> -        return return_value;
> -    }
> -
> -protected:
> -    pthread_t m_thread_that_tried;
> -    std::string m_failure_message;
> -};
> -
> -class LoggingMutex : public Mutex
> -{
> -public:
> -    LoggingMutex() : Mutex(),m_locked(false)  {}
> -    LoggingMutex(Mutex::Type type) : Mutex (type),m_locked(false) {}
> -
> -    virtual
> -    ~LoggingMutex() = default;
> -
> -    virtual int
> -    Lock ();
> -
> -    virtual int
> -    Unlock ();
> -
> -    virtual int
> -    TryLock(const char *failure_message = nullptr);
> -
> -protected:
> -    bool m_locked;
> -};
> -#endif // LLDB_CONFIGURATION_DEBUG
> -
> -} // namespace lldb_private
> -
> -#endif // liblldb_Mutex_h_
>
> Modified: lldb/trunk/include/lldb/Host/Predicate.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Predicate.h?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Host/Predicate.h (original)
> +++ lldb/trunk/include/lldb/Host/Predicate.h Thu Jul 28 12:32:20 2016
> @@ -15,11 +15,12 @@
>  #include <time.h>
>
>  // C++ Includes
> +#include <condition_variable>
> +#include <mutex>
> +
>  // Other libraries and framework includes
>  // Project includes
>  #include "lldb/lldb-defines.h"
> -#include "lldb/Host/Mutex.h"
> -#include "lldb/Host/Condition.h"
>
>  //#define DB_PTHREAD_LOG_EVENTS
>
> @@ -97,7 +98,7 @@ public:
>      T
>      GetValue () const
>      {
> -        Mutex::Locker locker(m_mutex);
> +        std::lock_guard<std::mutex> guard(m_mutex);
>          T value = m_value;
>          return value;
>      }
> @@ -120,7 +121,7 @@ public:
>      void
>      SetValue (T value, PredicateBroadcastType broadcast_type)
>      {
> -        Mutex::Locker locker(m_mutex);
> +        std::lock_guard<std::mutex> guard(m_mutex);
>  #ifdef DB_PTHREAD_LOG_EVENTS
>          printf("%s (value = 0x%8.8x, broadcast_type = %i)\n",
> __FUNCTION__, value, broadcast_type);
>  #endif
> @@ -148,7 +149,7 @@ public:
>      void
>      SetValueBits (T bits, PredicateBroadcastType broadcast_type)
>      {
> -        Mutex::Locker locker(m_mutex);
> +        std::lock_guard<std::mutex> guard(m_mutex);
>  #ifdef DB_PTHREAD_LOG_EVENTS
>          printf("%s (bits = 0x%8.8x, broadcast_type = %i)\n",
> __FUNCTION__, bits, broadcast_type);
>  #endif
> @@ -176,7 +177,7 @@ public:
>      void
>      ResetValueBits (T bits, PredicateBroadcastType broadcast_type)
>      {
> -        Mutex::Locker locker(m_mutex);
> +        std::lock_guard<std::mutex> guard(m_mutex);
>  #ifdef DB_PTHREAD_LOG_EVENTS
>          printf("%s (bits = 0x%8.8x, broadcast_type = %i)\n",
> __FUNCTION__, bits, broadcast_type);
>  #endif
> @@ -213,21 +214,30 @@ public:
>      ///     occurred.
>      //------------------------------------------------------------------
>      T
> -    WaitForSetValueBits(T bits, const TimeValue *abstime = nullptr)
> +    WaitForSetValueBits(T bits, const std::chrono::microseconds &timeout
> = std::chrono::microseconds(0))
>      {
> -        int err = 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 (Mutex::Locker) to allow us to return at any point in
> this
> +        // class (std::lock_guard) to allow us to return at any point in
> this
>          // function and not have to worry about unlocking the mutex.
> -        Mutex::Locker locker(m_mutex);
> +        std::unique_lock<std::mutex> lock(m_mutex);
>  #ifdef DB_PTHREAD_LOG_EVENTS
> -        printf("%s (bits = 0x%8.8x, abstime = %p), m_value = 0x%8.8x\n",
> __FUNCTION__, bits, abstime, m_value);
> +        printf("%s (bits = 0x%8.8x, timeout = %llu), m_value =
> 0x%8.8x\n", __FUNCTION__, bits, timeout.count(),
> +               m_value);
>  #endif
> -        while (err == 0 && ((m_value & bits) == 0))
> +        while ((m_value & bits) == 0)
>          {
> -            err = m_condition.Wait (m_mutex, abstime);
> +            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)
> +                    break;
> +            }
>          }
>  #ifdef DB_PTHREAD_LOG_EVENTS
>          printf("%s (bits = 0x%8.8x), m_value = 0x%8.8x, returning
> 0x%8.8x\n", __FUNCTION__, bits, m_value, m_value & bits);
> @@ -262,23 +272,31 @@ public:
>      ///     unrecoverable error occurs.
>      //------------------------------------------------------------------
>      T
> -    WaitForResetValueBits(T bits, const TimeValue *abstime = nullptr)
> +    WaitForResetValueBits(T bits, const std::chrono::microseconds
> &timeout = std::chrono::microseconds(0))
>      {
> -        int err = 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 (Mutex::Locker) to allow us to return at any point in
> this
> +        // class (std::lock_guard) to allow us to return at any point in
> this
>          // function and not have to worry about unlocking the mutex.
> -        Mutex::Locker locker(m_mutex);
> +        std::unique_lock<std::mutex> lock(m_mutex);
>
>  #ifdef DB_PTHREAD_LOG_EVENTS
> -        printf("%s (bits = 0x%8.8x, abstime = %p), m_value = 0x%8.8x\n",
> __FUNCTION__, bits, abstime, m_value);
> +        printf("%s (bits = 0x%8.8x, timeout = %llu), m_value =
> 0x%8.8x\n", __FUNCTION__, bits, timeout.count(),
> +               m_value);
>  #endif
> -        while (err == 0 && ((m_value & bits) != 0))
> +        while ((m_value & bits) != 0)
>          {
> -            err = m_condition.Wait (m_mutex, abstime);
> +            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)
> +                    break;
> +            }
>          }
>
>  #ifdef DB_PTHREAD_LOG_EVENTS
> @@ -317,25 +335,39 @@ public:
>      ///     @li \b false otherwise
>      //------------------------------------------------------------------
>      bool
> -    WaitForValueEqualTo(T value, const TimeValue *abstime = nullptr, bool
> *timed_out = nullptr)
> +    WaitForValueEqualTo(T value, const std::chrono::microseconds &timeout
> = std::chrono::microseconds(0),
> +                        bool *timed_out = nullptr)
>      {
> -        int err = 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 (Mutex::Locker) to allow us to return at any point in
> this
> +        // class (std::lock_guard) to allow us to return at any point in
> this
>          // function and not have to worry about unlocking the mutex.
> -        Mutex::Locker locker(m_mutex);
> +        std::unique_lock<std::mutex> lock(m_mutex);
>
>  #ifdef DB_PTHREAD_LOG_EVENTS
> -        printf("%s (value = 0x%8.8x, abstime = %p), m_value = 0x%8.8x\n",
> __FUNCTION__, value, abstime, m_value);
> +        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 (err == 0 && m_value != value)
> +        while (m_value != value)
>          {
> -            err = m_condition.Wait (m_mutex, abstime, timed_out);
> +            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;
> +                    break;
> +                }
> +            }
>          }
>
>          return m_value == value;
> @@ -378,26 +410,39 @@ public:
>      //------------------------------------------------------------------
>      bool
>      WaitForValueEqualToAndSetValueTo(T wait_value, T new_value,
> -                                     const TimeValue *abstime = nullptr,
> +                                     const std::chrono::microseconds
> &timeout = std::chrono::microseconds(0),
>                                       bool *timed_out = nullptr)
>      {
> -        int err = 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 (Mutex::Locker) to allow us to return at any point in
> this
> +        // class (std::lock_guard) to allow us to return at any point in
> this
>          // function and not have to worry about unlocking the mutex.
> -        Mutex::Locker locker(m_mutex);
> +        std::unique_lock<std::mutex> lock(m_mutex);
>
>  #ifdef DB_PTHREAD_LOG_EVENTS
> -        printf("%s (wait_value = 0x%8.8x, new_value = 0x%8.8x, abstime =
> %p), m_value = 0x%8.8x\n", __FUNCTION__, wait_value, new_value, abstime,
> m_value);
> +        printf("%s (wait_value = 0x%8.8x, new_value = 0x%8.8x, timeout =
> %llu), m_value = 0x%8.8x\n", __FUNCTION__,
> +               wait_value, new_value, timeout.count(), m_value);
>  #endif
>          if (timed_out)
>              *timed_out = false;
>
> -        while (err == 0 && m_value != wait_value)
> +        while (m_value != wait_value)
>          {
> -            err = m_condition.Wait (m_mutex, abstime, timed_out);
> +            if (timeout == std::chrono::microseconds(0))
> +            {
> +                m_condition.wait(lock);
> +            }
> +            else
> +            {
> +                std::cv_status result = m_condition.wait_for(m_mutex,
> timeout);
> +                if (result == std::cv_status::timeout)
> +                {
> +                    if (timed_out)
> +                        *timed_out = true;
> +                    break;
> +                }
> +            }
>          }
>
>          if (m_value == wait_value)
> @@ -438,21 +483,31 @@ public:
>      ///     @li \b false otherwise
>      //------------------------------------------------------------------
>      bool
> -    WaitForValueNotEqualTo(T value, T &new_value, const TimeValue
> *abstime = nullptr)
> +    WaitForValueNotEqualTo(T value, T &new_value,
> +                           const std::chrono::microseconds &timeout =
> std::chrono::microseconds(0))
>      {
> -        int err = 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 (Mutex::Locker) to allow us to return at any point in
> this
> +        // class (std::lock_guard) to allow us to return at any point in
> this
>          // function and not have to worry about unlocking the mutex.
> -        Mutex::Locker locker(m_mutex);
> +        std::unique_lock<std::mutex> lock(m_mutex);
>  #ifdef DB_PTHREAD_LOG_EVENTS
> -        printf("%s (value = 0x%8.8x, abstime = %p), m_value = 0x%8.8x\n",
> __FUNCTION__, value, abstime, m_value);
> +        printf("%s (value = 0x%8.8x, timeout = %llu), m_value =
> 0x%8.8x\n", __FUNCTION__, value, timeout.count(),
> +               m_value);
>  #endif
> -        while (err == 0 && m_value == value)
> +        while (m_value == value)
>          {
> -            err = m_condition.Wait (m_mutex, abstime);
> +            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)
> +                    break;
> +            }
>          }
>
>          if (m_value != value)
> @@ -469,8 +524,9 @@ protected:
>      // blocking between the main thread and the spotlight index thread.
>
>  //----------------------------------------------------------------------
>      T           m_value;        ///< The templatized value T that we are
> protecting access to
> -    mutable Mutex m_mutex;      ///< The mutex to use when accessing the
> data
> -    Condition   m_condition;    ///< The pthread condition variable to
> use for signaling that data available or changed.
> +    mutable std::mutex m_mutex; ///< The mutex to use when accessing the
> data
> +    std::condition_variable
> +        m_condition; ///< The pthread condition variable to use for
> signaling that data available or changed.
>
>  private:
>      //------------------------------------------------------------------
> @@ -496,7 +552,7 @@ private:
>          printf("%s (old_value = 0x%8.8x, broadcast_type = %i) m_value =
> 0x%8.8x, broadcast = %u\n", __FUNCTION__, old_value, broadcast_type,
> m_value, broadcast);
>  #endif
>          if (broadcast)
> -            m_condition.Broadcast();
> +            m_condition.notify_all();
>      }
>
>      DISALLOW_COPY_AND_ASSIGN(Predicate);
>
> Modified: lldb/trunk/include/lldb/Host/ProcessRunLock.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/ProcessRunLock.h?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Host/ProcessRunLock.h (original)
> +++ lldb/trunk/include/lldb/Host/ProcessRunLock.h Thu Jul 28 12:32:20 2016
> @@ -18,7 +18,6 @@
>  // Other libraries and framework includes
>  // Project includes
>  #include "lldb/lldb-defines.h"
> -#include "lldb/Host/Condition.h"
>
>  //----------------------------------------------------------------------
>  /// Enumerations for broadcasting.
>
> Modified: lldb/trunk/include/lldb/Target/Process.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/include/lldb/Target/Process.h (original)
> +++ lldb/trunk/include/lldb/Target/Process.h Thu Jul 28 12:32:20 2016
> @@ -16,6 +16,7 @@
>  #include <limits.h>
>
>  // C++ Includes
> +#include <chrono>
>  #include <list>
>  #include <memory>
>  #include <mutex>
> @@ -2920,12 +2921,9 @@ public:
>      // function releases the run lock after the stop. Setting
> use_run_lock to false
>      // will avoid this behavior.
>      lldb::StateType
> -    WaitForProcessToStop(const TimeValue *timeout,
> -                         lldb::EventSP *event_sp_ptr = nullptr,
> -                         bool wait_always = true,
> -                         lldb::ListenerSP hijack_listener =
> lldb::ListenerSP(),
> -                         Stream *stream = nullptr,
> -                         bool use_run_lock = true);
> +    WaitForProcessToStop(const std::chrono::microseconds &timeout,
> lldb::EventSP *event_sp_ptr = nullptr,
> +                         bool wait_always = true, lldb::ListenerSP
> hijack_listener = lldb::ListenerSP(),
> +                         Stream *stream = nullptr, bool use_run_lock =
> true);
>
>      uint32_t
>      GetIOHandlerID () const
> @@ -2947,8 +2945,7 @@ public:
>      SyncIOHandler (uint32_t iohandler_id, uint64_t timeout_msec);
>
>      lldb::StateType
> -    WaitForStateChangedEvents(const TimeValue *timeout,
> -                              lldb::EventSP &event_sp,
> +    WaitForStateChangedEvents(const std::chrono::microseconds &timeout,
> lldb::EventSP &event_sp,
>                                lldb::ListenerSP hijack_listener); // Pass
> an empty ListenerSP to use builtin listener
>
>
>  //--------------------------------------------------------------------------------------
> @@ -3538,21 +3535,20 @@ protected:
>      HaltPrivate();
>
>      lldb::StateType
> -    WaitForProcessStopPrivate (const TimeValue *timeout, lldb::EventSP
> &event_sp);
> +    WaitForProcessStopPrivate(const std::chrono::microseconds &timeout,
> lldb::EventSP &event_sp);
>
>      // This waits for both the state change broadcaster, and the control
> broadcaster.
>      // If control_only, it only waits for the control broadcaster.
>
>      bool
> -    WaitForEventsPrivate (const TimeValue *timeout, lldb::EventSP
> &event_sp, bool control_only);
> +    WaitForEventsPrivate(const std::chrono::microseconds &timeout,
> lldb::EventSP &event_sp, bool control_only);
>
>      lldb::StateType
> -    WaitForStateChangedEventsPrivate (const TimeValue *timeout,
> lldb::EventSP &event_sp);
> +    WaitForStateChangedEventsPrivate(const std::chrono::microseconds
> &timeout, lldb::EventSP &event_sp);
>
>      lldb::StateType
> -    WaitForState (const TimeValue *timeout,
> -                  const lldb::StateType *match_states,
> -                  const uint32_t num_match_states);
> +    WaitForState(const std::chrono::microseconds &timeout, const
> lldb::StateType *match_states,
> +                 const uint32_t num_match_states);
>
>      size_t
>      WriteMemoryPrivate (lldb::addr_t addr, const void *buf, size_t size,
> Error &error);
>
> Modified: lldb/trunk/source/API/SBListener.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBListener.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/API/SBListener.cpp (original)
> +++ lldb/trunk/source/API/SBListener.cpp Thu Jul 28 12:32:20 2016
> @@ -17,7 +17,6 @@
>  #include "lldb/Core/Listener.h"
>  #include "lldb/Core/Log.h"
>  #include "lldb/Core/StreamString.h"
> -#include "lldb/Host/TimeValue.h"
>
>
>  using namespace lldb;
> @@ -202,15 +201,14 @@ SBListener::WaitForEvent (uint32_t timeo
>
>      if (m_opaque_sp)
>      {
> -        TimeValue time_value;
> +        std::chrono::microseconds timeout = std::chrono::microseconds(0);
>          if (timeout_secs != UINT32_MAX)
>          {
>              assert (timeout_secs != 0); // Take this out after all calls
> with timeout set to zero have been removed....
> -            time_value = TimeValue::Now();
> -            time_value.OffsetWithSeconds (timeout_secs);
> +            timeout = std::chrono::seconds(timeout_secs);
>          }
>          EventSP event_sp;
> -        if (m_opaque_sp->WaitForEvent (time_value.IsValid() ? &time_value
> : NULL, event_sp))
> +        if (m_opaque_sp->WaitForEvent(timeout, event_sp))
>          {
>              event.reset (event_sp);
>              success = true;
> @@ -247,16 +245,11 @@ SBListener::WaitForEventForBroadcaster
>  {
>      if (m_opaque_sp && broadcaster.IsValid())
>      {
> -        TimeValue time_value;
> +        std::chrono::microseconds timeout = std::chrono::microseconds(0);
>          if (num_seconds != UINT32_MAX)
> -        {
> -            time_value = TimeValue::Now();
> -            time_value.OffsetWithSeconds (num_seconds);
> -        }
> +            timeout = std::chrono::seconds(num_seconds);
>          EventSP event_sp;
> -        if (m_opaque_sp->WaitForEventForBroadcaster (time_value.IsValid()
> ? &time_value : NULL,
> -
>  broadcaster.get(),
> -                                                         event_sp))
> +        if (m_opaque_sp->WaitForEventForBroadcaster(timeout,
> broadcaster.get(), event_sp))
>          {
>              event.reset (event_sp);
>              return true;
> @@ -278,17 +271,11 @@ SBListener::WaitForEventForBroadcasterWi
>  {
>      if (m_opaque_sp && broadcaster.IsValid())
>      {
> -        TimeValue time_value;
> +        std::chrono::microseconds timeout = std::chrono::microseconds(0);
>          if (num_seconds != UINT32_MAX)
> -        {
> -            time_value = TimeValue::Now();
> -            time_value.OffsetWithSeconds (num_seconds);
> -        }
> +            timeout = std::chrono::seconds(num_seconds);
>          EventSP event_sp;
> -        if (m_opaque_sp->WaitForEventForBroadcasterWithType
> (time_value.IsValid() ? &time_value : NULL,
> -
> broadcaster.get(),
> -
> event_type_mask,
> -                                                              event_sp))
> +        if (m_opaque_sp->WaitForEventForBroadcasterWithType(timeout,
> broadcaster.get(), event_type_mask, event_sp))
>          {
>              event.reset (event_sp);
>              return true;
>
> Modified: lldb/trunk/source/Core/Communication.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Core/Communication.cpp (original)
> +++ lldb/trunk/source/Core/Communication.cpp Thu Jul 28 12:32:20 2016
> @@ -156,18 +156,14 @@ Communication::Read (void *dst, size_t d
>              status = eConnectionStatusNoConnection;
>              return 0;
>          }
> -        // Set the timeout appropriately
> -        TimeValue timeout_time;
> -        if (timeout_usec != UINT32_MAX)
> -        {
> -            timeout_time = TimeValue::Now();
> -            timeout_time.OffsetWithMicroSeconds (timeout_usec);
> -        }
>
>          ListenerSP
> listener_sp(Listener::MakeListener("Communication::Read"));
>          listener_sp->StartListeningForEvents (this,
> eBroadcastBitReadThreadGotBytes | eBroadcastBitReadThreadDidExit);
>          EventSP event_sp;
> -        while (listener_sp->WaitForEvent (timeout_time.IsValid() ?
> &timeout_time : nullptr, event_sp))
> +        std::chrono::microseconds timeout = std::chrono::microseconds(0);
> +        if (timeout_usec != UINT32_MAX)
> +            timeout = std::chrono::microseconds(timeout_usec);
> +        while (listener_sp->WaitForEvent(timeout, event_sp))
>          {
>              const uint32_t event_type = event_sp->GetType();
>              if (event_type & eBroadcastBitReadThreadGotBytes)
> @@ -439,7 +435,7 @@ Communication::SynchronizeWithReadThread
>
>      // Wait for the synchronization event.
>      EventSP event_sp;
> -    listener_sp->WaitForEvent(nullptr, event_sp);
> +    listener_sp->WaitForEvent(std::chrono::microseconds(0), event_sp);
>  }
>
>  void
>
> Modified: lldb/trunk/source/Core/Debugger.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Core/Debugger.cpp (original)
> +++ lldb/trunk/source/Core/Debugger.cpp Thu Jul 28 12:32:20 2016
> @@ -1608,7 +1608,7 @@ Debugger::DefaultEventHandler()
>      while (!done)
>      {
>          EventSP event_sp;
> -        if (listener_sp->WaitForEvent(nullptr, event_sp))
> +        if (listener_sp->WaitForEvent(std::chrono::microseconds(0),
> event_sp))
>          {
>              if (event_sp)
>              {
> @@ -1705,7 +1705,7 @@ Debugger::StartEventHandlerThread()
>          // eBroadcastBitEventThreadIsListening so we don't need to check
> the event, we just need
>          // to wait an infinite amount of time for it (nullptr timeout as
> the first parameter)
>          lldb::EventSP event_sp;
> -        listener_sp->WaitForEvent(nullptr, event_sp);
> +        listener_sp->WaitForEvent(std::chrono::microseconds(0), event_sp);
>      }
>      return m_event_handler_thread.IsJoinable();
>  }
>
> Modified: lldb/trunk/source/Core/Listener.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Listener.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Core/Listener.cpp (original)
> +++ lldb/trunk/source/Core/Listener.cpp Thu Jul 28 12:32:20 2016
> @@ -19,7 +19,6 @@
>  #include "lldb/Core/Log.h"
>  #include "lldb/Core/StreamString.h"
>  #include "lldb/Core/Event.h"
> -#include "lldb/Host/TimeValue.h"
>
>  using namespace lldb;
>  using namespace lldb_private;
> @@ -41,7 +40,7 @@ namespace
>  } // anonymous namespace
>
>  Listener::Listener(const char *name)
> -    : m_name(name), m_broadcasters(), m_broadcasters_mutex(), m_events(),
> m_events_mutex(Mutex::eMutexTypeNormal)
> +    : m_name(name), m_broadcasters(), m_broadcasters_mutex(), m_events(),
> m_events_mutex()
>  {
>      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
>      if (log != nullptr)
> @@ -63,7 +62,7 @@ void
>  Listener::Clear()
>  {
>      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
> -    std::lock_guard<std::recursive_mutex> guard(m_broadcasters_mutex);
> +    std::lock_guard<std::recursive_mutex>
> broadcasters_guard(m_broadcasters_mutex);
>      broadcaster_collection::iterator pos, end = m_broadcasters.end();
>      for (pos = m_broadcasters.begin(); pos != end; ++pos)
>      {
> @@ -73,7 +72,7 @@ Listener::Clear()
>      }
>      m_broadcasters.clear();
>
> -    Mutex::Locker event_locker(m_events_mutex);
> +    std::lock_guard<std::mutex> events_guard(m_events_mutex);
>      m_events.clear();
>      size_t num_managers = m_broadcaster_managers.size();
>
> @@ -96,7 +95,7 @@ Listener::StartListeningForEvents (Broad
>          // Scope for "locker"
>          // Tell the broadcaster to add this object as a listener
>          {
> -            std::lock_guard<std::recursive_mutex>
> guard(m_broadcasters_mutex);
> +            std::lock_guard<std::recursive_mutex>
> broadcasters_guard(m_broadcasters_mutex);
>              Broadcaster::BroadcasterImplWP
> impl_wp(broadcaster->GetBroadcasterImpl());
>              m_broadcasters.insert(std::make_pair(impl_wp,
> BroadcasterInfo(event_mask)));
>          }
> @@ -123,7 +122,7 @@ Listener::StartListeningForEvents (Broad
>          // Scope for "locker"
>          // Tell the broadcaster to add this object as a listener
>          {
> -            std::lock_guard<std::recursive_mutex>
> guard(m_broadcasters_mutex);
> +            std::lock_guard<std::recursive_mutex>
> broadcasters_guard(m_broadcasters_mutex);
>              Broadcaster::BroadcasterImplWP
> impl_wp(broadcaster->GetBroadcasterImpl());
>              m_broadcasters.insert(std::make_pair(impl_wp,
>
> BroadcasterInfo(event_mask, callback, callback_user_data)));
> @@ -154,7 +153,7 @@ Listener::StopListeningForEvents (Broadc
>      {
>          // Scope for "locker"
>          {
> -            std::lock_guard<std::recursive_mutex>
> guard(m_broadcasters_mutex);
> +            std::lock_guard<std::recursive_mutex>
> broadcasters_guard(m_broadcasters_mutex);
>              m_broadcasters.erase (broadcaster->GetBroadcasterImpl());
>          }
>          // Remove the broadcaster from our set of broadcasters
> @@ -171,13 +170,13 @@ Listener::BroadcasterWillDestruct (Broad
>  {
>      // Scope for "broadcasters_locker"
>      {
> -        std::lock_guard<std::recursive_mutex> guard(m_broadcasters_mutex);
> +        std::lock_guard<std::recursive_mutex>
> broadcasters_guard(m_broadcasters_mutex);
>          m_broadcasters.erase (broadcaster->GetBroadcasterImpl());
>      }
>
>      // Scope for "event_locker"
>      {
> -        Mutex::Locker event_locker(m_events_mutex);
> +        std::lock_guard<std::mutex> events_guard(m_events_mutex);
>          // Remove all events for this broadcaster object.
>          event_collection::iterator pos = m_events.begin();
>          while (pos != m_events.end())
> @@ -212,9 +211,9 @@ Listener::AddEvent (EventSP &event_sp)
>                       static_cast<void*>(this), m_name.c_str(),
>                       static_cast<void*>(event_sp.get()));
>
> -    Mutex::Locker locker(m_events_mutex);
> +    std::lock_guard<std::mutex> guard(m_events_mutex);
>      m_events.push_back (event_sp);
> -    m_events_condition.Broadcast();
> +    m_events_condition.notify_all();
>  }
>
>  class EventBroadcasterMatches
> @@ -279,15 +278,11 @@ private:
>  };
>
>  bool
> -Listener::FindNextEventInternal
> -(
> -    Mutex::Locker& lock,
> -    Broadcaster *broadcaster,   // nullptr for any broadcaster
> -    const ConstString *broadcaster_names, // nullptr for any event
> -    uint32_t num_broadcaster_names,
> -    uint32_t event_type_mask,
> -    EventSP &event_sp,
> -    bool remove)
> +Listener::FindNextEventInternal(std::unique_lock<std::mutex> &lock,
> +                                Broadcaster *broadcaster,             //
> nullptr for any broadcaster
> +                                const ConstString *broadcaster_names, //
> nullptr for any event
> +                                uint32_t num_broadcaster_names, uint32_t
> event_type_mask, EventSP &event_sp,
> +                                bool remove)
>  {
>      // NOTE: callers of this function must lock m_events_mutex using a
> Mutex::Locker
>      // and pass the locker as the first argument. m_events_mutex is no
> longer recursive.
> @@ -325,7 +320,7 @@ Listener::FindNextEventInternal
>              // Unlock the event queue here.  We've removed this event and
> are about to return
>              // it so it should be okay to get the next event off the
> queue here - and it might
>              // be useful to do that in the "DoOnRemoval".
> -            lock.Unlock();
> +            lock.unlock();
>              event_sp->DoOnRemoval();
>          }
>          return true;
> @@ -338,9 +333,9 @@ Listener::FindNextEventInternal
>  Event *
>  Listener::PeekAtNextEvent ()
>  {
> -    Mutex::Locker lock(m_events_mutex);
> +    std::unique_lock<std::mutex> guard(m_events_mutex);
>      EventSP event_sp;
> -    if (FindNextEventInternal(lock, nullptr, nullptr, 0, 0, event_sp,
> false))
> +    if (FindNextEventInternal(guard, nullptr, nullptr, 0, 0, event_sp,
> false))
>          return event_sp.get();
>      return nullptr;
>  }
> @@ -348,9 +343,9 @@ Listener::PeekAtNextEvent ()
>  Event *
>  Listener::PeekAtNextEventForBroadcaster (Broadcaster *broadcaster)
>  {
> -    Mutex::Locker lock(m_events_mutex);
> +    std::unique_lock<std::mutex> guard(m_events_mutex);
>      EventSP event_sp;
> -    if (FindNextEventInternal(lock, broadcaster, nullptr, 0, 0, event_sp,
> false))
> +    if (FindNextEventInternal(guard, broadcaster, nullptr, 0, 0,
> event_sp, false))
>          return event_sp.get();
>      return nullptr;
>  }
> @@ -358,9 +353,9 @@ Listener::PeekAtNextEventForBroadcaster
>  Event *
>  Listener::PeekAtNextEventForBroadcasterWithType (Broadcaster
> *broadcaster, uint32_t event_type_mask)
>  {
> -    Mutex::Locker lock(m_events_mutex);
> +    std::unique_lock<std::mutex> guard(m_events_mutex);
>      EventSP event_sp;
> -    if (FindNextEventInternal(lock, broadcaster, nullptr, 0,
> event_type_mask, event_sp, false))
> +    if (FindNextEventInternal(guard, broadcaster, nullptr, 0,
> event_type_mask, event_sp, false))
>          return event_sp.get();
>      return nullptr;
>  }
> @@ -372,8 +367,9 @@ Listener::GetNextEventInternal(Broadcast
>                                 uint32_t event_type_mask,
>                                 EventSP &event_sp)
>  {
> -    Mutex::Locker lock(m_events_mutex);
> -    return FindNextEventInternal (lock, broadcaster, broadcaster_names,
> num_broadcaster_names, event_type_mask, event_sp, true);
> +    std::unique_lock<std::mutex> guard(m_events_mutex);
> +    return FindNextEventInternal(guard, broadcaster, broadcaster_names,
> num_broadcaster_names, event_type_mask,
> +                                 event_sp, true);
>  }
>
>  bool
> @@ -395,20 +391,17 @@ Listener::GetNextEventForBroadcasterWith
>  }
>
>  bool
> -Listener::WaitForEventsInternal(const TimeValue *timeout,
> +Listener::WaitForEventsInternal(const std::chrono::microseconds &timeout,
>                                  Broadcaster *broadcaster,             //
> nullptr for any broadcaster
>                                  const ConstString *broadcaster_names, //
> nullptr for any event
> -                                uint32_t num_broadcaster_names,
> -                                uint32_t event_type_mask,
> -                                EventSP &event_sp)
> +                                uint32_t num_broadcaster_names, uint32_t
> event_type_mask, EventSP &event_sp)
>  {
>      Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EVENTS));
>      if (log != nullptr)
> -        log->Printf ("%p Listener::WaitForEventsInternal (timeout = { %p
> }) for %s",
> -                     static_cast<void*>(this), static_cast<const
> void*>(timeout),
> -                     m_name.c_str());
> +        log->Printf("%p Listener::WaitForEventsInternal (timeout = %llu
> us) for %s", static_cast<void *>(this),
> +                    static_cast<unsigned long long>(timeout.count()),
> m_name.c_str());
>
> -    Mutex::Locker lock(m_events_mutex);
> +    std::unique_lock<std::mutex> lock(m_events_mutex);
>
>      while (true)
>      {
> @@ -418,23 +411,26 @@ Listener::WaitForEventsInternal(const Ti
>          }
>          else
>          {
> -            bool timed_out = false;
> -            if (m_events_condition.Wait(m_events_mutex, timeout,
> &timed_out) != 0)
> +            std::cv_status result = std::cv_status::no_timeout;
> +            if (timeout == std::chrono::microseconds(0))
> +                m_events_condition.wait(lock);
> +            else
> +                result = m_events_condition.wait_for(lock, timeout);
> +
> +            if (result == std::cv_status::timeout)
>              {
> -                if (timed_out)
> -                {
> -                    log = lldb_private::GetLogIfAllCategoriesSet
> (LIBLLDB_LOG_EVENTS);
> -                    if (log != nullptr)
> -                        log->Printf ("%p
> Listener::WaitForEventsInternal() timed out for %s",
> -                                     static_cast<void*>(this),
> m_name.c_str());
> -                }
> -                else
> -                {
> -                    log = lldb_private::GetLogIfAllCategoriesSet
> (LIBLLDB_LOG_EVENTS);
> -                    if (log != nullptr)
> -                        log->Printf ("%p
> Listener::WaitForEventsInternal() unknown error for %s",
> -                                     static_cast<void*>(this),
> m_name.c_str());
> -                }
> +              log =
> lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS);
> +              if (log)
> +                  log->Printf("%p Listener::WaitForEventsInternal() timed
> out for %s", static_cast<void *>(this),
> +                              m_name.c_str());
> +              return false;
> +            }
> +            else if (result != std::cv_status::no_timeout)
> +            {
> +                log =
> lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS);
> +                if (log)
> +                    log->Printf("%p Listener::WaitForEventsInternal()
> unknown error for %s", static_cast<void *>(this),
> +                                m_name.c_str());
>                  return false;
>              }
>          }
> @@ -444,24 +440,21 @@ Listener::WaitForEventsInternal(const Ti
>  }
>
>  bool
> -Listener::WaitForEventForBroadcasterWithType(const TimeValue *timeout,
> -                                             Broadcaster *broadcaster,
> -                                             uint32_t event_type_mask,
> -                                             EventSP &event_sp)
> +Listener::WaitForEventForBroadcasterWithType(const
> std::chrono::microseconds &timeout, Broadcaster *broadcaster,
> +                                             uint32_t event_type_mask,
> EventSP &event_sp)
>  {
>      return WaitForEventsInternal(timeout, broadcaster, nullptr, 0,
> event_type_mask, event_sp);
>  }
>
>  bool
> -Listener::WaitForEventForBroadcaster(const TimeValue *timeout,
> -                                     Broadcaster *broadcaster,
> +Listener::WaitForEventForBroadcaster(const std::chrono::microseconds
> &timeout, Broadcaster *broadcaster,
>                                       EventSP &event_sp)
>  {
>      return WaitForEventsInternal(timeout, broadcaster, nullptr, 0, 0,
> event_sp);
>  }
>
>  bool
> -Listener::WaitForEvent (const TimeValue *timeout, EventSP &event_sp)
> +Listener::WaitForEvent(const std::chrono::microseconds &timeout, EventSP
> &event_sp)
>  {
>      return WaitForEventsInternal(timeout, nullptr, nullptr, 0, 0,
> event_sp);
>  }
>
> Modified: lldb/trunk/source/Host/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/CMakeLists.txt?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Host/CMakeLists.txt (original)
> +++ lldb/trunk/source/Host/CMakeLists.txt Thu Jul 28 12:32:20 2016
> @@ -4,7 +4,6 @@ macro(add_host_subdirectory group)
>  endmacro()
>
>  add_host_subdirectory(common
> -  common/Condition.cpp
>    common/File.cpp
>    common/FileCache.cpp
>    common/FileSpec.cpp
> @@ -17,7 +16,6 @@ add_host_subdirectory(common
>    common/HostThread.cpp
>    common/IOObject.cpp
>    common/LockFileBase.cpp
> -  common/Mutex.cpp
>    common/MonitoringProcessLauncher.cpp
>    common/NativeBreakpoint.cpp
>    common/NativeBreakpointList.cpp
> @@ -60,7 +58,6 @@ add_host_subdirectory(posix
>
>  if (CMAKE_SYSTEM_NAME MATCHES "Windows")
>    add_host_subdirectory(windows
> -    windows/Condition.cpp
>      windows/ConnectionGenericFileWindows.cpp
>      windows/EditLineWin.cpp
>      windows/FileSystem.cpp
> @@ -69,7 +66,6 @@ if (CMAKE_SYSTEM_NAME MATCHES "Windows")
>      windows/HostProcessWindows.cpp
>      windows/HostThreadWindows.cpp
>      windows/LockFileWindows.cpp
> -    windows/Mutex.cpp
>      windows/PipeWindows.cpp
>      windows/ProcessLauncherWindows.cpp
>      windows/ProcessRunLock.cpp
>
> Removed: lldb/trunk/source/Host/common/Condition.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Condition.cpp?rev=277010&view=auto
>
> ==============================================================================
> --- lldb/trunk/source/Host/common/Condition.cpp (original)
> +++ lldb/trunk/source/Host/common/Condition.cpp (removed)
> @@ -1,108 +0,0 @@
> -//===-- Condition.cpp -------------------------------------------*- C++
> -*-===//
> -//
> -//                     The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
>
> -//===----------------------------------------------------------------------===//
> -
> -#include <errno.h>
> -
> -#include "lldb/Host/Condition.h"
> -#include "lldb/Host/TimeValue.h"
> -
> -
> -using namespace lldb_private;
> -
> -#ifndef _WIN32
> -
> -//----------------------------------------------------------------------
> -// Default constructor
> -//
> -// The default constructor will initialize a new pthread condition
> -// and maintain the condition in the object state.
> -//----------------------------------------------------------------------
> -Condition::Condition () :
> -    m_condition()
> -{
> -    ::pthread_cond_init (&m_condition, NULL);
> -}
> -
> -//----------------------------------------------------------------------
> -// Destructor
> -//
> -// Destroys the pthread condition that the object owns.
> -//----------------------------------------------------------------------
> -Condition::~Condition ()
> -{
> -    ::pthread_cond_destroy (&m_condition);
> -}
> -
> -//----------------------------------------------------------------------
> -// Unblock all threads waiting for a condition variable
> -//----------------------------------------------------------------------
> -int
> -Condition::Broadcast ()
> -{
> -    return ::pthread_cond_broadcast (&m_condition);
> -}
> -
> -//----------------------------------------------------------------------
> -// Unblocks one thread waiting for the condition variable
> -//----------------------------------------------------------------------
> -int
> -Condition::Signal ()
> -{
> -    return ::pthread_cond_signal (&m_condition);
> -}
> -
> -//----------------------------------------------------------------------
> -// The Wait() function atomically blocks the current thread
> -// waiting on the owned condition variable, and unblocks the mutex
> -// specified by "mutex".  The waiting thread unblocks only after
> -// another thread calls Signal(), or Broadcast() with the same
> -// condition variable, or if "abstime" is valid (non-NULL) this
> -// function will return when the system time reaches the time
> -// specified in "abstime". If "abstime" is NULL this function will
> -// wait for an infinite amount of time for the condition variable
> -// to be signaled or broadcasted.
> -//
> -// The current thread re-acquires the lock on "mutex".
> -//----------------------------------------------------------------------
> -int
> -Condition::Wait (Mutex &mutex, const TimeValue *abstime, bool *timed_out)
> -{
> -    int err = 0;
> -    do
> -    {
> -        if (abstime && abstime->IsValid())
> -        {
> -            struct timespec abstime_ts = abstime->GetAsTimeSpec();
> -            err = ::pthread_cond_timedwait (&m_condition,
> mutex.GetMutex(), &abstime_ts);
> -        }
> -        else
> -            err = ::pthread_cond_wait (&m_condition, mutex.GetMutex());
> -    } while (err == EINTR);
> -
> -    if (timed_out != NULL)
> -    {
> -        if (err == ETIMEDOUT)
> -            *timed_out = true;
> -        else
> -            *timed_out = false;
> -    }
> -
> -    return err;
> -}
> -
> -#endif
> -
> -//----------------------------------------------------------------------
> -// Get accessor to the pthread condition object
> -//----------------------------------------------------------------------
> -lldb::condition_t *
> -Condition::GetCondition()
> -{
> -    return &m_condition;
> -}
>
> Modified: lldb/trunk/source/Host/common/Host.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Host/common/Host.cpp (original)
> +++ lldb/trunk/source/Host/common/Host.cpp Thu Jul 28 12:32:20 2016
> @@ -620,14 +620,8 @@ Host::RunShellCommand(const Args &args,
>
>      if (error.Success())
>      {
> -        TimeValue *timeout_ptr = nullptr;
> -        TimeValue timeout_time(TimeValue::Now());
> -        if (timeout_sec > 0) {
> -            timeout_time.OffsetWithSeconds(timeout_sec);
> -            timeout_ptr = &timeout_time;
> -        }
>          bool timed_out = false;
> -        shell_info_sp->process_reaped.WaitForValueEqualTo(true,
> timeout_ptr, &timed_out);
> +        shell_info_sp->process_reaped.WaitForValueEqualTo(true,
> std::chrono::seconds(timeout_sec), &timed_out);
>          if (timed_out)
>          {
>              error.SetErrorString("timed out waiting for shell command to
> complete");
> @@ -635,10 +629,8 @@ Host::RunShellCommand(const Args &args,
>              // Kill the process since it didn't complete within the
> timeout specified
>              Kill (pid, SIGKILL);
>              // Wait for the monitor callback to get the message
> -            timeout_time = TimeValue::Now();
> -            timeout_time.OffsetWithSeconds(1);
>              timed_out = false;
> -            shell_info_sp->process_reaped.WaitForValueEqualTo(true,
> &timeout_time, &timed_out);
> +            shell_info_sp->process_reaped.WaitForValueEqualTo(true,
> std::chrono::seconds(1), &timed_out);
>          }
>          else
>          {
>
> Removed: lldb/trunk/source/Host/common/Mutex.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Mutex.cpp?rev=277010&view=auto
>
> ==============================================================================
> --- lldb/trunk/source/Host/common/Mutex.cpp (original)
> +++ lldb/trunk/source/Host/common/Mutex.cpp (removed)
> @@ -1,398 +0,0 @@
> -//===-- Mutex.cpp -----------------------------------------------*- C++
> -*-===//
> -//
> -//                     The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
>
> -//===----------------------------------------------------------------------===//
> -
> -#include "lldb/Host/Mutex.h"
> -#include "lldb/Host/Host.h"
> -
> -#ifndef _WIN32
> -#include <pthread.h>
> -#endif
> -#include <string.h>
> -#include <stdio.h>
> -
> -#if 0
> -// This logging is way too verbose to enable even for a log channel.
> -// This logging can be enabled by changing the "#if 0", but should be
> -// reverted prior to checking in.
> -#include <cstdio>
> -#define DEBUG_LOG(fmt, ...) printf(fmt, ## __VA_ARGS__)
> -#else
> -#define DEBUG_LOG(fmt, ...)
> -#endif
> -
> -// Enable extra mutex error checking
> -#if 0 // LLDB_CONFIGURATION_DEBUG
> -#define ENABLE_MUTEX_ERROR_CHECKING 1
> -#include <inttypes.h>
> -#endif
> -
> -#if ENABLE_MUTEX_ERROR_CHECKING
> -#include <set>
> -
> -enum MutexAction
> -{
> -    eMutexActionInitialized,
> -    eMutexActionDestroyed,
> -    eMutexActionAssertInitialized
> -};
> -
> -static bool
> -error_check_mutex (pthread_mutex_t *m, MutexAction action)
> -{
> -    typedef std::set<pthread_mutex_t *> mutex_set;
> -    static pthread_mutex_t g_mutex_set_mutex = PTHREAD_MUTEX_INITIALIZER;
> -    static mutex_set g_initialized_mutex_set;
> -    static mutex_set g_destroyed_mutex_set;
> -
> -    bool success = true;
> -    int err;
> -    // Manually call lock so we don't to any of this error checking
> -    err = ::pthread_mutex_lock (&g_mutex_set_mutex);
> -    assert(err == 0);
> -    switch (action)
> -    {
> -        case eMutexActionInitialized:
> -            // Make sure this isn't already in our initialized mutex
> set...
> -            assert (g_initialized_mutex_set.find(m) ==
> g_initialized_mutex_set.end());
> -            // Remove this from the destroyed set in case it was ever in
> there
> -            g_destroyed_mutex_set.erase(m);
> -            // Add the mutex to the initialized set
> -            g_initialized_mutex_set.insert(m);
> -            break;
> -
> -        case eMutexActionDestroyed:
> -            // Make sure this isn't already in our destroyed mutex set...
> -            assert (g_destroyed_mutex_set.find(m) ==
> g_destroyed_mutex_set.end());
> -            // Remove this from the initialized so we can put it into the
> destroyed set
> -            g_initialized_mutex_set.erase(m);
> -            // Add the mutex to the destroyed set
> -            g_destroyed_mutex_set.insert(m);
> -            break;
> -        case eMutexActionAssertInitialized:
> -            // This function will return true if "m" is in the
> initialized mutex set
> -            success = g_initialized_mutex_set.find(m) !=
> g_initialized_mutex_set.end();
> -            assert (success);
> -            break;
> -    }
> -    // Manually call unlock so we don't to any of this error checking
> -    err = ::pthread_mutex_unlock (&g_mutex_set_mutex);
> -    assert(err == 0);
> -    return success;
> -}
> -
> -#endif
> -
> -using namespace lldb_private;
> -
> -//----------------------------------------------------------------------
> -// Default constructor.
> -//
> -// This will create a scoped mutex locking object that doesn't have
> -// a mutex to lock. One will need to be provided using the Reset()
> -// method.
> -//----------------------------------------------------------------------
> -Mutex::Locker::Locker () :
> -    m_mutex_ptr(NULL)
> -{
> -}
> -
> -//----------------------------------------------------------------------
> -// Constructor with a Mutex object.
> -//
> -// This will create a scoped mutex locking object that extracts the
> -// mutex owned by "m" and locks it.
> -//----------------------------------------------------------------------
> -Mutex::Locker::Locker (Mutex& m) :
> -    m_mutex_ptr(NULL)
> -{
> -    Lock (m);
> -}
> -
> -//----------------------------------------------------------------------
> -// Constructor with a Mutex object pointer.
> -//
> -// This will create a scoped mutex locking object that extracts the
> -// mutex owned by "m" and locks it.
> -//----------------------------------------------------------------------
> -Mutex::Locker::Locker (Mutex* m) :
> -    m_mutex_ptr(NULL)
> -{
> -    if (m)
> -        Lock (m);
> -}
> -
> -//----------------------------------------------------------------------
> -// Destructor
> -//
> -// Unlocks any owned mutex object (if it is valid).
> -//----------------------------------------------------------------------
> -Mutex::Locker::~Locker ()
> -{
> -    Unlock();
> -}
> -
> -//----------------------------------------------------------------------
> -// Unlock the current mutex in this object (if this owns a valid
> -// mutex) and lock the new "mutex" object if it is non-NULL.
> -//----------------------------------------------------------------------
> -void
> -Mutex::Locker::Lock (Mutex &mutex)
> -{
> -    // We already have this mutex locked or both are NULL...
> -    if (m_mutex_ptr == &mutex)
> -        return;
> -
> -    Unlock ();
> -
> -    m_mutex_ptr = &mutex;
> -    m_mutex_ptr->Lock();
> -}
> -
> -void
> -Mutex::Locker::Unlock ()
> -{
> -    if (m_mutex_ptr)
> -    {
> -        m_mutex_ptr->Unlock ();
> -        m_mutex_ptr = NULL;
> -    }
> -}
> -
> -bool
> -Mutex::Locker::TryLock (Mutex &mutex, const char *failure_message)
> -{
> -    // We already have this mutex locked!
> -    if (m_mutex_ptr == &mutex)
> -        return true;
> -
> -    Unlock ();
> -
> -    if (mutex.TryLock(failure_message) == 0)
> -        m_mutex_ptr = &mutex;
> -
> -    return m_mutex_ptr != NULL;
> -}
> -
> -#ifndef _WIN32
> -
> -//----------------------------------------------------------------------
> -// Default constructor.
> -//
> -// Creates a pthread mutex with no attributes.
> -//----------------------------------------------------------------------
> -Mutex::Mutex () :
> -    m_mutex()
> -{
> -    int err;
> -    err = ::pthread_mutex_init (&m_mutex, NULL);
> -#if ENABLE_MUTEX_ERROR_CHECKING
> -    if (err == 0)
> -        error_check_mutex (&m_mutex, eMutexActionInitialized);
> -#endif
> -    assert(err == 0);
> -}
> -
> -//----------------------------------------------------------------------
> -// Default constructor.
> -//
> -// Creates a pthread mutex with "type" as the mutex type.
> -//----------------------------------------------------------------------
> -Mutex::Mutex (Mutex::Type type) :
> -    m_mutex()
> -{
> -    int err;
> -    ::pthread_mutexattr_t attr;
> -    err = ::pthread_mutexattr_init (&attr);
> -    assert(err == 0);
> -    switch (type)
> -    {
> -    case eMutexTypeNormal:
> -#if ENABLE_MUTEX_ERROR_CHECKING
> -        err = ::pthread_mutexattr_settype (&attr,
> PTHREAD_MUTEX_ERRORCHECK);
> -#else
> -        err = ::pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_NORMAL);
> -#endif
> -        break;
> -
> -    case eMutexTypeRecursive:
> -        err = ::pthread_mutexattr_settype (&attr,
> PTHREAD_MUTEX_RECURSIVE);
> -        break;
> -    }
> -    assert(err == 0);
> -    err = ::pthread_mutex_init (&m_mutex, &attr);
> -#if ENABLE_MUTEX_ERROR_CHECKING
> -    if (err == 0)
> -        error_check_mutex (&m_mutex, eMutexActionInitialized);
> -#endif
> -    assert(err == 0);
> -    err = ::pthread_mutexattr_destroy (&attr);
> -    assert(err == 0);
> -}
> -
> -//----------------------------------------------------------------------
> -// Destructor.
> -//
> -// Destroys the mutex owned by this object.
> -//----------------------------------------------------------------------
> -Mutex::~Mutex()
> -{
> -#if ENABLE_MUTEX_ERROR_CHECKING
> -    int err = ::pthread_mutex_destroy (&m_mutex);
> -    assert(err == 0);
> -    if (err == 0)
> -        error_check_mutex (&m_mutex, eMutexActionDestroyed);
> -    else
> -    {
> -        Host::SetCrashDescriptionWithFormat ("%s error:
> pthread_mutex_destroy() => err = %i (%s)", __PRETTY_FUNCTION__, err,
> strerror(err));
> -        assert(err == 0);
> -    }
> -    memset (&m_mutex, '\xba', sizeof(m_mutex));
> -#else
> -    ::pthread_mutex_destroy (&m_mutex);
> -#endif
> -}
> -
> -//----------------------------------------------------------------------
> -// Locks the mutex owned by this object, if the mutex is already
> -// locked, the calling thread will block until the mutex becomes
> -// available.
> -//
> -// RETURNS
> -//  The error code from the pthread_mutex_lock() function call.
> -//----------------------------------------------------------------------
> -int
> -Mutex::Lock()
> -{
> -    DEBUG_LOG ("[%4.4" PRIx64 "/%4.4" PRIx64 "] pthread_mutex_lock
> (%p)...\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(),
> &m_mutex);
> -
> -#if ENABLE_MUTEX_ERROR_CHECKING
> -    error_check_mutex (&m_mutex, eMutexActionAssertInitialized);
> -#endif
> -
> -    int err = ::pthread_mutex_lock (&m_mutex);
> -
> -
> -#if ENABLE_MUTEX_ERROR_CHECKING
> -    if (err)
> -    {
> -        Host::SetCrashDescriptionWithFormat ("%s error:
> pthread_mutex_lock(%p) => err = %i (%s)", __PRETTY_FUNCTION__, &m_mutex,
> err, strerror(err));
> -        assert(err == 0);
> -    }
> -#endif
> -    DEBUG_LOG ("[%4.4" PRIx64 "/%4.4" PRIx64 "] pthread_mutex_lock (%p)
> => %i\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(),
> &m_mutex, err);
> -    return err;
> -}
> -
> -//----------------------------------------------------------------------
> -// Attempts to lock the mutex owned by this object without blocking.
> -// If the mutex is already locked, TryLock() will not block waiting
> -// for the mutex, but will return an error condition.
> -//
> -// RETURNS
> -//  The error code from the pthread_mutex_trylock() function call.
> -//----------------------------------------------------------------------
> -int
> -Mutex::TryLock(const char *failure_message)
> -{
> -#if ENABLE_MUTEX_ERROR_CHECKING
> -    error_check_mutex (&m_mutex, eMutexActionAssertInitialized);
> -#endif
> -
> -    int err = ::pthread_mutex_trylock (&m_mutex);
> -    DEBUG_LOG ("[%4.4" PRIx64 "/%4.4" PRIx64 "] pthread_mutex_trylock
> (%p) => %i\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(),
> &m_mutex, err);
> -    return err;
> -}
> -
> -//----------------------------------------------------------------------
> -// If the current thread holds the lock on the owned mutex, then
> -// Unlock() will unlock the mutex. Calling Unlock() on this object
> -// that the calling thread does not hold will result in undefined
> -// behavior.
> -//
> -// RETURNS
> -//  The error code from the pthread_mutex_unlock() function call.
> -//----------------------------------------------------------------------
> -int
> -Mutex::Unlock()
> -{
> -#if ENABLE_MUTEX_ERROR_CHECKING
> -    error_check_mutex (&m_mutex, eMutexActionAssertInitialized);
> -#endif
> -
> -    int err = ::pthread_mutex_unlock (&m_mutex);
> -
> -#if ENABLE_MUTEX_ERROR_CHECKING
> -    if (err)
> -    {
> -        Host::SetCrashDescriptionWithFormat ("%s error:
> pthread_mutex_unlock(%p) => err = %i (%s)", __PRETTY_FUNCTION__, &m_mutex,
> err, strerror(err));
> -        assert(err == 0);
> -    }
> -#endif
> -    DEBUG_LOG ("[%4.4" PRIx64 "/%4.4" PRIx64 "] pthread_mutex_unlock (%p)
> => %i\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(),
> &m_mutex, err);
> -    return err;
> -}
> -
> -#endif
> -
> -//----------------------------------------------------------------------
> -// Mutex get accessor.
> -//----------------------------------------------------------------------
> -lldb::mutex_t *
> -Mutex::GetMutex()
> -{
> -    return &m_mutex;
> -}
> -
> -#ifdef LLDB_CONFIGURATION_DEBUG
> -int
> -TrackingMutex::Unlock ()
> -{
> -    if (!m_failure_message.empty())
> -        Host::SetCrashDescriptionWithFormat ("Unlocking lock (on thread
> %p) that thread: %p failed to get: %s",
> -                                             pthread_self(),
> -                                             m_thread_that_tried,
> -                                             m_failure_message.c_str());
> -    assert (m_failure_message.empty());
> -    return Mutex::Unlock();
> -}
> -
> -int
> -LoggingMutex::Lock ()
> -{
> -    printf("locking mutex %p by [%4.4" PRIx64 "/%4.4" PRIx64 "]...",
> this, Host::GetCurrentProcessID(), Host::GetCurrentThreadID());
> -    int x = Mutex::Lock();
> -    m_locked = true;
> -    printf("%d\n",x);
> -    return x;
> -}
> -
> -int
> -LoggingMutex::Unlock ()
> -{
> -    printf("unlocking mutex %p by [%4.4" PRIx64 "/%4.4" PRIx64 "]...",
> this, Host::GetCurrentProcessID(), Host::GetCurrentThreadID());
> -    int x = Mutex::Unlock();
> -    m_locked = false;
> -    printf("%d\n",x);
> -    return x;
> -}
> -
> -int
> -LoggingMutex::TryLock (const char *failure_message)
> -{
> -    printf("trylocking mutex %p by [%4.4" PRIx64 "/%4.4" PRIx64 "]...",
> this, Host::GetCurrentProcessID(), Host::GetCurrentThreadID());
> -    int x = Mutex::TryLock(failure_message);
> -    if (x == 0)
> -        m_locked = true;
> -    printf("%d\n",x);
> -    return x;
> -}
> -
> -#endif
> -
> -
>
> Modified: lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp
> (original)
> +++ lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp Thu Jul
> 28 12:32:20 2016
> @@ -877,11 +877,7 @@ ConnectionFileDescriptor::GetListeningPo
>      if (timeout_sec == UINT32_MAX)
>          m_port_predicate.WaitForValueNotEqualTo(0, bound_port);
>      else
> -    {
> -        TimeValue timeout = TimeValue::Now();
> -        timeout.OffsetWithSeconds(timeout_sec);
> -        m_port_predicate.WaitForValueNotEqualTo(0, bound_port, &timeout);
> -    }
> +        m_port_predicate.WaitForValueNotEqualTo(0, bound_port,
> std::chrono::seconds(timeout_sec));
>      return bound_port;
>  }
>
>
> Removed: lldb/trunk/source/Host/windows/Condition.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Condition.cpp?rev=277010&view=auto
>
> ==============================================================================
> --- lldb/trunk/source/Host/windows/Condition.cpp (original)
> +++ lldb/trunk/source/Host/windows/Condition.cpp (removed)
> @@ -1,98 +0,0 @@
> -//===-- Condition.cpp -------------------------------------------*- C++
> -*-===//
> -//
> -//                     The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
>
> -//===----------------------------------------------------------------------===//
> -
> -#include <errno.h>
> -
> -#include "lldb/Host/Condition.h"
> -#include "lldb/Host/TimeValue.h"
> -#include "lldb/Host/windows/windows.h"
> -
> -
> -using namespace lldb_private;
> -
> -//----------------------------------------------------------------------
> -// Default constructor
> -//
> -// The default constructor will initialize a new pthread condition
> -// and maintain the condition in the object state.
> -//----------------------------------------------------------------------
> -Condition::Condition () :
> -    m_condition()
> -{
> -    m_condition =
> static_cast<PCONDITION_VARIABLE>(malloc(sizeof(CONDITION_VARIABLE)));
> -
> InitializeConditionVariable(static_cast<PCONDITION_VARIABLE>(m_condition));
> -}
> -
> -//----------------------------------------------------------------------
> -// Destructor
> -//
> -// Destroys the pthread condition that the object owns.
> -//----------------------------------------------------------------------
> -Condition::~Condition ()
> -{
> -    free(m_condition);
> -}
> -
> -//----------------------------------------------------------------------
> -// Unblock all threads waiting for a condition variable
> -//----------------------------------------------------------------------
> -int
> -Condition::Broadcast ()
> -{
> -
> WakeAllConditionVariable(static_cast<PCONDITION_VARIABLE>(m_condition));
> -    return 0;
> -}
> -
> -//----------------------------------------------------------------------
> -// Unblocks one thread waiting for the condition variable
> -//----------------------------------------------------------------------
> -int
> -Condition::Signal ()
> -{
> -    WakeConditionVariable(static_cast<PCONDITION_VARIABLE>(m_condition));
> -    return 0;
> -}
> -
> -//----------------------------------------------------------------------
> -// The Wait() function atomically blocks the current thread
> -// waiting on the owned condition variable, and unblocks the mutex
> -// specified by "mutex".  The waiting thread unblocks only after
> -// another thread calls Signal(), or Broadcast() with the same
> -// condition variable, or if "abstime" is valid (non-NULL) this
> -// function will return when the system time reaches the time
> -// specified in "abstime". If "abstime" is NULL this function will
> -// wait for an infinite amount of time for the condition variable
> -// to be signaled or broadcasted.
> -//
> -// The current thread re-acquires the lock on "mutex".
> -//----------------------------------------------------------------------
> -int
> -Condition::Wait (Mutex &mutex, const TimeValue *abstime, bool *timed_out)
> -{
> -    DWORD wait = INFINITE;
> -    if (abstime != NULL) {
> -        int wval = (*abstime - TimeValue::Now()) / 1000000;
> -        if (wval < 0) wval = 0;
> -
> -        wait = wval;
> -    }
> -
> -    int err =
> SleepConditionVariableCS(static_cast<PCONDITION_VARIABLE>(m_condition),
> static_cast<PCRITICAL_SECTION>(mutex.m_mutex), wait);
> -
> -    if (timed_out != NULL)
> -    {
> -        if ((err == 0) && GetLastError() == ERROR_TIMEOUT)
> -            *timed_out = true;
> -        else
> -            *timed_out = false;
> -    }
> -
> -    return err == 0;
> -}
> -
>
> Removed: lldb/trunk/source/Host/windows/Mutex.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Mutex.cpp?rev=277010&view=auto
>
> ==============================================================================
> --- lldb/trunk/source/Host/windows/Mutex.cpp (original)
> +++ lldb/trunk/source/Host/windows/Mutex.cpp (removed)
> @@ -1,109 +0,0 @@
> -//===-- Mutex.cpp -----------------------------------------------*- C++
> -*-===//
> -//
> -//                     The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
>
> -//===----------------------------------------------------------------------===//
> -
> -#include "lldb/Host/Mutex.h"
> -#include "lldb/Host/Host.h"
> -#include "lldb/Host/windows/windows.h"
> -
> -#include <string.h>
> -#include <stdio.h>
> -
> -#if 0
> -// This logging is way too verbose to enable even for a log channel.
> -// This logging can be enabled by changing the "#if 0", but should be
> -// reverted prior to checking in.
> -#include <cstdio>
> -#define DEBUG_LOG(fmt, ...) printf(fmt, ## __VA_ARGS__)
> -#else
> -#define DEBUG_LOG(fmt, ...)
> -#endif
> -
> -using namespace lldb_private;
> -
> -//----------------------------------------------------------------------
> -// Default constructor.
> -//
> -// Creates a pthread mutex with no attributes.
> -//----------------------------------------------------------------------
> -Mutex::Mutex () :
> -    m_mutex()
> -{
> -    m_mutex =
> static_cast<PCRITICAL_SECTION>(malloc(sizeof(CRITICAL_SECTION)));
> -    InitializeCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
> -}
> -
> -//----------------------------------------------------------------------
> -// Default constructor.
> -//
> -// Creates a pthread mutex with "type" as the mutex type.
> -//----------------------------------------------------------------------
> -Mutex::Mutex (Mutex::Type type) :
> -    m_mutex()
> -{
> -    m_mutex =
> static_cast<PCRITICAL_SECTION>(malloc(sizeof(CRITICAL_SECTION)));
> -    InitializeCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
> -}
> -
> -//----------------------------------------------------------------------
> -// Destructor.
> -//
> -// Destroys the mutex owned by this object.
> -//----------------------------------------------------------------------
> -Mutex::~Mutex()
> -{
> -    DeleteCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
> -    free(m_mutex);
> -}
> -
> -//----------------------------------------------------------------------
> -// Locks the mutex owned by this object, if the mutex is already
> -// locked, the calling thread will block until the mutex becomes
> -// available.
> -//
> -// RETURNS
> -//  The error code from the pthread_mutex_lock() function call.
> -//----------------------------------------------------------------------
> -int
> -Mutex::Lock()
> -{
> -    DEBUG_LOG ("[%4.4" PRIx64 "/%4.4" PRIx64 "] pthread_mutex_lock
> (%p)...\n", Host::GetCurrentProcessID(), Host::GetCurrentThreadID(),
> m_mutex);
> -
> -    EnterCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
> -    return 0;
> -}
> -
> -//----------------------------------------------------------------------
> -// Attempts to lock the mutex owned by this object without blocking.
> -// If the mutex is already locked, TryLock() will not block waiting
> -// for the mutex, but will return an error condition.
> -//
> -// RETURNS
> -//  The error code from the pthread_mutex_trylock() function call.
> -//----------------------------------------------------------------------
> -int
> -Mutex::TryLock(const char *failure_message)
> -{
> -    return
> TryEnterCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex)) == 0;
> -}
> -
> -//----------------------------------------------------------------------
> -// If the current thread holds the lock on the owned mutex, then
> -// Unlock() will unlock the mutex. Calling Unlock() on this object
> -// that the calling thread does not hold will result in undefined
> -// behavior.
> -//
> -// RETURNS
> -//  The error code from the pthread_mutex_unlock() function call.
> -//----------------------------------------------------------------------
> -int
> -Mutex::Unlock()
> -{
> -    LeaveCriticalSection(static_cast<PCRITICAL_SECTION>(m_mutex));
> -    return 0;
> -}
>
> Modified:
> lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> ---
> lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
> (original)
> +++
> lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
> Thu Jul 28 12:32:20 2016
> @@ -22,7 +22,6 @@
>  #include "lldb/Host/FileSpec.h"
>  #include "lldb/Core/StructuredData.h"
>  #include "lldb/Core/UUID.h"
> -#include "lldb/Host/Mutex.h"
>  #include "lldb/Target/Process.h"
>  #include "lldb/Utility/SafeMachO.h"
>
>
> Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original)
> +++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Thu Jul 28
> 12:32:20 2016
> @@ -699,7 +699,8 @@ PlatformLinux::DebugProcess (ProcessLaun
>          // Handle the hijacking of process events.
>          if (listener_sp)
>          {
> -            const StateType state = process_sp->WaitForProcessToStop
> (NULL, NULL, false, listener_sp);
> +            const StateType state =
> +
> process_sp->WaitForProcessToStop(std::chrono::microseconds(0), NULL, false,
> listener_sp);
>
>              if (state == eStateStopped)
>              {
>
> Modified:
> lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
> (original)
> +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
> Thu Jul 28 12:32:20 2016
> @@ -210,11 +210,10 @@ CommunicationKDP::GetSequenceMutex(std::
>      return (lock =
> std::unique_lock<std::recursive_mutex>(m_sequence_mutex,
> std::try_to_lock)).owns_lock();
>  }
>
> -
>  bool
> -CommunicationKDP::WaitForNotRunningPrivate (const TimeValue *timeout_ptr)
> +CommunicationKDP::WaitForNotRunningPrivate(const
> std::chrono::microseconds &timeout)
>  {
> -    return m_is_running.WaitForValueEqualTo (false, timeout_ptr, NULL);
> +    return m_is_running.WaitForValueEqualTo(false, timoeut, NULL);
>  }
>
>  size_t
>
> Modified:
> lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
> (original)
> +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h Thu
> Jul 28 12:32:20 2016
> @@ -249,7 +249,7 @@ protected:
>                                                  uint32_t timeout_usec);
>
>      bool
> -    WaitForNotRunningPrivate (const lldb_private::TimeValue *timeout_ptr);
> +    WaitForNotRunningPrivate(const std::chrono::microseconds &timeout);
>
>      void
>      MakeRequestPacketHeader (CommandType request_type,
>
> Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
> (original)
> +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp Thu Jul
> 28 12:32:20 2016
> @@ -941,7 +941,7 @@ ProcessKDP::AsyncThread (void *arg)
>              if (log)
>                  log->Printf ("ProcessKDP::AsyncThread (pid = %" PRIu64 ")
> listener.WaitForEvent (NULL, event_sp)...",
>                               pid);
> -            if (listener_sp->WaitForEvent (NULL, event_sp))
> +            if (listener_sp->WaitForEvent(stsd::chrono::micrseconds(0),
> event_sp))
>              {
>                  uint32_t event_type = event_sp->GetType();
>                  if (log)
>
> Modified:
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> ---
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
> (original)
> +++
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Thu
> Jul 28 12:32:20 2016
> @@ -152,23 +152,22 @@ GDBRemoteCommunication::History::Dump (L
>  //----------------------------------------------------------------------
>  // GDBRemoteCommunication constructor
>  //----------------------------------------------------------------------
> -GDBRemoteCommunication::GDBRemoteCommunication(const char *comm_name,
> -                                               const char *listener_name)
> :
> -    Communication(comm_name),
> +GDBRemoteCommunication::GDBRemoteCommunication(const char *comm_name,
> const char *listener_name)
> +    : Communication(comm_name),
>  #ifdef LLDB_CONFIGURATION_DEBUG
> -    m_packet_timeout (1000),
> +      m_packet_timeout(1000),
>  #else
> -    m_packet_timeout (1),
> +      m_packet_timeout(1),
>  #endif
> -    m_echo_number(0),
> -    m_supports_qEcho (eLazyBoolCalculate),
> -    m_sequence_mutex (Mutex::eMutexTypeRecursive),
> -    m_public_is_running (false),
> -    m_private_is_running (false),
> -    m_history (512),
> -    m_send_acks (true),
> -    m_compression_type (CompressionType::None),
> -    m_listen_url ()
> +      m_echo_number(0),
> +      m_supports_qEcho(eLazyBoolCalculate),
> +      m_sequence_mutex(),
> +      m_public_is_running(false),
> +      m_private_is_running(false),
> +      m_history(512),
> +      m_send_acks(true),
> +      m_compression_type(CompressionType::None),
> +      m_listen_url()
>  {
>  }
>
> @@ -229,7 +228,7 @@ GDBRemoteCommunication::SendNack ()
>  GDBRemoteCommunication::PacketResult
>  GDBRemoteCommunication::SendPacket (const char *payload, size_t
> payload_length)
>  {
> -    Mutex::Locker locker(m_sequence_mutex);
> +    std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
>      return SendPacketNoLock (payload, payload_length);
>  }
>
> @@ -323,20 +322,19 @@ GDBRemoteCommunication::GetAck ()
>  }
>
>  bool
> -GDBRemoteCommunication::GetSequenceMutex (Mutex::Locker& locker, const
> char *failure_message)
> +GDBRemoteCommunication::GetSequenceMutex(std::unique_lock<std::recursive_mutex>
> &lock, const char *failure_message)
>  {
>      if (IsRunning())
> -        return locker.TryLock (m_sequence_mutex, failure_message);
> +        return (lock =
> std::unique_lock<std::recursive_mutex>(m_sequence_mutex,
> std::try_to_lock)).owns_lock();
>
> -    locker.Lock (m_sequence_mutex);
> +    lock = std::unique_lock<std::recursive_mutex>(m_sequence_mutex);
>      return true;
>  }
>
> -
>  bool
> -GDBRemoteCommunication::WaitForNotRunningPrivate (const TimeValue
> *timeout_ptr)
> +GDBRemoteCommunication::WaitForNotRunningPrivate(const
> std::chrono::microseconds &timeout)
>  {
> -    return m_private_is_running.WaitForValueEqualTo (false, timeout_ptr,
> NULL);
> +    return m_private_is_running.WaitForValueEqualTo(false, timeout, NULL);
>  }
>
>  GDBRemoteCommunication::PacketResult
> @@ -356,20 +354,22 @@ GDBRemoteCommunication::ReadPacket (Stri
>  GDBRemoteCommunication::PacketResult
>  GDBRemoteCommunication::PopPacketFromQueue (StringExtractorGDBRemote
> &response, uint32_t timeout_usec)
>  {
> -    // Calculate absolute timeout value
> -    TimeValue timeout = TimeValue::Now();
> -    timeout.OffsetWithMicroSeconds(timeout_usec);
> +    auto until = std::chrono::system_clock::now() +
> std::chrono::microseconds(timeout_usec);
>
> -    do
> +    while (true)
>      {
>          // scope for the mutex
>          {
>              // lock down the packet queue
> -            Mutex::Locker locker(m_packet_queue_mutex);
> +            std::unique_lock<std::mutex> lock(m_packet_queue_mutex);
>
>              // Wait on condition variable.
>              if (m_packet_queue.size() == 0)
> -                m_condition_queue_not_empty.Wait(m_packet_queue_mutex,
> &timeout);
> +            {
> +                std::cv_status result =
> m_condition_queue_not_empty.wait_until(lock, until);
> +                if (result == std::cv_status::timeout)
> +                  break;
> +            }
>
>              if (m_packet_queue.size() > 0)
>              {
> @@ -389,7 +389,7 @@ GDBRemoteCommunication::PopPacketFromQue
>               return PacketResult::ErrorDisconnected;
>
>        // Loop while not timed out
> -    } while (TimeValue::Now() < timeout);
> +    }
>
>      return PacketResult::ErrorReplyTimeout;
>  }
> @@ -1479,12 +1479,11 @@ void GDBRemoteCommunication::AppendBytes
>              // scope for the mutex
>              {
>                  // lock down the packet queue
> -                Mutex::Locker locker(m_packet_queue_mutex);
> +                std::lock_guard<std::mutex> guard(m_packet_queue_mutex);
>                  // push a new packet into the queue
>                  m_packet_queue.push(packet);
>                  // Signal condition variable that we have a packet
> -                m_condition_queue_not_empty.Signal();
> -
> +                m_condition_queue_not_empty.notify_one();
>              }
>          }
>
>
> Modified:
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
> (original)
> +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
> Thu Jul 28 12:32:20 2016
> @@ -12,6 +12,8 @@
>
>  // C Includes
>  // C++ Includes
> +#include <condition_variable>
> +#include <mutex>
>  #include <string>
>  #include <queue>
>  #include <vector>
> @@ -22,7 +24,6 @@
>  #include "lldb/Core/Communication.h"
>  #include "lldb/Core/Listener.h"
>  #include "lldb/Host/HostThread.h"
> -#include "lldb/Host/Mutex.h"
>  #include "lldb/Host/Predicate.h"
>  #include "lldb/Host/TimeValue.h"
>  #include "lldb/Interpreter/Args.h"
> @@ -114,7 +115,7 @@ public:
>                          size_t payload_length);
>
>      bool
> -    GetSequenceMutex(Mutex::Locker& locker, const char *failure_message =
> nullptr);
> +    GetSequenceMutex(std::unique_lock<std::recursive_mutex> &lock, const
> char *failure_message = nullptr);
>
>      PacketType
>      CheckForPacket (const uint8_t *src,
> @@ -285,9 +286,9 @@ protected:
>      uint32_t m_echo_number;
>      LazyBool m_supports_qEcho;
>  #ifdef ENABLE_MUTEX_ERROR_CHECKING
> -    TrackingMutex m_sequence_mutex;
> +#error TrackingMutex is no longer supported
>  #else
> -    Mutex m_sequence_mutex;    // Restrict access to sending/receiving
> packets to a single thread at a time
> +    std::recursive_mutex m_sequence_mutex; // Restrict access to
> sending/receiving packets to a single thread at a time
>  #endif
>      Predicate<bool> m_public_is_running;
>      Predicate<bool> m_private_is_running;
> @@ -320,7 +321,7 @@ protected:
>                                                  bool sync_on_timeout);
>
>      bool
> -    WaitForNotRunningPrivate (const TimeValue *timeout_ptr);
> +    WaitForNotRunningPrivate(const std::chrono::microseconds &timeout);
>
>      bool
>      CompressionIsEnabled ()
> @@ -364,8 +365,8 @@ protected:
>
>  private:
>      std::queue<StringExtractorGDBRemote> m_packet_queue; // The packet
> queue
> -    lldb_private::Mutex m_packet_queue_mutex;            // Mutex for
> accessing queue
> -    Condition m_condition_queue_not_empty;               // Condition
> variable to wait for packets
> +    std::mutex m_packet_queue_mutex;                     // Mutex for
> accessing queue
> +    std::condition_variable m_condition_queue_not_empty; // Condition
> variable to wait for packets
>
>      HostThread m_listen_thread;
>      std::string m_listen_url;
>
> Modified:
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> ---
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
> (original)
> +++
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
> Thu Jul 28 12:32:20 2016
> @@ -720,9 +720,10 @@ GDBRemoteCommunicationClient::SendPacket
>      std::string &response_string
>  )
>  {
> -    Mutex::Locker locker;
> -    if (!GetSequenceMutex(locker,
> -
> "ProcessGDBRemote::SendPacketsAndConcatenateResponses() failed due to not
> getting the sequence mutex"))
> +    std::unique_lock<std::recursive_mutex> lock;
> +    if (!GetSequenceMutex(
> +            lock,
> +            "ProcessGDBRemote::SendPacketsAndConcatenateResponses()
> failed due to not getting the sequence mutex"))
>      {
>          Log *log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet
> (GDBR_LOG_PROCESS | GDBR_LOG_PACKETS));
>          if (log)
> @@ -821,7 +822,7 @@ GDBRemoteCommunicationClient::SendPacket
>  )
>  {
>      PacketResult packet_result = PacketResult::ErrorSendFailed;
> -    Mutex::Locker locker;
> +    std::unique_lock<std::recursive_mutex> lock;
>      Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet
> (GDBR_LOG_PROCESS));
>
>      // In order to stop async notifications from being processed in the
> middle of the
> @@ -829,7 +830,7 @@ GDBRemoteCommunicationClient::SendPacket
>      static ListenerSP
> hijack_listener_sp(Listener::MakeListener("lldb.NotifyHijacker"));
>      HijackBroadcaster(hijack_listener_sp,
> eBroadcastBitGdbReadThreadGotNotify);
>
> -    if (GetSequenceMutex (locker))
> +    if (GetSequenceMutex(lock))
>      {
>          packet_result = SendPacketAndWaitForResponseNoLock (payload,
> payload_length, response);
>      }
> @@ -848,19 +849,22 @@ GDBRemoteCommunicationClient::SendPacket
>                      log->Printf ("async: async packet = %s",
> m_async_packet.c_str());
>
>                  bool timed_out = false;
> -                if (SendInterrupt(locker, 2, timed_out))
> +                if (SendInterrupt(lock, 2, timed_out))
>                  {
>                      if (m_interrupt_sent)
>                      {
>                          m_interrupt_sent = false;
> -                        TimeValue timeout_time;
> -                        timeout_time = TimeValue::Now();
> -                        timeout_time.OffsetWithSeconds (m_packet_timeout);
> +
> +
> std::chrono::time_point<std::chrono::system_clock> until;
> +                        until = std::chrono::system_clock::now() +
> std::chrono::seconds(m_packet_timeout);
>
>                          if (log)
>                              log->Printf ("async: sent interrupt");
>
> -                        if (m_async_packet_predicate.WaitForValueEqualTo
> (false, &timeout_time, &timed_out))
> +                        if (m_async_packet_predicate.WaitForValueEqualTo(
> +                                false,
> std::chrono::duration_cast<std::chrono::microseconds>(
> +                                           until -
> std::chrono::system_clock::now()),
> +                                &timed_out))
>                          {
>                              if (log)
>                                  log->Printf ("async: got response");
> @@ -876,7 +880,10 @@ GDBRemoteCommunicationClient::SendPacket
>                          }
>
>                          // Make sure we wait until the continue packet
> has been sent again...
> -                        if (m_private_is_running.WaitForValueEqualTo
> (true, &timeout_time, &timed_out))
> +                        if (m_private_is_running.WaitForValueEqualTo(
> +                                true,
> std::chrono::duration_cast<std::chrono::microseconds>(
> +                                          until -
> std::chrono::system_clock::now()),
> +                                &timed_out))
>                          {
>                              if (log)
>                              {
> @@ -1045,7 +1052,7 @@ GDBRemoteCommunicationClient::SendvContP
>          log->Printf("GDBRemoteCommunicationClient::%s ()", __FUNCTION__);
>
>      // we want to lock down packet sending while we continue
> -    Mutex::Locker locker(m_sequence_mutex);
> +    std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
>
>      // here we broadcast this before we even send the packet!!
>      // this signals doContinue() to exit
> @@ -1094,7 +1101,7 @@ GDBRemoteCommunicationClient::SendContin
>      if (log)
>          log->Printf ("GDBRemoteCommunicationClient::%s ()", __FUNCTION__);
>
> -    Mutex::Locker locker(m_sequence_mutex);
> +    std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
>      StateType state = eStateRunning;
>
>      m_public_is_running.SetValue (true, eBroadcastNever);
> @@ -1394,8 +1401,8 @@ GDBRemoteCommunicationClient::SendAsyncS
>      std::lock_guard<std::recursive_mutex> guard(m_async_mutex);
>      m_async_signal = signo;
>      bool timed_out = false;
> -    Mutex::Locker locker;
> -    if (SendInterrupt (locker, 1, timed_out))
> +    std::unique_lock<std::recursive_mutex> lock;
> +    if (SendInterrupt(lock, 1, timed_out))
>          return true;
>      m_async_signal = -1;
>      return false;
> @@ -1412,12 +1419,8 @@ GDBRemoteCommunicationClient::SendAsyncS
>  // (gdb remote protocol requires this), and do what we need to do, then
> resume.
>
>  bool
> -GDBRemoteCommunicationClient::SendInterrupt
> -(
> -    Mutex::Locker& locker,
> -    uint32_t seconds_to_wait_for_stop,
> -    bool &timed_out
> -)
> +GDBRemoteCommunicationClient::SendInterrupt(std::unique_lock<std::recursive_mutex>
> &lock,
> +                                            uint32_t
> seconds_to_wait_for_stop, bool &timed_out)
>  {
>      timed_out = false;
>      Log *log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet
> (GDBR_LOG_PROCESS | GDBR_LOG_PACKETS));
> @@ -1425,7 +1428,7 @@ GDBRemoteCommunicationClient::SendInterr
>      if (IsRunning())
>      {
>          // Only send an interrupt if our debugserver is running...
> -        if (GetSequenceMutex (locker))
> +        if (GetSequenceMutex(lock))
>          {
>              if (log)
>                  log->Printf ("SendInterrupt () - got sequence mutex
> without having to interrupt");
> @@ -1444,13 +1447,8 @@ GDBRemoteCommunicationClient::SendInterr
>                  m_interrupt_sent = true;
>                  if (seconds_to_wait_for_stop)
>                  {
> -                    TimeValue timeout;
> -                    if (seconds_to_wait_for_stop)
> -                    {
> -                        timeout = TimeValue::Now();
> -                        timeout.OffsetWithSeconds
> (seconds_to_wait_for_stop);
> -                    }
> -                    if (m_private_is_running.WaitForValueEqualTo (false,
> &timeout, &timed_out))
> +                    if (m_private_is_running.WaitForValueEqualTo(false,
> std::chrono::seconds(seconds_to_wait_for_stop),
> +
>  &timed_out))
>                      {
>                          if (log)
>                              log->PutCString ("SendInterrupt () - sent
> interrupt, private state stopped");
> @@ -3653,10 +3651,10 @@ size_t
>  GDBRemoteCommunicationClient::GetCurrentThreadIDs
> (std::vector<lldb::tid_t> &thread_ids,
>                                                     bool
> &sequence_mutex_unavailable)
>  {
> -    Mutex::Locker locker;
> +    std::unique_lock<std::recursive_mutex> lock;
>      thread_ids.clear();
> -
> -    if (GetSequenceMutex (locker, "ProcessGDBRemote::UpdateThreadList()
> failed due to not getting the sequence mutex"))
> +
> +    if (GetSequenceMutex(lock, "ProcessGDBRemote::UpdateThreadList()
> failed due to not getting the sequence mutex"))
>      {
>          sequence_mutex_unavailable = false;
>          StringExtractorGDBRemote response;
> @@ -4203,8 +4201,8 @@ GDBRemoteCommunicationClient::AvoidGPack
>  bool
>  GDBRemoteCommunicationClient::ReadRegister(lldb::tid_t tid, uint32_t reg,
> StringExtractorGDBRemote &response)
>  {
> -    Mutex::Locker locker;
> -    if (GetSequenceMutex (locker, "Didn't get sequence mutex for p
> packet."))
> +    std::unique_lock<std::recursive_mutex> lock;
> +    if (GetSequenceMutex(lock, "Didn't get sequence mutex for p packet."))
>      {
>          const bool thread_suffix_supported = GetThreadSuffixSupported();
>
> @@ -4228,8 +4226,8 @@ GDBRemoteCommunicationClient::ReadRegist
>  bool
>  GDBRemoteCommunicationClient::ReadAllRegisters (lldb::tid_t tid,
> StringExtractorGDBRemote &response)
>  {
> -    Mutex::Locker locker;
> -    if (GetSequenceMutex (locker, "Didn't get sequence mutex for g
> packet."))
> +    std::unique_lock<std::recursive_mutex> lock;
> +    if (GetSequenceMutex(lock, "Didn't get sequence mutex for g packet."))
>      {
>          const bool thread_suffix_supported = GetThreadSuffixSupported();
>
> @@ -4256,8 +4254,8 @@ GDBRemoteCommunicationClient::SaveRegist
>          return false;
>
>      m_supports_QSaveRegisterState = eLazyBoolYes;
> -    Mutex::Locker locker;
> -    if (GetSequenceMutex (locker, "Didn't get sequence mutex for
> QSaveRegisterState."))
> +    std::unique_lock<std::recursive_mutex> lock;
> +    if (GetSequenceMutex(lock, "Didn't get sequence mutex for
> QSaveRegisterState."))
>      {
>          const bool thread_suffix_supported = GetThreadSuffixSupported();
>          if (thread_suffix_supported || SetCurrentThread(tid))
> @@ -4298,9 +4296,9 @@ GDBRemoteCommunicationClient::RestoreReg
>      // order to be useful
>      if (m_supports_QSaveRegisterState == eLazyBoolNo)
>          return false;
> -
> -    Mutex::Locker locker;
> -    if (GetSequenceMutex (locker, "Didn't get sequence mutex for
> QRestoreRegisterState."))
> +
> +    std::unique_lock<std::recursive_mutex> lock;
> +    if (GetSequenceMutex(lock, "Didn't get sequence mutex for
> QRestoreRegisterState."))
>      {
>          const bool thread_suffix_supported = GetThreadSuffixSupported();
>          if (thread_suffix_supported || SetCurrentThread(tid))
> @@ -4530,8 +4528,10 @@ GDBRemoteCommunicationClient::ServeSymbo
>
>      if (m_supports_qSymbol && m_qSymbol_requests_done == false)
>      {
> -        Mutex::Locker locker;
> -        if (GetSequenceMutex(locker,
> "GDBRemoteCommunicationClient::ServeSymbolLookups() failed due to not
> getting the sequence mutex"))
> +        std::unique_lock<std::recursive_mutex> lock;
> +        if (GetSequenceMutex(
> +                lock,
> +                "GDBRemoteCommunicationClient::ServeSymbolLookups()
> failed due to not getting the sequence mutex"))
>          {
>              StreamString packet;
>              packet.PutCString ("qSymbol::");
>
> Modified:
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> ---
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
> (original)
> +++
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
> Thu Jul 28 12:32:20 2016
> @@ -105,9 +105,7 @@ public:
>      SendAsyncSignal (int signo);
>
>      bool
> -    SendInterrupt (Mutex::Locker &locker,
> -                   uint32_t seconds_to_wait_for_stop,
> -                   bool &timed_out);
> +    SendInterrupt(std::unique_lock<std::recursive_mutex> &lock, uint32_t
> seconds_to_wait_for_stop, bool &timed_out);
>
>      lldb::pid_t
>      GetCurrentProcessID (bool allow_lazy = true);
>
> Modified:
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> ---
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
> (original)
> +++
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
> Thu Jul 28 12:32:20 2016
> @@ -401,8 +401,8 @@ GDBRemoteRegisterContext::WriteRegisterB
>                                    reg_info->byte_size,          // dst
> length
>                                    m_reg_data.GetByteOrder()))   // dst
> byte order
>      {
> -        Mutex::Locker locker;
> -        if (gdb_comm.GetSequenceMutex (locker, "Didn't get sequence mutex
> for write register."))
> +        std::unique_lock<std::recursive_mutex> lock;
> +        if (gdb_comm.GetSequenceMutex(lock, "Didn't get sequence mutex
> for write register."))
>          {
>              const bool thread_suffix_supported =
> gdb_comm.GetThreadSuffixSupported();
>              ProcessSP process_sp (m_thread.GetProcess());
> @@ -570,8 +570,8 @@ GDBRemoteRegisterContext::ReadAllRegiste
>
>      const bool use_g_packet = gdb_comm.AvoidGPackets ((ProcessGDBRemote
> *)process) == false;
>
> -    Mutex::Locker locker;
> -    if (gdb_comm.GetSequenceMutex (locker, "Didn't get sequence mutex for
> read all registers."))
> +    std::unique_lock<std::recursive_mutex> lock;
> +    if (gdb_comm.GetSequenceMutex(lock, "Didn't get sequence mutex for
> read all registers."))
>      {
>          SyncThreadState(process);
>
> @@ -679,8 +679,8 @@ GDBRemoteRegisterContext::WriteAllRegist
>      const bool use_g_packet = gdb_comm.AvoidGPackets ((ProcessGDBRemote
> *)process) == false;
>
>      StringExtractorGDBRemote response;
> -    Mutex::Locker locker;
> -    if (gdb_comm.GetSequenceMutex (locker, "Didn't get sequence mutex for
> write all registers."))
> +    std::unique_lock<std::recursive_mutex> lock;
> +    if (gdb_comm.GetSequenceMutex(lock, "Didn't get sequence mutex for
> write all registers."))
>      {
>          const bool thread_suffix_supported =
> gdb_comm.GetThreadSuffixSupported();
>          ProcessSP process_sp (m_thread.GetProcess());
>
> Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
> (original)
> +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu
> Jul 28 12:32:20 2016
> @@ -1590,9 +1590,6 @@ ProcessGDBRemote::DoResume ()
>          else
>          {
>              EventSP event_sp;
> -            TimeValue timeout;
> -            timeout = TimeValue::Now();
> -            timeout.OffsetWithSeconds (5);
>              if (!m_async_thread.IsJoinable())
>              {
>                  error.SetErrorString ("Trying to resume but the async
> thread is dead.");
> @@ -1603,7 +1600,7 @@ ProcessGDBRemote::DoResume ()
>
>              m_async_broadcaster.BroadcastEvent
> (eBroadcastBitAsyncContinue, new EventDataBytes (continue_packet.GetData(),
> continue_packet.GetSize()));
>
> -            if (listener_sp->WaitForEvent (&timeout, event_sp) == false)
> +            if (listener_sp->WaitForEvent(std::chrono::seconds(5),
> event_sp) == false)
>              {
>                  error.SetErrorString("Resume timed out.");
>                  if (log)
> @@ -2717,7 +2714,7 @@ ProcessGDBRemote::DoHalt (bool &caused_s
>      Error error;
>
>      bool timed_out = false;
> -    Mutex::Locker locker;
> +    std::unique_lock<std::recursive_mutex> lock;
>
>      if (m_public_state.GetValue() == eStateAttaching)
>      {
> @@ -2727,7 +2724,7 @@ ProcessGDBRemote::DoHalt (bool &caused_s
>      }
>      else
>      {
> -        if (!m_gdb_comm.SendInterrupt (locker, 2, timed_out))
> +        if (!m_gdb_comm.SendInterrupt(lock, 2, timed_out))
>          {
>              if (timed_out)
>                  error.SetErrorString("timed out sending interrupt
> packet");
> @@ -3860,7 +3857,7 @@ ProcessGDBRemote::AsyncThread (void *arg
>      {
>          if (log)
>              log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %" PRIu64
> ") listener.WaitForEvent (NULL, event_sp)...", __FUNCTION__, arg,
> process->GetID());
> -        if (process->m_async_listener_sp->WaitForEvent (NULL, event_sp))
> +        if
> (process->m_async_listener_sp->WaitForEvent(std::chrono::microseconds(0),
> event_sp))
>          {
>              const uint32_t event_type = event_sp->GetType();
>              if (event_sp->BroadcasterIs (&process->m_async_broadcaster))
>
> Modified: lldb/trunk/source/Target/Process.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Target/Process.cpp (original)
> +++ lldb/trunk/source/Target/Process.cpp Thu Jul 28 12:32:20 2016
> @@ -978,10 +978,8 @@ Process::SyncIOHandler (uint32_t iohandl
>      if (!m_process_input_reader)
>          return;
>
> -    TimeValue timeout = TimeValue::Now();
> -    timeout.OffsetWithMicroSeconds(timeout_msec*1000);
>      uint32_t new_iohandler_id = 0;
> -    m_iohandler_sync.WaitForValueNotEqualTo(iohandler_id,
> new_iohandler_id, &timeout);
> +    m_iohandler_sync.WaitForValueNotEqualTo(iohandler_id,
> new_iohandler_id, std::chrono::milliseconds(timeout_msec));
>
>      Log *log(lldb_private::GetLogIfAllCategoriesSet
> (LIBLLDB_LOG_PROCESS));
>      if (log)
> @@ -989,12 +987,8 @@ Process::SyncIOHandler (uint32_t iohandl
>  }
>
>  StateType
> -Process::WaitForProcessToStop (const TimeValue *timeout,
> -                               EventSP *event_sp_ptr,
> -                               bool wait_always,
> -                               ListenerSP hijack_listener_sp,
> -                               Stream *stream,
> -                               bool use_run_lock)
> +Process::WaitForProcessToStop(const std::chrono::microseconds &timeout,
> EventSP *event_sp_ptr, bool wait_always,
> +                              ListenerSP hijack_listener_sp, Stream
> *stream, bool use_run_lock)
>  {
>      // We can't just wait for a "stopped" event, because the stopped
> event may have restarted the target.
>      // We have to actually check each event, and in the case of a stopped
> event check the restarted flag
> @@ -1009,8 +1003,7 @@ Process::WaitForProcessToStop (const Tim
>
>      Log *log(lldb_private::GetLogIfAllCategoriesSet
> (LIBLLDB_LOG_PROCESS));
>      if (log)
> -        log->Printf ("Process::%s (timeout = %p)", __FUNCTION__,
> -                     static_cast<const void*>(timeout));
> +        log->Printf("Process::%s (timeout = %llu)", __FUNCTION__,
> static_cast<unsigned long long>(timeout.count()));
>
>      if (!wait_always &&
>          StateIsStoppedState(state, true) &&
> @@ -1029,7 +1022,7 @@ Process::WaitForProcessToStop (const Tim
>      while (state != eStateInvalid)
>      {
>          EventSP event_sp;
> -        state = WaitForStateChangedEvents (timeout, event_sp,
> hijack_listener_sp);
> +        state = WaitForStateChangedEvents(std::chrono::milliseconds(0),
> event_sp, hijack_listener_sp);
>          if (event_sp_ptr && event_sp)
>              *event_sp_ptr = event_sp;
>
> @@ -1265,8 +1258,7 @@ Process::HandleProcessStateChangedEvent
>  }
>
>  StateType
> -Process::WaitForState(const TimeValue *timeout,
> -                      const StateType *match_states,
> +Process::WaitForState(const std::chrono::microseconds &timeout, const
> StateType *match_states,
>                        const uint32_t num_match_states)
>  {
>      EventSP event_sp;
> @@ -1307,13 +1299,14 @@ Process::RestoreProcessEvents ()
>  }
>
>  StateType
> -Process::WaitForStateChangedEvents (const TimeValue *timeout, EventSP
> &event_sp, ListenerSP hijack_listener_sp)
> +Process::WaitForStateChangedEvents(const std::chrono::microseconds
> &timeout, EventSP &event_sp,
> +                                   ListenerSP hijack_listener_sp)
>  {
>      Log *log(lldb_private::GetLogIfAllCategoriesSet
> (LIBLLDB_LOG_PROCESS));
>
>      if (log)
> -        log->Printf ("Process::%s (timeout = %p, event_sp)...",
> __FUNCTION__,
> -                     static_cast<const void*>(timeout));
> +        log->Printf("Process::%s (timeout = %llu, event_sp)...",
> __FUNCTION__,
> +                    static_cast<unsigned long long>(timeout.count()));
>
>      ListenerSP listener_sp = hijack_listener_sp;
>      if (!listener_sp)
> @@ -1332,9 +1325,8 @@ Process::WaitForStateChangedEvents (cons
>      }
>
>      if (log)
> -        log->Printf ("Process::%s (timeout = %p, event_sp) => %s",
> -                     __FUNCTION__, static_cast<const void*>(timeout),
> -                     StateAsCString(state));
> +        log->Printf("Process::%s (timeout = %llu, event_sp) => %s",
> __FUNCTION__,
> +                    static_cast<unsigned long long>(timeout.count()),
> StateAsCString(state));
>      return state;
>  }
>
> @@ -1367,13 +1359,13 @@ Process::PeekAtStateChangedEvents ()
>  }
>
>  StateType
> -Process::WaitForStateChangedEventsPrivate (const TimeValue *timeout,
> EventSP &event_sp)
> +Process::WaitForStateChangedEventsPrivate(const std::chrono::microseconds
> &timeout, EventSP &event_sp)
>  {
>      Log *log(lldb_private::GetLogIfAllCategoriesSet
> (LIBLLDB_LOG_PROCESS));
>
>      if (log)
> -        log->Printf ("Process::%s (timeout = %p, event_sp)...",
> __FUNCTION__,
> -                     static_cast<const void*>(timeout));
> +        log->Printf("Process::%s (timeout = %llu, event_sp)...",
> __FUNCTION__,
> +                    static_cast<unsigned long long>(timeout.count()));
>
>      StateType state = eStateInvalid;
>      if (m_private_state_listener_sp->WaitForEventForBroadcasterWithType
> (timeout,
> @@ -1387,20 +1379,20 @@ Process::WaitForStateChangedEventsPrivat
>      // to the command-line, and that could disable the log, which would
> render the
>      // log we got above invalid.
>      if (log)
> -        log->Printf ("Process::%s (timeout = %p, event_sp) => %s",
> -                     __FUNCTION__, static_cast<const void *>(timeout),
> -                     state == eStateInvalid ? "TIMEOUT" :
> StateAsCString(state));
> +        log->Printf("Process::%s (timeout = %llu, event_sp) => %s",
> __FUNCTION__,
> +                    static_cast<unsigned long long>(timeout.count()),
> +                    state == eStateInvalid ? "TIMEOUT" :
> StateAsCString(state));
>      return state;
>  }
>
>  bool
> -Process::WaitForEventsPrivate (const TimeValue *timeout, EventSP
> &event_sp, bool control_only)
> +Process::WaitForEventsPrivate(const std::chrono::microseconds &timeout,
> EventSP &event_sp, bool control_only)
>  {
>      Log *log(lldb_private::GetLogIfAllCategoriesSet
> (LIBLLDB_LOG_PROCESS));
>
>      if (log)
> -        log->Printf ("Process::%s (timeout = %p, event_sp)...",
> __FUNCTION__,
> -                     static_cast<const void*>(timeout));
> +        log->Printf("Process::%s (timeout = %llu, event_sp)...",
> __FUNCTION__,
> +                    static_cast<unsigned long long>(timeout.count()));
>
>      if (control_only)
>          return
> m_private_state_listener_sp->WaitForEventForBroadcaster(timeout,
> &m_private_state_control_broadcaster, event_sp);
> @@ -1751,7 +1743,7 @@ Process::ResumeSynchronous (Stream *stre
>      Error error = PrivateResume();
>      if (error.Success())
>      {
> -        StateType state = WaitForProcessToStop (NULL, NULL, true,
> listener_sp, stream);
> +        StateType state =
> WaitForProcessToStop(std::chrono::microseconds(0), NULL, true, listener_sp,
> stream);
>          const bool must_be_alive = false; // eStateExited is ok, so this
> must be false
>          if (!StateIsStoppedState(state, must_be_alive))
>              error.SetErrorStringWithFormat("process not in stopped state
> after synchronous resume: %s", StateAsCString(state));
> @@ -2891,7 +2883,7 @@ Process::DisableWatchpoint (Watchpoint *
>  }
>
>  StateType
> -Process::WaitForProcessStopPrivate (const TimeValue *timeout, EventSP
> &event_sp)
> +Process::WaitForProcessStopPrivate(const std::chrono::microseconds
> &timeout, EventSP &event_sp)
>  {
>      StateType state;
>      // Now wait for the process to launch and return control to us, and
> then
> @@ -2987,10 +2979,7 @@ Process::Launch (ProcessLaunchInfo &laun
>                  else
>                  {
>                      EventSP event_sp;
> -                    TimeValue timeout_time;
> -                    timeout_time = TimeValue::Now();
> -                    timeout_time.OffsetWithSeconds(10);
> -                    StateType state =
> WaitForProcessStopPrivate(&timeout_time, event_sp);
> +                    StateType state =
> WaitForProcessStopPrivate(std::chrono::seconds(10), event_sp);
>
>                      if (state == eStateInvalid || !event_sp)
>                      {
> @@ -3083,7 +3072,7 @@ Process::LoadCore ()
>
>          // Wait indefinitely for a stopped event since we just posted one
> above...
>          lldb::EventSP event_sp;
> -        listener_sp->WaitForEvent (nullptr, event_sp);
> +        listener_sp->WaitForEvent(std::chrono::microseconds(0), event_sp);
>          StateType state =
> ProcessEventData::GetStateFromEvent(event_sp.get());
>
>          if (!StateIsStoppedState (state, false))
> @@ -3502,8 +3491,8 @@ Process::ConnectRemote (Stream *strm, co
>          if (GetID() != LLDB_INVALID_PROCESS_ID)
>          {
>              EventSP event_sp;
> -            StateType state = WaitForProcessStopPrivate(nullptr,
> event_sp);
> -
> +            StateType state =
> WaitForProcessStopPrivate(std::chrono::microseconds(0), event_sp);
> +
>              if (state == eStateStopped || state == eStateCrashed)
>              {
>                  // If we attached and actually have a process on the
> other end, then
> @@ -3612,11 +3601,8 @@ Process::Halt (bool clear_thread_plans,
>      }
>
>      // Wait for 10 second for the process to stop.
> -    TimeValue timeout_time;
> -    timeout_time = TimeValue::Now();
> -    timeout_time.OffsetWithSeconds(10);
> -    StateType state = WaitForProcessToStop(&timeout_time, &event_sp,
> true, halt_listener_sp,
> -                                           nullptr, use_run_lock);
> +    StateType state =
> +        WaitForProcessToStop(std::chrono::seconds(10), &event_sp, true,
> halt_listener_sp, nullptr, use_run_lock);
>      RestoreProcessEvents();
>
>      if (state == eStateInvalid || ! event_sp)
> @@ -3649,10 +3635,7 @@ Process::StopForDestroyOrDetach(lldb::Ev
>          SendAsyncInterrupt();
>
>          // Consume the interrupt event.
> -        TimeValue timeout (TimeValue::Now());
> -        timeout.OffsetWithSeconds(10);
> -
> -        StateType state = WaitForProcessToStop (&timeout, &exit_event_sp,
> true, listener_sp);
> +        StateType state = WaitForProcessToStop(std::chrono::seconds(10),
> &exit_event_sp, true, listener_sp);
>
>          RestoreProcessEvents();
>
> @@ -4125,12 +4108,9 @@ Process::ControlPrivateStateThread (uint
>              while (!receipt_received)
>              {
>                  bool timed_out = false;
> -                TimeValue timeout_time;
> -                timeout_time = TimeValue::Now();
> -                timeout_time.OffsetWithSeconds(2);
>                  // Check for a receipt for 2 seconds and then check if
> the private state
>                  // thread is still around.
> -                receipt_received = event_receipt_sp->WaitForEventReceived
> (&timeout_time, &timed_out);
> +                receipt_received =
> event_receipt_sp->WaitForEventReceived(std::chrono::seconds(2), &timed_out);
>                  if (!receipt_received)
>                  {
>                      // Check if the private state thread is still around.
> If it isn't then we are done waiting
> @@ -4326,7 +4306,7 @@ Process::RunPrivateStateThread (bool is_
>      while (!exit_now)
>      {
>          EventSP event_sp;
> -        WaitForEventsPrivate(nullptr, event_sp, control_only);
> +        WaitForEventsPrivate(std::chrono::microseconds(0), event_sp,
> control_only);
>          if (event_sp->BroadcasterIs(&m_private_state_control_broadcaster))
>          {
>              if (log)
> @@ -5351,9 +5331,6 @@ Process::RunThreadPlan(ExecutionContext
>          lldb::EventSP event_sp;
>          lldb::StateType stop_state = lldb::eStateInvalid;
>
> -        TimeValue* timeout_ptr = nullptr;
> -        TimeValue real_timeout;
> -
>          bool before_first_timeout = true;  // This is set to false the
> first time that we have to halt the target.
>          bool do_resume = true;
>          bool handle_running_event = true;
> @@ -5454,6 +5431,7 @@ Process::RunThreadPlan(ExecutionContext
>  #endif
>          TimeValue one_thread_timeout;
>          TimeValue final_timeout;
> +        std::chrono::microseconds timeout = std::chrono::microseconds(0);
>
>          while (true)
>          {
> @@ -5484,10 +5462,7 @@ Process::RunThreadPlan(ExecutionContext
>                      }
>                  }
>
> -                TimeValue resume_timeout = TimeValue::Now();
> -                resume_timeout.OffsetWithMicroSeconds(500000);
> -
> -                got_event = listener_sp->WaitForEvent(&resume_timeout,
> event_sp);
> +                got_event =
> listener_sp->WaitForEvent(std::chrono::microseconds(500000), event_sp);
>                  if (!got_event)
>                  {
>                      if (log)
> @@ -5552,33 +5527,16 @@ Process::RunThreadPlan(ExecutionContext
>              if (before_first_timeout)
>              {
>                  if (options.GetTryAllThreads())
> -                {
> -                    one_thread_timeout = TimeValue::Now();
> -
> one_thread_timeout.OffsetWithMicroSeconds(one_thread_timeout_usec);
> -                    timeout_ptr = &one_thread_timeout;
> -                }
> +                    timeout =
> std::chrono::microseconds(one_thread_timeout_usec);
>                  else
> -                {
> -                    if (timeout_usec == 0)
> -                        timeout_ptr = nullptr;
> -                    else
> -                    {
> -                        final_timeout = TimeValue::Now();
> -                        final_timeout.OffsetWithMicroSeconds
> (timeout_usec);
> -                        timeout_ptr = &final_timeout;
> -                    }
> -                }
> +                    timeout = std::chrono::microseconds(timeout_usec);
>              }
>              else
>              {
>                  if (timeout_usec == 0)
> -                    timeout_ptr = nullptr;
> +                    timeout = std::chrono::microseconds(0);
>                  else
> -                {
> -                    final_timeout = TimeValue::Now();
> -                    final_timeout.OffsetWithMicroSeconds
> (all_threads_timeout_usec);
> -                    timeout_ptr = &final_timeout;
> -                }
> +                    timeout =
> std::chrono::microseconds(all_threads_timeout_usec);
>              }
>
>              do_resume = true;
> @@ -5589,11 +5547,15 @@ Process::RunThreadPlan(ExecutionContext
>
>              if (log)
>              {
> -                if (timeout_ptr)
> +                if (timeout.count())
>                  {
> -                    log->Printf ("Process::RunThreadPlan(): about to wait
> - now is %" PRIu64 " - endpoint is %" PRIu64,
> -
>  TimeValue::Now().GetAsMicroSecondsSinceJan1_1970(),
> -
>  timeout_ptr->GetAsMicroSecondsSinceJan1_1970());
> +                    log->Printf(
> +                        "Process::RunThreadPlan(): about to wait - now is
> %llu - endpoint is %llu",
> +                        static_cast<unsigned long
> long>(std::chrono::system_clock::now().time_since_epoch().count()),
> +                        static_cast<unsigned long long>(
> +
> std::chrono::time_point<std::chrono::system_clock,
> std::chrono::microseconds>(timeout)
> +                                .time_since_epoch()
> +                                .count()));
>                  }
>                  else
>                  {
> @@ -5611,7 +5573,7 @@ Process::RunThreadPlan(ExecutionContext
>              }
>              else
>  #endif
> -            got_event = listener_sp->WaitForEvent (timeout_ptr, event_sp);
> +                got_event = listener_sp->WaitForEvent(timeout, event_sp);
>
>              if (got_event)
>              {
> @@ -5810,10 +5772,7 @@ Process::RunThreadPlan(ExecutionContext
>                          if (log)
>                              log->PutCString ("Process::RunThreadPlan():
> Halt succeeded.");
>
> -                        real_timeout = TimeValue::Now();
> -                        real_timeout.OffsetWithMicroSeconds(500000);
> -
> -                        got_event =
> listener_sp->WaitForEvent(&real_timeout, event_sp);
> +                        got_event =
> listener_sp->WaitForEvent(std::chrono::microseconds(500000), event_sp);
>
>                          if (got_event)
>                          {
>
> Modified: lldb/trunk/source/Target/Target.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=277011&r1=277010&r2=277011&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Target/Target.cpp (original)
> +++ lldb/trunk/source/Target/Target.cpp Thu Jul 28 12:32:20 2016
> @@ -3103,8 +3103,9 @@ Target::Launch (ProcessLaunchInfo &launc
>                  m_process_sp->HijackProcessEvents(hijack_listener_sp);
>              }
>
> -            StateType state = m_process_sp->WaitForProcessToStop(nullptr,
> nullptr, false, hijack_listener_sp, nullptr);
> -
> +            StateType state =
> m_process_sp->WaitForProcessToStop(std::chrono::microseconds(0), nullptr,
> false,
> +
>  hijack_listener_sp, nullptr);
> +
>              if (state == eStateStopped)
>              {
>                  if (!launch_info.GetFlags().Test(eLaunchFlagStopAtEntry))
> @@ -3114,7 +3115,8 @@ Target::Launch (ProcessLaunchInfo &launc
>                          error = m_process_sp->PrivateResume();
>                          if (error.Success())
>                          {
> -                            state =
> m_process_sp->WaitForProcessToStop(nullptr, nullptr, true,
> hijack_listener_sp, stream);
> +                            state =
> m_process_sp->WaitForProcessToStop(std::chrono::microseconds(0), nullptr,
> true,
> +
>  hijack_listener_sp, stream);
>                              const bool must_be_alive = false; //
> eStateExited is ok, so this must be false
>                              if (!StateIsStoppedState(state,
> must_be_alive))
>                              {
> @@ -3243,7 +3245,8 @@ Target::Attach (ProcessAttachInfo &attac
>          }
>          else
>          {
> -            state = process_sp->WaitForProcessToStop (nullptr, nullptr,
> false, attach_info.GetHijackListener(), stream);
> +            state =
> process_sp->WaitForProcessToStop(std::chrono::microseconds(0), nullptr,
> false,
> +
>  attach_info.GetHijackListener(), stream);
>              process_sp->RestoreProcessEvents ();
>
>              if (state != eStateStopped)
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>



-- 
-Todd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20160728/793580bc/attachment-0001.html>


More information about the lldb-dev mailing list