remove use of Mutex in favour of std::{,recursive_}mutex
This is a pretty straightforward first pass over removing a number of uses of
Mutex in favor of std::mutex or std::recursive_mutex. The problem is that there
are interfaces which take Mutex::Locker & to lock internal locks. This patch
cleans up most of the easy cases. The only non-trivial change is in
CommandObjectTarget.cpp where a Mutex::Locker was split into two.
llvm-svn: 269877
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index 3062623..a290501 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -9,7 +9,6 @@
// C Includes
// C++ Includes
-#include <mutex>
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
@@ -271,36 +270,36 @@
return class_name;
}
-Thread::Thread (Process &process, lldb::tid_t tid, bool use_invalid_index_id) :
- ThreadProperties (false),
- UserID (tid),
- Broadcaster(process.GetTarget().GetDebugger().GetBroadcasterManager(), Thread::GetStaticBroadcasterClass().AsCString()),
- m_process_wp (process.shared_from_this()),
- m_stop_info_sp (),
- m_stop_info_stop_id (0),
- m_stop_info_override_stop_id (0),
- m_index_id (use_invalid_index_id ? LLDB_INVALID_INDEX32 : process.GetNextThreadIndexID(tid)),
- m_reg_context_sp (),
- m_state (eStateUnloaded),
- m_state_mutex (Mutex::eMutexTypeRecursive),
- m_plan_stack (),
- m_completed_plan_stack(),
- m_frame_mutex (Mutex::eMutexTypeRecursive),
- m_curr_frames_sp (),
- m_prev_frames_sp (),
- m_resume_signal (LLDB_INVALID_SIGNAL_NUMBER),
- m_resume_state (eStateRunning),
- m_temporary_resume_state (eStateRunning),
- m_unwinder_ap (),
- m_destroy_called (false),
- m_override_should_notify (eLazyBoolCalculate),
- m_extended_info_fetched (false),
- m_extended_info ()
+Thread::Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id)
+ : ThreadProperties(false),
+ UserID(tid),
+ Broadcaster(process.GetTarget().GetDebugger().GetBroadcasterManager(),
+ Thread::GetStaticBroadcasterClass().AsCString()),
+ m_process_wp(process.shared_from_this()),
+ m_stop_info_sp(),
+ m_stop_info_stop_id(0),
+ m_stop_info_override_stop_id(0),
+ m_index_id(use_invalid_index_id ? LLDB_INVALID_INDEX32 : process.GetNextThreadIndexID(tid)),
+ m_reg_context_sp(),
+ m_state(eStateUnloaded),
+ m_state_mutex(),
+ m_plan_stack(),
+ m_completed_plan_stack(),
+ m_frame_mutex(),
+ m_curr_frames_sp(),
+ m_prev_frames_sp(),
+ m_resume_signal(LLDB_INVALID_SIGNAL_NUMBER),
+ m_resume_state(eStateRunning),
+ m_temporary_resume_state(eStateRunning),
+ m_unwinder_ap(),
+ m_destroy_called(false),
+ m_override_should_notify(eLazyBoolCalculate),
+ m_extended_info_fetched(false),
+ m_extended_info()
{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
if (log)
- log->Printf ("%p Thread::Thread(tid = 0x%4.4" PRIx64 ")",
- static_cast<void*>(this), GetID());
+ log->Printf("%p Thread::Thread(tid = 0x%4.4" PRIx64 ")", static_cast<void *>(this), GetID());
CheckInWithManager();
QueueFundamentalPlan(true);
@@ -345,7 +344,7 @@
m_stop_info_sp.reset();
m_reg_context_sp.reset();
m_unwinder_ap.reset();
- Mutex::Locker locker(m_frame_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
m_curr_frames_sp.reset();
m_prev_frames_sp.reset();
}
@@ -645,14 +644,14 @@
Thread::GetState() const
{
// If any other threads access this we will need a mutex for it
- Mutex::Locker locker(m_state_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
return m_state;
}
void
Thread::SetState(StateType state)
{
- Mutex::Locker locker(m_state_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
m_state = state;
}
@@ -1823,7 +1822,7 @@
Thread::GetStackFrameList ()
{
StackFrameListSP frame_list_sp;
- Mutex::Locker locker(m_frame_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
if (m_curr_frames_sp)
{
frame_list_sp = m_curr_frames_sp;
@@ -1839,7 +1838,7 @@
void
Thread::ClearStackFrames ()
{
- Mutex::Locker locker(m_frame_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
Unwind *unwinder = GetUnwinder ();
if (unwinder)