diff options
Diffstat (limited to 'lldb/source/Plugins')
56 files changed, 416 insertions, 424 deletions
diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h index 6359146d81d..e8f09a4d3ab 100644 --- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h +++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include <memory> +#include <mutex> #include <string> // Other libraries and framework includes @@ -22,7 +23,6 @@ #include "lldb/Core/Address.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Host/Mutex.h" // Opaque references to C++ Objects in LLVM's MC. namespace llvm @@ -147,7 +147,7 @@ protected: void Lock(InstructionLLVMC *inst, const lldb_private::ExecutionContext *exe_ctx) { - m_mutex.Lock(); + m_mutex.lock(); m_inst = inst; m_exe_ctx = exe_ctx; } @@ -156,12 +156,12 @@ protected: { m_inst = NULL; m_exe_ctx = NULL; - m_mutex.Unlock(); + m_mutex.unlock(); } const lldb_private::ExecutionContext *m_exe_ctx; InstructionLLVMC *m_inst; - lldb_private::Mutex m_mutex; + std::mutex m_mutex; bool m_data_from_file; std::unique_ptr<LLVMCDisassembler> m_disasm_ap; diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 1360edd9fd4..4021b44c96a 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -452,16 +452,16 @@ DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress (lldb::addr_t addr, Proc //---------------------------------------------------------------------- // 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 @@ DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel (Process* process, lldb::ad // 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 @@ DynamicLoaderDarwinKernel::DidLaunch () 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 @@ DynamicLoaderDarwinKernel::BreakpointHit (StoppointCallbackContext *context, 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 @@ DynamicLoaderDarwinKernel::ParseKextSummaries (const Address &kext_summary_addr, 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 @@ DynamicLoaderDarwinKernel::ReadKextSummaries (const Address &kext_summary_addr, 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 @@ DynamicLoaderDarwinKernel::PutToLog(Log *log) const 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 5b313bfc910..47fba086a4a 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 @@ protected: 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 fba11f6aea8..d12f0ab05d9 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -138,18 +138,18 @@ DynamicLoaderMacOSXDYLD::CreateInstance (Process* process, bool force) //---------------------------------------------------------------------- // 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 @@ DynamicLoaderMacOSXDYLD::ProcessDidExec () 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 @@ DynamicLoaderMacOSXDYLD::NotifyBreakpointHit (void *baton, 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 @@ DynamicLoaderMacOSXDYLD::AddModulesUsingImageInfosAddress (lldb::addr_t image_in 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 @@ DynamicLoaderMacOSXDYLD::RemoveModulesUsingImageInfosAddress (lldb::addr_t image { 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 @@ bool 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 @@ DynamicLoaderMacOSXDYLD::PutToLog(Log *log) const 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 8fd60d0b6ac..a5bb85fbf66 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 @@ protected: 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 a7fdf4d2216..67694c96025 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 diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp index 711d324d8aa..5cf99a573d8 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp @@ -499,11 +499,9 @@ ClassDescriptorV2::GetInstanceSize () return 0; } -ClassDescriptorV2::iVarsStorage::iVarsStorage (): -m_filled(false), -m_ivars(), -m_mutex(Mutex::eMutexTypeRecursive) -{} +ClassDescriptorV2::iVarsStorage::iVarsStorage() : m_filled(false), m_ivars(), m_mutex() +{ +} size_t ClassDescriptorV2::iVarsStorage::size () @@ -522,7 +520,7 @@ ClassDescriptorV2::iVarsStorage::fill (AppleObjCRuntimeV2& runtime, ClassDescrip { if (m_filled) return; - Mutex::Locker lock(m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_VERBOSE)); if (log) log->Printf("[ClassDescriptorV2::iVarsStorage::fill] class_name = %s", descriptor.GetClassName().AsCString("<unknown")); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h index 18591ecd6e9..f5fc8bc0644 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h @@ -12,10 +12,11 @@ // C Includes // C++ Includes +#include <mutex> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" -#include "lldb/Host/Mutex.h" #include "lldb/Target/ObjCLanguageRuntime.h" #include "AppleObjCRuntimeV2.h" @@ -247,7 +248,7 @@ private: private: bool m_filled; std::vector<iVarDescriptor> m_ivars; - Mutex m_mutex; + std::recursive_mutex m_mutex; }; // The constructor should only be invoked by the runtime as it builds its caches diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 0f79427559b..55516341889 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -379,27 +379,27 @@ ExtractRuntimeGlobalSymbol (Process* process, } } -AppleObjCRuntimeV2::AppleObjCRuntimeV2 (Process *process, - const ModuleSP &objc_module_sp) : - AppleObjCRuntime (process), - m_get_class_info_code(), - m_get_class_info_args (LLDB_INVALID_ADDRESS), - m_get_class_info_args_mutex (Mutex::eMutexTypeNormal), - m_get_shared_cache_class_info_code(), - m_get_shared_cache_class_info_args (LLDB_INVALID_ADDRESS), - m_get_shared_cache_class_info_args_mutex (Mutex::eMutexTypeNormal), - m_decl_vendor_ap (), - m_isa_hash_table_ptr (LLDB_INVALID_ADDRESS), - m_hash_signature (), - m_has_object_getClass (false), - m_loaded_objc_opt (false), - m_non_pointer_isa_cache_ap(NonPointerISACache::CreateInstance(*this,objc_module_sp)), - m_tagged_pointer_vendor_ap(TaggedPointerVendorV2::CreateInstance(*this,objc_module_sp)), - m_encoding_to_type_sp(), - m_noclasses_warning_emitted(false) +AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process, const ModuleSP &objc_module_sp) + : AppleObjCRuntime(process), + m_get_class_info_code(), + m_get_class_info_args(LLDB_INVALID_ADDRESS), + m_get_class_info_args_mutex(), + m_get_shared_cache_class_info_code(), + m_get_shared_cache_class_info_args(LLDB_INVALID_ADDRESS), + m_get_shared_cache_class_info_args_mutex(), + m_decl_vendor_ap(), + m_isa_hash_table_ptr(LLDB_INVALID_ADDRESS), + m_hash_signature(), + m_has_object_getClass(false), + m_loaded_objc_opt(false), + m_non_pointer_isa_cache_ap(NonPointerISACache::CreateInstance(*this, objc_module_sp)), + m_tagged_pointer_vendor_ap(TaggedPointerVendorV2::CreateInstance(*this, objc_module_sp)), + m_encoding_to_type_sp(), + m_noclasses_warning_emitted(false) { static const ConstString g_gdb_object_getClass("gdb_object_getClass"); - m_has_object_getClass = (objc_module_sp->FindFirstSymbolWithNameAndType(g_gdb_object_getClass, eSymbolTypeCode) != NULL); + m_has_object_getClass = + (objc_module_sp->FindFirstSymbolWithNameAndType(g_gdb_object_getClass, eSymbolTypeCode) != NULL); } bool @@ -1483,8 +1483,8 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(RemoteNXMapTable &hash_table if (class_infos_addr == LLDB_INVALID_ADDRESS) return false; - - Mutex::Locker locker(m_get_class_info_args_mutex); + + std::lock_guard<std::mutex> guard(m_get_class_info_args_mutex); // Fill in our function argument values arguments.GetValueAtIndex(0)->GetScalar() = hash_table.GetTableLoadAddress(); @@ -1735,9 +1735,9 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() if (class_infos_addr == LLDB_INVALID_ADDRESS) return DescriptorMapUpdateResult::Fail(); - - Mutex::Locker locker(m_get_shared_cache_class_info_args_mutex); - + + std::lock_guard<std::mutex> guard(m_get_shared_cache_class_info_args_mutex); + // Fill in our function argument values arguments.GetValueAtIndex(0)->GetScalar() = objc_opt_ptr; arguments.GetValueAtIndex(1)->GetScalar() = class_infos_addr; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h index 8b4ca8f4e9b..4b27c740048 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h @@ -14,6 +14,7 @@ // C++ Includes #include <map> #include <memory> +#include <mutex> // Other libraries and framework includes // Project includes @@ -353,11 +354,11 @@ private: std::unique_ptr<UtilityFunction> m_get_class_info_code; lldb::addr_t m_get_class_info_args; - Mutex m_get_class_info_args_mutex; + std::mutex m_get_class_info_args_mutex; std::unique_ptr<UtilityFunction> m_get_shared_cache_class_info_code; lldb::addr_t m_get_shared_cache_class_info_args; - Mutex m_get_shared_cache_class_info_args_mutex; + std::mutex m_get_shared_cache_class_info_args_mutex; std::unique_ptr<DeclVendor> m_decl_vendor_ap; lldb::addr_t m_isa_hash_table_ptr; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp index 614c267d0be..56aa36ecb0d 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -751,8 +751,8 @@ AppleObjCTrampolineHandler::SetupDispatchFunction(Thread &thread, ValueList &dis // Scope for mutex locker: { - Mutex::Locker locker(m_impl_function_mutex); - + std::lock_guard<std::mutex> guard(m_impl_function_mutex); + // First stage is to make the ClangUtility to hold our injected function: if (!m_impl_code.get()) diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h index 42d3461ddfa..b11beea9197 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h @@ -13,12 +13,12 @@ // C Includes // C++ Includes #include <map> +#include <mutex> #include <vector> // Other libraries and framework includes // Project includes #include "lldb/lldb-public.h" -#include "lldb/Host/Mutex.h" #include "lldb/Expression/UtilityFunction.h" namespace lldb_private @@ -196,7 +196,7 @@ private: lldb::ProcessWP m_process_wp; lldb::ModuleSP m_objc_module_sp; std::unique_ptr<UtilityFunction> m_impl_code; - Mutex m_impl_function_mutex; + std::mutex m_impl_function_mutex; lldb::addr_t m_impl_fn_addr; lldb::addr_t m_impl_stret_fn_addr; lldb::addr_t m_msg_forward_addr; diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp index f2a74b05fe2..984a9ece12e 100644 --- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -35,7 +35,6 @@ typedef struct ar_hdr #include "lldb/Core/PluginManager.h" #include "lldb/Core/Stream.h" #include "lldb/Core/Timer.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/ObjectFile.h" using namespace lldb; @@ -226,7 +225,7 @@ ObjectContainerBSDArchive::Archive::FindObject (const ConstString &object_name, ObjectContainerBSDArchive::Archive::shared_ptr ObjectContainerBSDArchive::Archive::FindCachedArchive (const FileSpec &file, const ArchSpec &arch, const TimeValue &time, lldb::offset_t file_offset) { - Mutex::Locker locker(Archive::GetArchiveCacheMutex ()); + std::lock_guard<std::recursive_mutex> guard(Archive::GetArchiveCacheMutex()); shared_ptr archive_sp; Archive::Map &archive_map = Archive::GetArchiveCache (); Archive::Map::iterator pos = archive_map.find (file); @@ -281,7 +280,7 @@ ObjectContainerBSDArchive::Archive::ParseAndCacheArchiveForFile const size_t num_objects = archive_sp->ParseObjects (); if (num_objects > 0) { - Mutex::Locker locker(Archive::GetArchiveCacheMutex ()); + std::lock_guard<std::recursive_mutex> guard(Archive::GetArchiveCacheMutex()); Archive::GetArchiveCache().insert(std::make_pair(file, archive_sp)); } else @@ -299,14 +298,13 @@ ObjectContainerBSDArchive::Archive::GetArchiveCache () return g_archive_map; } -Mutex & -ObjectContainerBSDArchive::Archive::GetArchiveCacheMutex () +std::recursive_mutex & +ObjectContainerBSDArchive::Archive::GetArchiveCacheMutex() { - static Mutex g_archive_map_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_archive_map_mutex; return g_archive_map_mutex; } - void ObjectContainerBSDArchive::Initialize() { diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h index cbb3848dc7c..03b0bf3e2f0 100644 --- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h +++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h @@ -12,6 +12,8 @@ // C Includes // C++ Includes +#include <mutex> + // Other libraries and framework includes // Project includes #include "lldb/Symbol/ObjectContainer.h" @@ -138,8 +140,8 @@ protected: static Map & GetArchiveCache (); - static lldb_private::Mutex & - GetArchiveCacheMutex (); + static std::recursive_mutex & + GetArchiveCacheMutex(); static Archive::shared_ptr FindCachedArchive (const lldb_private::FileSpec &file, diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index fe299b17f59..7f963c9f3f9 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2938,7 +2938,7 @@ ObjectFileELF::GetSymtab() return NULL; uint64_t symbol_id = 0; - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); // Sharable objects and dynamic executables usually have 2 distinct symbol // tables, one named ".symtab", and the other ".dynsym". The dynsym is a smaller @@ -3102,7 +3102,7 @@ ObjectFileELF::Dump(Stream *s) return; } - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); s->Printf("%p: ", static_cast<void *>(this)); s->Indent(); s->PutCString("ObjectFileELF"); diff --git a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp index 3103ed8fb8f..7b1627ddd73 100644 --- a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp +++ b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp @@ -158,7 +158,7 @@ ObjectFileJIT::GetSymtab() ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); if (m_symtab_ap.get() == NULL) { m_symtab_ap.reset(new Symtab(this)); @@ -200,7 +200,7 @@ ObjectFileJIT::Dump (Stream *s) ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); s->Printf("%p: ", static_cast<void*>(this)); s->Indent(); s->PutCString("ObjectFileJIT"); diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 09fc922fc72..6a105195c5a 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1217,7 +1217,7 @@ ObjectFileMachO::ParseHeader () ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); bool can_parse = false; lldb::offset_t offset = 0; m_data.SetByteOrder (endian::InlHostByteOrder()); @@ -1457,7 +1457,7 @@ ObjectFileMachO::GetSymtab() ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); if (m_symtab_ap.get() == NULL) { m_symtab_ap.reset(new Symtab(this)); @@ -4755,7 +4755,7 @@ ObjectFileMachO::Dump (Stream *s) ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); s->Printf("%p: ", static_cast<void*>(this)); s->Indent(); if (m_header.magic == MH_MAGIC_64 || m_header.magic == MH_CIGAM_64) @@ -4911,7 +4911,7 @@ ObjectFileMachO::GetUUID (lldb_private::UUID* uuid) ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic); return GetUUID (m_header, m_data, offset, *uuid); } @@ -4925,7 +4925,7 @@ ObjectFileMachO::GetDependentModules (FileSpecList& files) ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); struct load_command load_cmd; lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic); std::vector<std::string> rpath_paths; @@ -5053,7 +5053,7 @@ ObjectFileMachO::GetEntryPointAddress () ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); struct load_command load_cmd; lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic); uint32_t i; @@ -5203,7 +5203,7 @@ ObjectFileMachO::GetNumThreadContexts () ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); if (!m_thread_context_offsets_valid) { m_thread_context_offsets_valid = true; @@ -5237,7 +5237,7 @@ ObjectFileMachO::GetThreadContextAtIndex (uint32_t idx, lldb_private::Thread &th ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); if (!m_thread_context_offsets_valid) GetNumThreadContexts (); @@ -5373,7 +5373,7 @@ ObjectFileMachO::GetVersion (uint32_t *versions, uint32_t num_versions) ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); struct dylib_command load_cmd; lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic); uint32_t version_cmd = 0; @@ -5428,7 +5428,7 @@ ObjectFileMachO::GetArchitecture (ArchSpec &arch) ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); return GetArchitecture (m_header, m_data, MachHeaderSizeFromMagic(m_header.magic), arch); } return false; diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h index 9f7cb3e40dd..251a0865e78 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h @@ -19,7 +19,6 @@ #include "lldb/Core/FileSpecList.h" #include "lldb/Core/RangeMap.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/ObjectFile.h" //---------------------------------------------------------------------- diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index 48b9f8816a3..8e942f5bdb9 100644 --- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -212,7 +212,7 @@ ObjectFilePECOFF::ParseHeader () ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); m_sect_headers.clear(); m_data.SetByteOrder (eByteOrderLittle); lldb::offset_t offset = 0; @@ -534,7 +534,7 @@ ObjectFilePECOFF::GetSymtab() ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); if (m_symtab_ap.get() == NULL) { SectionList *sect_list = GetSectionList(); @@ -689,7 +689,7 @@ ObjectFilePECOFF::CreateSections (SectionList &unified_section_list) ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); const uint32_t nsects = m_sect_headers.size(); ModuleSP module_sp (GetModule()); for (uint32_t idx = 0; idx<nsects; ++idx) @@ -847,7 +847,7 @@ ObjectFilePECOFF::Dump(Stream *s) ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); s->Printf("%p: ", static_cast<void*>(this)); s->Indent(); s->PutCString("ObjectFilePECOFF"); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp index eea2844d564..a5f165e1f92 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp @@ -252,7 +252,7 @@ FileSpec PlatformAppleSimulator::GetCoreSimulatorPath() { #if defined(__APPLE__) - Mutex::Locker locker (m_mutex); + std::lock_guard<std::mutex> guard(m_mutex); if (!m_core_simulator_framework_path.hasValue()) { const char *developer_dir = GetDeveloperDirectory(); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp index f537934a917..097d58dcfbc 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp @@ -304,7 +304,7 @@ EnumerateDirectoryCallback (void *baton, FileSpec::FileType file_type, const Fil const char * PlatformAppleTVSimulator::GetSDKDirectoryAsCString() { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::mutex> guard(m_mutex); if (m_sdk_directory.empty()) { const char *developer_dir = GetDeveloperDirectory(); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp index ea8e789b292..46e5970bc08 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp @@ -304,7 +304,7 @@ EnumerateDirectoryCallback (void *baton, FileSpec::FileType file_type, const Fil const char * PlatformAppleWatchSimulator::GetSDKDirectoryAsCString() { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::mutex> guard(m_mutex); if (m_sdk_directory.empty()) { const char *developer_dir = GetDeveloperDirectory(); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 905cd6229bf..62ada5a70a5 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -1015,7 +1015,7 @@ PlatformDarwin::ARMGetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch const char * PlatformDarwin::GetDeveloperDirectory() { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::mutex> guard(m_mutex); if (m_developer_directory.empty()) { bool developer_dir_path_valid = false; @@ -1572,10 +1572,10 @@ PlatformDarwin::AddClangModuleCompilationOptionsForSDKType (Target *target, std: FileSpec sysroot_spec; // Scope for mutex locker below { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::mutex> guard(m_mutex); sysroot_spec = GetSDKDirectoryForModules(sdk_type); } - + if (sysroot_spec.IsDirectory()) { options.push_back("-isysroot"); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp index cbe9c7949a4..99b9324417b 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp @@ -308,7 +308,7 @@ EnumerateDirectoryCallback (void *baton, FileSpec::FileType file_type, const Fil const char * PlatformiOSSimulator::GetSDKDirectoryAsCString() { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::mutex> guard(m_mutex); if (m_sdk_directory.empty()) { const char *developer_dir = GetDeveloperDirectory(); diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp index 69b527a513f..debad980a31 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -229,7 +229,7 @@ ProcessFreeBSD::WillResume() void ProcessFreeBSD::SendMessage(const ProcessMessage &message) { - Mutex::Locker lock(m_message_mutex); + std::lock_guard<std::recursive_mutex> guard(m_message_mutex); switch (message.GetKind()) { @@ -274,7 +274,7 @@ ProcessFreeBSD::ProcessFreeBSD(lldb::TargetSP target_sp, lldb::ListenerSP listen m_byte_order(endian::InlHostByteOrder()), m_monitor(NULL), m_module(NULL), - m_message_mutex (Mutex::eMutexTypeRecursive), + m_message_mutex(), m_exit_now(false), m_seen_initial_stop(), m_resume_signo(0) @@ -603,7 +603,7 @@ ProcessFreeBSD::RefreshStateAfterStop() if (log && log->GetMask().Test(POSIX_LOG_VERBOSE)) log->Printf ("ProcessFreeBSD::%s(), message_queue size = %d", __FUNCTION__, (int)m_message_queue.size()); - Mutex::Locker lock(m_message_mutex); + std::lock_guard<std::recursive_mutex> guard(m_message_mutex); // This method used to only handle one message. Changing it to loop allows // it to handle the case where we hit a breakpoint while handling a different diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h index a1d255c34cb..888e2a90ad7 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h @@ -13,8 +13,9 @@ // C Includes // C++ Includes -#include <set> +#include <mutex> #include <queue> +#include <set> // Other libraries and framework includes #include "lldb/Target/Process.h" @@ -212,7 +213,7 @@ protected: lldb_private::Module *m_module; /// Message queue notifying this instance of inferior process state changes. - lldb_private::Mutex m_message_mutex; + std::recursive_mutex m_message_mutex; std::queue<ProcessMessage> m_message_queue; /// Drive any exit events to completion. diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp index 2318a657578..16707a5c8b9 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp @@ -1348,7 +1348,7 @@ ProcessMonitor::ServeOperation(OperationArgs *args) void ProcessMonitor::DoOperation(Operation *op) { - Mutex::Locker lock(m_operation_mutex); + std::lock_guard<std::mutex> guard(m_operation_mutex); m_operation = op; diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h index 27cdd3e7000..93f6be11136 100644 --- a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h +++ b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h @@ -15,11 +15,12 @@ #include <signal.h> // C++ Includes +#include <mutex> + // Other libraries and framework includes #include "lldb/lldb-types.h" #include "lldb/Host/FileSpec.h" #include "lldb/Host/HostThread.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -223,7 +224,7 @@ private: // current operation which must be executed on the privileged thread Operation *m_operation; - lldb_private::Mutex m_operation_mutex; + std::mutex m_operation_mutex; // semaphores notified when Operation is ready to be processed and when // the operation is complete. diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp index 2cbd94a2f96..813c810bff9 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -284,8 +284,8 @@ bool CommunicationKDP::CheckForPacket (const uint8_t *src, size_t src_len, DataExtractor &packet) { // Put the packet data into the buffer in a thread safe fashion - Mutex::Locker locker(m_bytes_mutex); - + std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS)); if (src && src_len > 0) diff --git a/lldb/source/Plugins/Process/Utility/HistoryThread.cpp b/lldb/source/Plugins/Process/Utility/HistoryThread.cpp index 206b8290c5f..20a10106c2a 100644 --- a/lldb/source/Plugins/Process/Utility/HistoryThread.cpp +++ b/lldb/source/Plugins/Process/Utility/HistoryThread.cpp @@ -22,28 +22,24 @@ using namespace lldb_private; // Constructor -HistoryThread::HistoryThread (lldb_private::Process &process, - lldb::tid_t tid, - std::vector<lldb::addr_t> pcs, - uint32_t stop_id, - bool stop_id_is_valid) : - Thread (process, tid, true), - m_framelist_mutex(), - m_framelist(), - m_pcs (pcs), - m_stop_id (stop_id), - m_stop_id_is_valid (stop_id_is_valid), - m_extended_unwind_token (LLDB_INVALID_ADDRESS), - m_queue_name (), - m_thread_name (), - m_originating_unique_thread_id (tid), - m_queue_id (LLDB_INVALID_QUEUE_ID) +HistoryThread::HistoryThread(lldb_private::Process &process, lldb::tid_t tid, std::vector<lldb::addr_t> pcs, + uint32_t stop_id, bool stop_id_is_valid) + : Thread(process, tid, true), + m_framelist_mutex(), + m_framelist(), + m_pcs(pcs), + m_stop_id(stop_id), + m_stop_id_is_valid(stop_id_is_valid), + m_extended_unwind_token(LLDB_INVALID_ADDRESS), + m_queue_name(), + m_thread_name(), + m_originating_unique_thread_id(tid), + m_queue_id(LLDB_INVALID_QUEUE_ID) { - m_unwinder_ap.reset (new HistoryUnwind (*this, pcs, stop_id_is_valid)); - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); + m_unwinder_ap.reset(new HistoryUnwind(*this, pcs, stop_id_is_valid)); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT)); if (log) - log->Printf ("%p HistoryThread::HistoryThread", - static_cast<void*>(this)); + log->Printf("%p HistoryThread::HistoryThread", static_cast<void *>(this)); } // Destructor @@ -78,7 +74,9 @@ HistoryThread::CreateRegisterContextForFrame (StackFrame *frame) lldb::StackFrameListSP HistoryThread::GetStackFrameList () { - Mutex::Locker (m_framelist_mutex); // FIXME do not throw away the lock after we acquire it.. + // FIXME do not throw away the lock after we acquire it.. + std::unique_lock<std::mutex> lock(m_framelist_mutex); + lock.release(); if (m_framelist.get() == NULL) { m_framelist.reset (new StackFrameList (*this, StackFrameListSP(), true)); diff --git a/lldb/source/Plugins/Process/Utility/HistoryThread.h b/lldb/source/Plugins/Process/Utility/HistoryThread.h index e87f6496134..43ac13c2d8b 100644 --- a/lldb/source/Plugins/Process/Utility/HistoryThread.h +++ b/lldb/source/Plugins/Process/Utility/HistoryThread.h @@ -12,10 +12,11 @@ // C Includes // C++ Includes +#include <mutex> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" -#include "lldb/Host/Mutex.h" #include "lldb/Core/Broadcaster.h" #include "lldb/Core/Event.h" #include "lldb/Core/UserID.h" @@ -125,7 +126,7 @@ protected: virtual lldb::StackFrameListSP GetStackFrameList (); - mutable Mutex m_framelist_mutex; + mutable std::mutex m_framelist_mutex; lldb::StackFrameListSP m_framelist; std::vector<lldb::addr_t> m_pcs; uint32_t m_stop_id; diff --git a/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp b/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp index 14afcbee0b4..62e4bc0a347 100644 --- a/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp +++ b/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp @@ -40,7 +40,7 @@ HistoryUnwind::~HistoryUnwind () void HistoryUnwind::DoClear () { - Mutex::Locker locker(m_unwind_mutex); + std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex); m_pcs.clear(); m_stop_id_is_valid = false; } @@ -64,7 +64,9 @@ HistoryUnwind::DoCreateRegisterContextForFrame (StackFrame *frame) bool HistoryUnwind::DoGetFrameInfoAtIndex (uint32_t frame_idx, lldb::addr_t& cfa, lldb::addr_t& pc) { - Mutex::Locker (m_unwind_mutex); // FIXME do not throw away the lock after we acquire it.. + // FIXME do not throw away the lock after we acquire it.. + std::unique_lock<std::recursive_mutex> guard(m_unwind_mutex); + guard.release(); if (frame_idx < m_pcs.size()) { cfa = frame_idx; diff --git a/lldb/source/Plugins/Process/Utility/HistoryUnwind.h b/lldb/source/Plugins/Process/Utility/HistoryUnwind.h index 2cb78bc1dc6..890604fcb68 100644 --- a/lldb/source/Plugins/Process/Utility/HistoryUnwind.h +++ b/lldb/source/Plugins/Process/Utility/HistoryUnwind.h @@ -17,7 +17,6 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" -#include "lldb/Host/Mutex.h" #include "lldb/Target/Unwind.h" namespace lldb_private { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 891cc22fec7..4689e0bc299 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -793,8 +793,8 @@ GDBRemoteCommunication::PacketType GDBRemoteCommunication::CheckForPacket (const uint8_t *src, size_t src_len, StringExtractorGDBRemote &packet) { // Put the packet data into the buffer in a thread safe fashion - Mutex::Locker locker(m_bytes_mutex); - + std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); if (src && src_len > 0) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 1a109307b88..5f2678d24cf 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -55,79 +55,79 @@ using namespace lldb_private::process_gdb_remote; //---------------------------------------------------------------------- // GDBRemoteCommunicationClient constructor //---------------------------------------------------------------------- -GDBRemoteCommunicationClient::GDBRemoteCommunicationClient() : - GDBRemoteCommunication("gdb-remote.client", "gdb-remote.client.rx_packet"), - m_supports_not_sending_acks (eLazyBoolCalculate), - m_supports_thread_suffix (eLazyBoolCalculate), - m_supports_threads_in_stop_reply (eLazyBoolCalculate), - m_supports_vCont_all (eLazyBoolCalculate), - m_supports_vCont_any (eLazyBoolCalculate), - m_supports_vCont_c (eLazyBoolCalculate), - m_supports_vCont_C (eLazyBoolCalculate), - m_supports_vCont_s (eLazyBoolCalculate), - m_supports_vCont_S (eLazyBoolCalculate), - m_qHostInfo_is_valid (eLazyBoolCalculate), - m_curr_pid_is_valid (eLazyBoolCalculate), - m_qProcessInfo_is_valid (eLazyBoolCalculate), - m_qGDBServerVersion_is_valid (eLazyBoolCalculate), - m_supports_alloc_dealloc_memory (eLazyBoolCalculate), - m_supports_memory_region_info (eLazyBoolCalculate), - m_supports_watchpoint_support_info (eLazyBoolCalculate), - m_supports_detach_stay_stopped (eLazyBoolCalculate), - m_watchpoints_trigger_after_instruction(eLazyBoolCalculate), - m_attach_or_wait_reply(eLazyBoolCalculate), - m_prepare_for_reg_writing_reply (eLazyBoolCalculate), - m_supports_p (eLazyBoolCalculate), - m_supports_x (eLazyBoolCalculate), - m_avoid_g_packets (eLazyBoolCalculate), - m_supports_QSaveRegisterState (eLazyBoolCalculate), - m_supports_qXfer_auxv_read (eLazyBoolCalculate), - m_supports_qXfer_libraries_read (eLazyBoolCalculate), - m_supports_qXfer_libraries_svr4_read (eLazyBoolCalculate), - m_supports_qXfer_features_read (eLazyBoolCalculate), - m_supports_augmented_libraries_svr4_read (eLazyBoolCalculate), - m_supports_jThreadExtendedInfo (eLazyBoolCalculate), - m_supports_jLoadedDynamicLibrariesInfos (eLazyBoolCalculate), - m_supports_qProcessInfoPID (true), - m_supports_qfProcessInfo (true), - m_supports_qUserName (true), - m_supports_qGroupName (true), - m_supports_qThreadStopInfo (true), - m_supports_z0 (true), - m_supports_z1 (true), - m_supports_z2 (true), - m_supports_z3 (true), - m_supports_z4 (true), - m_supports_QEnvironment (true), - m_supports_QEnvironmentHexEncoded (true), - m_supports_qSymbol (true), - m_qSymbol_requests_done (false), - m_supports_qModuleInfo (true), - m_supports_jThreadsInfo (true), - m_curr_pid (LLDB_INVALID_PROCESS_ID), - m_curr_tid (LLDB_INVALID_THREAD_ID), - m_curr_tid_run (LLDB_INVALID_THREAD_ID), - m_num_supported_hardware_watchpoints (0), - m_async_mutex (Mutex::eMutexTypeRecursive), - m_async_packet_predicate (false), - m_async_packet (), - m_async_result (PacketResult::Success), - m_async_response (), - m_async_signal (-1), - m_interrupt_sent (false), - m_thread_id_to_used_usec_map (), - m_host_arch(), - m_process_arch(), - m_os_version_major (UINT32_MAX), - m_os_version_minor (UINT32_MAX), - m_os_version_update (UINT32_MAX), - m_os_build (), - m_os_kernel (), - m_hostname (), - m_gdb_server_name(), - m_gdb_server_version(UINT32_MAX), - m_default_packet_timeout (0), - m_max_packet_size (0) +GDBRemoteCommunicationClient::GDBRemoteCommunicationClient() + : GDBRemoteCommunication("gdb-remote.client", "gdb-remote.client.rx_packet"), + m_supports_not_sending_acks(eLazyBoolCalculate), + m_supports_thread_suffix(eLazyBoolCalculate), + m_supports_threads_in_stop_reply(eLazyBoolCalculate), + m_supports_vCont_all(eLazyBoolCalculate), + m_supports_vCont_any(eLazyBoolCalculate), + m_supports_vCont_c(eLazyBoolCalculate), + m_supports_vCont_C(eLazyBoolCalculate), + m_supports_vCont_s(eLazyBoolCalculate), + m_supports_vCont_S(eLazyBoolCalculate), + m_qHostInfo_is_valid(eLazyBoolCalculate), + m_curr_pid_is_valid(eLazyBoolCalculate), + m_qProcessInfo_is_valid(eLazyBoolCalculate), + m_qGDBServerVersion_is_valid(eLazyBoolCalculate), + m_supports_alloc_dealloc_memory(eLazyBoolCalculate), + m_supports_memory_region_info(eLazyBoolCalculate), + m_supports_watchpoint_support_info(eLazyBoolCalculate), + m_supports_detach_stay_stopped(eLazyBoolCalculate), + m_watchpoints_trigger_after_instruction(eLazyBoolCalculate), + m_attach_or_wait_reply(eLazyBoolCalculate), + m_prepare_for_reg_writing_reply(eLazyBoolCalculate), + m_supports_p(eLazyBoolCalculate), + m_supports_x(eLazyBoolCalculate), + m_avoid_g_packets(eLazyBoolCalculate), + m_supports_QSaveRegisterState(eLazyBoolCalculate), + m_supports_qXfer_auxv_read(eLazyBoolCalculate), + m_supports_qXfer_libraries_read(eLazyBoolCalculate), + m_supports_qXfer_libraries_svr4_read(eLazyBoolCalculate), + m_supports_qXfer_features_read(eLazyBoolCalculate), + m_supports_augmented_libraries_svr4_read(eLazyBoolCalculate), + m_supports_jThreadExtendedInfo(eLazyBoolCalculate), + m_supports_jLoadedDynamicLibrariesInfos(eLazyBoolCalculate), + m_supports_qProcessInfoPID(true), + m_supports_qfProcessInfo(true), + m_supports_qUserName(true), + m_supports_qGroupName(true), + m_supports_qThreadStopInfo(true), + m_supports_z0(true), + m_supports_z1(true), + m_supports_z2(true), + m_supports_z3(true), + m_supports_z4(true), + m_supports_QEnvironment(true), + m_supports_QEnvironmentHexEncoded(true), + m_supports_qSymbol(true), + m_qSymbol_requests_done(false), + m_supports_qModuleInfo(true), + m_supports_jThreadsInfo(true), + m_curr_pid(LLDB_INVALID_PROCESS_ID), + m_curr_tid(LLDB_INVALID_THREAD_ID), + m_curr_tid_run(LLDB_INVALID_THREAD_ID), + m_num_supported_hardware_watchpoints(0), + m_async_mutex(), + m_async_packet_predicate(false), + m_async_packet(), + m_async_result(PacketResult::Success), + m_async_response(), + m_async_signal(-1), + m_interrupt_sent(false), + m_thread_id_to_used_usec_map(), + m_host_arch(), + m_process_arch(), + m_os_version_major(UINT32_MAX), + m_os_version_minor(UINT32_MAX), + m_os_version_update(UINT32_MAX), + m_os_build(), + m_os_kernel(), + m_hostname(), + m_gdb_server_name(), + m_gdb_server_version(UINT32_MAX), + m_default_packet_timeout(0), + m_max_packet_size(0) { } @@ -820,7 +820,7 @@ GDBRemoteCommunicationClient::SendPacketAndWaitForResponse { if (IsRunning()) { - Mutex::Locker async_locker (m_async_mutex); + std::lock_guard<std::recursive_mutex> guard(m_async_mutex); m_async_packet.assign(payload, payload_length); m_async_response.CopyResponseValidator(response); m_async_packet_predicate.SetValue (true, eBroadcastNever); @@ -1372,7 +1372,7 @@ GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse bool GDBRemoteCommunicationClient::SendAsyncSignal (int signo) { - Mutex::Locker async_locker (m_async_mutex); + std::lock_guard<std::recursive_mutex> guard(m_async_mutex); m_async_signal = signo; bool timed_out = false; Mutex::Locker locker; diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index 33114d2611f..096c4cf8101 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include <map> +#include <mutex> #include <string> #include <vector> @@ -631,7 +632,7 @@ protected: // If we need to send a packet while the target is running, the m_async_XXX // member variables take care of making this happen. - Mutex m_async_mutex; + std::recursive_mutex m_async_mutex; Predicate<bool> m_async_packet_predicate; std::string m_async_packet; PacketResult m_async_result; diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h index f55b2eb3f4d..d2fd70042cc 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h @@ -17,7 +17,6 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-private-forward.h" -#include "lldb/Host/Mutex.h" #include "lldb/Target/Process.h" #include "GDBRemoteCommunicationServer.h" diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 0274aa89acc..66e300a519f 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -76,23 +76,22 @@ namespace //---------------------------------------------------------------------- // GDBRemoteCommunicationServerLLGS constructor //---------------------------------------------------------------------- -GDBRemoteCommunicationServerLLGS::GDBRemoteCommunicationServerLLGS( - const lldb::PlatformSP& platform_sp, - MainLoop &mainloop) : - GDBRemoteCommunicationServerCommon ("gdb-remote.server", "gdb-remote.server.rx_packet"), - m_platform_sp (platform_sp), - m_mainloop (mainloop), - m_current_tid (LLDB_INVALID_THREAD_ID), - m_continue_tid (LLDB_INVALID_THREAD_ID), - m_debugged_process_mutex (Mutex::eMutexTypeRecursive), - m_debugged_process_sp (), - m_stdio_communication ("process.stdio"), - m_inferior_prev_state (StateType::eStateInvalid), - m_active_auxv_buffer_sp (), - m_saved_registers_mutex (), - m_saved_registers_map (), - m_next_saved_registers_id (1), - m_handshake_completed (false) +GDBRemoteCommunicationServerLLGS::GDBRemoteCommunicationServerLLGS(const lldb::PlatformSP &platform_sp, + MainLoop &mainloop) + : GDBRemoteCommunicationServerCommon("gdb-remote.server", "gdb-remote.server.rx_packet"), + m_platform_sp(platform_sp), + m_mainloop(mainloop), + m_current_tid(LLDB_INVALID_THREAD_ID), + m_continue_tid(LLDB_INVALID_THREAD_ID), + m_debugged_process_mutex(), + m_debugged_process_sp(), + m_stdio_communication("process.stdio"), + m_inferior_prev_state(StateType::eStateInvalid), + m_active_auxv_buffer_sp(), + m_saved_registers_mutex(), + m_saved_registers_map(), + m_next_saved_registers_id(1), + m_handshake_completed(false) { assert(platform_sp); RegisterPacketHandlers(); @@ -210,7 +209,7 @@ GDBRemoteCommunicationServerLLGS::LaunchProcess () Error error; { - Mutex::Locker locker (m_debugged_process_mutex); + std::lock_guard<std::recursive_mutex> guard(m_debugged_process_mutex); assert (!m_debugged_process_sp && "lldb-gdbserver creating debugged process but one already exists"); error = NativeProcessProtocol::Launch( m_process_launch_info, @@ -2593,7 +2592,7 @@ GDBRemoteCommunicationServerLLGS::Handle_QSaveRegisterState (StringExtractorGDBR // Save the register data buffer under the save id. { - Mutex::Locker locker (m_saved_registers_mutex); + std::lock_guard<std::mutex> guard(m_saved_registers_mutex); m_saved_registers_map[save_id] = register_data_sp; } @@ -2643,7 +2642,7 @@ GDBRemoteCommunicationServerLLGS::Handle_QRestoreRegisterState (StringExtractorG // Retrieve register state buffer, then remove from the list. DataBufferSP register_data_sp; { - Mutex::Locker locker (m_saved_registers_mutex); + std::lock_guard<std::mutex> guard(m_saved_registers_mutex); // Find the register set buffer for the given save id. auto it = m_saved_registers_map.find (save_id); @@ -2947,7 +2946,7 @@ GDBRemoteCommunicationServerLLGS::GetCurrentThreadID () const uint32_t GDBRemoteCommunicationServerLLGS::GetNextSavedRegistersID () { - Mutex::Locker locker (m_saved_registers_mutex); + std::lock_guard<std::mutex> guard(m_saved_registers_mutex); return m_next_saved_registers_id++; } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h index f16057781dd..066e4985062 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h @@ -12,12 +12,12 @@ // C Includes // C++ Includes +#include <mutex> #include <unordered_map> // Other libraries and framework includes #include "lldb/lldb-private-forward.h" #include "lldb/Core/Communication.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Host/MainLoop.h" @@ -119,7 +119,7 @@ protected: MainLoop::ReadHandleUP m_network_handle_up; lldb::tid_t m_current_tid; lldb::tid_t m_continue_tid; - Mutex m_debugged_process_mutex; + std::recursive_mutex m_debugged_process_mutex; NativeProcessProtocolSP m_debugged_process_sp; Communication m_stdio_communication; @@ -127,7 +127,7 @@ protected: lldb::StateType m_inferior_prev_state; lldb::DataBufferSP m_active_auxv_buffer_sp; - Mutex m_saved_registers_mutex; + std::mutex m_saved_registers_mutex; std::unordered_map<uint32_t, lldb::DataBufferSP> m_saved_registers_map; uint32_t m_next_saved_registers_id; bool m_handshake_completed : 1; diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp index b2969746ce1..e16e9e4a3b8 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -48,14 +48,14 @@ using namespace lldb_private::process_gdb_remote; // GDBRemoteCommunicationServerPlatform constructor //---------------------------------------------------------------------- GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform(const Socket::SocketProtocol socket_protocol, - const char* socket_scheme) : - GDBRemoteCommunicationServerCommon ("gdb-remote.server", "gdb-remote.server.rx_packet"), - m_socket_protocol(socket_protocol), - m_socket_scheme(socket_scheme), - m_spawned_pids_mutex (Mutex::eMutexTypeRecursive), - m_platform_sp (Platform::GetHostPlatform ()), - m_port_map (), - m_port_offset(0) + const char *socket_scheme) + : GDBRemoteCommunicationServerCommon("gdb-remote.server", "gdb-remote.server.rx_packet"), + m_socket_protocol(socket_protocol), + m_socket_scheme(socket_scheme), + m_spawned_pids_mutex(), + m_platform_sp(Platform::GetHostPlatform()), + m_port_map(), + m_port_offset(0) { m_pending_gdb_server.pid = LLDB_INVALID_PROCESS_ID; m_pending_gdb_server.port = 0; @@ -78,11 +78,7 @@ GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform(const &GDBRemoteCommunicationServerPlatform::Handle_jSignalsInfo); RegisterPacketHandler(StringExtractorGDBRemote::eServerPacketType_interrupt, - [this](StringExtractorGDBRemote packet, - Error &error, - bool &interrupt, - bool &quit) - { + [this](StringExtractorGDBRemote packet, Error &error, bool &interrupt, bool &quit) { error.SetErrorString("interrupt received"); interrupt = true; return PacketResult::Success; @@ -156,7 +152,7 @@ GDBRemoteCommunicationServerPlatform::LaunchGDBServer(const lldb_private::Args& pid = debugserver_launch_info.GetProcessID(); if (pid != LLDB_INVALID_PROCESS_ID) { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex); m_spawned_pids.insert(pid); if (port > 0) AssociatePortWithProcess(port, pid); @@ -261,7 +257,7 @@ GDBRemoteCommunicationServerPlatform::Handle_qKillSpawnedProcess (StringExtracto // verify that we know anything about this pid. // Scope for locker { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex); if (m_spawned_pids.find(pid) == m_spawned_pids.end()) { // not a pid we know about @@ -281,7 +277,7 @@ GDBRemoteCommunicationServerPlatform::KillSpawnedProcess (lldb::pid_t pid) { // make sure we know about this process { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex); if (m_spawned_pids.find(pid) == m_spawned_pids.end()) return false; } @@ -293,7 +289,7 @@ GDBRemoteCommunicationServerPlatform::KillSpawnedProcess (lldb::pid_t pid) for (size_t i=0; i<10; ++i) { { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex); if (m_spawned_pids.find(pid) == m_spawned_pids.end()) { // it is now killed @@ -305,7 +301,7 @@ GDBRemoteCommunicationServerPlatform::KillSpawnedProcess (lldb::pid_t pid) // check one more time after the final usleep { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex); if (m_spawned_pids.find(pid) == m_spawned_pids.end()) return true; } @@ -317,7 +313,7 @@ GDBRemoteCommunicationServerPlatform::KillSpawnedProcess (lldb::pid_t pid) for (size_t i=0; i<10; ++i) { { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex); if (m_spawned_pids.find(pid) == m_spawned_pids.end()) { // it is now killed @@ -330,7 +326,7 @@ GDBRemoteCommunicationServerPlatform::KillSpawnedProcess (lldb::pid_t pid) // check one more time after the final usleep // Scope for locker { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex); if (m_spawned_pids.find(pid) == m_spawned_pids.end()) return true; } @@ -444,7 +440,7 @@ GDBRemoteCommunicationServerPlatform::Handle_jSignalsInfo(StringExtractorGDBRemo bool GDBRemoteCommunicationServerPlatform::DebugserverProcessReaped (lldb::pid_t pid) { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex); FreePortForProcess(pid); m_spawned_pids.erase(pid); return true; @@ -479,7 +475,7 @@ GDBRemoteCommunicationServerPlatform::LaunchProcess () if (pid != LLDB_INVALID_PROCESS_ID) { // add to spawned pids - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex); m_spawned_pids.insert(pid); } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h index 1e948d4d5c6..646d267dcb9 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include <map> +#include <mutex> #include <set> // Other libraries and framework includes @@ -82,7 +83,7 @@ public: protected: const Socket::SocketProtocol m_socket_protocol; const std::string m_socket_scheme; - Mutex m_spawned_pids_mutex; + std::recursive_mutex m_spawned_pids_mutex; std::set<lldb::pid_t> m_spawned_pids; lldb::PlatformSP m_platform_sp; diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index d9d551421f4..47a861042cd 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -267,39 +267,39 @@ ProcessGDBRemote::CanDebug (lldb::TargetSP target_sp, bool plugin_specified_by_n //---------------------------------------------------------------------- // ProcessGDBRemote constructor //---------------------------------------------------------------------- -ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp, ListenerSP listener_sp) : - Process (target_sp, listener_sp), - m_flags (0), - m_gdb_comm (), - m_debugserver_pid (LLDB_INVALID_PROCESS_ID), - m_last_stop_packet_mutex (Mutex::eMutexTypeRecursive), - m_register_info (), - m_async_broadcaster (NULL, "lldb.process.gdb-remote.async-broadcaster"), - m_async_listener_sp(Listener::MakeListener("lldb.process.gdb-remote.async-listener")), - m_async_thread_state_mutex(Mutex::eMutexTypeRecursive), - m_thread_ids (), - m_thread_pcs (), - m_jstopinfo_sp (), - m_jthreadsinfo_sp (), - m_continue_c_tids (), - m_continue_C_tids (), - m_continue_s_tids (), - m_continue_S_tids (), - m_max_memory_size (0), - m_remote_stub_max_memory_size (0), - m_addr_to_mmap_size (), - m_thread_create_bp_sp (), - m_waiting_for_attach (false), - m_destroy_tried_resuming (false), - m_command_sp (), - m_breakpoint_pc_offset (0), - m_initial_tid (LLDB_INVALID_THREAD_ID) +ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp, ListenerSP listener_sp) + : Process(target_sp, listener_sp), + m_flags(0), + m_gdb_comm(), + m_debugserver_pid(LLDB_INVALID_PROCESS_ID), + m_last_stop_packet_mutex(), + m_register_info(), + m_async_broadcaster(NULL, "lldb.process.gdb-remote.async-broadcaster"), + m_async_listener_sp(Listener::MakeListener("lldb.process.gdb-remote.async-listener")), + m_async_thread_state_mutex(), + m_thread_ids(), + m_thread_pcs(), + m_jstopinfo_sp(), + m_jthreadsinfo_sp(), + m_continue_c_tids(), + m_continue_C_tids(), + m_continue_s_tids(), + m_continue_S_tids(), + m_max_memory_size(0), + m_remote_stub_max_memory_size(0), + m_addr_to_mmap_size(), + m_thread_create_bp_sp(), + m_waiting_for_attach(false), + m_destroy_tried_resuming(false), + m_command_sp(), + m_breakpoint_pc_offset(0), + m_initial_tid(LLDB_INVALID_THREAD_ID) { - m_async_broadcaster.SetEventName (eBroadcastBitAsyncThreadShouldExit, "async thread should exit"); - m_async_broadcaster.SetEventName (eBroadcastBitAsyncContinue, "async thread continue"); - m_async_broadcaster.SetEventName (eBroadcastBitAsyncThreadDidExit, "async thread did exit"); + m_async_broadcaster.SetEventName(eBroadcastBitAsyncThreadShouldExit, "async thread should exit"); + m_async_broadcaster.SetEventName(eBroadcastBitAsyncContinue, "async thread continue"); + m_async_broadcaster.SetEventName(eBroadcastBitAsyncThreadDidExit, "async thread did exit"); - Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_ASYNC)); + Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_ASYNC)); const uint32_t async_event_mask = eBroadcastBitAsyncContinue | eBroadcastBitAsyncThreadShouldExit; @@ -309,8 +309,8 @@ ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp, ListenerSP listener log->Printf("ProcessGDBRemote::%s failed to listen for m_async_broadcaster events", __FUNCTION__); } - const uint32_t gdb_event_mask = Communication::eBroadcastBitReadThreadDidExit | - GDBRemoteCommunication::eBroadcastBitGdbReadThreadGotNotify; + const uint32_t gdb_event_mask = + Communication::eBroadcastBitReadThreadDidExit | GDBRemoteCommunication::eBroadcastBitGdbReadThreadGotNotify; if (m_async_listener_sp->StartListeningForEvents(&m_gdb_comm, gdb_event_mask) != gdb_event_mask) { if (log) @@ -1729,8 +1729,8 @@ ProcessGDBRemote::UpdateThreadIDList () // Lock the thread stack while we access it //Mutex::Locker stop_stack_lock(m_last_stop_packet_mutex); - Mutex::Locker stop_stack_lock; - if (stop_stack_lock.TryLock(m_last_stop_packet_mutex)) + std::unique_lock<std::recursive_mutex> stop_stack_lock(m_last_stop_packet_mutex, std::defer_lock); + if (stop_stack_lock.try_lock()) { // Get the number of stop packets on the stack int nItems = m_stop_packet_stack.size(); @@ -2673,7 +2673,7 @@ ProcessGDBRemote::RefreshStateAfterStop () // Scope for the lock { // Lock the thread stack while we access it - Mutex::Locker stop_stack_lock(m_last_stop_packet_mutex); + std::lock_guard<std::recursive_mutex> guard(m_last_stop_packet_mutex); // Get the number of stop packets on the stack int nItems = m_stop_packet_stack.size(); // Iterate over them @@ -2975,7 +2975,7 @@ ProcessGDBRemote::SetLastStopPacket (const StringExtractorGDBRemote &response) // Scope the lock { // Lock the thread stack while we access it - Mutex::Locker stop_stack_lock(m_last_stop_packet_mutex); + std::lock_guard<std::recursive_mutex> guard(m_last_stop_packet_mutex); // We are are not using non-stop mode, there can only be one last stop // reply packet, so clear the list. @@ -3761,7 +3761,7 @@ ProcessGDBRemote::StartAsyncThread () if (log) log->Printf ("ProcessGDBRemote::%s ()", __FUNCTION__); - Mutex::Locker start_locker(m_async_thread_state_mutex); + std::lock_guard<std::recursive_mutex> guard(m_async_thread_state_mutex); if (!m_async_thread.IsJoinable()) { // Create a thread that watches our internal state and controls which @@ -3783,7 +3783,7 @@ ProcessGDBRemote::StopAsyncThread () if (log) log->Printf ("ProcessGDBRemote::%s ()", __FUNCTION__); - Mutex::Locker start_locker(m_async_thread_state_mutex); + std::lock_guard<std::recursive_mutex> guard(m_async_thread_state_mutex); if (m_async_thread.IsJoinable()) { m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncThreadShouldExit); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index 815435c0f74..6d373965fc4 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -14,6 +14,7 @@ // C++ Includes #include <atomic> #include <map> +#include <mutex> #include <string> #include <vector> @@ -279,12 +280,12 @@ protected: GDBRemoteCommunicationClient m_gdb_comm; std::atomic<lldb::pid_t> m_debugserver_pid; std::vector<StringExtractorGDBRemote> m_stop_packet_stack; // The stop packet stack replaces the last stop packet variable - Mutex m_last_stop_packet_mutex; + std::recursive_mutex m_last_stop_packet_mutex; GDBRemoteDynamicRegisterInfo m_register_info; Broadcaster m_async_broadcaster; lldb::ListenerSP m_async_listener_sp; HostThread m_async_thread; - Mutex m_async_thread_state_mutex; + std::recursive_mutex m_async_thread_state_mutex; typedef std::vector<lldb::tid_t> tid_collection; typedef std::vector< std::pair<lldb::tid_t,int> > tid_sig_collection; typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index fed324a1a88..2c7914ad593 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2069,7 +2069,7 @@ DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Ty { SymbolFileDWARF *dwarf = die.GetDWARF(); - lldb_private::Mutex::Locker locker(dwarf->GetObjectFile()->GetModule()->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(dwarf->GetObjectFile()->GetModule()->GetMutex()); // Disable external storage for this type so we don't get anymore // clang::ExternalASTSource queries for this type. diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index e3e5b7cb0ed..a2c466aacd2 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1619,7 +1619,7 @@ SymbolFileDWARF::HasForwardDeclForClangType (const CompilerType &compiler_type) bool SymbolFileDWARF::CompleteType (CompilerType &compiler_type) { - lldb_private::Mutex::Locker locker(GetObjectFile()->GetModule()->GetMutex()); + std::lock_guard<std::recursive_mutex> guard(GetObjectFile()->GetModule()->GetMutex()); ClangASTContext *clang_type_system = llvm::dyn_cast_or_null<ClangASTContext>(compiler_type.GetTypeSystem()); if (clang_type_system) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index b762d641a4b..2cf497c9529 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -208,7 +208,7 @@ public: ObjectFile *oso_objfile = GetObjectFile (); if (oso_objfile) { - Mutex::Locker locker (m_mutex); + std::lock_guard<std::recursive_mutex> guard(m_mutex); SymbolVendor* symbol_vendor = Module::GetSymbolVendor(can_create, feedback_strm); if (symbol_vendor) { diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp index 688626e717d..38998469dcb 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp @@ -96,12 +96,12 @@ extern \"C\" } \n\ "; -AppleGetItemInfoHandler::AppleGetItemInfoHandler (Process *process) : - m_process (process), - m_get_item_info_impl_code (), - m_get_item_info_function_mutex(), - m_get_item_info_return_buffer_addr (LLDB_INVALID_ADDRESS), - m_get_item_info_retbuffer_mutex() +AppleGetItemInfoHandler::AppleGetItemInfoHandler(Process *process) + : m_process(process), + m_get_item_info_impl_code(), + m_get_item_info_function_mutex(), + m_get_item_info_return_buffer_addr(LLDB_INVALID_ADDRESS), + m_get_item_info_retbuffer_mutex() { } @@ -110,14 +110,14 @@ AppleGetItemInfoHandler::~AppleGetItemInfoHandler () } void -AppleGetItemInfoHandler::Detach () +AppleGetItemInfoHandler::Detach() { if (m_process && m_process->IsAlive() && m_get_item_info_return_buffer_addr != LLDB_INVALID_ADDRESS) { - Mutex::Locker locker; - locker.TryLock (m_get_item_info_retbuffer_mutex); // Even if we don't get the lock, deallocate the buffer - m_process->DeallocateMemory (m_get_item_info_return_buffer_addr); + std::unique_lock<std::mutex> lock(m_get_item_info_retbuffer_mutex, std::defer_lock); + lock.try_lock(); // Even if we don't get the lock, deallocate the buffer + m_process->DeallocateMemory(m_get_item_info_return_buffer_addr); } } @@ -143,8 +143,8 @@ AppleGetItemInfoHandler::SetupGetItemInfoFunction(Thread &thread, ValueList &get // Scope for mutex locker: { - Mutex::Locker locker(m_get_item_info_function_mutex); - + std::lock_guard<std::mutex> guard(m_get_item_info_function_mutex); + // First stage is to make the UtilityFunction to hold our injected function: if (!m_get_item_info_impl_code.get()) @@ -296,8 +296,7 @@ AppleGetItemInfoHandler::GetItemInfo (Thread &thread, uint64_t item, addr_t page page_to_free_size_value.SetValueType (Value::eValueTypeScalar); page_to_free_size_value.SetCompilerType (clang_uint64_type); - - Mutex::Locker locker(m_get_item_info_retbuffer_mutex); + std::lock_guard<std::mutex> guard(m_get_item_info_retbuffer_mutex); if (m_get_item_info_return_buffer_addr == LLDB_INVALID_ADDRESS) { addr_t bufaddr = process_sp->AllocateMemory (32, ePermissionsReadable | ePermissionsWritable, error); diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h index 51182a62493..dc341d672d6 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h @@ -13,13 +13,14 @@ // C Includes // C++ Includes #include <map> +#include <mutex> #include <vector> + // Other libraries and framework includes // Project includes #include "lldb/lldb-public.h" #include "lldb/Core/Error.h" #include "lldb/Expression/UtilityFunction.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/CompilerType.h" // This class will insert a UtilityFunction into the inferior process for @@ -105,11 +106,10 @@ private: lldb_private::Process *m_process; std::unique_ptr<UtilityFunction> m_get_item_info_impl_code; - Mutex m_get_item_info_function_mutex; + std::mutex m_get_item_info_function_mutex; lldb::addr_t m_get_item_info_return_buffer_addr; - Mutex m_get_item_info_retbuffer_mutex; - + std::mutex m_get_item_info_retbuffer_mutex; }; } // using namespace lldb_private diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp index c262ffc9fba..d311f5fb5f6 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp @@ -100,12 +100,12 @@ extern \"C\" } \n\ "; -AppleGetPendingItemsHandler::AppleGetPendingItemsHandler (Process *process) : - m_process (process), - m_get_pending_items_impl_code (), - m_get_pending_items_function_mutex(), - m_get_pending_items_return_buffer_addr (LLDB_INVALID_ADDRESS), - m_get_pending_items_retbuffer_mutex() +AppleGetPendingItemsHandler::AppleGetPendingItemsHandler(Process *process) + : m_process(process), + m_get_pending_items_impl_code(), + m_get_pending_items_function_mutex(), + m_get_pending_items_return_buffer_addr(LLDB_INVALID_ADDRESS), + m_get_pending_items_retbuffer_mutex() { } @@ -114,14 +114,13 @@ AppleGetPendingItemsHandler::~AppleGetPendingItemsHandler () } void -AppleGetPendingItemsHandler::Detach () +AppleGetPendingItemsHandler::Detach() { - if (m_process && m_process->IsAlive() && m_get_pending_items_return_buffer_addr != LLDB_INVALID_ADDRESS) { - Mutex::Locker locker; - locker.TryLock (m_get_pending_items_retbuffer_mutex); // Even if we don't get the lock, deallocate the buffer - m_process->DeallocateMemory (m_get_pending_items_return_buffer_addr); + std::unique_lock<std::mutex> lock(m_get_pending_items_retbuffer_mutex, std::defer_lock); + lock.try_lock(); // Even if we don't get the lock, deallocate the buffer + m_process->DeallocateMemory(m_get_pending_items_return_buffer_addr); } } @@ -149,8 +148,8 @@ AppleGetPendingItemsHandler::SetupGetPendingItemsFunction(Thread &thread, ValueL // Scope for mutex locker: { - Mutex::Locker locker(m_get_pending_items_function_mutex); - + std::lock_guard<std::mutex> guard(m_get_pending_items_function_mutex); + // First stage is to make the ClangUtility to hold our injected function: if (!m_get_pending_items_impl_code.get()) @@ -298,8 +297,7 @@ AppleGetPendingItemsHandler::GetPendingItems (Thread &thread, addr_t queue, addr page_to_free_size_value.SetValueType (Value::eValueTypeScalar); page_to_free_size_value.SetCompilerType (clang_uint64_type); - - Mutex::Locker locker(m_get_pending_items_retbuffer_mutex); + std::lock_guard<std::mutex> guard(m_get_pending_items_retbuffer_mutex); if (m_get_pending_items_return_buffer_addr == LLDB_INVALID_ADDRESS) { addr_t bufaddr = process_sp->AllocateMemory (32, ePermissionsReadable | ePermissionsWritable, error); diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h index 445c4a0fb82..96fbf4a548c 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h @@ -13,12 +13,13 @@ // C Includes // C++ Includes #include <map> +#include <mutex> #include <vector> + // Other libraries and framework includes // Project includes #include "lldb/lldb-public.h" #include "lldb/Core/Error.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/CompilerType.h" // This class will insert a UtilityFunction into the inferior process for @@ -107,11 +108,10 @@ private: lldb_private::Process *m_process; std::unique_ptr<UtilityFunction> m_get_pending_items_impl_code; - Mutex m_get_pending_items_function_mutex; + std::mutex m_get_pending_items_function_mutex; lldb::addr_t m_get_pending_items_return_buffer_addr; - Mutex m_get_pending_items_retbuffer_mutex; - + std::mutex m_get_pending_items_retbuffer_mutex; }; } // using namespace lldb_private diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp index e1f045124ee..e90fe6d5d17 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp @@ -96,12 +96,12 @@ extern \"C\" } \n\ "; -AppleGetQueuesHandler::AppleGetQueuesHandler (Process *process) : - m_process (process), - m_get_queues_impl_code_up (), - m_get_queues_function_mutex(), - m_get_queues_return_buffer_addr (LLDB_INVALID_ADDRESS), - m_get_queues_retbuffer_mutex() +AppleGetQueuesHandler::AppleGetQueuesHandler(Process *process) + : m_process(process), + m_get_queues_impl_code_up(), + m_get_queues_function_mutex(), + m_get_queues_return_buffer_addr(LLDB_INVALID_ADDRESS), + m_get_queues_retbuffer_mutex() { } @@ -110,14 +110,14 @@ AppleGetQueuesHandler::~AppleGetQueuesHandler () } void -AppleGetQueuesHandler::Detach () +AppleGetQueuesHandler::Detach() { if (m_process && m_process->IsAlive() && m_get_queues_return_buffer_addr != LLDB_INVALID_ADDRESS) { - Mutex::Locker locker; - locker.TryLock (m_get_queues_retbuffer_mutex); // Even if we don't get the lock, deallocate the buffer - m_process->DeallocateMemory (m_get_queues_return_buffer_addr); + std::unique_lock<std::mutex> lock(m_get_queues_retbuffer_mutex, std::defer_lock); + lock.try_lock(); // Even if we don't get the lock, deallocate the buffer + m_process->DeallocateMemory(m_get_queues_return_buffer_addr); } } @@ -159,8 +159,8 @@ AppleGetQueuesHandler::SetupGetQueuesFunction (Thread &thread, ValueList &get_qu // Scope for mutex locker: { - Mutex::Locker locker(m_get_queues_function_mutex); - + std::lock_guard<std::mutex> guard(m_get_queues_function_mutex); + // First stage is to make the ClangUtility to hold our injected function: if (!m_get_queues_impl_code_up.get()) @@ -297,8 +297,7 @@ AppleGetQueuesHandler::GetCurrentQueues (Thread &thread, addr_t page_to_free, ui page_to_free_size_value.SetValueType (Value::eValueTypeScalar); page_to_free_size_value.SetCompilerType (clang_uint64_type); - - Mutex::Locker locker(m_get_queues_retbuffer_mutex); + std::lock_guard<std::mutex> guard(m_get_queues_retbuffer_mutex); if (m_get_queues_return_buffer_addr == LLDB_INVALID_ADDRESS) { addr_t bufaddr = process_sp->AllocateMemory (32, ePermissionsReadable | ePermissionsWritable, error); diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h index 6f3df5f6280..b7ca26dafc3 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h @@ -13,12 +13,13 @@ // C Includes // C++ Includes #include <map> +#include <mutex> #include <vector> + // Other libraries and framework includes // Project includes #include "lldb/lldb-public.h" #include "lldb/Core/Error.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/CompilerType.h" // This class will insert a UtilityFunction into the inferior process for @@ -104,11 +105,10 @@ private: lldb_private::Process *m_process; std::unique_ptr<UtilityFunction> m_get_queues_impl_code_up; - Mutex m_get_queues_function_mutex; + std::mutex m_get_queues_function_mutex; lldb::addr_t m_get_queues_return_buffer_addr; - Mutex m_get_queues_retbuffer_mutex; - + std::mutex m_get_queues_retbuffer_mutex; }; } // using namespace lldb_private diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp index 266e461a8a4..85ad012c59f 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp @@ -103,12 +103,12 @@ extern \"C\" } \n\ "; -AppleGetThreadItemInfoHandler::AppleGetThreadItemInfoHandler (Process *process) : - m_process (process), - m_get_thread_item_info_impl_code (), - m_get_thread_item_info_function_mutex(), - m_get_thread_item_info_return_buffer_addr (LLDB_INVALID_ADDRESS), - m_get_thread_item_info_retbuffer_mutex() +AppleGetThreadItemInfoHandler::AppleGetThreadItemInfoHandler(Process *process) + : m_process(process), + m_get_thread_item_info_impl_code(), + m_get_thread_item_info_function_mutex(), + m_get_thread_item_info_return_buffer_addr(LLDB_INVALID_ADDRESS), + m_get_thread_item_info_retbuffer_mutex() { } @@ -117,14 +117,14 @@ AppleGetThreadItemInfoHandler::~AppleGetThreadItemInfoHandler () } void -AppleGetThreadItemInfoHandler::Detach () +AppleGetThreadItemInfoHandler::Detach() { if (m_process && m_process->IsAlive() && m_get_thread_item_info_return_buffer_addr != LLDB_INVALID_ADDRESS) { - Mutex::Locker locker; - locker.TryLock (m_get_thread_item_info_retbuffer_mutex); // Even if we don't get the lock, deallocate the buffer - m_process->DeallocateMemory (m_get_thread_item_info_return_buffer_addr); + std::unique_lock<std::mutex> lock(m_get_thread_item_info_retbuffer_mutex, std::defer_lock); + lock.try_lock(); // Even if we don't get the lock, deallocate the buffer + m_process->DeallocateMemory(m_get_thread_item_info_return_buffer_addr); } } @@ -152,8 +152,8 @@ AppleGetThreadItemInfoHandler::SetupGetThreadItemInfoFunction (Thread &thread, V // Scope for mutex locker: { - Mutex::Locker locker(m_get_thread_item_info_function_mutex); - + std::lock_guard<std::mutex> guard(m_get_thread_item_info_function_mutex); + // First stage is to make the ClangUtility to hold our injected function: if (!m_get_thread_item_info_impl_code.get()) @@ -300,8 +300,7 @@ AppleGetThreadItemInfoHandler::GetThreadItemInfo (Thread &thread, tid_t thread_i page_to_free_size_value.SetValueType (Value::eValueTypeScalar); page_to_free_size_value.SetCompilerType (clang_uint64_type); - - Mutex::Locker locker(m_get_thread_item_info_retbuffer_mutex); + std::lock_guard<std::mutex> guard(m_get_thread_item_info_retbuffer_mutex); if (m_get_thread_item_info_return_buffer_addr == LLDB_INVALID_ADDRESS) { addr_t bufaddr = process_sp->AllocateMemory (32, ePermissionsReadable | ePermissionsWritable, error); diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h index c1798fb515b..21a63e8c225 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h @@ -13,12 +13,13 @@ // C Includes // C++ Includes #include <map> +#include <mutex> #include <vector> + // Other libraries and framework includes // Project includes #include "lldb/lldb-public.h" #include "lldb/Core/Error.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/CompilerType.h" // This class will insert a UtilityFunction into the inferior process for @@ -101,11 +102,10 @@ private: lldb_private::Process *m_process; std::unique_ptr<UtilityFunction> m_get_thread_item_info_impl_code; - Mutex m_get_thread_item_info_function_mutex; + std::mutex m_get_thread_item_info_function_mutex; lldb::addr_t m_get_thread_item_info_return_buffer_addr; - Mutex m_get_thread_item_info_retbuffer_mutex; - + std::mutex m_get_thread_item_info_retbuffer_mutex; }; } // using namespace lldb_private diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp index 37af5b83019..9ec36b383af 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp @@ -83,25 +83,25 @@ SystemRuntimeMacOSX::CreateInstance (Process* process) //---------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------- -SystemRuntimeMacOSX::SystemRuntimeMacOSX (Process* process) : - SystemRuntime(process), - m_break_id(LLDB_INVALID_BREAK_ID), - m_mutex(Mutex::eMutexTypeRecursive), - m_get_queues_handler(process), - m_get_pending_items_handler(process), - m_get_item_info_handler(process), - m_get_thread_item_info_handler(process), - m_page_to_free(LLDB_INVALID_ADDRESS), - m_page_to_free_size(0), - m_lib_backtrace_recording_info(), - m_dispatch_queue_offsets_addr (LLDB_INVALID_ADDRESS), - m_libdispatch_offsets(), - m_libpthread_layout_offsets_addr (LLDB_INVALID_ADDRESS), - m_libpthread_offsets(), - m_dispatch_tsd_indexes_addr (LLDB_INVALID_ADDRESS), - m_libdispatch_tsd_indexes(), - m_dispatch_voucher_offsets_addr (LLDB_INVALID_ADDRESS), - m_libdispatch_voucher_offsets() +SystemRuntimeMacOSX::SystemRuntimeMacOSX(Process *process) + : SystemRuntime(process), + m_break_id(LLDB_INVALID_BREAK_ID), + m_mutex(), + m_get_queues_handler(process), + m_get_pending_items_handler(process), + m_get_item_info_handler(process), + m_get_thread_item_info_handler(process), + m_page_to_free(LLDB_INVALID_ADDRESS), + m_page_to_free_size(0), + m_lib_backtrace_recording_info(), + m_dispatch_queue_offsets_addr(LLDB_INVALID_ADDRESS), + m_libdispatch_offsets(), + m_libpthread_layout_offsets_addr(LLDB_INVALID_ADDRESS), + m_libpthread_offsets(), + m_dispatch_tsd_indexes_addr(LLDB_INVALID_ADDRESS), + m_libdispatch_tsd_indexes(), + m_dispatch_voucher_offsets_addr(LLDB_INVALID_ADDRESS), + m_libdispatch_voucher_offsets() { } @@ -128,7 +128,7 @@ SystemRuntimeMacOSX::Detach () void SystemRuntimeMacOSX::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); diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h index 8fe15fa4d8a..b685a056f5c 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h @@ -12,8 +12,9 @@ // C Includes // C++ Includes -#include <vector> +#include <mutex> #include <string> +#include <vector> // Other libraries and framework include // Project includes @@ -23,7 +24,6 @@ #include "lldb/Core/StructuredData.h" #include "lldb/Core/UUID.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Host/Mutex.h" #include "lldb/Target/Process.h" #include "lldb/Target/QueueItem.h" @@ -124,7 +124,7 @@ public: protected: lldb::user_id_t m_break_id; - mutable lldb_private::Mutex m_mutex; + mutable std::recursive_mutex m_mutex; private: struct libBacktraceRecording_info { |