diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2016-05-19 05:13:57 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2016-05-19 05:13:57 +0000 |
commit | bb19a13c0b3fe1ecdc1e46bbf2b06ffc1e25e04e (patch) | |
tree | a4383c7cf16b2a6b8e8aa1ff61435ceec0c6a7de /lldb/source/Plugins/Process | |
parent | fe12d0e3e551a29b880ecfc7673810ce18567765 (diff) | |
download | bcm5719-llvm-bb19a13c0b3fe1ecdc1e46bbf2b06ffc1e25e04e.tar.gz bcm5719-llvm-bb19a13c0b3fe1ecdc1e46bbf2b06ffc1e25e04e.zip |
second pass over removal of Mutex and Condition
llvm-svn: 270024
Diffstat (limited to 'lldb/source/Plugins/Process')
4 files changed, 39 insertions, 37 deletions
diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp index debad980a31..3a72a65da69 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -143,7 +143,7 @@ ProcessFreeBSD::DoResume() SetPrivateState(eStateRunning); - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex()); bool do_step = false; for (tid_collection::const_iterator t_pos = m_run_tids.begin(), t_end = m_run_tids.end(); t_pos != t_end; ++t_pos) @@ -630,7 +630,7 @@ ProcessFreeBSD::RefreshStateAfterStop() if (log) log->Printf ("ProcessFreeBSD::%s() removing thread, tid = %" PRIi64, __FUNCTION__, tid); - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex()); ThreadSP thread_sp = m_thread_list.RemoveThreadByID(tid, false); thread_sp.reset(); @@ -801,7 +801,7 @@ ProcessFreeBSD::EnableWatchpoint(Watchpoint *wp, bool notify) // Try to find a vacant watchpoint slot in the inferiors' main thread uint32_t wp_hw_index = LLDB_INVALID_INDEX32; - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex()); FreeBSDThread *thread = static_cast<FreeBSDThread*>( m_thread_list.GetThreadAtIndex(0, false).get()); @@ -871,7 +871,7 @@ ProcessFreeBSD::DisableWatchpoint(Watchpoint *wp, bool notify) if (wp->IsHardware()) { bool wp_disabled = true; - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex()); uint32_t thread_count = m_thread_list.GetSize(false); for (uint32_t i = 0; i < thread_count; ++i) { @@ -901,7 +901,7 @@ Error ProcessFreeBSD::GetWatchpointSupportInfo(uint32_t &num) { Error error; - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex()); FreeBSDThread *thread = static_cast<FreeBSDThread*>( m_thread_list.GetThreadAtIndex(0, false).get()); if (thread) @@ -924,7 +924,7 @@ ProcessFreeBSD::GetWatchpointSupportInfo(uint32_t &num, bool &after) uint32_t ProcessFreeBSD::UpdateThreadListIfNeeded() { - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex()); // Do not allow recursive updates. return m_thread_list.GetSize(false); } @@ -1015,7 +1015,7 @@ bool ProcessFreeBSD::IsAThreadRunning() { bool is_running = false; - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex()); uint32_t thread_count = m_thread_list.GetSize(false); for (uint32_t i = 0; i < thread_count; ++i) { diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp index 813c810bff9..29a0d58f708 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -37,21 +37,21 @@ using namespace lldb_private; //---------------------------------------------------------------------- // CommunicationKDP constructor //---------------------------------------------------------------------- -CommunicationKDP::CommunicationKDP (const char *comm_name) : - Communication(comm_name), - m_addr_byte_size (4), - m_byte_order (eByteOrderLittle), - m_packet_timeout (5), - m_sequence_mutex (Mutex::eMutexTypeRecursive), - m_is_running (false), - m_session_key (0u), - m_request_sequence_id (0u), - m_exception_sequence_id (0u), - m_kdp_version_version (0u), - m_kdp_version_feature (0u), - m_kdp_hostinfo_cpu_mask (0u), - m_kdp_hostinfo_cpu_type (0u), - m_kdp_hostinfo_cpu_subtype (0u) +CommunicationKDP::CommunicationKDP(const char *comm_name) + : Communication(comm_name), + m_addr_byte_size(4), + m_byte_order(eByteOrderLittle), + m_packet_timeout(5), + m_sequence_mutex(), + m_is_running(false), + m_session_key(0u), + m_request_sequence_id(0u), + m_exception_sequence_id(0u), + m_kdp_version_version(0u), + m_kdp_version_feature(0u), + m_kdp_hostinfo_cpu_mask(0u), + m_kdp_hostinfo_cpu_type(0u), + m_kdp_hostinfo_cpu_subtype(0u) { } @@ -69,7 +69,7 @@ CommunicationKDP::~CommunicationKDP() bool CommunicationKDP::SendRequestPacket (const PacketStreamType &request_packet) { - Mutex::Locker locker(m_sequence_mutex); + std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex); return SendRequestPacketNoLock (request_packet); } @@ -111,7 +111,7 @@ CommunicationKDP::SendRequestAndGetReply (const CommandType command, return false; } - Mutex::Locker locker(m_sequence_mutex); + std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex); #ifdef LLDB_CONFIGURATION_DEBUG // NOTE: this only works for packets that are in native endian byte order assert (request_packet.GetSize() == *((uint16_t *)(request_packet.GetData() + 2))); @@ -205,9 +205,9 @@ CommunicationKDP::SendRequestPacketNoLock (const PacketStreamType &request_packe } bool -CommunicationKDP::GetSequenceMutex (Mutex::Locker& locker) +CommunicationKDP::GetSequenceMutex(std::unique_lock<std::recursive_mutex> &lock) { - return locker.TryLock (m_sequence_mutex); + return (lock = std::unique_lock<std::recursive_mutex>(m_sequence_mutex, std::try_to_lock)).owns_lock(); } @@ -220,7 +220,7 @@ CommunicationKDP::WaitForNotRunningPrivate (const TimeValue *timeout_ptr) size_t CommunicationKDP::WaitForPacketWithTimeoutMicroSeconds (DataExtractor &packet, uint32_t timeout_usec) { - Mutex::Locker locker(m_sequence_mutex); + std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex); return WaitForPacketWithTimeoutMicroSecondsNoLock (packet, timeout_usec); } diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h index 98a146d5a06..89e55a561e7 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include <list> +#include <mutex> #include <string> // Other libraries and framework includes @@ -21,7 +22,6 @@ #include "lldb/Core/Communication.h" #include "lldb/Core/Listener.h" #include "lldb/Core/StreamBuffer.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/Predicate.h" #include "lldb/Host/TimeValue.h" @@ -109,7 +109,7 @@ public: uint32_t usec); bool - GetSequenceMutex(lldb_private::Mutex::Locker& locker); + GetSequenceMutex(std::unique_lock<std::recursive_mutex> &lock); bool CheckForPacket (const uint8_t *src, @@ -324,7 +324,7 @@ protected: uint32_t m_addr_byte_size; lldb::ByteOrder m_byte_order; uint32_t m_packet_timeout; - lldb_private::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 lldb_private::Predicate<bool> m_is_running; uint32_t m_session_key; uint8_t m_request_sequence_id; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index a7a335d993e..53bf9f653ab 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1646,7 +1646,7 @@ ProcessGDBRemote::HandleStopReplySequence () void ProcessGDBRemote::ClearThreadIDList () { - Mutex::Locker locker(m_thread_list_real.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list_real.GetMutex()); m_thread_ids.clear(); m_thread_pcs.clear(); } @@ -1696,7 +1696,7 @@ ProcessGDBRemote::UpdateThreadPCsFromStopReplyThreadsValue (std::string &value) bool ProcessGDBRemote::UpdateThreadIDList () { - Mutex::Locker locker(m_thread_list_real.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list_real.GetMutex()); if (m_jthreadsinfo_sp) { @@ -1944,7 +1944,7 @@ ProcessGDBRemote::SetThreadStopInfo (lldb::tid_t tid, // m_thread_list_real does have its own mutex, but we need to // hold onto the mutex between the call to m_thread_list_real.FindThreadByID(...) // and the m_thread_list_real.AddThread(...) so it doesn't change on us - Mutex::Locker locker (m_thread_list_real.GetMutex ()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list_real.GetMutex()); thread_sp = m_thread_list_real.FindThreadByProtocolID(tid, false); if (!thread_sp) @@ -2440,7 +2440,8 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet) } else if (key.compare("threads") == 0) { - Mutex::Locker locker(m_thread_list_real.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list_real.GetMutex()); + m_thread_ids.clear(); // A comma separated list of all threads in the current // process that includes the thread for this stop reply @@ -2663,7 +2664,8 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet) void ProcessGDBRemote::RefreshStateAfterStop () { - Mutex::Locker locker(m_thread_list_real.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(m_thread_list_real.GetMutex()); + m_thread_ids.clear(); m_thread_pcs.clear(); // Set the thread stop info. It might have a "threads" key whose value is @@ -2818,7 +2820,7 @@ ProcessGDBRemote::DoDestroy () ThreadList &threads = GetThreadList(); { - Mutex::Locker locker(threads.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(threads.GetMutex()); size_t num_threads = threads.GetSize(); for (size_t i = 0; i < num_threads; i++) @@ -2853,7 +2855,7 @@ ProcessGDBRemote::DoDestroy () // have to run the risk of letting those threads proceed a bit. { - Mutex::Locker locker(threads.GetMutex()); + std::lock_guard<std::recursive_mutex> guard(threads.GetMutex()); size_t num_threads = threads.GetSize(); for (size_t i = 0; i < num_threads; i++) |