diff options
| author | Saleem Abdulrasool <compnerd@compnerd.org> | 2016-05-18 01:59:10 +0000 |
|---|---|---|
| committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2016-05-18 01:59:10 +0000 |
| commit | 16ff8604690ea63a3a82dd3b156061afb84dbcf1 (patch) | |
| tree | a2d912258ecb0690f4a810ca1e438fc277160326 /lldb/source/Plugins/SystemRuntime | |
| parent | a36a61d46ac3f2ea10e78ac816bca5784bc8ba35 (diff) | |
| download | bcm5719-llvm-16ff8604690ea63a3a82dd3b156061afb84dbcf1.tar.gz bcm5719-llvm-16ff8604690ea63a3a82dd3b156061afb84dbcf1.zip | |
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
Diffstat (limited to 'lldb/source/Plugins/SystemRuntime')
10 files changed, 91 insertions, 96 deletions
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 { |

