[Lldb-commits] [lldb] r341089 - Move Predicate.h from Host to Utility

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 30 10:51:10 PDT 2018


Author: teemperor
Date: Thu Aug 30 10:51:10 2018
New Revision: 341089

URL: http://llvm.org/viewvc/llvm-project?rev=341089&view=rev
Log:
Move Predicate.h from Host to Utility

Summary:
This class was initially in Host because its implementation used to be
very OS-specific. However, with C++11, it has become a very simple
std::condition_variable wrapper, with no host-specific code.

It is also a general purpose utility class, so it makes sense for it to
live in a place where it can be used by everyone.

This has no effect on the layering right now, but it enables me to later
move the Listener+Broadcaster+Event combo to a lower layer, which is
important, as these are used in a lot of places (notably for launching a
process in Host code).

Reviewers: jingham, zturner, teemperor

Reviewed By: zturner

Subscribers: xiaobai, mgorny, lldb-commits

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

Added:
    lldb/trunk/include/lldb/Utility/Predicate.h
      - copied, changed from r341086, lldb/trunk/include/lldb/Host/Predicate.h
    lldb/trunk/unittests/Utility/PredicateTest.cpp
      - copied, changed from r341086, lldb/trunk/unittests/Host/PredicateTest.cpp
Removed:
    lldb/trunk/include/lldb/Host/Predicate.h
    lldb/trunk/unittests/Host/PredicateTest.cpp
Modified:
    lldb/trunk/include/lldb/Core/Event.h
    lldb/trunk/include/lldb/Core/IOHandler.h
    lldb/trunk/include/lldb/Host/Editline.h
    lldb/trunk/include/lldb/Host/Socket.h
    lldb/trunk/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
    lldb/trunk/include/lldb/module.modulemap
    lldb/trunk/source/Core/IOHandler.cpp
    lldb/trunk/source/Host/common/Host.cpp
    lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
    lldb/trunk/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
    lldb/trunk/source/Plugins/Process/Windows/Common/DebuggerThread.h
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
    lldb/trunk/unittests/Core/BroadcasterTest.cpp
    lldb/trunk/unittests/Host/CMakeLists.txt
    lldb/trunk/unittests/Utility/CMakeLists.txt

Modified: lldb/trunk/include/lldb/Core/Event.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Event.h?rev=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Event.h (original)
+++ lldb/trunk/include/lldb/Core/Event.h Thu Aug 30 10:51:10 2018
@@ -11,8 +11,8 @@
 #define liblldb_Event_h_
 
 #include "lldb/Core/Broadcaster.h"
-#include "lldb/Host/Predicate.h"
 #include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Predicate.h"
 #include "lldb/Utility/StructuredData.h"
 #include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN
 #include "lldb/lldb-forward.h" // for EventDataSP, ProcessSP, Struct...

Modified: lldb/trunk/include/lldb/Core/IOHandler.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/IOHandler.h?rev=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/IOHandler.h (original)
+++ lldb/trunk/include/lldb/Core/IOHandler.h Thu Aug 30 10:51:10 2018
@@ -11,9 +11,9 @@
 #define liblldb_IOHandler_h_
 
 #include "lldb/Core/ValueObjectList.h"
-#include "lldb/Host/Predicate.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/Flags.h"
+#include "lldb/Utility/Predicate.h"
 #include "lldb/Utility/Stream.h"
 #include "lldb/Utility/StringList.h"
 #include "lldb/lldb-defines.h"  // for DISALLOW_COPY_AND_ASSIGN

Modified: lldb/trunk/include/lldb/Host/Editline.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Editline.h?rev=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Editline.h (original)
+++ lldb/trunk/include/lldb/Host/Editline.h Thu Aug 30 10:51:10 2018
@@ -54,8 +54,8 @@
 #include <vector>
 
 #include "lldb/Host/ConnectionFileDescriptor.h"
