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/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 1360edd..4021b44 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -452,16 +452,16 @@
//----------------------------------------------------------------------
// Constructor
//----------------------------------------------------------------------
-DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel (Process* process, lldb::addr_t kernel_addr) :
- DynamicLoader(process),
- m_kernel_load_address (kernel_addr),
- m_kernel(),
- m_kext_summary_header_ptr_addr (),
- m_kext_summary_header_addr (),
- m_kext_summary_header (),
- m_known_kexts (),
- m_mutex(Mutex::eMutexTypeRecursive),
- m_break_id (LLDB_INVALID_BREAK_ID)
+DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel(Process *process, lldb::addr_t kernel_addr)
+ : DynamicLoader(process),
+ m_kernel_load_address(kernel_addr),
+ m_kernel(),
+ m_kext_summary_header_ptr_addr(),
+ m_kext_summary_header_addr(),
+ m_kext_summary_header(),
+ m_known_kexts(),
+ m_mutex(),
+ m_break_id(LLDB_INVALID_BREAK_ID)
{
Error error;
PlatformSP platform_sp(Platform::Create(PlatformDarwinKernel::GetPluginNameStatic(), error));
@@ -470,7 +470,7 @@
// shouldn't be done if kext loading is explicitly disabled.
if (platform_sp.get() && GetGlobalProperties()->GetLoadKexts())
{
- process->GetTarget().SetPlatform (platform_sp);
+ process->GetTarget().SetPlatform(platform_sp);
}
}
@@ -521,7 +521,7 @@
void
DynamicLoaderDarwinKernel::Clear (bool clear_process)
{
- Mutex::Locker locker(m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_process->IsAlive() && LLDB_BREAK_ID_IS_VALID(m_break_id))
m_process->ClearBreakpointSiteByID(m_break_id);
@@ -1131,7 +1131,7 @@
bool
DynamicLoaderDarwinKernel::ReadKextSummaryHeader ()
{
- Mutex::Locker locker(m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
// the all image infos is already valid for this process stop ID
@@ -1216,8 +1216,8 @@
Log *log(GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER));
if (log)
log->Printf ("Kexts-changed breakpoint hit, there are %d kexts currently.\n", count);
-
- Mutex::Locker locker(m_mutex);
+
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!ReadKextSummaries (kext_summary_addr, count, kext_summaries))
return false;
@@ -1438,8 +1438,8 @@
bool
DynamicLoaderDarwinKernel::ReadAllKextSummaries ()
{
- Mutex::Locker locker(m_mutex);
-
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+
if (ReadKextSummaryHeader ())
{
if (m_kext_summary_header.entry_count > 0 && m_kext_summary_header_addr.IsValid())
@@ -1508,7 +1508,7 @@
if (log == NULL)
return;
- Mutex::Locker locker(m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
log->Printf("gLoadedKextSummaries = 0x%16.16" PRIx64 " { version=%u, entry_size=%u, entry_count=%u }",
m_kext_summary_header_addr.GetFileAddress(),
m_kext_summary_header.version,
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
index 5b313bf..47fba08 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
@@ -12,8 +12,9 @@
// C Includes
// C++ Includes
-#include <vector>
+#include <mutex>
#include <string>
+#include <vector>
// Other libraries and framework includes
// Project includes
@@ -21,7 +22,6 @@
#include "lldb/Host/FileSpec.h"
#include "lldb/Host/TimeValue.h"
#include "lldb/Core/UUID.h"
-#include "lldb/Host/Mutex.h"
#include "lldb/Target/Process.h"
class DynamicLoaderDarwinKernel : public lldb_private::DynamicLoader
@@ -361,7 +361,7 @@
lldb_private::Address m_kext_summary_header_addr;
OSKextLoadedKextSummaryHeader m_kext_summary_header;
KextImageInfo::collection m_known_kexts;
- mutable lldb_private::Mutex m_mutex;
+ mutable std::recursive_mutex m_mutex;
lldb::user_id_t m_break_id;
private:
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index fba11f6..d12f0ab 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -138,18 +138,18 @@
//----------------------------------------------------------------------
// Constructor
//----------------------------------------------------------------------
-DynamicLoaderMacOSXDYLD::DynamicLoaderMacOSXDYLD (Process* process) :
- DynamicLoader(process),
- m_dyld(),
- m_dyld_module_wp(),
- m_dyld_all_image_infos_addr(LLDB_INVALID_ADDRESS),
- m_dyld_all_image_infos(),
- m_dyld_all_image_infos_stop_id (UINT32_MAX),
- m_break_id(LLDB_INVALID_BREAK_ID),
- m_dyld_image_infos(),
- m_dyld_image_infos_stop_id (UINT32_MAX),
- m_mutex(Mutex::eMutexTypeRecursive),
- m_process_image_addr_is_all_images_infos (false)
+DynamicLoaderMacOSXDYLD::DynamicLoaderMacOSXDYLD(Process *process)
+ : DynamicLoader(process),
+ m_dyld(),
+ m_dyld_module_wp(),
+ m_dyld_all_image_infos_addr(LLDB_INVALID_ADDRESS),
+ m_dyld_all_image_infos(),
+ m_dyld_all_image_infos_stop_id(UINT32_MAX),
+ m_break_id(LLDB_INVALID_BREAK_ID),
+ m_dyld_image_infos(),
+ m_dyld_image_infos_stop_id(UINT32_MAX),
+ m_mutex(),
+ m_process_image_addr_is_all_images_infos(false)
{
}
@@ -244,7 +244,7 @@
void
DynamicLoaderMacOSXDYLD::Clear (bool clear_process)
{
- Mutex::Locker locker(m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (LLDB_BREAK_ID_IS_VALID(m_break_id))
m_process->GetTarget().RemoveBreakpointByID (m_break_id);
@@ -683,7 +683,7 @@
bool
DynamicLoaderMacOSXDYLD::ReadAllImageInfosStructure ()
{
- Mutex::Locker locker(m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
// the all image infos is already valid for this process stop ID
if (m_process->GetStopID() == m_dyld_all_image_infos_stop_id)
@@ -974,8 +974,8 @@
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER));
if (log)
log->Printf ("Adding %d modules.\n", image_infos_count);
-
- Mutex::Locker locker(m_mutex);
+
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_process->GetStopID() == m_dyld_image_infos_stop_id)
return true;
@@ -1097,8 +1097,8 @@
{
DYLDImageInfo::collection image_infos;
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER));
-
- Mutex::Locker locker(m_mutex);
+
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_process->GetStopID() == m_dyld_image_infos_stop_id)
return true;
@@ -1239,8 +1239,8 @@
DynamicLoaderMacOSXDYLD::InitializeFromAllImageInfos ()
{
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER));
-
- Mutex::Locker locker(m_mutex);
+
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_process->GetStopID() == m_dyld_image_infos_stop_id
|| m_dyld_image_infos.size() != 0)
return false;
@@ -1678,7 +1678,7 @@
if (log == NULL)
return;
- Mutex::Locker locker(m_mutex);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
log->Printf("dyld_all_image_infos = { version=%d, count=%d, addr=0x%8.8" PRIx64 ", notify=0x%8.8" PRIx64 " }",
m_dyld_all_image_infos.version,
m_dyld_all_image_infos.dylib_info_count,
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
index 8fd60d0..a5bb85f 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
@@ -12,6 +12,7 @@
// C Includes
// C++ Includes
+#include <mutex>
#include <vector>
// Other libraries and framework includes
@@ -20,7 +21,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"
@@ -374,7 +374,7 @@
lldb::user_id_t m_break_id;
DYLDImageInfo::collection m_dyld_image_infos; // Current shared libraries information
uint32_t m_dyld_image_infos_stop_id; // The process stop ID that "m_dyld_image_infos" is valid for
- mutable lldb_private::Mutex m_mutex;
+ mutable std::recursive_mutex m_mutex;
lldb_private::Process::Notifications m_notification_callbacks;
bool m_process_image_addr_is_all_images_infos;
diff --git a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
index a7fdf4d..67694c9 100644
--- a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
+++ b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
@@ -17,7 +17,6 @@
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Host/FileSpec.h"
#include "lldb/Core/UUID.h"
-#include "lldb/Host/Mutex.h"
#include "lldb/Target/Process.h"
class DynamicLoaderStatic : public lldb_private::DynamicLoader