-#include "lldb/Host/Predicate.h"
 #include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Predicate.h"
 
 namespace lldb_private {
 namespace line_editor {

Removed: lldb/trunk/include/lldb/Host/Predicate.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Predicate.h?rev=341088&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Host/Predicate.h (original)
+++ lldb/trunk/include/lldb/Host/Predicate.h (removed)
@@ -1,260 +0,0 @@
-//===-- Predicate.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_Predicate_h_
-#define liblldb_Predicate_h_
-
-// C Includes
-#include <stdint.h>
-#include <time.h>
-
-// C++ Includes
-#include <condition_variable>
-#include <mutex>
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Utility/Timeout.h"
-#include "lldb/lldb-defines.h"
-
-//#define DB_PTHREAD_LOG_EVENTS
-
-//----------------------------------------------------------------------
-/// Enumerations for broadcasting.
-//----------------------------------------------------------------------
-namespace lldb_private {
-
-typedef enum {
-  eBroadcastNever,   ///< No broadcast will be sent when the value is modified.
-  eBroadcastAlways,  ///< Always send a broadcast when the value is modified.
-  eBroadcastOnChange ///< Only broadcast if the value changes when the value is
-                     ///modified.
-} PredicateBroadcastType;
-
-//----------------------------------------------------------------------
-/// @class Predicate Predicate.h "lldb/Host/Predicate.h"
-/// A C++ wrapper class for providing threaded access to a value of
-/// type T.
-///
-/// A templatized class that provides multi-threaded access to a value
-/// of type T. Threads can efficiently wait for bits within T to be set
-/// or reset, or wait for T to be set to be equal/not equal to a
-/// specified values.
-//----------------------------------------------------------------------
-template <class T> class Predicate {
-public:
-  //------------------------------------------------------------------
-  /// Default constructor.
-  ///
-  /// Initializes the mutex, condition and value with their default
-  /// constructors.
-  //------------------------------------------------------------------
-  Predicate() : m_value(), m_mutex(), m_condition() {}
-
-  //------------------------------------------------------------------
-  /// Construct with initial T value \a initial_value.
-  ///
-  /// Initializes the mutex and condition with their default
-  /// constructors, and initializes the value with \a initial_value.
-  ///
-  /// @param[in] initial_value
-  ///     The initial value for our T object.
-  //------------------------------------------------------------------
-  Predicate(T initial_value)
-      : m_value(initial_value), m_mutex(), m_condition() {}
-
-  //------------------------------------------------------------------
-  /// Destructor.
-  ///
-  /// Destroy the condition, mutex, and T objects.
-  //------------------------------------------------------------------
-  ~Predicate() = default;
-
-  //------------------------------------------------------------------
-  /// Value get accessor.
-  ///
-  /// Copies the current \a m_value in a thread safe manor and returns
-  /// the copied value.
-  ///
-  /// @return
-  ///     A copy of the current value.
-  //------------------------------------------------------------------
-  T GetValue() const {
-    std::lock_guard<std::mutex> guard(m_mutex);
-    T value = m_value;
-    return value;
-  }
-
-  //------------------------------------------------------------------
-  /// Value set accessor.
-  ///
-  /// Set the contained \a m_value to \a new_value in a thread safe
-  /// way and broadcast if needed.
-  ///
-  /// @param[in] value
-  ///     The new value to set.
-  ///
-  /// @param[in] broadcast_type
-  ///     A value indicating when and if to broadcast. See the
-  ///     PredicateBroadcastType enumeration for details.
-  ///
-  /// @see Predicate::Broadcast()
-  //------------------------------------------------------------------
-  void SetValue(T value, PredicateBroadcastType broadcast_type) {
-    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
-    const T old_value = m_value;
-    m_value = value;
-
-    Broadcast(old_value, broadcast_type);
-  }
-
-  //------------------------------------------------------------------
-  /// Wait for Cond(m_value) to be true.
-  ///
-  /// Waits in a thread safe way for Cond(m_value) to be true. If Cond(m_value)
-  /// is already true, this function will return without waiting.
-  ///
-  /// It is possible for the value to be changed between the time the value is
-  /// set and the time the waiting thread wakes up. If the value no longer
-  /// satisfies the condition when the waiting thread wakes up, it will go back
-  /// into a wait state. It may be necessary for the calling code to use
-  /// additional thread synchronization methods to detect transitory states.
-  ///
-  /// @param[in] Cond
-  ///     The condition we want \a m_value satisfy.
-  ///
-  /// @param[in] timeout
-  ///     How long to wait for the condition to hold.
-  ///
-  /// @return
-  ///     @li m_value if Cond(m_value) is true.
-  ///     @li None otherwise (timeout occurred).
-  //------------------------------------------------------------------
-  template <typename C>
-  llvm::Optional<T> WaitFor(C Cond, const Timeout<std::micro> &timeout) {
-    std::unique_lock<std::mutex> lock(m_mutex);
-    auto RealCond = [&] { return Cond(m_value); };
-    if (!timeout) {
-      m_condition.wait(lock, RealCond);
-      return m_value;
-    }
-    if (m_condition.wait_for(lock, *timeout, RealCond))
-      return m_value;
-    return llvm::None;
-  }
-  //------------------------------------------------------------------
-  /// Wait for \a m_value to be equal to \a value.
-  ///
-  /// Waits in a thread safe way for \a m_value to be equal to \a
-  /// value. If \a m_value is already equal to \a value, this
-  /// function will return without waiting.
-  ///
-  /// It is possible for the value to be changed between the time
-  /// the value is set and the time the waiting thread wakes up.
-  /// If the value no longer matches the requested value when the
-  /// waiting thread wakes up, it will go back into a wait state.  It
-  /// may be necessary for the calling code to use additional thread
-  /// synchronization methods to detect transitory states.
-  ///
-  /// @param[in] value
-  ///     The value we want \a m_value to be equal to.
-  ///
-  /// @param[in] timeout
-  ///     How long to wait for the condition to hold.
-  ///
-  /// @return
-  ///     @li \b true if the \a m_value is equal to \a value
-  ///     @li \b false otherwise (timeout occurred)
-  //------------------------------------------------------------------
-  bool WaitForValueEqualTo(T value,
-                           const Timeout<std::micro> &timeout = llvm::None) {
-    return WaitFor([&value](T current) { return value == current; }, timeout) !=
-           llvm::None;
-  }
-
-  //------------------------------------------------------------------
-  /// Wait for \a m_value to not be equal to \a value.
-  ///
-  /// Waits in a thread safe way for \a m_value to not be equal to \a
-  /// value. If \a m_value is already not equal to \a value, this
-  /// function will return without waiting.
-  ///
-  /// It is possible for the value to be changed between the time
-  /// the value is set and the time the waiting thread wakes up.
-  /// If the value is equal to the test value when the waiting thread
-  /// wakes up, it will go back into a wait state.  It may be
-  /// necessary for the calling code to use additional thread
-  /// synchronization methods to detect transitory states.
-  ///
-  /// @param[in] value
-  ///     The value we want \a m_value to not be equal to.
-  ///
-  /// @param[in] timeout
-  ///     How long to wait for the condition to hold.
-  ///
-  /// @return
-  ///     @li m_value if m_value != value
-  ///     @li None otherwise (timeout occurred).
-  //------------------------------------------------------------------
-  llvm::Optional<T>
-  WaitForValueNotEqualTo(T value,
-                         const Timeout<std::micro> &timeout = llvm::None) {
-    return WaitFor([&value](T current) { return value != current; }, timeout);
-  }
-
-protected:
-  //----------------------------------------------------------------------
-  // pthread condition and mutex variable to control access and allow blocking
-  // between the main thread and the spotlight index thread.
-  //----------------------------------------------------------------------
-  T m_value; ///< The templatized value T that we are protecting access to
-  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:
-  //------------------------------------------------------------------
-  /// Broadcast if needed.
-  ///
-  /// Check to see if we need to broadcast to our condition variable
-  /// depending on the \a old_value and on the \a broadcast_type.
-  ///
-  /// If \a broadcast_type is eBroadcastNever, no broadcast will be
-  /// sent.
-  ///
-  /// If \a broadcast_type is eBroadcastAlways, the condition variable
-  /// will always be broadcast.
-  ///
-  /// If \a broadcast_type is eBroadcastOnChange, the condition
-  /// variable be broadcast if the owned value changes.
-  //------------------------------------------------------------------
-  void Broadcast(T old_value, PredicateBroadcastType broadcast_type) {
-    bool broadcast =
-        (broadcast_type == eBroadcastAlways) ||
-        ((broadcast_type == eBroadcastOnChange) && old_value != m_value);
-#ifdef DB_PTHREAD_LOG_EVENTS
-    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.notify_all();
-  }
-
-  DISALLOW_COPY_AND_ASSIGN(Predicate);
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_Predicate_h_

Modified: lldb/trunk/include/lldb/Host/Socket.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Socket.h?rev=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Socket.h (original)
+++ lldb/trunk/include/lldb/Host/Socket.h Thu Aug 30 10:51:10 2018
@@ -15,9 +15,9 @@
 
 #include "lldb/lldb-private.h"
 
-#include "lldb/Host/Predicate.h"
 #include "lldb/Host/SocketAddress.h"
 #include "lldb/Utility/IOObject.h"
+#include "lldb/Utility/Predicate.h"
 #include "lldb/Utility/Status.h"
 
 #ifdef _WIN32

Modified: lldb/trunk/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h?rev=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h (original)
+++ lldb/trunk/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h Thu Aug 30 10:51:10 2018
@@ -20,9 +20,9 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Host/Pipe.h"
-#include "lldb/Host/Predicate.h"
 #include "lldb/Utility/Connection.h"
 #include "lldb/Utility/IOObject.h"
+#include "lldb/Utility/Predicate.h"
 
 namespace lldb_private {
 

Copied: lldb/trunk/include/lldb/Utility/Predicate.h (from r341086, lldb/trunk/include/lldb/Host/Predicate.h)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Predicate.h?p2=lldb/trunk/include/lldb/Utility/Predicate.h&p1=lldb/trunk/include/lldb/Host/Predicate.h&r1=341086&r2=341089&rev=341089&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Predicate.h (original)
+++ lldb/trunk/include/lldb/Utility/Predicate.h Thu Aug 30 10:51:10 2018
@@ -34,11 +34,11 @@ typedef enum {
   eBroadcastNever,   ///< No broadcast will be sent when the value is modified.
   eBroadcastAlways,  ///< Always send a broadcast when the value is modified.
   eBroadcastOnChange ///< Only broadcast if the value changes when the value is
-                     ///modified.
+                     /// modified.
 } PredicateBroadcastType;
 
 //----------------------------------------------------------------------
-/// @class Predicate Predicate.h "lldb/Host/Predicate.h"
+/// @class Predicate Predicate.h "lldb/Utility/Predicate.h"
 /// A C++ wrapper class for providing threaded access to a value of
 /// type T.
 ///
@@ -220,8 +220,8 @@ protected:
   T m_value; ///< The templatized value T that we are protecting access to
   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.
+                                       /// use for signaling that data available
+                                       /// or changed.
 
 private:
   //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/module.modulemap?rev=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/include/lldb/module.modulemap (original)
+++ lldb/trunk/include/lldb/module.modulemap Thu Aug 30 10:51:10 2018
@@ -38,7 +38,6 @@ module lldb_Host {
   module PipeBase { header "Host/PipeBase.h" export * }
   module Pipe { header "Host/Pipe.h" export * }
   module PosixApi { header "Host/PosixApi.h" export * }
-  module Predicate { header "Host/Predicate.h" export * }
   module ProcessLauncher { header "Host/ProcessLauncher.h" export * }
   module ProcessRunLock { header "Host/ProcessRunLock.h" export * }
   module PseudoTerminal { header "Host/PseudoTerminal.h" export * }

Modified: lldb/trunk/source/Core/IOHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/IOHandler.cpp?rev=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/source/Core/IOHandler.cpp (original)
+++ lldb/trunk/source/Core/IOHandler.cpp Thu Aug 30 10:51:10 2018
@@ -26,7 +26,7 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Host/File.h"            // for File
-#include "lldb/Host/Predicate.h"       // for Predicate, ::eBroad...
+#include "lldb/Utility/Predicate.h"    // for Predicate, ::eBroad...
 #include "lldb/Utility/Status.h"       // for Status
 #include "lldb/Utility/StreamString.h" // for StreamString
 #include "lldb/Utility/StringList.h"   // for StringList

Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Thu Aug 30 10:51:10 2018
@@ -52,7 +52,6 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Host/HostProcess.h"
 #include "lldb/Host/MonitoringProcessLauncher.h"
-#include "lldb/Host/Predicate.h"
 #include "lldb/Host/ProcessLauncher.h"
 #include "lldb/Host/ThreadLauncher.h"
 #include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
@@ -62,6 +61,7 @@
 #include "lldb/Utility/DataBufferLLVM.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/Predicate.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/lldb-private-forward.h"
 #include "llvm/ADT/SmallString.h"

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=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h Thu Aug 30 10:51:10 2018
@@ -21,7 +21,7 @@
 #include "lldb/Core/Communication.h"
 #include "lldb/Core/Listener.h"
 #include "lldb/Core/StreamBuffer.h"
-#include "lldb/Host/Predicate.h"
+#include "lldb/Utility/Predicate.h"
 #include "lldb/lldb-private.h"
 
 class CommunicationKDP : public lldb_private::Communication {

Modified: lldb/trunk/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/DebuggerThread.cpp?rev=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/DebuggerThread.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/DebuggerThread.cpp Thu Aug 30 10:51:10 2018
@@ -12,7 +12,6 @@
 #include "IDebugDelegate.h"
 
 #include "lldb/Core/ModuleSpec.h"
-#include "lldb/Host/Predicate.h"
 #include "lldb/Host/ThreadLauncher.h"
 #include "lldb/Host/windows/HostProcessWindows.h"
 #include "lldb/Host/windows/HostThreadWindows.h"
@@ -21,6 +20,7 @@
 #include "lldb/Target/ProcessLaunchInfo.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/Predicate.h"
 #include "lldb/Utility/Status.h"
 
 #include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"

Modified: lldb/trunk/source/Plugins/Process/Windows/Common/DebuggerThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/DebuggerThread.h?rev=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/DebuggerThread.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/DebuggerThread.h Thu Aug 30 10:51:10 2018
@@ -16,8 +16,8 @@
 #include "ForwardDecl.h"
 #include "lldb/Host/HostProcess.h"
 #include "lldb/Host/HostThread.h"
-#include "lldb/Host/Predicate.h"
 #include "lldb/Host/windows/windows.h"
+#include "lldb/Utility/Predicate.h"
 
 namespace lldb_private {
 

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=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h Thu Aug 30 10:51:10 2018
@@ -23,8 +23,8 @@
 #include "lldb/Core/Communication.h"
 #include "lldb/Core/Listener.h"
 #include "lldb/Host/HostThread.h"
-#include "lldb/Host/Predicate.h"
 #include "lldb/Utility/Args.h"
+#include "lldb/Utility/Predicate.h"
 #include "lldb/lldb-public.h"
 
 #include "lldb/Utility/StringExtractorGDBRemote.h"

Modified: lldb/trunk/unittests/Core/BroadcasterTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/BroadcasterTest.cpp?rev=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/unittests/Core/BroadcasterTest.cpp (original)
+++ lldb/trunk/unittests/Core/BroadcasterTest.cpp Thu Aug 30 10:51:10 2018
@@ -12,7 +12,7 @@
 #include "lldb/Core/Broadcaster.h"
 #include "lldb/Core/Event.h"
 #include "lldb/Core/Listener.h"
-#include "lldb/Host/Predicate.h"
+#include "lldb/Utility/Predicate.h"
 
 #include <thread>
 

Modified: lldb/trunk/unittests/Host/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/CMakeLists.txt?rev=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/unittests/Host/CMakeLists.txt (original)
+++ lldb/trunk/unittests/Host/CMakeLists.txt Thu Aug 30 10:51:10 2018
@@ -3,7 +3,6 @@ set (FILES
   HostInfoTest.cpp
   HostTest.cpp
   MainLoopTest.cpp
-  PredicateTest.cpp
   SocketAddressTest.cpp
   SocketTest.cpp
   SymbolsTest.cpp

Removed: lldb/trunk/unittests/Host/PredicateTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/PredicateTest.cpp?rev=341088&view=auto
==============================================================================
--- lldb/trunk/unittests/Host/PredicateTest.cpp (original)
+++ lldb/trunk/unittests/Host/PredicateTest.cpp (removed)
@@ -1,34 +0,0 @@
-//===-- PredicateTest.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/Predicate.h"
-#include "gtest/gtest.h"
-#include <thread>
-
-using namespace lldb_private;
-
-TEST(Predicate, WaitForValueEqualTo) {
-  Predicate<int> P(0);
-  EXPECT_TRUE(P.WaitForValueEqualTo(0));
-  EXPECT_FALSE(P.WaitForValueEqualTo(1, std::chrono::milliseconds(10)));
-
-  std::thread Setter([&P] {
-    std::this_thread::sleep_for(std::chrono::milliseconds(100));
-    P.SetValue(1, eBroadcastAlways);
-  });
-  EXPECT_TRUE(P.WaitForValueEqualTo(1));
-  Setter.join();
-}
-
-TEST(Predicate, WaitForValueNotEqualTo) {
-  Predicate<int> P(0);
-  EXPECT_EQ(0, P.WaitForValueNotEqualTo(1));
-  EXPECT_EQ(llvm::None,
-            P.WaitForValueNotEqualTo(0, std::chrono::milliseconds(10)));
-}

Modified: lldb/trunk/unittests/Utility/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/CMakeLists.txt?rev=341089&r1=341088&r2=341089&view=diff
==============================================================================
--- lldb/trunk/unittests/Utility/CMakeLists.txt (original)
+++ lldb/trunk/unittests/Utility/CMakeLists.txt Thu Aug 30 10:51:10 2018
@@ -12,6 +12,7 @@ add_lldb_unittest(UtilityTests
   JSONTest.cpp
   LogTest.cpp
   NameMatchesTest.cpp
+  PredicateTest.cpp
   RegisterValueTest.cpp
   ScalarTest.cpp
   StateTest.cpp

Copied: lldb/trunk/unittests/Utility/PredicateTest.cpp (from r341086, lldb/trunk/unittests/Host/PredicateTest.cpp)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Utility/PredicateTest.cpp?p2=lldb/trunk/unittests/Utility/PredicateTest.cpp&p1=lldb/trunk/unittests/Host/PredicateTest.cpp&r1=341086&r2=341089&rev=341089&view=diff
==============================================================================
--- lldb/trunk/unittests/Host/PredicateTest.cpp (original)
+++ lldb/trunk/unittests/Utility/PredicateTest.cpp Thu Aug 30 10:51:10 2018
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/Host/Predicate.h"
+#include "lldb/Utility/Predicate.h"
 #include "gtest/gtest.h"
 #include <thread>
 




More information about the lldb-commits mailing list