Index: include/lldb/Breakpoint/BreakpointLocationList.h =================================================================== --- include/lldb/Breakpoint/BreakpointLocationList.h +++ include/lldb/Breakpoint/BreakpointLocationList.h @@ -13,13 +13,13 @@ // C Includes // C++ Includes #include +#include #include // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" #include "lldb/Core/Address.h" -#include "lldb/Host/Mutex.h" #include "lldb/Utility/Iterable.h" namespace lldb_private { @@ -270,7 +270,7 @@ Breakpoint &m_owner; collection m_locations; // Vector of locations, sorted by ID addr_map m_address_to_location; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; lldb::break_id_t m_next_id; BreakpointLocationCollection *m_new_location_recorder; Index: include/lldb/Breakpoint/BreakpointSite.h =================================================================== --- include/lldb/Breakpoint/BreakpointSite.h +++ include/lldb/Breakpoint/BreakpointSite.h @@ -14,12 +14,12 @@ // C++ Includes #include +#include // Other libraries and framework includes // Project includes #include "lldb/lldb-forward.h" -#include "lldb/Host/Mutex.h" #include "lldb/Core/UserID.h" #include "lldb/Breakpoint/StoppointLocation.h" #include "lldb/Breakpoint/BreakpointLocationCollection.h" @@ -297,7 +297,7 @@ // Consider adding an optimization where if there is only one // owner, we don't store a list. The usual case will be only one owner... BreakpointLocationCollection m_owners; ///< This has the BreakpointLocations that share this breakpoint site. - Mutex m_owners_mutex; ///< This mutex protects the owners collection. + std::recursive_mutex m_owners_mutex; ///< This mutex protects the owners collection. static lldb::break_id_t GetNextID(); Index: include/lldb/Breakpoint/BreakpointSiteList.h =================================================================== --- include/lldb/Breakpoint/BreakpointSiteList.h +++ include/lldb/Breakpoint/BreakpointSiteList.h @@ -13,11 +13,12 @@ // C Includes // C++ Includes #include +#include #include + // Other libraries and framework includes // Project includes #include "lldb/Breakpoint/BreakpointSite.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -189,16 +190,17 @@ size_t GetSize() const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return m_bp_site_list.size(); } bool IsEmpty() const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return m_bp_site_list.empty(); } + protected: typedef std::map collection; @@ -208,7 +210,7 @@ collection::const_iterator GetIDConstIterator(lldb::break_id_t breakID) const; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; collection m_bp_site_list; // The breakpoint site list. }; Index: include/lldb/Core/Broadcaster.h =================================================================== --- include/lldb/Core/Broadcaster.h +++ include/lldb/Core/Broadcaster.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -22,7 +23,6 @@ // Project includes #include "lldb/lldb-private.h" #include "lldb/Core/ConstString.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -126,8 +126,8 @@ typedef std::set listener_collection; collection m_event_map; listener_collection m_listeners; - - Mutex m_manager_mutex; + + mutable std::recursive_mutex m_manager_mutex; // A couple of comparator classes for find_if: @@ -625,7 +625,7 @@ Broadcaster &m_broadcaster; ///< The broadcsater that this implements event_names_map m_event_names; ///< Optionally define event names for readability and logging for each event bit collection m_listeners; ///< A list of Listener / event_mask pairs that are listening to this broadcaster. - Mutex m_listeners_mutex; ///< A mutex that protects \a m_listeners. + std::recursive_mutex m_listeners_mutex; ///< A mutex that protects \a m_listeners. std::vector m_hijacking_listeners; // A simple mechanism to intercept events from a broadcaster std::vector m_hijacking_masks; // At some point we may want to have a stack or Listener // collections, but for now this is just for private hijacking. Index: include/lldb/Core/Communication.h =================================================================== --- include/lldb/Core/Communication.h +++ include/lldb/Core/Communication.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include +#include #include // Other libraries and framework includes @@ -21,7 +22,6 @@ #include "lldb/Core/Broadcaster.h" #include "lldb/Core/Error.h" #include "lldb/Host/HostThread.h" -#include "lldb/Host/Mutex.h" #include "lldb/lldb-private.h" namespace lldb_private { @@ -358,10 +358,10 @@ HostThread m_read_thread; ///< The read thread handle in case we need to cancel the thread. std::atomic m_read_thread_enabled; std::atomic m_read_thread_did_exit; - std::string m_bytes; ///< A buffer to cache bytes read in the ReadThread function. - Mutex m_bytes_mutex; ///< A mutex to protect multi-threaded access to the cached bytes. - Mutex m_write_mutex; ///< Don't let multiple threads write at the same time... - Mutex m_synchronize_mutex; + std::string m_bytes; ///< A buffer to cache bytes read in the ReadThread function. + std::recursive_mutex m_bytes_mutex; ///< A mutex to protect multi-threaded access to the cached bytes. + std::mutex m_write_mutex; ///< Don't let multiple threads write at the same time... + std::mutex m_synchronize_mutex; ReadThreadBytesReceived m_callback; void *m_callback_baton; bool m_close_on_eof; Index: include/lldb/Core/History.h =================================================================== --- include/lldb/Core/History.h +++ include/lldb/Core/History.h @@ -14,13 +14,13 @@ #include // C++ Includes +#include #include #include // Other libraries and framework includes // Project includes #include "lldb/lldb-public.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -34,11 +34,7 @@ public: typedef const void * HistoryEvent; - HistorySource () : - m_mutex (Mutex::eMutexTypeRecursive), - m_events () - { - } + HistorySource() : m_mutex(), m_events() {} virtual ~HistorySource() @@ -51,19 +47,19 @@ virtual HistoryEvent CreateHistoryEvent () = 0; - + virtual void DeleteHistoryEvent (HistoryEvent event) = 0; - + virtual void DumpHistoryEvent (Stream &strm, HistoryEvent event) = 0; virtual size_t GetHistoryEventCount() = 0; - + virtual HistoryEvent GetHistoryEventAtIndex (uint32_t idx) = 0; - + virtual HistoryEvent GetCurrentHistoryEvent () = 0; @@ -71,16 +67,16 @@ virtual int CompareHistoryEvents (const HistoryEvent lhs, const HistoryEvent rhs) = 0; - + virtual bool IsCurrentHistoryEvent (const HistoryEvent event) = 0; private: typedef std::stack collection; - Mutex m_mutex; + std::recursive_mutex m_mutex; collection m_events; - + DISALLOW_COPY_AND_ASSIGN (HistorySource); }; Index: include/lldb/Core/IOHandler.h =================================================================== --- include/lldb/Core/IOHandler.h +++ include/lldb/Core/IOHandler.h @@ -15,6 +15,7 @@ // C++ Includes #include +#include #include #include @@ -709,75 +710,70 @@ class IOHandlerStack { public: - IOHandlerStack () : - m_stack(), - m_mutex(Mutex::eMutexTypeRecursive), - m_top (nullptr) - { - } - + IOHandlerStack() : m_stack(), m_mutex(), m_top(nullptr) {} + ~IOHandlerStack() = default; - + size_t - GetSize () const + GetSize() const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); return m_stack.size(); } - + void - Push (const lldb::IOHandlerSP& sp) + Push(const lldb::IOHandlerSP &sp) { if (sp) { - Mutex::Locker locker (m_mutex); - sp->SetPopped (false); - m_stack.push_back (sp); + std::lock_guard guard(m_mutex); + sp->SetPopped(false); + m_stack.push_back(sp); // Set m_top the non-locking IsTop() call m_top = sp.get(); } } - + bool - IsEmpty () const + IsEmpty() const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); return m_stack.empty(); } - + lldb::IOHandlerSP - Top () + Top() { lldb::IOHandlerSP sp; { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (!m_stack.empty()) sp = m_stack.back(); } return sp; } - + void - Pop () + Pop() { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (!m_stack.empty()) { - lldb::IOHandlerSP sp (m_stack.back()); + lldb::IOHandlerSP sp(m_stack.back()); m_stack.pop_back(); - sp->SetPopped (true); + sp->SetPopped(true); } // Set m_top the non-locking IsTop() call m_top = (m_stack.empty() ? nullptr : m_stack.back().get()); } - Mutex & + std::recursive_mutex & GetMutex() { return m_mutex; } - + bool IsTop (const lldb::IOHandlerSP &io_handler_sp) const { @@ -785,13 +781,12 @@ } bool - CheckTopIOHandlerTypes (IOHandler::Type top_type, IOHandler::Type second_top_type) + CheckTopIOHandlerTypes(IOHandler::Type top_type, IOHandler::Type second_top_type) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); const size_t num_io_handlers = m_stack.size(); - return (num_io_handlers >= 2 && - m_stack[num_io_handlers-1]->GetType() == top_type && - m_stack[num_io_handlers-2]->GetType() == second_top_type); + return (num_io_handlers >= 2 && m_stack[num_io_handlers - 1]->GetType() == top_type && + m_stack[num_io_handlers - 2]->GetType() == second_top_type); } ConstString @@ -818,9 +813,9 @@ protected: typedef std::vector collection; collection m_stack; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; IOHandler *m_top; - + private: DISALLOW_COPY_AND_ASSIGN (IOHandlerStack); }; Index: include/lldb/Core/Listener.h =================================================================== --- include/lldb/Core/Listener.h +++ include/lldb/Core/Listener.h @@ -14,6 +14,7 @@ // C++ Includes #include #include +#include #include #include @@ -175,7 +176,7 @@ std::string m_name; broadcaster_collection m_broadcasters; - Mutex m_broadcasters_mutex; // Protects m_broadcasters + std::recursive_mutex m_broadcasters_mutex; // Protects m_broadcasters event_collection m_events; Mutex m_events_mutex; // Protects m_broadcasters and m_events Condition m_events_condition; Index: include/lldb/Core/Module.h =================================================================== --- include/lldb/Core/Module.h +++ include/lldb/Core/Module.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include +#include #include #include @@ -22,7 +23,6 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/UUID.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/TimeValue.h" #include "lldb/Symbol/SymbolContextScope.h" #include "lldb/Symbol/TypeSystem.h" @@ -68,7 +68,7 @@ static Module * GetAllocatedModuleAtIndex (size_t idx); - static Mutex * + static std::recursive_mutex & GetAllocationModuleCollectionMutex(); //------------------------------------------------------------------ @@ -986,8 +986,8 @@ // SymbolVendor, SymbolFile and ObjectFile member objects should // lock the module mutex to avoid deadlocks. //------------------------------------------------------------------ - Mutex & - GetMutex () const + std::recursive_mutex & + GetMutex() const { return m_mutex; } @@ -1106,7 +1106,7 @@ //------------------------------------------------------------------ // Member Variables //------------------------------------------------------------------ - mutable Mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments. + mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments. TimeValue m_mod_time; ///< The modification time for this module when it was created. ArchSpec m_arch; ///< The architecture for this module. UUID m_uuid; ///< Each module is assumed to have a unique identifier to help match it up to debug symbols. Index: include/lldb/Core/ModuleSpec.h =================================================================== --- include/lldb/Core/ModuleSpec.h +++ include/lldb/Core/ModuleSpec.h @@ -12,6 +12,7 @@ // C Includes // C++ Includes +#include #include // Other libraries and framework includes @@ -20,7 +21,6 @@ #include "lldb/Core/Stream.h" #include "lldb/Core/UUID.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Host/Mutex.h" #include "lldb/Target/PathMappingList.h" namespace lldb_private { @@ -447,30 +447,24 @@ class ModuleSpecList { public: - ModuleSpecList () : - m_specs(), - m_mutex(Mutex::eMutexTypeRecursive) - { - } + ModuleSpecList() : m_specs(), m_mutex() {} - ModuleSpecList (const ModuleSpecList &rhs) : - m_specs(), - m_mutex(Mutex::eMutexTypeRecursive) + ModuleSpecList(const ModuleSpecList &rhs) : m_specs(), m_mutex() { - Mutex::Locker lhs_locker(m_mutex); - Mutex::Locker rhs_locker(rhs.m_mutex); + std::lock_guard lhs_guard(m_mutex); + std::lock_guard rhs_guard(rhs.m_mutex); m_specs = rhs.m_specs; } ~ModuleSpecList() = default; ModuleSpecList & - operator = (const ModuleSpecList &rhs) + operator=(const ModuleSpecList &rhs) { if (this != &rhs) { - Mutex::Locker lhs_locker(m_mutex); - Mutex::Locker rhs_locker(rhs.m_mutex); + std::lock_guard lhs_guard(m_mutex); + std::lock_guard rhs_guard(rhs.m_mutex); m_specs = rhs.m_specs; } return *this; @@ -479,29 +473,29 @@ size_t GetSize() const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return m_specs.size(); } void - Clear () + Clear() { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); m_specs.clear(); } void - Append (const ModuleSpec &spec) + Append(const ModuleSpec &spec) { - Mutex::Locker locker(m_mutex); - m_specs.push_back (spec); + std::lock_guard guard(m_mutex); + m_specs.push_back(spec); } void - Append (const ModuleSpecList &rhs) + Append(const ModuleSpecList &rhs) { - Mutex::Locker lhs_locker(m_mutex); - Mutex::Locker rhs_locker(rhs.m_mutex); + std::lock_guard lhs_guard(m_mutex); + std::lock_guard rhs_guard(rhs.m_mutex); m_specs.insert(m_specs.end(), rhs.m_specs.begin(), rhs.m_specs.end()); } @@ -514,9 +508,9 @@ } bool - GetModuleSpecAtIndex (size_t i, ModuleSpec &module_spec) const + GetModuleSpecAtIndex(size_t i, ModuleSpec &module_spec) const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (i < m_specs.size()) { module_spec = m_specs[i]; @@ -527,11 +521,11 @@ } bool - FindMatchingModuleSpec (const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const + FindMatchingModuleSpec(const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); bool exact_arch_match = true; - for (auto spec: m_specs) + for (auto spec : m_specs) { if (spec.Matches(module_spec, exact_arch_match)) { @@ -539,12 +533,12 @@ return true; } } - + // If there was an architecture, retry with a compatible arch if (module_spec.GetArchitecturePtr()) { exact_arch_match = false; - for (auto spec: m_specs) + for (auto spec : m_specs) { if (spec.Matches(module_spec, exact_arch_match)) { @@ -556,41 +550,41 @@ match_module_spec.Clear(); return false; } - + size_t - FindMatchingModuleSpecs (const ModuleSpec &module_spec, ModuleSpecList &matching_list) const + FindMatchingModuleSpecs(const ModuleSpec &module_spec, ModuleSpecList &matching_list) const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); bool exact_arch_match = true; const size_t initial_match_count = matching_list.GetSize(); - for (auto spec: m_specs) + for (auto spec : m_specs) { if (spec.Matches(module_spec, exact_arch_match)) - matching_list.Append (spec); + matching_list.Append(spec); } - + // If there was an architecture, retry with a compatible arch if no matches were found if (module_spec.GetArchitecturePtr() && (initial_match_count == matching_list.GetSize())) { exact_arch_match = false; - for (auto spec: m_specs) + for (auto spec : m_specs) { if (spec.Matches(module_spec, exact_arch_match)) - matching_list.Append (spec); + matching_list.Append(spec); } } return matching_list.GetSize() - initial_match_count; } void - Dump (Stream &strm) + Dump(Stream &strm) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); uint32_t idx = 0; - for (auto spec: m_specs) + for (auto spec : m_specs) { strm.Printf("[%u] ", idx); - spec.Dump (strm); + spec.Dump(strm); strm.EOL(); ++idx; } @@ -599,7 +593,7 @@ protected: typedef std::vector collection; ///< The module collection type. collection m_specs; ///< The collection of modules. - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; }; } // namespace lldb_private Index: include/lldb/Core/StreamCallback.h =================================================================== --- include/lldb/Core/StreamCallback.h +++ include/lldb/Core/StreamCallback.h @@ -10,11 +10,11 @@ #ifndef liblldb_StreamCallback_h_ #define liblldb_StreamCallback_h_ +#include #include #include "lldb/Core/Stream.h" #include "lldb/Core/StreamString.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -37,8 +37,8 @@ lldb::LogOutputCallback m_callback; void *m_baton; collection m_accumulated_data; - Mutex m_collection_mutex; - + std::mutex m_collection_mutex; + StreamString &FindStreamForThread(lldb::tid_t cur_tid); }; Index: include/lldb/Core/StreamTee.h =================================================================== --- include/lldb/Core/StreamTee.h +++ include/lldb/Core/StreamTee.h @@ -12,50 +12,37 @@ #include +#include + #include "lldb/Core/Stream.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { class StreamTee : public Stream { public: - StreamTee () : - Stream (), - m_streams_mutex (Mutex::eMutexTypeRecursive), - m_streams () - { - } + StreamTee() : Stream(), m_streams_mutex(), m_streams() {} - StreamTee (lldb::StreamSP &stream_sp): - Stream (), - m_streams_mutex (Mutex::eMutexTypeRecursive), - m_streams () + StreamTee(lldb::StreamSP &stream_sp) : Stream(), m_streams_mutex(), m_streams() { // No need to lock mutex during construction if (stream_sp) - m_streams.push_back (stream_sp); + m_streams.push_back(stream_sp); } - - StreamTee (lldb::StreamSP &stream_sp, lldb::StreamSP &stream_2_sp) : - Stream (), - m_streams_mutex (Mutex::eMutexTypeRecursive), - m_streams () + StreamTee(lldb::StreamSP &stream_sp, lldb::StreamSP &stream_2_sp) : Stream(), m_streams_mutex(), m_streams() { // No need to lock mutex during construction if (stream_sp) - m_streams.push_back (stream_sp); + m_streams.push_back(stream_sp); if (stream_2_sp) - m_streams.push_back (stream_2_sp); + m_streams.push_back(stream_2_sp); } - - StreamTee (const StreamTee &rhs) : - Stream (rhs), - m_streams_mutex (Mutex::eMutexTypeRecursive), - m_streams() // Don't copy until we lock down "rhs" + + StreamTee(const StreamTee &rhs) : Stream(rhs), m_streams_mutex(), m_streams() { - Mutex::Locker locker (rhs.m_streams_mutex); + // Don't copy until we lock down "rhs" + std::lock_guard guard(rhs.m_streams_mutex); m_streams = rhs.m_streams; } @@ -64,21 +51,22 @@ } StreamTee & - operator = (const StreamTee &rhs) + operator=(const StreamTee &rhs) { - if (this != &rhs) { + if (this != &rhs) + { Stream::operator=(rhs); - Mutex::Locker lhs_locker (m_streams_mutex); - Mutex::Locker rhs_locker (rhs.m_streams_mutex); - m_streams = rhs.m_streams; + std::lock_guard lhs_locker(m_streams_mutex); + std::lock_guard rhs_locker(rhs.m_streams_mutex); + m_streams = rhs.m_streams; } return *this; } void - Flush () override + Flush() override { - Mutex::Locker locker (m_streams_mutex); + std::lock_guard guard(m_streams_mutex); collection::iterator pos, end; for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) { @@ -88,17 +76,17 @@ // to valid values. Stream *strm = pos->get(); if (strm) - strm->Flush (); + strm->Flush(); } } size_t - Write (const void *s, size_t length) override + Write(const void *s, size_t length) override { - Mutex::Locker locker (m_streams_mutex); + std::lock_guard guard(m_streams_mutex); if (m_streams.empty()) return 0; - + size_t min_bytes_written = SIZE_MAX; collection::iterator pos, end; for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) @@ -110,7 +98,7 @@ Stream *strm = pos->get(); if (strm) { - const size_t bytes_written = strm->Write (s, length); + const size_t bytes_written = strm->Write(s, length); if (min_bytes_written > bytes_written) min_bytes_written = bytes_written; } @@ -121,39 +109,39 @@ } size_t - AppendStream (const lldb::StreamSP &stream_sp) + AppendStream(const lldb::StreamSP &stream_sp) { size_t new_idx = m_streams.size(); - Mutex::Locker locker (m_streams_mutex); - m_streams.push_back (stream_sp); + std::lock_guard guard(m_streams_mutex); + m_streams.push_back(stream_sp); return new_idx; } size_t - GetNumStreams () const + GetNumStreams() const { size_t result = 0; { - Mutex::Locker locker (m_streams_mutex); + std::lock_guard guard(m_streams_mutex); result = m_streams.size(); } return result; } lldb::StreamSP - GetStreamAtIndex (uint32_t idx) + GetStreamAtIndex(uint32_t idx) { lldb::StreamSP stream_sp; - Mutex::Locker locker (m_streams_mutex); + std::lock_guard guard(m_streams_mutex); if (idx < m_streams.size()) stream_sp = m_streams[idx]; return stream_sp; } void - SetStreamAtIndex (uint32_t idx, const lldb::StreamSP& stream_sp) + SetStreamAtIndex(uint32_t idx, const lldb::StreamSP &stream_sp) { - Mutex::Locker locker (m_streams_mutex); + std::lock_guard guard(m_streams_mutex); // Resize our stream vector as necessary to fit as many streams // as needed. This also allows this class to be used with hard // coded indexes that can be used contain many streams, not all @@ -162,10 +150,10 @@ m_streams.resize(idx + 1); m_streams[idx] = stream_sp; } - + protected: typedef std::vector collection; - mutable Mutex m_streams_mutex; + mutable std::recursive_mutex m_streams_mutex; collection m_streams; }; Index: include/lldb/Core/ThreadSafeSTLMap.h =================================================================== --- include/lldb/Core/ThreadSafeSTLMap.h +++ include/lldb/Core/ThreadSafeSTLMap.h @@ -13,11 +13,11 @@ // C Includes // C++ Includes #include +#include // Other libraries and framework includes // Project includes #include "lldb/lldb-defines.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -31,11 +31,7 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - ThreadSafeSTLMap() : - m_collection (), - m_mutex (Mutex::eMutexTypeRecursive) - { - } + ThreadSafeSTLMap() : m_collection(), m_mutex() {} ~ThreadSafeSTLMap() { @@ -44,22 +40,22 @@ bool IsEmpty() const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return m_collection.empty(); } - + void Clear() { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return m_collection.clear(); } size_t - Erase (const _Key& key) + Erase(const _Key &key) { - Mutex::Locker locker(m_mutex); - return EraseNoLock (key); + std::lock_guard guard(m_mutex); + return EraseNoLock(key); } size_t @@ -69,10 +65,10 @@ } bool - GetValueForKey (const _Key& key, _Tp &value) const + GetValueForKey(const _Key &key, _Tp &value) const { - Mutex::Locker locker(m_mutex); - return GetValueForKeyNoLock (key, value); + std::lock_guard guard(m_mutex); + return GetValueForKeyNoLock(key, value); } // Call this if you have already manually locked the mutex using the @@ -90,10 +86,10 @@ } bool - GetFirstKeyForValue (const _Tp &value, _Key& key) const + GetFirstKeyForValue(const _Tp &value, _Key &key) const { - Mutex::Locker locker(m_mutex); - return GetFirstKeyForValueNoLock (value, key); + std::lock_guard guard(m_mutex); + return GetFirstKeyForValueNoLock(value, key); } bool @@ -112,13 +108,10 @@ } bool - LowerBound (const _Key& key, - _Key& match_key, - _Tp &match_value, - bool decrement_if_not_equal) const + LowerBound(const _Key &key, _Key &match_key, _Tp &match_value, bool decrement_if_not_equal) const { - Mutex::Locker locker(m_mutex); - return LowerBoundNoLock (key, match_key, match_value, decrement_if_not_equal); + std::lock_guard guard(m_mutex); + return LowerBoundNoLock(key, match_key, match_value, decrement_if_not_equal); } bool @@ -149,10 +142,10 @@ } void - SetValueForKey (const _Key& key, const _Tp &value) + SetValueForKey(const _Key &key, const _Tp &value) { - Mutex::Locker locker(m_mutex); - SetValueForKeyNoLock (key, value); + std::lock_guard guard(m_mutex); + SetValueForKeyNoLock(key, value); } // Call this if you have already manually locked the mutex using the @@ -163,15 +156,15 @@ m_collection[key] = value; } - Mutex & - GetMutex () + std::recursive_mutex & + GetMutex() { return m_mutex; } private: collection m_collection; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; //------------------------------------------------------------------ // For ThreadSafeSTLMap only Index: include/lldb/Core/ThreadSafeValue.h =================================================================== --- include/lldb/Core/ThreadSafeValue.h +++ include/lldb/Core/ThreadSafeValue.h @@ -11,10 +11,12 @@ #define liblldb_ThreadSafeValue_h_ // C Includes + // C++ Includes +#include + // Other libraries and framework includes // Project includes -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -25,28 +27,20 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - ThreadSafeValue() : - m_value (), - m_mutex (Mutex::eMutexTypeRecursive) - { - } + ThreadSafeValue() : m_value(), m_mutex() {} - ThreadSafeValue(const T& value) : - m_value (value), - m_mutex (Mutex::eMutexTypeRecursive) - { - } + ThreadSafeValue(const T &value) : m_value(value), m_mutex() {} ~ThreadSafeValue() { } T - GetValue () const + GetValue() const { T value; { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); value = m_value; } return value; @@ -61,9 +55,9 @@ } void - SetValue (const T& value) + SetValue(const T &value) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); m_value = value; } @@ -75,15 +69,15 @@ m_value = value; } - Mutex & - GetMutex () + std::recursive_mutex & + GetMutex() { return m_mutex; } private: T m_value; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; //------------------------------------------------------------------ // For ThreadSafeValue only Index: include/lldb/Core/UserSettingsController.h =================================================================== --- include/lldb/Core/UserSettingsController.h +++ include/lldb/Core/UserSettingsController.h @@ -24,7 +24,6 @@ #include "lldb/Core/StringList.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamString.h" -#include "lldb/Host/Mutex.h" #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { Index: include/lldb/Core/ValueObject.h =================================================================== --- include/lldb/Core/ValueObject.h +++ include/lldb/Core/ValueObject.h @@ -1034,35 +1034,32 @@ class ChildrenManager { public: - ChildrenManager() : - m_mutex(Mutex::eMutexTypeRecursive), - m_children(), - m_children_count(0) - {} - + ChildrenManager() : m_mutex(), m_children(), m_children_count(0) {} + bool - HasChildAtIndex (size_t idx) + HasChildAtIndex(size_t idx) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return (m_children.find(idx) != m_children.end()); } - - ValueObject* - GetChildAtIndex (size_t idx) + + ValueObject * + GetChildAtIndex(size_t idx) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); const auto iter = m_children.find(idx); return ((iter == m_children.end()) ? nullptr : iter->second); } - + void - SetChildAtIndex (size_t idx, ValueObject* valobj) + SetChildAtIndex(size_t idx, ValueObject *valobj) { - ChildrenPair pair(idx,valobj); // we do not need to be mutex-protected to make a pair - Mutex::Locker locker(m_mutex); + // we do not need to be mutex-protected to make a pair + ChildrenPair pair(idx, valobj); + std::lock_guard guard(m_mutex); m_children.insert(pair); } - + void SetChildrenCount (size_t count) { @@ -1074,20 +1071,20 @@ { return m_children_count; } - + void Clear(size_t new_count = 0) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); m_children_count = new_count; m_children.clear(); } - + private: typedef std::map ChildrenMap; typedef ChildrenMap::iterator ChildrenIterator; typedef ChildrenMap::value_type ChildrenPair; - Mutex m_mutex; + std::recursive_mutex m_mutex; ChildrenMap m_children; size_t m_children_count; }; Index: include/lldb/DataFormatters/FormatCache.h =================================================================== --- include/lldb/DataFormatters/FormatCache.h +++ include/lldb/DataFormatters/FormatCache.h @@ -13,12 +13,12 @@ // C Includes // C++ Includes #include +#include // Other libraries and framework includes // Project includes #include "lldb/lldb-public.h" #include "lldb/Core/ConstString.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { class FormatCache @@ -82,7 +82,7 @@ }; typedef std::map CacheMap; CacheMap m_map; - Mutex m_mutex; + std::recursive_mutex m_mutex; uint64_t m_cache_hits; uint64_t m_cache_misses; Index: include/lldb/DataFormatters/FormatManager.h =================================================================== --- include/lldb/DataFormatters/FormatManager.h +++ include/lldb/DataFormatters/FormatManager.h @@ -15,6 +15,7 @@ #include #include #include +#include #include // Other libraries and framework includes @@ -289,7 +290,7 @@ std::atomic m_last_revision; FormatCache m_format_cache; - Mutex m_language_categories_mutex; + std::recursive_mutex m_language_categories_mutex; LanguageCategories m_language_categories_map; NamedSummariesMap m_named_summaries_map; TypeCategoryMap m_categories_map; Index: include/lldb/DataFormatters/FormattersContainer.h =================================================================== --- include/lldb/DataFormatters/FormattersContainer.h +++ include/lldb/DataFormatters/FormattersContainer.h @@ -15,6 +15,7 @@ #include #include #include +#include #include // Other libraries and framework includes @@ -81,33 +82,27 @@ typedef std::map MapType; typedef typename MapType::iterator MapIterator; typedef std::function ForEachCallback; - - FormatMap(IFormatChangeListener* lst) : - m_map(), - m_map_mutex(Mutex::eMutexTypeRecursive), - listener(lst) - { - } - + + FormatMap(IFormatChangeListener *lst) : m_map(), m_map_mutex(), listener(lst) {} + void - Add(KeyType name, - const ValueSP& entry) + Add(KeyType name, const ValueSP &entry) { if (listener) entry->GetRevision() = listener->GetCurrentRevision(); else entry->GetRevision() = 0; - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); m_map[name] = entry; if (listener) listener->Changed(); } - + bool - Delete (KeyType name) + Delete(KeyType name) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); MapIterator iter = m_map.find(name); if (iter == m_map.end()) return false; @@ -116,34 +111,33 @@ listener->Changed(); return true; } - + void - Clear () + Clear() { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); m_map.clear(); if (listener) listener->Changed(); } - + bool - Get(KeyType name, - ValueSP& entry) + Get(KeyType name, ValueSP &entry) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); MapIterator iter = m_map.find(name); if (iter == m_map.end()) return false; entry = iter->second; return true; } - + void - ForEach (ForEachCallback callback) + ForEach(ForEachCallback callback) { if (callback) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); MapIterator pos, end = m_map.end(); for (pos = m_map.begin(); pos != end; pos++) { @@ -153,17 +147,17 @@ } } } - + uint32_t GetCount () { return m_map.size(); } - + ValueSP - GetValueAtIndex (size_t index) + GetValueAtIndex(size_t index) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); MapIterator iter = m_map.begin(); MapIterator end = m_map.end(); while (index > 0) @@ -175,11 +169,11 @@ } return iter->second; } - + KeyType - GetKeyAtIndex (size_t index) + GetKeyAtIndex(size_t index) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); MapIterator iter = m_map.begin(); MapIterator end = m_map.end(); while (index > 0) @@ -191,24 +185,24 @@ } return iter->first; } - + protected: - MapType m_map; - Mutex m_map_mutex; + MapType m_map; + std::recursive_mutex m_map_mutex; IFormatChangeListener* listener; - + MapType& map () { return m_map; } - - Mutex& - mutex () + + std::recursive_mutex & + mutex() { return m_map_mutex; } - + friend class FormattersContainer; friend class FormatManager; }; @@ -332,24 +326,23 @@ } bool - Delete_Impl (ConstString type, lldb::RegularExpressionSP *dummy) - { - Mutex& x_mutex = m_format_map.mutex(); - lldb_private::Mutex::Locker locker(x_mutex); - MapIterator pos, end = m_format_map.map().end(); - for (pos = m_format_map.map().begin(); pos != end; pos++) - { - lldb::RegularExpressionSP regex = pos->first; - if ( ::strcmp(type.AsCString(),regex->GetText()) == 0) - { - m_format_map.map().erase(pos); - if (m_format_map.listener) - m_format_map.listener->Changed(); - return true; - } - } - return false; - } + Delete_Impl(ConstString type, lldb::RegularExpressionSP *dummy) + { + std::lock_guard guard(m_format_map.mutex()); + MapIterator pos, end = m_format_map.map().end(); + for (pos = m_format_map.map().begin(); pos != end; pos++) + { + lldb::RegularExpressionSP regex = pos->first; + if (::strcmp(type.AsCString(), regex->GetText()) == 0) + { + m_format_map.map().erase(pos); + if (m_format_map.listener) + m_format_map.listener->Changed(); + return true; + } + } + return false; + } bool Get_Impl (ConstString type, MapValueType& entry, ConstString *dummy) @@ -385,36 +378,34 @@ } bool - Get_Impl (ConstString key, MapValueType& value, lldb::RegularExpressionSP *dummy) - { - const char* key_cstr = key.AsCString(); - if (!key_cstr) - return false; - Mutex& x_mutex = m_format_map.mutex(); - lldb_private::Mutex::Locker locker(x_mutex); - MapIterator pos, end = m_format_map.map().end(); - for (pos = m_format_map.map().begin(); pos != end; pos++) - { - lldb::RegularExpressionSP regex = pos->first; - if (regex->Execute(key_cstr)) - { - value = pos->second; - return true; - } - } - return false; + Get_Impl(ConstString key, MapValueType &value, lldb::RegularExpressionSP *dummy) + { + const char *key_cstr = key.AsCString(); + if (!key_cstr) + return false; + std::lock_guard guard(m_format_map.mutex()); + MapIterator pos, end = m_format_map.map().end(); + for (pos = m_format_map.map().begin(); pos != end; pos++) + { + lldb::RegularExpressionSP regex = pos->first; + if (regex->Execute(key_cstr)) + { + value = pos->second; + return true; + } + } + return false; } - + bool - GetExact_Impl (ConstString key, MapValueType& value, lldb::RegularExpressionSP *dummy) + GetExact_Impl(ConstString key, MapValueType &value, lldb::RegularExpressionSP *dummy) { - Mutex& x_mutex = m_format_map.mutex(); - lldb_private::Mutex::Locker locker(x_mutex); + std::lock_guard guard(m_format_map.mutex()); MapIterator pos, end = m_format_map.map().end(); for (pos = m_format_map.map().begin(); pos != end; pos++) { lldb::RegularExpressionSP regex = pos->first; - if (strcmp(regex->GetText(),key.AsCString()) == 0) + if (strcmp(regex->GetText(), key.AsCString()) == 0) { value = pos->second; return true; Index: include/lldb/DataFormatters/TypeCategory.h =================================================================== --- include/lldb/DataFormatters/TypeCategory.h +++ include/lldb/DataFormatters/TypeCategory.h @@ -14,6 +14,7 @@ // C++ Includes #include #include +#include #include #include @@ -519,9 +520,9 @@ bool m_enabled; IFormatChangeListener* m_change_listener; - - Mutex m_mutex; - + + std::recursive_mutex m_mutex; + ConstString m_name; std::vector m_languages; Index: include/lldb/DataFormatters/TypeCategoryMap.h =================================================================== --- include/lldb/DataFormatters/TypeCategoryMap.h +++ include/lldb/DataFormatters/TypeCategoryMap.h @@ -15,6 +15,7 @@ #include #include #include +#include // Other libraries and framework includes // Project includes @@ -131,8 +132,8 @@ return ptr.get() == other.get(); } }; - - Mutex m_map_mutex; + + std::recursive_mutex m_map_mutex; IFormatChangeListener* listener; MapType m_map; @@ -147,12 +148,13 @@ { return m_active_categories; } - - Mutex& mutex () + + std::recursive_mutex & + mutex() { return m_map_mutex; } - + friend class FormattersContainer; friend class FormatManager; }; Index: include/lldb/Expression/IRExecutionUnit.h =================================================================== --- include/lldb/Expression/IRExecutionUnit.h +++ include/lldb/Expression/IRExecutionUnit.h @@ -26,7 +26,6 @@ #include "lldb/lldb-private.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Expression/IRMemoryMap.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" Index: include/lldb/Host/Editline.h =================================================================== --- include/lldb/Host/Editline.h +++ include/lldb/Host/Editline.h @@ -50,13 +50,13 @@ #endif #endif +#include #include #include #include "lldb/Host/Condition.h" #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/Predicate.h" namespace lldb_private { @@ -359,7 +359,7 @@ CompleteCallbackType m_completion_callback = nullptr; void * m_completion_callback_baton = nullptr; - Mutex m_output_mutex; + std::mutex m_output_mutex; }; } Index: include/lldb/Host/ProcessRunLock.h =================================================================== --- include/lldb/Host/ProcessRunLock.h +++ include/lldb/Host/ProcessRunLock.h @@ -18,7 +18,6 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-defines.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/Condition.h" //---------------------------------------------------------------------- Index: include/lldb/Host/common/NativeBreakpointList.h =================================================================== --- include/lldb/Host/common/NativeBreakpointList.h +++ include/lldb/Host/common/NativeBreakpointList.h @@ -12,11 +12,11 @@ #include "lldb/lldb-private-forward.h" #include "lldb/Core/Error.h" -#include "lldb/Host/Mutex.h" // #include "lldb/Host/NativeBreakpoint.h" #include #include +#include namespace lldb_private { @@ -48,7 +48,7 @@ private: typedef std::map BreakpointMap; - Mutex m_mutex; + std::recursive_mutex m_mutex; BreakpointMap m_breakpoints; }; } Index: include/lldb/Host/common/NativeProcessProtocol.h =================================================================== --- include/lldb/Host/common/NativeProcessProtocol.h +++ include/lldb/Host/common/NativeProcessProtocol.h @@ -10,12 +10,12 @@ #ifndef liblldb_NativeProcessProtocol_h_ #define liblldb_NativeProcessProtocol_h_ +#include #include #include "lldb/lldb-private-forward.h" #include "lldb/lldb-types.h" #include "lldb/Core/Error.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/MainLoop.h" #include "llvm/ADT/StringRef.h" @@ -364,15 +364,15 @@ std::vector m_threads; lldb::tid_t m_current_thread_id; - mutable Mutex m_threads_mutex; + mutable std::recursive_mutex m_threads_mutex; lldb::StateType m_state; - mutable Mutex m_state_mutex; + mutable std::recursive_mutex m_state_mutex; lldb_private::ExitType m_exit_type; int m_exit_status; std::string m_exit_description; - Mutex m_delegates_mutex; + std::recursive_mutex m_delegates_mutex; std::vector m_delegates; NativeBreakpointList m_breakpoint_list; NativeWatchpointList m_watchpoint_list; Index: include/lldb/Host/posix/ConnectionFileDescriptorPosix.h =================================================================== --- include/lldb/Host/posix/ConnectionFileDescriptorPosix.h +++ include/lldb/Host/posix/ConnectionFileDescriptorPosix.h @@ -13,13 +13,13 @@ // C++ Includes #include #include +#include #include "lldb/lldb-forward.h" // Other libraries and framework includes // Project includes #include "lldb/Core/Connection.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/Pipe.h" #include "lldb/Host/Predicate.h" #include "lldb/Host/IOObject.h" @@ -105,7 +105,7 @@ // the port number. Pipe m_pipe; - Mutex m_mutex; + std::recursive_mutex m_mutex; std::atomic m_shutting_down; // This marks that we are shutting down so if we get woken up from // BytesAvailable to disconnect, we won't try to read again. bool m_waiting_for_accept; Index: include/lldb/Initialization/SystemLifetimeManager.h =================================================================== --- include/lldb/Initialization/SystemLifetimeManager.h +++ include/lldb/Initialization/SystemLifetimeManager.h @@ -11,9 +11,9 @@ #define LLDB_INITIALIZATION_SYSTEM_LIFETIME_MANAGER_H #include "lldb/lldb-private-types.h" -#include "lldb/Host/Mutex.h" #include +#include namespace lldb_private { @@ -29,7 +29,7 @@ void Terminate(); private: - Mutex m_mutex; + std::recursive_mutex m_mutex; std::unique_ptr m_initializer; bool m_initialized; Index: include/lldb/Interpreter/CommandHistory.h =================================================================== --- include/lldb/Interpreter/CommandHistory.h +++ include/lldb/Interpreter/CommandHistory.h @@ -12,6 +12,7 @@ // C Includes // C++ Includes +#include #include #include @@ -19,7 +20,6 @@ // Project includes #include "lldb/lldb-private.h" #include "lldb/Core/Stream.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -66,7 +66,7 @@ DISALLOW_COPY_AND_ASSIGN(CommandHistory); typedef std::vector History; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; History m_history; }; Index: include/lldb/Symbol/ArmUnwindInfo.h =================================================================== --- include/lldb/Symbol/ArmUnwindInfo.h +++ include/lldb/Symbol/ArmUnwindInfo.h @@ -14,7 +14,6 @@ #include "lldb/Core/DataExtractor.h" #include "lldb/Core/RangeMap.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/lldb-private.h" Index: include/lldb/Symbol/FuncUnwinders.h =================================================================== --- include/lldb/Symbol/FuncUnwinders.h +++ include/lldb/Symbol/FuncUnwinders.h @@ -1,12 +1,12 @@ #ifndef liblldb_FuncUnwinders_h #define liblldb_FuncUnwinders_h +#include #include #include "lldb/Core/AddressRange.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/AddressRange.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -119,7 +119,7 @@ UnwindTable& m_unwind_table; AddressRange m_range; - Mutex m_mutex; + std::recursive_mutex m_mutex; lldb::UnwindPlanSP m_unwind_plan_assembly_sp; lldb::UnwindPlanSP m_unwind_plan_eh_frame_sp; Index: include/lldb/Target/JITLoaderList.h =================================================================== --- include/lldb/Target/JITLoaderList.h +++ include/lldb/Target/JITLoaderList.h @@ -10,10 +10,10 @@ #ifndef liblldb_JITLoaderList_h_ #define liblldb_JITLoaderList_h_ +#include #include #include "lldb/lldb-forward.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -52,7 +52,7 @@ private: std::vector m_jit_loaders_vec; - lldb_private::Mutex m_jit_loaders_mutex; + std::recursive_mutex m_jit_loaders_mutex; }; } // namespace lldb_private Index: include/lldb/Target/Platform.h =================================================================== --- include/lldb/Target/Platform.h +++ include/lldb/Target/Platform.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -28,7 +29,6 @@ #include "lldb/Core/UserSettingsController.h" #include "lldb/Interpreter/Options.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Host/Mutex.h" // TODO pull NativeDelegate class out of NativeProcessProtocol so we // can just forward ref the NativeDelegate rather than include it here. @@ -1079,7 +1079,8 @@ uint32_t m_update_os_version; ArchSpec m_system_arch; // The architecture of the kernel or the remote platform typedef std::map IDToNameMap; - Mutex m_mutex; // Mutex for modifying Platform data structures that should only be used for non-reentrant code + // Mutex for modifying Platform data structures that should only be used for non-reentrant code + std::mutex m_mutex; IDToNameMap m_uid_map; IDToNameMap m_gid_map; size_t m_max_uid_name_len; @@ -1112,9 +1113,9 @@ CalculateTrapHandlerSymbolNames () = 0; const char * - GetCachedUserName (uint32_t uid) + GetCachedUserName(uint32_t uid) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); // return the empty string if our string is NULL // so we can tell when things were in the negative // cached (didn't find a valid user name, don't keep @@ -1124,35 +1125,35 @@ } const char * - SetCachedUserName (uint32_t uid, const char *name, size_t name_len) + SetCachedUserName(uint32_t uid, const char *name, size_t name_len) { - Mutex::Locker locker (m_mutex); - ConstString const_name (name); + std::lock_guard guard(m_mutex); + ConstString const_name(name); m_uid_map[uid] = const_name; if (m_max_uid_name_len < name_len) m_max_uid_name_len = name_len; // Const strings lives forever in our const string pool, so we can return the const char * - return const_name.GetCString(); + return const_name.GetCString(); } void - SetUserNameNotFound (uint32_t uid) + SetUserNameNotFound(uint32_t uid) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_uid_map[uid] = ConstString(); } void - ClearCachedUserNames () + ClearCachedUserNames() { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_uid_map.clear(); } - + const char * - GetCachedGroupName (uint32_t gid) + GetCachedGroupName(uint32_t gid) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); // return the empty string if our string is NULL // so we can tell when things were in the negative // cached (didn't find a valid group name, don't keep @@ -1162,28 +1163,28 @@ } const char * - SetCachedGroupName (uint32_t gid, const char *name, size_t name_len) + SetCachedGroupName(uint32_t gid, const char *name, size_t name_len) { - Mutex::Locker locker (m_mutex); - ConstString const_name (name); + std::lock_guard guard(m_mutex); + ConstString const_name(name); m_gid_map[gid] = const_name; if (m_max_gid_name_len < name_len) m_max_gid_name_len = name_len; // Const strings lives forever in our const string pool, so we can return the const char * - return const_name.GetCString(); + return const_name.GetCString(); } void - SetGroupNameNotFound (uint32_t gid) + SetGroupNameNotFound(uint32_t gid) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_gid_map[gid] = ConstString(); } void - ClearCachedGroupNames () + ClearCachedGroupNames() { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_gid_map.clear(); } @@ -1236,20 +1237,15 @@ class PlatformList { public: - PlatformList() : - m_mutex (Mutex::eMutexTypeRecursive), - m_platforms (), - m_selected_platform_sp() - { - } + PlatformList() : m_mutex(), m_platforms(), m_selected_platform_sp() {} ~PlatformList() = default; void - Append (const lldb::PlatformSP &platform_sp, bool set_selected) + Append(const lldb::PlatformSP &platform_sp, bool set_selected) { - Mutex::Locker locker (m_mutex); - m_platforms.push_back (platform_sp); + std::lock_guard guard(m_mutex); + m_platforms.push_back(platform_sp); if (set_selected) m_selected_platform_sp = m_platforms.back(); } @@ -1257,16 +1253,16 @@ size_t GetSize() { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); return m_platforms.size(); } lldb::PlatformSP - GetAtIndex (uint32_t idx) + GetAtIndex(uint32_t idx) { lldb::PlatformSP platform_sp; { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (idx < m_platforms.size()) platform_sp = m_platforms[idx]; } @@ -1283,23 +1279,23 @@ /// processes. //------------------------------------------------------------------ lldb::PlatformSP - GetSelectedPlatform () + GetSelectedPlatform() { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (!m_selected_platform_sp && !m_platforms.empty()) m_selected_platform_sp = m_platforms.front(); - + return m_selected_platform_sp; } void - SetSelectedPlatform (const lldb::PlatformSP &platform_sp) + SetSelectedPlatform(const lldb::PlatformSP &platform_sp) { if (platform_sp) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); const size_t num_platforms = m_platforms.size(); - for (size_t idx=0; idx collection; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; collection m_platforms; lldb::PlatformSP m_selected_platform_sp; private: DISALLOW_COPY_AND_ASSIGN (PlatformList); }; - + class OptionGroupPlatformRSync : public lldb_private::OptionGroup { public: Index: include/lldb/Target/SectionLoadHistory.h =================================================================== --- include/lldb/Target/SectionLoadHistory.h +++ include/lldb/Target/SectionLoadHistory.h @@ -13,10 +13,10 @@ // C Includes // C++ Includes #include +#include // Project includes #include "lldb/lldb-public.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -31,11 +31,7 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - SectionLoadHistory () : - m_stop_id_to_section_load_list(), - m_mutex (Mutex::eMutexTypeRecursive) - { - } + SectionLoadHistory() : m_stop_id_to_section_load_list(), m_mutex() {} ~SectionLoadHistory() { @@ -98,7 +94,7 @@ typedef std::map StopIDToSectionLoadList; StopIDToSectionLoadList m_stop_id_to_section_load_list; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; private: DISALLOW_COPY_AND_ASSIGN (SectionLoadHistory); Index: include/lldb/Target/SectionLoadList.h =================================================================== --- include/lldb/Target/SectionLoadList.h +++ include/lldb/Target/SectionLoadList.h @@ -13,13 +13,13 @@ // C Includes // C++ Includes #include +#include // Other libraries and framework includes #include "llvm/ADT/DenseMap.h" // Project includes #include "lldb/lldb-public.h" #include "lldb/Core/Section.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -29,13 +29,7 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - SectionLoadList () : - m_addr_to_sect (), - m_sect_to_addr (), - m_mutex (Mutex::eMutexTypeRecursive) - - { - } + SectionLoadList() : m_addr_to_sect(), m_sect_to_addr(), m_mutex() {} SectionLoadList (const SectionLoadList& rhs); @@ -84,7 +78,7 @@ typedef llvm::DenseMap sect_to_addr_collection; addr_to_sect_collection m_addr_to_sect; sect_to_addr_collection m_sect_to_addr; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; }; } // namespace lldb_private Index: include/lldb/Target/TargetList.h =================================================================== --- include/lldb/Target/TargetList.h +++ include/lldb/Target/TargetList.h @@ -12,12 +12,12 @@ // C Includes // C++ Includes +#include #include // Other libraries and framework includes // Project includes #include "lldb/Core/Broadcaster.h" -#include "lldb/Host/Mutex.h" #include "lldb/Target/Target.h" namespace lldb_private { @@ -229,7 +229,7 @@ //------------------------------------------------------------------ collection m_target_list; lldb::TargetSP m_dummy_target_sp; - mutable Mutex m_target_list_mutex; + mutable std::recursive_mutex m_target_list_mutex; uint32_t m_selected_target_idx; private: Index: include/lldb/Target/Thread.h =================================================================== --- include/lldb/Target/Thread.h +++ include/lldb/Target/Thread.h @@ -13,13 +13,13 @@ // C Includes // C++ Includes #include +#include #include #include // 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/StructuredData.h" @@ -1446,11 +1446,11 @@ const uint32_t m_index_id; ///< A unique 1 based index assigned to each thread for easy UI/command line access. lldb::RegisterContextSP m_reg_context_sp; ///< The register context for this thread's current register state. lldb::StateType m_state; ///< The state of our process. - mutable Mutex m_state_mutex; ///< Multithreaded protection for m_state. + mutable std::recursive_mutex m_state_mutex; ///< Multithreaded protection for m_state. plan_stack m_plan_stack; ///< The stack of plans this thread is executing. plan_stack m_completed_plan_stack; ///< Plans that have been completed by this stop. They get deleted when the thread resumes. plan_stack m_discarded_plan_stack; ///< Plans that have been discarded by this stop. They get deleted when the thread resumes. - mutable Mutex m_frame_mutex; ///< Multithreaded protection for m_state. + mutable std::recursive_mutex m_frame_mutex; ///< Multithreaded protection for m_state. lldb::StackFrameListSP m_curr_frames_sp; ///< The stack frames that get lazily populated after a thread stops. lldb::StackFrameListSP m_prev_frames_sp; ///< The previous stack frames from the last time this thread stopped. int m_resume_signal; ///< The signal that should be used when continuing this thread. Index: include/lldb/Target/ThreadPlan.h =================================================================== --- include/lldb/Target/ThreadPlan.h +++ include/lldb/Target/ThreadPlan.h @@ -12,13 +12,13 @@ // C Includes // C++ Includes +#include #include // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" #include "lldb/Core/UserID.h" -#include "lldb/Host/Mutex.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" @@ -632,7 +632,7 @@ ThreadPlanKind m_kind; std::string m_name; - Mutex m_plan_complete_mutex; + std::recursive_mutex m_plan_complete_mutex; LazyBool m_cached_plan_explains_stop; bool m_plan_complete; bool m_plan_private; Index: include/lldb/Target/ThreadPlanPython.h =================================================================== --- include/lldb/Target/ThreadPlanPython.h +++ include/lldb/Target/ThreadPlanPython.h @@ -19,7 +19,6 @@ #include "lldb/lldb-private.h" #include "lldb/Core/StructuredData.h" #include "lldb/Core/UserID.h" -#include "lldb/Host/Mutex.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" Index: include/lldb/Target/Unwind.h =================================================================== --- include/lldb/Target/Unwind.h +++ include/lldb/Target/Unwind.h @@ -12,10 +12,11 @@ // C Includes // C++ Includes +#include + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -25,11 +26,7 @@ //------------------------------------------------------------------ // Classes that inherit from Unwind can see and modify these //------------------------------------------------------------------ - Unwind(Thread &thread) : - m_thread (thread), - m_unwind_mutex(Mutex::eMutexTypeRecursive) - { - } + Unwind(Thread &thread) : m_thread(thread), m_unwind_mutex() {} public: virtual @@ -40,18 +37,17 @@ void Clear() { - Mutex::Locker locker(m_unwind_mutex); + std::lock_guard guard(m_unwind_mutex); DoClear(); - } uint32_t GetFrameCount() { - Mutex::Locker locker(m_unwind_mutex); + std::lock_guard guard(m_unwind_mutex); return DoGetFrameCount(); } - + uint32_t GetFramesUpTo (uint32_t end_idx) { @@ -70,21 +66,19 @@ } bool - GetFrameInfoAtIndex (uint32_t frame_idx, - lldb::addr_t& cfa, - lldb::addr_t& pc) + GetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa, lldb::addr_t &pc) { - Mutex::Locker locker(m_unwind_mutex); - return DoGetFrameInfoAtIndex (frame_idx, cfa, pc); + std::lock_guard guard(m_unwind_mutex); + return DoGetFrameInfoAtIndex(frame_idx, cfa, pc); } - + lldb::RegisterContextSP - CreateRegisterContextForFrame (StackFrame *frame) + CreateRegisterContextForFrame(StackFrame *frame) { - Mutex::Locker locker(m_unwind_mutex); - return DoCreateRegisterContextForFrame (frame); + std::lock_guard guard(m_unwind_mutex); + return DoCreateRegisterContextForFrame(frame); } - + Thread & GetThread() { @@ -110,7 +104,8 @@ DoCreateRegisterContextForFrame (StackFrame *frame) = 0; Thread &m_thread; - Mutex m_unwind_mutex; + std::recursive_mutex m_unwind_mutex; + private: DISALLOW_COPY_AND_ASSIGN (Unwind); }; Index: include/lldb/Utility/SharedCluster.h =================================================================== --- include/lldb/Utility/SharedCluster.h +++ include/lldb/Utility/SharedCluster.h @@ -11,7 +11,6 @@ #define utility_SharedCluster_h_ #include "lldb/Utility/SharingPtr.h" -#include "lldb/Host/Mutex.h" #include "llvm/ADT/SmallPtrSet.h" @@ -46,14 +45,12 @@ class ClusterManager { public: - ClusterManager () : - m_objects(), - m_external_ref(0), - m_mutex(Mutex::eMutexTypeNormal) {} - - ~ClusterManager () + ClusterManager() : m_objects(), m_external_ref(0), m_mutex() {} + + ~ClusterManager() { - for (typename llvm::SmallPtrSet::iterator pos = m_objects.begin(), end = m_objects.end(); pos != end; ++pos) + for (typename llvm::SmallPtrSet::iterator pos = m_objects.begin(), end = m_objects.end(); pos != end; + ++pos) { T *object = *pos; delete object; @@ -62,42 +59,44 @@ // Decrement refcount should have been called on this ClusterManager, // and it should have locked the mutex, now we will unlock it before // we destroy it... - m_mutex.Unlock(); + m_mutex.unlock(); } - - void ManageObject (T *new_object) + + void + ManageObject(T *new_object) { - Mutex::Locker locker (m_mutex); - m_objects.insert (new_object); + std::lock_guard guard(m_mutex); + m_objects.insert(new_object); } - - typename lldb_private::SharingPtr GetSharedPointer(T *desired_object) + + typename lldb_private::SharingPtr + GetSharedPointer(T *desired_object) { { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_external_ref++; - assert (m_objects.count(desired_object)); + assert(m_objects.count(desired_object)); } - return typename lldb_private::SharingPtr (desired_object, new imp::shared_ptr_refcount (this)); + return typename lldb_private::SharingPtr(desired_object, new imp::shared_ptr_refcount(this)); } - + private: - - void DecrementRefCount () + void + DecrementRefCount() { - m_mutex.Lock(); + m_mutex.lock(); m_external_ref--; if (m_external_ref == 0) delete this; else - m_mutex.Unlock(); + m_mutex.unlock(); } - + friend class imp::shared_ptr_refcount; - + llvm::SmallPtrSet m_objects; int m_external_ref; - Mutex m_mutex; + std::mutex m_mutex; }; } // namespace lldb_private Index: source/API/SBDebugger.cpp =================================================================== --- source/API/SBDebugger.cpp +++ source/API/SBDebugger.cpp @@ -191,8 +191,8 @@ // uses global collections and having two threads parsing the .lldbinit files can cause // mayhem. So to get around this for now we need to use a mutex to prevent bad things // from happening. - static Mutex g_mutex(Mutex::eMutexTypeRecursive); - Mutex::Locker locker(g_mutex); + static std::recursive_mutex g_mutex; + std::lock_guard guard(g_mutex); debugger.reset(Debugger::CreateInstance(callback, baton)); Index: source/Breakpoint/BreakpointLocationList.cpp =================================================================== --- source/Breakpoint/BreakpointLocationList.cpp +++ source/Breakpoint/BreakpointLocationList.cpp @@ -24,13 +24,8 @@ using namespace lldb; using namespace lldb_private; -BreakpointLocationList::BreakpointLocationList(Breakpoint &owner) : - m_owner (owner), - m_locations(), - m_address_to_location (), - m_mutex (Mutex::eMutexTypeRecursive), - m_next_id (0), - m_new_location_recorder (nullptr) +BreakpointLocationList::BreakpointLocationList(Breakpoint &owner) + : m_owner(owner), m_locations(), m_address_to_location(), m_mutex(), m_next_id(0), m_new_location_recorder(nullptr) { } @@ -39,7 +34,7 @@ BreakpointLocationSP BreakpointLocationList::Create (const Address &addr, bool resolve_indirect_symbols) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); // The location ID is just the size of the location list + 1 lldb::break_id_t bp_loc_id = ++m_next_id; BreakpointLocationSP bp_loc_sp (new BreakpointLocation (bp_loc_id, m_owner, addr, LLDB_INVALID_THREAD_ID, m_owner.IsHardware(), resolve_indirect_symbols)); @@ -84,7 +79,7 @@ BreakpointLocationSP BreakpointLocationList::FindByID (lldb::break_id_t break_id) const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); collection::const_iterator end = m_locations.end(); collection::const_iterator pos = std::lower_bound(m_locations.begin(), end, break_id, Compare); if (pos != end && (*pos)->GetID() == break_id) @@ -97,7 +92,7 @@ BreakpointLocationList::FindInModule (Module *module, BreakpointLocationCollection& bp_loc_list) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); const size_t orig_size = bp_loc_list.GetSize(); collection::iterator pos, end = m_locations.end(); @@ -116,7 +111,7 @@ const BreakpointLocationSP BreakpointLocationList::FindByAddress (const Address &addr) const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); BreakpointLocationSP bp_loc_sp; if (!m_locations.empty()) { @@ -150,7 +145,7 @@ { s->Printf("%p: ", static_cast(this)); //s->Indent(); - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); s->Printf("BreakpointLocationList with %" PRIu64 " BreakpointLocations:\n", (uint64_t)m_locations.size()); s->IndentMore(); collection::const_iterator pos, end = m_locations.end(); @@ -162,7 +157,7 @@ BreakpointLocationSP BreakpointLocationList::GetByIndex (size_t i) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); BreakpointLocationSP bp_loc_sp; if (i < m_locations.size()) bp_loc_sp = m_locations[i]; @@ -173,7 +168,7 @@ const BreakpointLocationSP BreakpointLocationList::GetByIndex (size_t i) const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); BreakpointLocationSP bp_loc_sp; if (i < m_locations.size()) bp_loc_sp = m_locations[i]; @@ -184,7 +179,7 @@ void BreakpointLocationList::ClearAllBreakpointSites () { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); collection::iterator pos, end = m_locations.end(); for (pos = m_locations.begin(); pos != end; ++pos) (*pos)->ClearBreakpointSite(); @@ -193,7 +188,7 @@ void BreakpointLocationList::ResolveAllBreakpointSites () { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); collection::iterator pos, end = m_locations.end(); for (pos = m_locations.begin(); pos != end; ++pos) @@ -207,7 +202,7 @@ BreakpointLocationList::GetHitCount () const { uint32_t hit_count = 0; - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); collection::const_iterator pos, end = m_locations.end(); for (pos = m_locations.begin(); pos != end; ++pos) hit_count += (*pos)->GetHitCount(); @@ -217,7 +212,7 @@ size_t BreakpointLocationList::GetNumResolvedLocations() const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); size_t resolve_count = 0; collection::const_iterator pos, end = m_locations.end(); for (pos = m_locations.begin(); pos != end; ++pos) @@ -231,7 +226,7 @@ void BreakpointLocationList::GetDescription (Stream *s, lldb::DescriptionLevel level) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); collection::iterator pos, end = m_locations.end(); for (pos = m_locations.begin(); pos != end; ++pos) @@ -244,7 +239,7 @@ BreakpointLocationSP BreakpointLocationList::AddLocation (const Address &addr, bool resolve_indirect_symbols, bool *new_location) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (new_location) *new_location = false; @@ -285,8 +280,8 @@ { if (bp_loc_sp) { - Mutex::Locker locker (m_mutex); - + std::lock_guard guard(m_mutex); + m_address_to_location.erase (bp_loc_sp->GetAddress()); collection::iterator pos, end = m_locations.end(); @@ -305,7 +300,7 @@ void BreakpointLocationList::RemoveInvalidLocations (const ArchSpec &arch) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); size_t idx = 0; // Don't cache m_location.size() as it will change since we might // remove locations from our vector... @@ -341,7 +336,7 @@ void BreakpointLocationList::StartRecordingNewLocations (BreakpointLocationCollection &new_locations) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); assert(m_new_location_recorder == nullptr); m_new_location_recorder = &new_locations; } @@ -349,7 +344,7 @@ void BreakpointLocationList::StopRecordingNewLocations () { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_new_location_recorder = nullptr; } Index: source/Breakpoint/BreakpointSite.cpp =================================================================== --- source/Breakpoint/BreakpointSite.cpp +++ source/Breakpoint/BreakpointSite.cpp @@ -23,17 +23,15 @@ using namespace lldb; using namespace lldb_private; -BreakpointSite::BreakpointSite(BreakpointSiteList *list, - const BreakpointLocationSP& owner, - lldb::addr_t addr, - bool use_hardware) : - StoppointLocation(GetNextID(), addr, 0, use_hardware), - m_type (eSoftware), // Process subclasses need to set this correctly using SetType() - m_saved_opcode(), - m_trap_opcode(), - m_enabled(false), // Need to create it disabled, so the first enable turns it on. - m_owners(), - m_owners_mutex(Mutex::eMutexTypeRecursive) +BreakpointSite::BreakpointSite(BreakpointSiteList *list, const BreakpointLocationSP &owner, lldb::addr_t addr, + bool use_hardware) + : StoppointLocation(GetNextID(), addr, 0, use_hardware), + m_type(eSoftware), // Process subclasses need to set this correctly using SetType() + m_saved_opcode(), + m_trap_opcode(), + m_enabled(false), // Need to create it disabled, so the first enable turns it on. + m_owners(), + m_owners_mutex() { m_owners.Add(owner); } @@ -61,7 +59,7 @@ bool BreakpointSite::ShouldStop (StoppointCallbackContext *context) { - Mutex::Locker locker(m_owners_mutex); + std::lock_guard guard(m_owners_mutex); IncrementHitCount(); return m_owners.ShouldStop (context); } @@ -69,7 +67,7 @@ bool BreakpointSite::IsBreakpointAtThisSite (lldb::break_id_t bp_id) { - Mutex::Locker locker(m_owners_mutex); + std::lock_guard guard(m_owners_mutex); const size_t owner_count = m_owners.GetSize(); for (size_t i = 0; i < owner_count; i++) { @@ -96,7 +94,7 @@ void BreakpointSite::GetDescription (Stream *s, lldb::DescriptionLevel level) { - Mutex::Locker locker(m_owners_mutex); + std::lock_guard guard(m_owners_mutex); if (level != lldb::eDescriptionLevelBrief) s->Printf ("breakpoint site: %d at 0x%8.8" PRIx64, GetID(), GetLoadAddress()); m_owners.GetDescription (s, level); @@ -166,14 +164,14 @@ void BreakpointSite::AddOwner (const BreakpointLocationSP &owner) { - Mutex::Locker locker(m_owners_mutex); + std::lock_guard guard(m_owners_mutex); m_owners.Add(owner); } size_t BreakpointSite::RemoveOwner (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) { - Mutex::Locker locker(m_owners_mutex); + std::lock_guard guard(m_owners_mutex); m_owners.Remove(break_id, break_loc_id); return m_owners.GetSize(); } @@ -181,28 +179,28 @@ size_t BreakpointSite::GetNumberOfOwners () { - Mutex::Locker locker(m_owners_mutex); + std::lock_guard guard(m_owners_mutex); return m_owners.GetSize(); } BreakpointLocationSP BreakpointSite::GetOwnerAtIndex (size_t index) { - Mutex::Locker locker(m_owners_mutex); + std::lock_guard guard(m_owners_mutex); return m_owners.GetByIndex (index); } bool BreakpointSite::ValidForThisThread (Thread *thread) { - Mutex::Locker locker(m_owners_mutex); + std::lock_guard guard(m_owners_mutex); return m_owners.ValidForThisThread(thread); } void BreakpointSite::BumpHitCounts() { - Mutex::Locker locker(m_owners_mutex); + std::lock_guard guard(m_owners_mutex); for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations()) { loc_sp->BumpHitCount(); @@ -255,7 +253,7 @@ size_t BreakpointSite::CopyOwnersList (BreakpointLocationCollection &out_collection) { - Mutex::Locker locker(m_owners_mutex); + std::lock_guard guard(m_owners_mutex); for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations()) { out_collection.Add(loc_sp); Index: source/Breakpoint/BreakpointSiteList.cpp =================================================================== --- source/Breakpoint/BreakpointSiteList.cpp +++ source/Breakpoint/BreakpointSiteList.cpp @@ -19,9 +19,7 @@ using namespace lldb; using namespace lldb_private; -BreakpointSiteList::BreakpointSiteList() : - m_mutex (Mutex::eMutexTypeRecursive), - m_bp_site_list() +BreakpointSiteList::BreakpointSiteList() : m_mutex(), m_bp_site_list() { } @@ -36,7 +34,7 @@ BreakpointSiteList::Add(const BreakpointSiteSP &bp) { lldb::addr_t bp_site_load_addr = bp->GetLoadAddress(); - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); collection::iterator iter = m_bp_site_list.find (bp_site_load_addr); if (iter == m_bp_site_list.end()) @@ -81,7 +79,7 @@ bool BreakpointSiteList::Remove (lldb::break_id_t break_id) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); collection::iterator pos = GetIDIterator(break_id); // Predicate if (pos != m_bp_site_list.end()) { @@ -94,7 +92,7 @@ bool BreakpointSiteList::RemoveByAddress (lldb::addr_t address) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); collection::iterator pos = m_bp_site_list.find(address); if (pos != m_bp_site_list.end()) { @@ -124,7 +122,7 @@ BreakpointSiteList::collection::iterator BreakpointSiteList::GetIDIterator (lldb::break_id_t break_id) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return std::find_if(m_bp_site_list.begin(), m_bp_site_list.end(), // Search full range BreakpointSiteIDMatches(break_id)); // Predicate } @@ -132,7 +130,7 @@ BreakpointSiteList::collection::const_iterator BreakpointSiteList::GetIDConstIterator (lldb::break_id_t break_id) const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return std::find_if(m_bp_site_list.begin(), m_bp_site_list.end(), // Search full range BreakpointSiteIDMatches(break_id)); // Predicate } @@ -140,7 +138,7 @@ BreakpointSiteSP BreakpointSiteList::FindByID (lldb::break_id_t break_id) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); BreakpointSiteSP stop_sp; collection::iterator pos = GetIDIterator(break_id); if (pos != m_bp_site_list.end()) @@ -152,7 +150,7 @@ const BreakpointSiteSP BreakpointSiteList::FindByID (lldb::break_id_t break_id) const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); BreakpointSiteSP stop_sp; collection::const_iterator pos = GetIDConstIterator(break_id); if (pos != m_bp_site_list.end()) @@ -165,7 +163,7 @@ BreakpointSiteList::FindByAddress (lldb::addr_t addr) { BreakpointSiteSP found_sp; - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); collection::iterator iter = m_bp_site_list.find(addr); if (iter != m_bp_site_list.end()) found_sp = iter->second; @@ -175,7 +173,7 @@ bool BreakpointSiteList::BreakpointSiteContainsBreakpoint (lldb::break_id_t bp_site_id, lldb::break_id_t bp_id) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); collection::const_iterator pos = GetIDConstIterator(bp_site_id); if (pos != m_bp_site_list.end()) return pos->second->IsBreakpointAtThisSite (bp_id); @@ -200,7 +198,7 @@ void BreakpointSiteList::ForEach (std::function const &callback) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); for (auto pair : m_bp_site_list) callback (pair.second.get()); } @@ -210,8 +208,8 @@ { if (lower_bound > upper_bound) return false; - - Mutex::Locker locker(m_mutex); + + std::lock_guard guard(m_mutex); collection::const_iterator lower, upper, pos; lower = m_bp_site_list.lower_bound(lower_bound); if (lower == m_bp_site_list.end() Index: source/Commands/CommandObjectTarget.cpp =================================================================== --- source/Commands/CommandObjectTarget.cpp +++ source/Commands/CommandObjectTarget.cpp @@ -1978,7 +1978,7 @@ if (check_global_list) { // Check the global list - Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex()); + std::lock_guard guard(Module::GetAllocationModuleCollectionMutex()); const size_t num_modules = Module::GetNumberAllocatedModules(); ModuleSP module_sp; for (size_t image_idx = 0; image_idx guard(Module::GetAllocationModuleCollectionMutex()); result.AppendWarningWithFormat("Unable to find an image that matches '%s'.\n", arg_cstr); } @@ -3291,16 +3291,20 @@ } size_t num_modules = 0; - Mutex::Locker locker; // This locker will be locked on the mutex in module_list_ptr if it is non-nullptr. - // Otherwise it will lock the AllocationModuleCollectionMutex when accessing - // the global module list directly. + + // This locker will be locked on the mutex in module_list_ptr if it is non-nullptr. + // Otherwise it will lock the AllocationModuleCollectionMutex when accessing + // the global module list directly. + std::unique_lock guard(Module::GetAllocationModuleCollectionMutex(), std::defer_lock); + Mutex::Locker locker; + const ModuleList *module_list_ptr = nullptr; const size_t argc = command.GetArgumentCount(); if (argc == 0) { if (use_global_module_list) { - locker.Lock (Module::GetAllocationModuleCollectionMutex()); + guard.lock(); num_modules = Module::GetNumberAllocatedModules(); } else @@ -3331,6 +3335,7 @@ if (module_list_ptr != nullptr) { + assert(use_global_module_list == false && "locking violation"); locker.Lock(module_list_ptr->GetMutex()); num_modules = module_list_ptr->GetSize(); } Index: source/Core/Broadcaster.cpp =================================================================== --- source/Core/Broadcaster.cpp +++ source/Core/Broadcaster.cpp @@ -32,12 +32,8 @@ static_cast(this), GetBroadcasterName().AsCString()); } -Broadcaster::BroadcasterImpl::BroadcasterImpl (Broadcaster &broadcaster) : - m_broadcaster(broadcaster), - m_listeners (), - m_listeners_mutex (Mutex::eMutexTypeRecursive), - m_hijacking_listeners(), - m_hijacking_masks() +Broadcaster::BroadcasterImpl::BroadcasterImpl(Broadcaster &broadcaster) + : m_broadcaster(broadcaster), m_listeners(), m_listeners_mutex(), m_hijacking_listeners(), m_hijacking_masks() { } @@ -90,7 +86,7 @@ void Broadcaster::BroadcasterImpl::Clear() { - Mutex::Locker listeners_locker(m_listeners_mutex); + std::lock_guard guard(m_listeners_mutex); // Make sure the listener forgets about this broadcaster. We do // this in the broadcaster in case the broadcaster object initiates @@ -152,7 +148,7 @@ if (!listener_sp) return 0; - Mutex::Locker locker(m_listeners_mutex); + std::lock_guard guard(m_listeners_mutex); // See if we already have this listener, and if so, update its mask @@ -186,8 +182,8 @@ bool Broadcaster::BroadcasterImpl::EventTypeHasListeners (uint32_t event_type) { - Mutex::Locker locker (m_listeners_mutex); - + std::lock_guard guard(m_listeners_mutex); + if (!m_hijacking_listeners.empty() && event_type & m_hijacking_masks.back()) return true; @@ -215,7 +211,7 @@ { if (listener) { - Mutex::Locker locker(m_listeners_mutex); + std::lock_guard guard(m_listeners_mutex); collection::iterator pos = m_listeners.begin(); // See if we already have this listener, and if so, update its mask while (pos != m_listeners.end()) @@ -275,7 +271,7 @@ const uint32_t event_type = event_sp->GetType(); - Mutex::Locker locker(m_listeners_mutex); + std::lock_guard guard(m_listeners_mutex); ListenerSP hijacking_listener_sp; @@ -343,7 +339,7 @@ bool Broadcaster::BroadcasterImpl::HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask) { - Mutex::Locker locker(m_listeners_mutex); + std::lock_guard guard(m_listeners_mutex); Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS)); if (log) @@ -358,7 +354,7 @@ bool Broadcaster::BroadcasterImpl::IsHijackedForEvent (uint32_t event_mask) { - Mutex::Locker locker(m_listeners_mutex); + std::lock_guard guard(m_listeners_mutex); if (!m_hijacking_listeners.empty()) return (event_mask & m_hijacking_masks.back()) != 0; @@ -381,7 +377,7 @@ void Broadcaster::BroadcasterImpl::RestoreBroadcaster () { - Mutex::Locker locker(m_listeners_mutex); + std::lock_guard guard(m_listeners_mutex); if (!m_hijacking_listeners.empty()) { @@ -425,8 +421,7 @@ BroadcastEventSpec & BroadcastEventSpec::operator=(const BroadcastEventSpec &rhs) = default; -BroadcasterManager::BroadcasterManager() : - m_manager_mutex(Mutex::eMutexTypeRecursive) +BroadcasterManager::BroadcasterManager() : m_manager_mutex() { } @@ -439,8 +434,8 @@ uint32_t BroadcasterManager::RegisterListenerForEvents (const lldb::ListenerSP &listener_sp, BroadcastEventSpec event_spec) { - Mutex::Locker locker(m_manager_mutex); - + std::lock_guard guard(m_manager_mutex); + collection::iterator iter = m_event_map.begin(), end_iter = m_event_map.end(); uint32_t available_bits = event_spec.GetEventBits(); @@ -463,7 +458,7 @@ bool BroadcasterManager::UnregisterListenerForEvents (const lldb::ListenerSP &listener_sp, BroadcastEventSpec event_spec) { - Mutex::Locker locker(m_manager_mutex); + std::lock_guard guard(m_manager_mutex); bool removed_some = false; if (m_listeners.erase(listener_sp) == 0) @@ -508,8 +503,8 @@ ListenerSP BroadcasterManager::GetListenerForEventSpec (BroadcastEventSpec event_spec) const { - Mutex::Locker locker(*(const_cast (&m_manager_mutex))); - + std::lock_guard guard(m_manager_mutex); + collection::const_iterator iter, end_iter = m_event_map.end(); iter = find_if (m_event_map.begin(), end_iter, BroadcastEventSpecMatches (event_spec)); if (iter != end_iter) @@ -521,7 +516,7 @@ void BroadcasterManager::RemoveListener(Listener *listener) { - Mutex::Locker locker(m_manager_mutex); + std::lock_guard guard(m_manager_mutex); ListenerMatchesPointer predicate (listener); listener_collection::iterator iter = m_listeners.begin(), end_iter = m_listeners.end(); @@ -543,7 +538,7 @@ void BroadcasterManager::RemoveListener (const lldb::ListenerSP &listener_sp) { - Mutex::Locker locker(m_manager_mutex); + std::lock_guard guard(m_manager_mutex); ListenerMatches predicate (listener_sp); if (m_listeners.erase (listener_sp) == 0) @@ -563,8 +558,8 @@ void BroadcasterManager::SignUpListenersForBroadcaster (Broadcaster &broadcaster) { - Mutex::Locker locker(m_manager_mutex); - + std::lock_guard guard(m_manager_mutex); + collection::iterator iter = m_event_map.begin(), end_iter = m_event_map.end(); while (iter != end_iter @@ -578,7 +573,7 @@ void BroadcasterManager::Clear () { - Mutex::Locker locker(m_manager_mutex); + std::lock_guard guard(m_manager_mutex); listener_collection::iterator end_iter = m_listeners.end(); for (listener_collection::iterator iter = m_listeners.begin(); iter != end_iter; iter++) Index: source/Core/Communication.cpp =================================================================== --- source/Core/Communication.cpp +++ source/Core/Communication.cpp @@ -33,31 +33,30 @@ return class_name; } -Communication::Communication(const char *name) : - Broadcaster(nullptr, name), - m_connection_sp(), - m_read_thread_enabled(false), - m_read_thread_did_exit(false), - m_bytes(), - m_bytes_mutex(Mutex::eMutexTypeRecursive), - m_write_mutex(Mutex::eMutexTypeNormal), - m_synchronize_mutex(Mutex::eMutexTypeNormal), - m_callback(nullptr), - m_callback_baton(nullptr), - m_close_on_eof(true) +Communication::Communication(const char *name) + : Broadcaster(nullptr, name), + m_connection_sp(), + m_read_thread_enabled(false), + m_read_thread_did_exit(false), + m_bytes(), + m_bytes_mutex(), + m_write_mutex(), + m_synchronize_mutex(), + m_callback(nullptr), + m_callback_baton(nullptr), + m_close_on_eof(true) { - lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION, - "%p Communication::Communication (name = %s)", - this, name); - - SetEventName (eBroadcastBitDisconnected, "disconnected"); - SetEventName (eBroadcastBitReadThreadGotBytes, "got bytes"); - SetEventName (eBroadcastBitReadThreadDidExit, "read thread did exit"); - SetEventName (eBroadcastBitReadThreadShouldExit, "read thread should exit"); - SetEventName (eBroadcastBitPacketAvailable, "packet available"); - SetEventName (eBroadcastBitNoMorePendingInput, "no more pending input"); - + lldb_private::LogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION, + "%p Communication::Communication (name = %s)", this, name); + + SetEventName(eBroadcastBitDisconnected, "disconnected"); + SetEventName(eBroadcastBitReadThreadGotBytes, "got bytes"); + SetEventName(eBroadcastBitReadThreadDidExit, "read thread did exit"); + SetEventName(eBroadcastBitReadThreadShouldExit, "read thread should exit"); + SetEventName(eBroadcastBitPacketAvailable, "packet available"); + SetEventName(eBroadcastBitNoMorePendingInput, "no more pending input"); + CheckInWithManager(); } @@ -205,7 +204,7 @@ { lldb::ConnectionSP connection_sp (m_connection_sp); - Mutex::Locker locker(m_write_mutex); + std::lock_guard guard(m_write_mutex); lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, "%p Communication::Write (src = %p, src_len = %" PRIu64 ") connection = %p", this, @@ -277,7 +276,7 @@ size_t Communication::GetCachedBytes (void *dst, size_t dst_len) { - Mutex::Locker locker(m_bytes_mutex); + std::lock_guard guard(m_bytes_mutex); if (!m_bytes.empty()) { // If DST is nullptr and we have a thread, then return the number @@ -311,7 +310,7 @@ } else if (bytes != nullptr && len > 0) { - Mutex::Locker locker(m_bytes_mutex); + std::lock_guard guard(m_bytes_mutex); m_bytes.append ((const char *)bytes, len); if (broadcast) BroadcastEventIfUnique (eBroadcastBitReadThreadGotBytes); @@ -425,7 +424,7 @@ Communication::SynchronizeWithReadThread () { // Only one thread can do the synchronization dance at a time. - Mutex::Locker locker(m_synchronize_mutex); + std::lock_guard guard(m_synchronize_mutex); // First start listening for the synchronization event. ListenerSP listener_sp(Listener::MakeListener("Communication::SyncronizeWithReadThread")); Index: source/Core/Debugger.cpp =================================================================== --- source/Core/Debugger.cpp +++ source/Core/Debugger.cpp @@ -12,6 +12,7 @@ // C Includes // C++ Includes #include +#include // Other libraries and framework includes #include "llvm/ADT/StringRef.h" @@ -67,10 +68,10 @@ #pragma mark Static Functions -static Mutex & -GetDebuggerListMutex () +static std::recursive_mutex & +GetDebuggerListMutex() { - static Mutex g_mutex(Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_mutex; return g_mutex; } @@ -469,7 +470,7 @@ assert(lldb_initialized && "Debugger::Terminate called without a matching Debugger::Initialize!"); // Clear our master list of debugger objects - Mutex::Locker locker (GetDebuggerListMutex ()); + std::lock_guard guard(GetDebuggerListMutex()); auto& debuggers = GetDebuggerList(); for (const auto& debugger: debuggers) debugger->Clear(); @@ -605,7 +606,7 @@ DebuggerSP debugger_sp (new Debugger(log_callback, baton)); if (lldb_initialized) { - Mutex::Locker locker (GetDebuggerListMutex ()); + std::lock_guard guard(GetDebuggerListMutex()); GetDebuggerList().push_back(debugger_sp); } debugger_sp->InstanceInitialize (); @@ -622,7 +623,7 @@ if (lldb_initialized) { - Mutex::Locker locker (GetDebuggerListMutex ()); + std::lock_guard guard(GetDebuggerListMutex()); DebuggerList &debugger_list = GetDebuggerList (); DebuggerList::iterator pos, end = debugger_list.end(); for (pos = debugger_list.begin (); pos != end; ++pos) @@ -642,7 +643,7 @@ DebuggerSP debugger_sp; if (lldb_initialized) { - Mutex::Locker locker (GetDebuggerListMutex ()); + std::lock_guard guard(GetDebuggerListMutex()); DebuggerList &debugger_list = GetDebuggerList(); DebuggerList::iterator pos, end = debugger_list.end(); @@ -664,7 +665,7 @@ TargetSP target_sp; if (lldb_initialized) { - Mutex::Locker locker (GetDebuggerListMutex ()); + std::lock_guard guard(GetDebuggerListMutex()); DebuggerList &debugger_list = GetDebuggerList(); DebuggerList::iterator pos, end = debugger_list.end(); for (pos = debugger_list.begin(); pos != end; ++pos) @@ -683,7 +684,7 @@ TargetSP target_sp; if (lldb_initialized) { - Mutex::Locker locker (GetDebuggerListMutex ()); + std::lock_guard guard(GetDebuggerListMutex()); DebuggerList &debugger_list = GetDebuggerList(); DebuggerList::iterator pos, end = debugger_list.end(); for (pos = debugger_list.begin(); pos != end; ++pos) @@ -922,33 +923,33 @@ } void -Debugger::DispatchInputInterrupt () +Debugger::DispatchInputInterrupt() { - Mutex::Locker locker (m_input_reader_stack.GetMutex()); - IOHandlerSP reader_sp (m_input_reader_stack.Top()); + std::lock_guard guard(m_input_reader_stack.GetMutex()); + IOHandlerSP reader_sp(m_input_reader_stack.Top()); if (reader_sp) reader_sp->Interrupt(); } void -Debugger::DispatchInputEndOfFile () +Debugger::DispatchInputEndOfFile() { - Mutex::Locker locker (m_input_reader_stack.GetMutex()); - IOHandlerSP reader_sp (m_input_reader_stack.Top()); + std::lock_guard guard(m_input_reader_stack.GetMutex()); + IOHandlerSP reader_sp(m_input_reader_stack.Top()); if (reader_sp) reader_sp->GotEOF(); } void -Debugger::ClearIOHandlers () +Debugger::ClearIOHandlers() { // The bottom input reader should be the main debugger input reader. We do not want to close that one here. - Mutex::Locker locker (m_input_reader_stack.GetMutex()); + std::lock_guard guard(m_input_reader_stack.GetMutex()); while (m_input_reader_stack.GetSize() > 1) { - IOHandlerSP reader_sp (m_input_reader_stack.Top()); + IOHandlerSP reader_sp(m_input_reader_stack.Top()); if (reader_sp) - PopIOHandler (reader_sp); + PopIOHandler(reader_sp); } } @@ -1041,16 +1042,16 @@ } void -Debugger::AdoptTopIOHandlerFilesIfInvalid (StreamFileSP &in, StreamFileSP &out, StreamFileSP &err) +Debugger::AdoptTopIOHandlerFilesIfInvalid(StreamFileSP &in, StreamFileSP &out, StreamFileSP &err) { // Before an IOHandler runs, it must have in/out/err streams. // This function is called when one ore more of the streams // are nullptr. We use the top input reader's in/out/err streams, // or fall back to the debugger file handles, or we fall back // onto stdin/stdout/stderr as a last resort. - - Mutex::Locker locker (m_input_reader_stack.GetMutex()); - IOHandlerSP top_reader_sp (m_input_reader_stack.Top()); + + std::lock_guard guard(m_input_reader_stack.GetMutex()); + IOHandlerSP top_reader_sp(m_input_reader_stack.Top()); // If no STDIN has been set, then set it appropriately if (!in) { @@ -1058,7 +1059,7 @@ in = top_reader_sp->GetInputStreamFile(); else in = GetInputFile(); - + // If there is nothing, use stdin if (!in) in = StreamFileSP(new StreamFile(stdin, false)); @@ -1070,7 +1071,7 @@ out = top_reader_sp->GetOutputStreamFile(); else out = GetOutputFile(); - + // If there is nothing, use stdout if (!out) out = StreamFileSP(new StreamFile(stdout, false)); @@ -1082,31 +1083,30 @@ err = top_reader_sp->GetErrorStreamFile(); else err = GetErrorFile(); - + // If there is nothing, use stderr if (!err) err = StreamFileSP(new StreamFile(stdout, false)); - } } void -Debugger::PushIOHandler (const IOHandlerSP& reader_sp) +Debugger::PushIOHandler(const IOHandlerSP &reader_sp) { if (!reader_sp) return; - - Mutex::Locker locker (m_input_reader_stack.GetMutex()); + + std::lock_guard guard(m_input_reader_stack.GetMutex()); // Get the current top input reader... - IOHandlerSP top_reader_sp (m_input_reader_stack.Top()); - + IOHandlerSP top_reader_sp(m_input_reader_stack.Top()); + // Don't push the same IO handler twice... if (reader_sp == top_reader_sp) return; // Push our new input reader - m_input_reader_stack.Push (reader_sp); + m_input_reader_stack.Push(reader_sp); reader_sp->Activate(); // Interrupt the top input reader to it will exit its Run() function @@ -1119,12 +1119,12 @@ } bool -Debugger::PopIOHandler (const IOHandlerSP& pop_reader_sp) +Debugger::PopIOHandler(const IOHandlerSP &pop_reader_sp) { - if (! pop_reader_sp) + if (!pop_reader_sp) return false; - Mutex::Locker locker (m_input_reader_stack.GetMutex()); + std::lock_guard guard(m_input_reader_stack.GetMutex()); // The reader on the stop of the stack is done, so let the next // read on the stack refresh its prompt and if there is one... @@ -1138,7 +1138,7 @@ reader_sp->Deactivate(); reader_sp->Cancel(); - m_input_reader_stack.Pop (); + m_input_reader_stack.Pop(); reader_sp = m_input_reader_stack.Top(); if (reader_sp) @@ -1164,7 +1164,7 @@ { if (lldb_initialized) { - Mutex::Locker locker (GetDebuggerListMutex ()); + std::lock_guard guard(GetDebuggerListMutex()); return GetDebuggerList().size(); } return 0; @@ -1177,9 +1177,9 @@ if (lldb_initialized) { - Mutex::Locker locker (GetDebuggerListMutex ()); + std::lock_guard guard(GetDebuggerListMutex()); DebuggerList &debugger_list = GetDebuggerList(); - + if (index < debugger_list.size()) debugger_sp = debugger_list[index]; } @@ -1194,7 +1194,7 @@ if (lldb_initialized) { - Mutex::Locker locker (GetDebuggerListMutex ()); + std::lock_guard guard(GetDebuggerListMutex()); DebuggerList &debugger_list = GetDebuggerList(); DebuggerList::iterator pos, end = debugger_list.end(); for (pos = debugger_list.begin(); pos != end; ++pos) Index: source/Core/IOHandler.cpp =================================================================== --- source/Core/IOHandler.cpp +++ source/Core/IOHandler.cpp @@ -169,13 +169,13 @@ } void -IOHandlerStack::PrintAsync (Stream *stream, const char *s, size_t len) +IOHandlerStack::PrintAsync(Stream *stream, const char *s, size_t len) { if (stream) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (m_top) - m_top->PrintAsync (stream, s, len); + m_top->PrintAsync(stream, s, len); } } Index: source/Core/Listener.cpp =================================================================== --- source/Core/Listener.cpp +++ source/Core/Listener.cpp @@ -40,12 +40,8 @@ }; } // anonymous namespace -Listener::Listener(const char *name) : - m_name (name), - m_broadcasters(), - m_broadcasters_mutex (Mutex::eMutexTypeRecursive), - m_events (), - m_events_mutex (Mutex::eMutexTypeNormal) +Listener::Listener(const char *name) + : m_name(name), m_broadcasters(), m_broadcasters_mutex(), m_events(), m_events_mutex(Mutex::eMutexTypeNormal) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); if (log != nullptr) @@ -67,7 +63,7 @@ Listener::Clear() { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); - Mutex::Locker locker(m_broadcasters_mutex); + std::lock_guard guard(m_broadcasters_mutex); broadcaster_collection::iterator pos, end = m_broadcasters.end(); for (pos = m_broadcasters.begin(); pos != end; ++pos) { @@ -100,7 +96,7 @@ // Scope for "locker" // Tell the broadcaster to add this object as a listener { - Mutex::Locker locker(m_broadcasters_mutex); + std::lock_guard guard(m_broadcasters_mutex); Broadcaster::BroadcasterImplWP impl_wp(broadcaster->GetBroadcasterImpl()); m_broadcasters.insert(std::make_pair(impl_wp, BroadcasterInfo(event_mask))); } @@ -127,7 +123,7 @@ // Scope for "locker" // Tell the broadcaster to add this object as a listener { - Mutex::Locker locker(m_broadcasters_mutex); + std::lock_guard guard(m_broadcasters_mutex); Broadcaster::BroadcasterImplWP impl_wp(broadcaster->GetBroadcasterImpl()); m_broadcasters.insert(std::make_pair(impl_wp, BroadcasterInfo(event_mask, callback, callback_user_data))); @@ -158,7 +154,7 @@ { // Scope for "locker" { - Mutex::Locker locker(m_broadcasters_mutex); + std::lock_guard guard(m_broadcasters_mutex); m_broadcasters.erase (broadcaster->GetBroadcasterImpl()); } // Remove the broadcaster from our set of broadcasters @@ -175,7 +171,7 @@ { // Scope for "broadcasters_locker" { - Mutex::Locker broadcasters_locker(m_broadcasters_mutex); + std::lock_guard guard(m_broadcasters_mutex); m_broadcasters.erase (broadcaster->GetBroadcasterImpl()); } @@ -474,7 +470,7 @@ Listener::HandleBroadcastEvent (EventSP &event_sp) { size_t num_handled = 0; - Mutex::Locker locker(m_broadcasters_mutex); + std::lock_guard guard(m_broadcasters_mutex); Broadcaster *broadcaster = event_sp->GetBroadcaster(); if (!broadcaster) return 0; @@ -507,8 +503,8 @@ // The BroadcasterManager mutex must be locked before m_broadcasters_mutex // to avoid violating the lock hierarchy (manager before broadcasters). - Mutex::Locker manager_locker(manager_sp->m_manager_mutex); - Mutex::Locker locker(m_broadcasters_mutex); + std::lock_guard manager_guard(manager_sp->m_manager_mutex); + std::lock_guard guard(m_broadcasters_mutex); uint32_t bits_acquired = manager_sp->RegisterListenerForEvents(this->shared_from_this(), event_spec); if (bits_acquired) @@ -530,8 +526,8 @@ { if (!manager_sp) return false; - - Mutex::Locker locker(m_broadcasters_mutex); + + std::lock_guard guard(m_broadcasters_mutex); return manager_sp->UnregisterListenerForEvents (this->shared_from_this(), event_spec); } Index: source/Core/Log.cpp =================================================================== --- source/Core/Log.cpp +++ source/Core/Log.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include // Other libraries and framework includes @@ -26,7 +27,6 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Core/StreamString.h" #include "lldb/Host/Host.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/ThisThread.h" #include "lldb/Host/TimeValue.h" #include "lldb/Interpreter/Args.h" @@ -147,8 +147,8 @@ if (m_options.Test(LLDB_LOG_OPTION_THREADSAFE)) { - static Mutex g_LogThreadedMutex(Mutex::eMutexTypeRecursive); - Mutex::Locker locker(g_LogThreadedMutex); + static std::recursive_mutex g_LogThreadedMutex; + std::lock_guard guard(g_LogThreadedMutex); stream_sp->PutCString(header.GetString().c_str()); stream_sp->Flush(); } Index: source/Core/Module.cpp =================================================================== --- source/Core/Module.cpp +++ source/Core/Module.cpp @@ -72,7 +72,7 @@ return *g_module_collection; } -Mutex * +std::recursive_mutex & Module::GetAllocationModuleCollectionMutex() { // NOTE: The mutex below must be leaked since the global module list in @@ -80,23 +80,23 @@ // if it will tear itself down before the "g_module_collection_mutex" below // will. So we leak a Mutex object below to safeguard against that - static Mutex *g_module_collection_mutex = nullptr; + static std::recursive_mutex *g_module_collection_mutex = nullptr; if (g_module_collection_mutex == nullptr) - g_module_collection_mutex = new Mutex (Mutex::eMutexTypeRecursive); // NOTE: known leak - return g_module_collection_mutex; + g_module_collection_mutex = new std::recursive_mutex; // NOTE: known leak + return *g_module_collection_mutex; } size_t Module::GetNumberAllocatedModules () { - Mutex::Locker locker (GetAllocationModuleCollectionMutex()); + std::lock_guard guard(GetAllocationModuleCollectionMutex()); return GetModuleCollection().size(); } Module * Module::GetAllocatedModuleAtIndex (size_t idx) { - Mutex::Locker locker (GetAllocationModuleCollectionMutex()); + std::lock_guard guard(GetAllocationModuleCollectionMutex()); ModuleCollection &modules = GetModuleCollection(); if (idx < modules.size()) return modules[idx]; @@ -140,44 +140,42 @@ #endif -Module::Module (const ModuleSpec &module_spec) : - m_mutex (Mutex::eMutexTypeRecursive), - m_mod_time (), - m_arch (), - m_uuid (), - m_file (), - m_platform_file(), - m_remote_install_file(), - m_symfile_spec (), - m_object_name (), - m_object_offset (), - m_object_mod_time (), - m_objfile_sp (), - m_symfile_ap (), - m_type_system_map(), - m_source_mappings (), - m_sections_ap(), - m_did_load_objfile (false), - m_did_load_symbol_vendor (false), - m_did_parse_uuid (false), - m_file_has_changed (false), - m_first_file_changed_log (false) +Module::Module(const ModuleSpec &module_spec) + : m_mutex(), + m_mod_time(), + m_arch(), + m_uuid(), + m_file(), + m_platform_file(), + m_remote_install_file(), + m_symfile_spec(), + m_object_name(), + m_object_offset(), + m_object_mod_time(), + m_objfile_sp(), + m_symfile_ap(), + m_type_system_map(), + m_source_mappings(), + m_sections_ap(), + m_did_load_objfile(false), + m_did_load_symbol_vendor(false), + m_did_parse_uuid(false), + m_file_has_changed(false), + m_first_file_changed_log(false) { // Scope for locker below... { - Mutex::Locker locker (GetAllocationModuleCollectionMutex()); + std::lock_guard guard(GetAllocationModuleCollectionMutex()); GetModuleCollection().push_back(this); } - Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES)); + Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_MODULES)); if (log != nullptr) - log->Printf ("%p Module::Module((%s) '%s%s%s%s')", - static_cast(this), - module_spec.GetArchitecture().GetArchitectureName(), - module_spec.GetFileSpec().GetPath().c_str(), - module_spec.GetObjectName().IsEmpty() ? "" : "(", - module_spec.GetObjectName().IsEmpty() ? "" : module_spec.GetObjectName().AsCString(""), - module_spec.GetObjectName().IsEmpty() ? "" : ")"); + log->Printf("%p Module::Module((%s) '%s%s%s%s')", static_cast(this), + module_spec.GetArchitecture().GetArchitectureName(), module_spec.GetFileSpec().GetPath().c_str(), + module_spec.GetObjectName().IsEmpty() ? "" : "(", + module_spec.GetObjectName().IsEmpty() ? "" : module_spec.GetObjectName().AsCString(""), + module_spec.GetObjectName().IsEmpty() ? "" : ")"); // First extract all module specifications from the file using the local // file path. If there are no specifications, then don't fill anything in @@ -194,18 +192,18 @@ ModuleSpec matching_module_spec; if (modules_specs.FindMatchingModuleSpec(module_spec, matching_module_spec) == 0) return; - + if (module_spec.GetFileSpec()) m_mod_time = module_spec.GetFileSpec().GetModificationTime(); else if (matching_module_spec.GetFileSpec()) m_mod_time = matching_module_spec.GetFileSpec().GetModificationTime(); - + // Copy the architecture from the actual spec if we got one back, else use the one that was specified if (matching_module_spec.GetArchitecture().IsValid()) m_arch = matching_module_spec.GetArchitecture(); else if (module_spec.GetArchitecture().IsValid()) m_arch = module_spec.GetArchitecture(); - + // Copy the file spec over and use the specified one (if there was one) so we // don't use a path that might have gotten resolved a path in 'matching_module_spec' if (module_spec.GetFileSpec()) @@ -218,57 +216,53 @@ m_platform_file = module_spec.GetPlatformFileSpec(); else if (matching_module_spec.GetPlatformFileSpec()) m_platform_file = matching_module_spec.GetPlatformFileSpec(); - + // Copy the symbol file spec over if (module_spec.GetSymbolFileSpec()) m_symfile_spec = module_spec.GetSymbolFileSpec(); else if (matching_module_spec.GetSymbolFileSpec()) m_symfile_spec = matching_module_spec.GetSymbolFileSpec(); - + // Copy the object name over if (matching_module_spec.GetObjectName()) m_object_name = matching_module_spec.GetObjectName(); else m_object_name = module_spec.GetObjectName(); - + // Always trust the object offset (file offset) and object modification // time (for mod time in a BSD static archive) of from the matching // module specification m_object_offset = matching_module_spec.GetObjectOffset(); m_object_mod_time = matching_module_spec.GetObjectModificationTime(); - } -Module::Module(const FileSpec& file_spec, - const ArchSpec& arch, - const ConstString *object_name, - lldb::offset_t object_offset, - const TimeValue *object_mod_time_ptr) : - m_mutex (Mutex::eMutexTypeRecursive), - m_mod_time (file_spec.GetModificationTime()), - m_arch (arch), - m_uuid (), - m_file (file_spec), - m_platform_file(), - m_remote_install_file (), - m_symfile_spec (), - m_object_name (), - m_object_offset (object_offset), - m_object_mod_time (), - m_objfile_sp (), - m_symfile_ap (), - m_type_system_map(), - m_source_mappings (), - m_sections_ap(), - m_did_load_objfile (false), - m_did_load_symbol_vendor (false), - m_did_parse_uuid (false), - m_file_has_changed (false), - m_first_file_changed_log (false) +Module::Module(const FileSpec &file_spec, const ArchSpec &arch, const ConstString *object_name, + lldb::offset_t object_offset, const TimeValue *object_mod_time_ptr) + : m_mutex(), + m_mod_time(file_spec.GetModificationTime()), + m_arch(arch), + m_uuid(), + m_file(file_spec), + m_platform_file(), + m_remote_install_file(), + m_symfile_spec(), + m_object_name(), + m_object_offset(object_offset), + m_object_mod_time(), + m_objfile_sp(), + m_symfile_ap(), + m_type_system_map(), + m_source_mappings(), + m_sections_ap(), + m_did_load_objfile(false), + m_did_load_symbol_vendor(false), + m_did_parse_uuid(false), + m_file_has_changed(false), + m_first_file_changed_log(false) { // Scope for locker below... { - Mutex::Locker locker (GetAllocationModuleCollectionMutex()); + std::lock_guard guard(GetAllocationModuleCollectionMutex()); GetModuleCollection().push_back(this); } @@ -278,40 +272,37 @@ if (object_mod_time_ptr) m_object_mod_time = *object_mod_time_ptr; - Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES)); + Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_MODULES)); if (log != nullptr) - log->Printf ("%p Module::Module((%s) '%s%s%s%s')", - static_cast(this), m_arch.GetArchitectureName(), - m_file.GetPath().c_str(), - m_object_name.IsEmpty() ? "" : "(", - m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""), - m_object_name.IsEmpty() ? "" : ")"); -} - -Module::Module () : - m_mutex (Mutex::eMutexTypeRecursive), - m_mod_time (), - m_arch (), - m_uuid (), - m_file (), - m_platform_file(), - m_remote_install_file (), - m_symfile_spec (), - m_object_name (), - m_object_offset (0), - m_object_mod_time (), - m_objfile_sp (), - m_symfile_ap (), - m_type_system_map(), - m_source_mappings (), - m_sections_ap(), - m_did_load_objfile (false), - m_did_load_symbol_vendor (false), - m_did_parse_uuid (false), - m_file_has_changed (false), - m_first_file_changed_log (false) -{ - Mutex::Locker locker (GetAllocationModuleCollectionMutex()); + log->Printf("%p Module::Module((%s) '%s%s%s%s')", static_cast(this), m_arch.GetArchitectureName(), + m_file.GetPath().c_str(), m_object_name.IsEmpty() ? "" : "(", + m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""), m_object_name.IsEmpty() ? "" : ")"); +} + +Module::Module() + : m_mutex(), + m_mod_time(), + m_arch(), + m_uuid(), + m_file(), + m_platform_file(), + m_remote_install_file(), + m_symfile_spec(), + m_object_name(), + m_object_offset(0), + m_object_mod_time(), + m_objfile_sp(), + m_symfile_ap(), + m_type_system_map(), + m_source_mappings(), + m_sections_ap(), + m_did_load_objfile(false), + m_did_load_symbol_vendor(false), + m_did_parse_uuid(false), + m_file_has_changed(false), + m_first_file_changed_log(false) +{ + std::lock_guard guard(GetAllocationModuleCollectionMutex()); GetModuleCollection().push_back(this); } @@ -319,10 +310,10 @@ { // Lock our module down while we tear everything down to make sure // we don't get any access to the module while it is being destroyed - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); // Scope for locker below... { - Mutex::Locker locker (GetAllocationModuleCollectionMutex()); + std::lock_guard guard(GetAllocationModuleCollectionMutex()); ModuleCollection &modules = GetModuleCollection(); ModuleCollection::iterator end = modules.end(); ModuleCollection::iterator pos = std::find(modules.begin(), end, this); @@ -357,7 +348,7 @@ } else { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (process_sp) { m_did_load_objfile = true; @@ -405,7 +396,7 @@ { if (!m_did_parse_uuid.load()) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (!m_did_parse_uuid.load()) { ObjectFile * obj_file = GetObjectFile (); @@ -429,7 +420,7 @@ void Module::ParseAllDebugSymbols() { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); size_t num_comp_units = GetNumCompileUnits(); if (num_comp_units == 0) return; @@ -484,7 +475,7 @@ size_t Module::GetNumCompileUnits() { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); Timer scoped_timer(__PRETTY_FUNCTION__, "Module::GetNumCompileUnits (module = %p)", static_cast(this)); @@ -497,7 +488,7 @@ CompUnitSP Module::GetCompileUnitAtIndex (size_t index) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); size_t num_comp_units = GetNumCompileUnits (); CompUnitSP cu_sp; @@ -513,7 +504,7 @@ bool Module::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); Timer scoped_timer(__PRETTY_FUNCTION__, "Module::ResolveFileAddress (vm_addr = 0x%" PRIx64 ")", vm_addr); SectionList *section_list = GetSectionList(); if (section_list) @@ -525,7 +516,7 @@ Module::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc, bool resolve_tail_call_address) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); uint32_t resolved_flags = 0; // Clear the result symbol context in case we don't find anything, but don't clear the target @@ -675,7 +666,7 @@ uint32_t Module::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); Timer scoped_timer(__PRETTY_FUNCTION__, "Module::ResolveSymbolContextForFilePath (%s:%u, check_inlines = %s, resolve_scope = 0x%8.8x)", file_spec.GetPath().c_str(), @@ -1037,7 +1028,7 @@ { if (!m_did_load_symbol_vendor.load()) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (!m_did_load_symbol_vendor.load() && can_create) { ObjectFile *obj_file = GetObjectFile (); @@ -1084,7 +1075,7 @@ void Module::GetDescription (Stream *s, lldb::DescriptionLevel level) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (level >= eDescriptionLevelFull) { @@ -1245,7 +1236,7 @@ void Module::Dump(Stream *s) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); //s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); s->Printf("Module %s%s%s%s\n", @@ -1287,7 +1278,7 @@ { if (!m_did_load_objfile.load()) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (!m_did_load_objfile.load()) { Timer scoped_timer(__PRETTY_FUNCTION__, @@ -1710,14 +1701,14 @@ bool Module::FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); return m_source_mappings.FindFile (orig_spec, new_spec); } bool Module::RemapSourceFile (const char *path, std::string &new_path) const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); return m_source_mappings.RemapPath(path, new_path); } Index: source/Core/PluginManager.cpp =================================================================== --- source/Core/PluginManager.cpp +++ source/Core/PluginManager.cpp @@ -12,6 +12,7 @@ // C Includes // C++ Includes #include +#include #include #include @@ -25,7 +26,6 @@ #include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" -#include "lldb/Host/Mutex.h" #include "lldb/Interpreter/OptionValueProperties.h" using namespace lldb; @@ -55,10 +55,10 @@ typedef std::map PluginTerminateMap; -static Mutex & -GetPluginMapMutex () +static std::recursive_mutex & +GetPluginMapMutex() { - static Mutex g_plugin_map_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_plugin_map_mutex; return g_plugin_map_mutex; } @@ -72,7 +72,7 @@ static bool PluginIsLoaded (const FileSpec &plugin_file_spec) { - Mutex::Locker locker (GetPluginMapMutex ()); + std::lock_guard guard(GetPluginMapMutex()); PluginTerminateMap &plugin_map = GetPluginMap (); return plugin_map.find (plugin_file_spec) != plugin_map.end(); } @@ -80,7 +80,7 @@ static void SetPluginInfo (const FileSpec &plugin_file_spec, const PluginInfo &plugin_info) { - Mutex::Locker locker (GetPluginMapMutex ()); + std::lock_guard guard(GetPluginMapMutex()); PluginTerminateMap &plugin_map = GetPluginMap (); assert (plugin_map.find (plugin_file_spec) == plugin_map.end()); plugin_map[plugin_file_spec] = plugin_info; @@ -209,7 +209,7 @@ void PluginManager::Terminate () { - Mutex::Locker locker (GetPluginMapMutex ()); + std::lock_guard guard(GetPluginMapMutex()); PluginTerminateMap &plugin_map = GetPluginMap (); PluginTerminateMap::const_iterator pos, end = plugin_map.end(); @@ -244,10 +244,10 @@ typedef std::vector ABIInstances; -static Mutex & -GetABIInstancesMutex () +static std::recursive_mutex & +GetABIInstancesMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -271,7 +271,7 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - Mutex::Locker locker (GetABIInstancesMutex ()); + std::lock_guard guard(GetABIInstancesMutex()); GetABIInstances ().push_back (instance); return true; } @@ -283,7 +283,7 @@ { if (create_callback) { - Mutex::Locker locker (GetABIInstancesMutex ()); + std::lock_guard guard(GetABIInstancesMutex()); ABIInstances &instances = GetABIInstances (); ABIInstances::iterator pos, end = instances.end(); @@ -302,7 +302,7 @@ ABICreateInstance PluginManager::GetABICreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetABIInstancesMutex ()); + std::lock_guard guard(GetABIInstancesMutex()); ABIInstances &instances = GetABIInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -314,7 +314,7 @@ { if (name) { - Mutex::Locker locker (GetABIInstancesMutex ()); + std::lock_guard guard(GetABIInstancesMutex()); ABIInstances &instances = GetABIInstances (); ABIInstances::iterator pos, end = instances.end(); @@ -345,10 +345,10 @@ typedef std::vector DisassemblerInstances; -static Mutex & -GetDisassemblerMutex () +static std::recursive_mutex & +GetDisassemblerMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -372,7 +372,7 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - Mutex::Locker locker (GetDisassemblerMutex ()); + std::lock_guard guard(GetDisassemblerMutex()); GetDisassemblerInstances ().push_back (instance); return true; } @@ -384,7 +384,7 @@ { if (create_callback) { - Mutex::Locker locker (GetDisassemblerMutex ()); + std::lock_guard guard(GetDisassemblerMutex()); DisassemblerInstances &instances = GetDisassemblerInstances (); DisassemblerInstances::iterator pos, end = instances.end(); @@ -403,7 +403,7 @@ DisassemblerCreateInstance PluginManager::GetDisassemblerCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetDisassemblerMutex ()); + std::lock_guard guard(GetDisassemblerMutex()); DisassemblerInstances &instances = GetDisassemblerInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -415,7 +415,7 @@ { if (name) { - Mutex::Locker locker (GetDisassemblerMutex ()); + std::lock_guard guard(GetDisassemblerMutex()); DisassemblerInstances &instances = GetDisassemblerInstances (); DisassemblerInstances::iterator pos, end = instances.end(); @@ -448,10 +448,10 @@ typedef std::vector DynamicLoaderInstances; -static Mutex & -GetDynamicLoaderMutex () +static std::recursive_mutex & +GetDynamicLoaderMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -477,7 +477,7 @@ instance.description = description; instance.create_callback = create_callback; instance.debugger_init_callback = debugger_init_callback; - Mutex::Locker locker (GetDynamicLoaderMutex ()); + std::lock_guard guard(GetDynamicLoaderMutex()); GetDynamicLoaderInstances ().push_back (instance); } return false; @@ -488,7 +488,7 @@ { if (create_callback) { - Mutex::Locker locker (GetDynamicLoaderMutex ()); + std::lock_guard guard(GetDynamicLoaderMutex()); DynamicLoaderInstances &instances = GetDynamicLoaderInstances (); DynamicLoaderInstances::iterator pos, end = instances.end(); @@ -507,7 +507,7 @@ DynamicLoaderCreateInstance PluginManager::GetDynamicLoaderCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetDynamicLoaderMutex ()); + std::lock_guard guard(GetDynamicLoaderMutex()); DynamicLoaderInstances &instances = GetDynamicLoaderInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -519,7 +519,7 @@ { if (name) { - Mutex::Locker locker (GetDynamicLoaderMutex ()); + std::lock_guard guard(GetDynamicLoaderMutex()); DynamicLoaderInstances &instances = GetDynamicLoaderInstances (); DynamicLoaderInstances::iterator pos, end = instances.end(); @@ -552,10 +552,10 @@ typedef std::vector JITLoaderInstances; -static Mutex & -GetJITLoaderMutex () +static std::recursive_mutex & +GetJITLoaderMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -581,7 +581,7 @@ instance.description = description; instance.create_callback = create_callback; instance.debugger_init_callback = debugger_init_callback; - Mutex::Locker locker (GetJITLoaderMutex ()); + std::lock_guard guard(GetJITLoaderMutex()); GetJITLoaderInstances ().push_back (instance); } return false; @@ -592,7 +592,7 @@ { if (create_callback) { - Mutex::Locker locker (GetJITLoaderMutex ()); + std::lock_guard guard(GetJITLoaderMutex()); JITLoaderInstances &instances = GetJITLoaderInstances (); JITLoaderInstances::iterator pos, end = instances.end(); @@ -611,7 +611,7 @@ JITLoaderCreateInstance PluginManager::GetJITLoaderCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetJITLoaderMutex ()); + std::lock_guard guard(GetJITLoaderMutex()); JITLoaderInstances &instances = GetJITLoaderInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -623,7 +623,7 @@ { if (name) { - Mutex::Locker locker (GetJITLoaderMutex ()); + std::lock_guard guard(GetJITLoaderMutex()); JITLoaderInstances &instances = GetJITLoaderInstances (); JITLoaderInstances::iterator pos, end = instances.end(); @@ -654,10 +654,10 @@ typedef std::vector EmulateInstructionInstances; -static Mutex & -GetEmulateInstructionMutex () +static std::recursive_mutex & +GetEmulateInstructionMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -681,7 +681,7 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - Mutex::Locker locker (GetEmulateInstructionMutex ()); + std::lock_guard guard(GetEmulateInstructionMutex()); GetEmulateInstructionInstances ().push_back (instance); } return false; @@ -692,7 +692,7 @@ { if (create_callback) { - Mutex::Locker locker (GetEmulateInstructionMutex ()); + std::lock_guard guard(GetEmulateInstructionMutex()); EmulateInstructionInstances &instances = GetEmulateInstructionInstances (); EmulateInstructionInstances::iterator pos, end = instances.end(); @@ -711,7 +711,7 @@ EmulateInstructionCreateInstance PluginManager::GetEmulateInstructionCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetEmulateInstructionMutex ()); + std::lock_guard guard(GetEmulateInstructionMutex()); EmulateInstructionInstances &instances = GetEmulateInstructionInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -723,7 +723,7 @@ { if (name) { - Mutex::Locker locker (GetEmulateInstructionMutex ()); + std::lock_guard guard(GetEmulateInstructionMutex()); EmulateInstructionInstances &instances = GetEmulateInstructionInstances (); EmulateInstructionInstances::iterator pos, end = instances.end(); @@ -756,10 +756,10 @@ typedef std::vector OperatingSystemInstances; -static Mutex & -GetOperatingSystemMutex () +static std::recursive_mutex & +GetOperatingSystemMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -784,7 +784,7 @@ instance.description = description; instance.create_callback = create_callback; instance.debugger_init_callback = debugger_init_callback; - Mutex::Locker locker (GetOperatingSystemMutex ()); + std::lock_guard guard(GetOperatingSystemMutex()); GetOperatingSystemInstances ().push_back (instance); } return false; @@ -795,7 +795,7 @@ { if (create_callback) { - Mutex::Locker locker (GetOperatingSystemMutex ()); + std::lock_guard guard(GetOperatingSystemMutex()); OperatingSystemInstances &instances = GetOperatingSystemInstances (); OperatingSystemInstances::iterator pos, end = instances.end(); @@ -814,7 +814,7 @@ OperatingSystemCreateInstance PluginManager::GetOperatingSystemCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetOperatingSystemMutex ()); + std::lock_guard guard(GetOperatingSystemMutex()); OperatingSystemInstances &instances = GetOperatingSystemInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -826,7 +826,7 @@ { if (name) { - Mutex::Locker locker (GetOperatingSystemMutex ()); + std::lock_guard guard(GetOperatingSystemMutex()); OperatingSystemInstances &instances = GetOperatingSystemInstances (); OperatingSystemInstances::iterator pos, end = instances.end(); @@ -857,10 +857,10 @@ typedef std::vector LanguageInstances; -static Mutex & -GetLanguageMutex () +static std::recursive_mutex & +GetLanguageMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -884,7 +884,7 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - Mutex::Locker locker (GetLanguageMutex ()); + std::lock_guard guard(GetLanguageMutex()); GetLanguageInstances ().push_back (instance); } return false; @@ -895,7 +895,7 @@ { if (create_callback) { - Mutex::Locker locker (GetLanguageMutex ()); + std::lock_guard guard(GetLanguageMutex()); LanguageInstances &instances = GetLanguageInstances (); LanguageInstances::iterator pos, end = instances.end(); @@ -914,7 +914,7 @@ LanguageCreateInstance PluginManager::GetLanguageCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetLanguageMutex ()); + std::lock_guard guard(GetLanguageMutex()); LanguageInstances &instances = GetLanguageInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -926,7 +926,7 @@ { if (name) { - Mutex::Locker locker (GetLanguageMutex ()); + std::lock_guard guard(GetLanguageMutex()); LanguageInstances &instances = GetLanguageInstances (); LanguageInstances::iterator pos, end = instances.end(); @@ -958,10 +958,10 @@ typedef std::vector LanguageRuntimeInstances; -static Mutex & -GetLanguageRuntimeMutex () +static std::recursive_mutex & +GetLanguageRuntimeMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -987,7 +987,7 @@ instance.description = description; instance.create_callback = create_callback; instance.command_callback = command_callback; - Mutex::Locker locker (GetLanguageRuntimeMutex ()); + std::lock_guard guard(GetLanguageRuntimeMutex()); GetLanguageRuntimeInstances ().push_back (instance); } return false; @@ -998,7 +998,7 @@ { if (create_callback) { - Mutex::Locker locker (GetLanguageRuntimeMutex ()); + std::lock_guard guard(GetLanguageRuntimeMutex()); LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances (); LanguageRuntimeInstances::iterator pos, end = instances.end(); @@ -1017,7 +1017,7 @@ LanguageRuntimeCreateInstance PluginManager::GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetLanguageRuntimeMutex ()); + std::lock_guard guard(GetLanguageRuntimeMutex()); LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -1027,7 +1027,7 @@ LanguageRuntimeGetCommandObject PluginManager::GetLanguageRuntimeGetCommandObjectAtIndex (uint32_t idx) { - Mutex::Locker locker (GetLanguageRuntimeMutex ()); + std::lock_guard guard(GetLanguageRuntimeMutex()); LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances (); if (idx < instances.size()) return instances[idx].command_callback; @@ -1039,7 +1039,7 @@ { if (name) { - Mutex::Locker locker (GetLanguageRuntimeMutex ()); + std::lock_guard guard(GetLanguageRuntimeMutex()); LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances (); LanguageRuntimeInstances::iterator pos, end = instances.end(); @@ -1070,10 +1070,10 @@ typedef std::vector SystemRuntimeInstances; -static Mutex & -GetSystemRuntimeMutex () +static std::recursive_mutex & +GetSystemRuntimeMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -1097,7 +1097,7 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - Mutex::Locker locker (GetSystemRuntimeMutex ()); + std::lock_guard guard(GetSystemRuntimeMutex()); GetSystemRuntimeInstances ().push_back (instance); } return false; @@ -1108,7 +1108,7 @@ { if (create_callback) { - Mutex::Locker locker (GetSystemRuntimeMutex ()); + std::lock_guard guard(GetSystemRuntimeMutex()); SystemRuntimeInstances &instances = GetSystemRuntimeInstances (); SystemRuntimeInstances::iterator pos, end = instances.end(); @@ -1127,7 +1127,7 @@ SystemRuntimeCreateInstance PluginManager::GetSystemRuntimeCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetSystemRuntimeMutex ()); + std::lock_guard guard(GetSystemRuntimeMutex()); SystemRuntimeInstances &instances = GetSystemRuntimeInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -1139,7 +1139,7 @@ { if (name) { - Mutex::Locker locker (GetSystemRuntimeMutex ()); + std::lock_guard guard(GetSystemRuntimeMutex()); SystemRuntimeInstances &instances = GetSystemRuntimeInstances (); SystemRuntimeInstances::iterator pos, end = instances.end(); @@ -1176,10 +1176,10 @@ typedef std::vector ObjectFileInstances; -static Mutex & -GetObjectFileMutex () +static std::recursive_mutex & +GetObjectFileMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -1209,7 +1209,7 @@ instance.create_memory_callback = create_memory_callback; instance.save_core = save_core; instance.get_module_specifications = get_module_specifications; - Mutex::Locker locker (GetObjectFileMutex ()); + std::lock_guard guard(GetObjectFileMutex()); GetObjectFileInstances ().push_back (instance); } return false; @@ -1220,7 +1220,7 @@ { if (create_callback) { - Mutex::Locker locker (GetObjectFileMutex ()); + std::lock_guard guard(GetObjectFileMutex()); ObjectFileInstances &instances = GetObjectFileInstances (); ObjectFileInstances::iterator pos, end = instances.end(); @@ -1239,7 +1239,7 @@ ObjectFileCreateInstance PluginManager::GetObjectFileCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetObjectFileMutex ()); + std::lock_guard guard(GetObjectFileMutex()); ObjectFileInstances &instances = GetObjectFileInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -1249,7 +1249,7 @@ ObjectFileCreateMemoryInstance PluginManager::GetObjectFileCreateMemoryCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetObjectFileMutex ()); + std::lock_guard guard(GetObjectFileMutex()); ObjectFileInstances &instances = GetObjectFileInstances (); if (idx < instances.size()) return instances[idx].create_memory_callback; @@ -1259,7 +1259,7 @@ ObjectFileGetModuleSpecifications PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetObjectFileMutex ()); + std::lock_guard guard(GetObjectFileMutex()); ObjectFileInstances &instances = GetObjectFileInstances (); if (idx < instances.size()) return instances[idx].get_module_specifications; @@ -1271,7 +1271,7 @@ { if (name) { - Mutex::Locker locker (GetObjectFileMutex ()); + std::lock_guard guard(GetObjectFileMutex()); ObjectFileInstances &instances = GetObjectFileInstances (); ObjectFileInstances::iterator pos, end = instances.end(); @@ -1289,7 +1289,7 @@ { if (name) { - Mutex::Locker locker (GetObjectFileMutex ()); + std::lock_guard guard(GetObjectFileMutex()); ObjectFileInstances &instances = GetObjectFileInstances (); ObjectFileInstances::iterator pos, end = instances.end(); @@ -1306,7 +1306,7 @@ PluginManager::SaveCore (const lldb::ProcessSP &process_sp, const FileSpec &outfile) { Error error; - Mutex::Locker locker (GetObjectFileMutex ()); + std::lock_guard guard(GetObjectFileMutex()); ObjectFileInstances &instances = GetObjectFileInstances (); ObjectFileInstances::iterator pos, end = instances.end(); @@ -1339,10 +1339,10 @@ typedef std::vector ObjectContainerInstances; -static Mutex & -GetObjectContainerMutex () +static std::recursive_mutex & +GetObjectContainerMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -1368,7 +1368,7 @@ instance.description = description; instance.create_callback = create_callback; instance.get_module_specifications = get_module_specifications; - Mutex::Locker locker (GetObjectContainerMutex ()); + std::lock_guard guard(GetObjectContainerMutex()); GetObjectContainerInstances ().push_back (instance); } return false; @@ -1379,7 +1379,7 @@ { if (create_callback) { - Mutex::Locker locker (GetObjectContainerMutex ()); + std::lock_guard guard(GetObjectContainerMutex()); ObjectContainerInstances &instances = GetObjectContainerInstances (); ObjectContainerInstances::iterator pos, end = instances.end(); @@ -1398,7 +1398,7 @@ ObjectContainerCreateInstance PluginManager::GetObjectContainerCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetObjectContainerMutex ()); + std::lock_guard guard(GetObjectContainerMutex()); ObjectContainerInstances &instances = GetObjectContainerInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -1410,7 +1410,7 @@ { if (name) { - Mutex::Locker locker (GetObjectContainerMutex ()); + std::lock_guard guard(GetObjectContainerMutex()); ObjectContainerInstances &instances = GetObjectContainerInstances (); ObjectContainerInstances::iterator pos, end = instances.end(); @@ -1426,7 +1426,7 @@ ObjectFileGetModuleSpecifications PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetObjectContainerMutex ()); + std::lock_guard guard(GetObjectContainerMutex()); ObjectContainerInstances &instances = GetObjectContainerInstances (); if (idx < instances.size()) return instances[idx].get_module_specifications; @@ -1451,10 +1451,10 @@ typedef std::vector LogInstances; -static Mutex & -GetLogMutex () +static std::recursive_mutex & +GetLogMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -1478,7 +1478,7 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - Mutex::Locker locker (GetLogMutex ()); + std::lock_guard gard(GetLogMutex()); GetLogInstances ().push_back (instance); } return false; @@ -1489,7 +1489,7 @@ { if (create_callback) { - Mutex::Locker locker (GetLogMutex ()); + std::lock_guard gard(GetLogMutex()); LogInstances &instances = GetLogInstances (); LogInstances::iterator pos, end = instances.end(); @@ -1508,7 +1508,7 @@ const char * PluginManager::GetLogChannelCreateNameAtIndex (uint32_t idx) { - Mutex::Locker locker (GetLogMutex ()); + std::lock_guard gard(GetLogMutex()); LogInstances &instances = GetLogInstances (); if (idx < instances.size()) return instances[idx].name.GetCString(); @@ -1518,7 +1518,7 @@ LogChannelCreateInstance PluginManager::GetLogChannelCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetLogMutex ()); + std::lock_guard gard(GetLogMutex()); LogInstances &instances = GetLogInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -1530,7 +1530,7 @@ { if (name) { - Mutex::Locker locker (GetLogMutex ()); + std::lock_guard gard(GetLogMutex()); LogInstances &instances = GetLogInstances (); LogInstances::iterator pos, end = instances.end(); @@ -1563,10 +1563,10 @@ typedef std::vector PlatformInstances; -static Mutex & -GetPlatformInstancesMutex () +static std::recursive_mutex & +GetPlatformInstancesMutex() { - static Mutex g_platform_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_platform_instances_mutex; return g_platform_instances_mutex; } @@ -1585,8 +1585,8 @@ { if (create_callback) { - Mutex::Locker locker (GetPlatformInstancesMutex ()); - + std::lock_guard guard(GetPlatformInstancesMutex()); + PlatformInstance instance; assert ((bool)name); instance.name = name; @@ -1603,7 +1603,7 @@ const char * PluginManager::GetPlatformPluginNameAtIndex (uint32_t idx) { - Mutex::Locker locker (GetPlatformInstancesMutex ()); + std::lock_guard guard(GetPlatformInstancesMutex()); PlatformInstances &instances = GetPlatformInstances (); if (idx < instances.size()) return instances[idx].name.GetCString(); @@ -1613,7 +1613,7 @@ const char * PluginManager::GetPlatformPluginDescriptionAtIndex (uint32_t idx) { - Mutex::Locker locker (GetPlatformInstancesMutex ()); + std::lock_guard guard(GetPlatformInstancesMutex()); PlatformInstances &instances = GetPlatformInstances (); if (idx < instances.size()) return instances[idx].description.c_str(); @@ -1625,7 +1625,7 @@ { if (create_callback) { - Mutex::Locker locker (GetPlatformInstancesMutex ()); + std::lock_guard guard(GetPlatformInstancesMutex()); PlatformInstances &instances = GetPlatformInstances (); PlatformInstances::iterator pos, end = instances.end(); @@ -1644,7 +1644,7 @@ PlatformCreateInstance PluginManager::GetPlatformCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetPlatformInstancesMutex ()); + std::lock_guard guard(GetPlatformInstancesMutex()); PlatformInstances &instances = GetPlatformInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -1656,7 +1656,7 @@ { if (name) { - Mutex::Locker locker (GetPlatformInstancesMutex ()); + std::lock_guard guard(GetPlatformInstancesMutex()); PlatformInstances &instances = GetPlatformInstances (); PlatformInstances::iterator pos, end = instances.end(); @@ -1674,7 +1674,7 @@ { if (name) { - Mutex::Locker locker (GetPlatformInstancesMutex ()); + std::lock_guard guard(GetPlatformInstancesMutex()); PlatformInstances &instances = GetPlatformInstances (); llvm::StringRef name_sref(name); @@ -1709,10 +1709,10 @@ typedef std::vector ProcessInstances; -static Mutex & -GetProcessMutex () +static std::recursive_mutex & +GetProcessMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -1738,7 +1738,7 @@ instance.description = description; instance.create_callback = create_callback; instance.debugger_init_callback = debugger_init_callback; - Mutex::Locker locker (GetProcessMutex ()); + std::lock_guard guard(GetProcessMutex()); GetProcessInstances ().push_back (instance); } return false; @@ -1747,7 +1747,7 @@ const char * PluginManager::GetProcessPluginNameAtIndex (uint32_t idx) { - Mutex::Locker locker (GetProcessMutex ()); + std::lock_guard guard(GetProcessMutex()); ProcessInstances &instances = GetProcessInstances (); if (idx < instances.size()) return instances[idx].name.GetCString(); @@ -1757,7 +1757,7 @@ const char * PluginManager::GetProcessPluginDescriptionAtIndex (uint32_t idx) { - Mutex::Locker locker (GetProcessMutex ()); + std::lock_guard guard(GetProcessMutex()); ProcessInstances &instances = GetProcessInstances (); if (idx < instances.size()) return instances[idx].description.c_str(); @@ -1769,7 +1769,7 @@ { if (create_callback) { - Mutex::Locker locker (GetProcessMutex ()); + std::lock_guard guard(GetProcessMutex()); ProcessInstances &instances = GetProcessInstances (); ProcessInstances::iterator pos, end = instances.end(); @@ -1788,7 +1788,7 @@ ProcessCreateInstance PluginManager::GetProcessCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetProcessMutex ()); + std::lock_guard guard(GetProcessMutex()); ProcessInstances &instances = GetProcessInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -1800,7 +1800,7 @@ { if (name) { - Mutex::Locker locker (GetProcessMutex ()); + std::lock_guard guard(GetProcessMutex()); ProcessInstances &instances = GetProcessInstances (); ProcessInstances::iterator pos, end = instances.end(); @@ -1833,10 +1833,10 @@ typedef std::vector ScriptInterpreterInstances; -static Mutex & +static std::recursive_mutex & GetScriptInterpreterMutex() { - static Mutex g_instances_mutex(Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -1860,7 +1860,7 @@ instance.description = description; instance.create_callback = create_callback; instance.language = script_language; - Mutex::Locker locker(GetScriptInterpreterMutex()); + std::lock_guard guard(GetScriptInterpreterMutex()); GetScriptInterpreterInstances().push_back(instance); return false; } @@ -1870,7 +1870,7 @@ { if (!create_callback) return false; - Mutex::Locker locker(GetScriptInterpreterMutex()); + std::lock_guard guard(GetScriptInterpreterMutex()); ScriptInterpreterInstances &instances = GetScriptInterpreterInstances(); ScriptInterpreterInstances::iterator pos, end = instances.end(); @@ -1888,7 +1888,7 @@ ScriptInterpreterCreateInstance PluginManager::GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx) { - Mutex::Locker locker(GetScriptInterpreterMutex()); + std::lock_guard guard(GetScriptInterpreterMutex()); ScriptInterpreterInstances &instances = GetScriptInterpreterInstances(); if (idx < instances.size()) return instances[idx].create_callback; @@ -1898,7 +1898,7 @@ lldb::ScriptInterpreterSP PluginManager::GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang, CommandInterpreter &interpreter) { - Mutex::Locker locker(GetScriptInterpreterMutex()); + std::lock_guard guard(GetScriptInterpreterMutex()); ScriptInterpreterInstances &instances = GetScriptInterpreterInstances(); ScriptInterpreterInstances::iterator pos, end = instances.end(); @@ -1937,10 +1937,10 @@ typedef std::vector SymbolFileInstances; -static Mutex & -GetSymbolFileMutex () +static std::recursive_mutex & +GetSymbolFileMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -1966,7 +1966,7 @@ instance.description = description; instance.create_callback = create_callback; instance.debugger_init_callback = debugger_init_callback; - Mutex::Locker locker (GetSymbolFileMutex ()); + std::lock_guard guard(GetSymbolFileMutex()); GetSymbolFileInstances ().push_back (instance); } return false; @@ -1977,7 +1977,7 @@ { if (create_callback) { - Mutex::Locker locker (GetSymbolFileMutex ()); + std::lock_guard guard(GetSymbolFileMutex()); SymbolFileInstances &instances = GetSymbolFileInstances (); SymbolFileInstances::iterator pos, end = instances.end(); @@ -1996,7 +1996,7 @@ SymbolFileCreateInstance PluginManager::GetSymbolFileCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetSymbolFileMutex ()); + std::lock_guard guard(GetSymbolFileMutex()); SymbolFileInstances &instances = GetSymbolFileInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -2008,7 +2008,7 @@ { if (name) { - Mutex::Locker locker (GetSymbolFileMutex ()); + std::lock_guard guard(GetSymbolFileMutex()); SymbolFileInstances &instances = GetSymbolFileInstances (); SymbolFileInstances::iterator pos, end = instances.end(); @@ -2039,10 +2039,10 @@ typedef std::vector SymbolVendorInstances; -static Mutex & -GetSymbolVendorMutex () +static std::recursive_mutex & +GetSymbolVendorMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -2066,7 +2066,7 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - Mutex::Locker locker (GetSymbolVendorMutex ()); + std::lock_guard guard(GetSymbolVendorMutex()); GetSymbolVendorInstances ().push_back (instance); } return false; @@ -2077,7 +2077,7 @@ { if (create_callback) { - Mutex::Locker locker (GetSymbolVendorMutex ()); + std::lock_guard guard(GetSymbolVendorMutex()); SymbolVendorInstances &instances = GetSymbolVendorInstances (); SymbolVendorInstances::iterator pos, end = instances.end(); @@ -2096,7 +2096,7 @@ SymbolVendorCreateInstance PluginManager::GetSymbolVendorCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetSymbolVendorMutex ()); + std::lock_guard guard(GetSymbolVendorMutex()); SymbolVendorInstances &instances = GetSymbolVendorInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -2108,7 +2108,7 @@ { if (name) { - Mutex::Locker locker (GetSymbolVendorMutex ()); + std::lock_guard guard(GetSymbolVendorMutex()); SymbolVendorInstances &instances = GetSymbolVendorInstances (); SymbolVendorInstances::iterator pos, end = instances.end(); @@ -2139,10 +2139,10 @@ typedef std::vector UnwindAssemblyInstances; -static Mutex & -GetUnwindAssemblyMutex () +static std::recursive_mutex & +GetUnwindAssemblyMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -2166,7 +2166,7 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - Mutex::Locker locker (GetUnwindAssemblyMutex ()); + std::lock_guard guard(GetUnwindAssemblyMutex()); GetUnwindAssemblyInstances ().push_back (instance); } return false; @@ -2177,7 +2177,7 @@ { if (create_callback) { - Mutex::Locker locker (GetUnwindAssemblyMutex ()); + std::lock_guard guard(GetUnwindAssemblyMutex()); UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances (); UnwindAssemblyInstances::iterator pos, end = instances.end(); @@ -2196,7 +2196,7 @@ UnwindAssemblyCreateInstance PluginManager::GetUnwindAssemblyCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetUnwindAssemblyMutex ()); + std::lock_guard guard(GetUnwindAssemblyMutex()); UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -2208,7 +2208,7 @@ { if (name) { - Mutex::Locker locker (GetUnwindAssemblyMutex ()); + std::lock_guard guard(GetUnwindAssemblyMutex()); UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances (); UnwindAssemblyInstances::iterator pos, end = instances.end(); @@ -2239,10 +2239,10 @@ typedef std::vector MemoryHistoryInstances; -static Mutex & -GetMemoryHistoryMutex () +static std::recursive_mutex & +GetMemoryHistoryMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -2266,7 +2266,7 @@ if (description && description[0]) instance.description = description; instance.create_callback = create_callback; - Mutex::Locker locker (GetMemoryHistoryMutex ()); + std::lock_guard guard(GetMemoryHistoryMutex()); GetMemoryHistoryInstances ().push_back (instance); } return false; @@ -2277,7 +2277,7 @@ { if (create_callback) { - Mutex::Locker locker (GetMemoryHistoryMutex ()); + std::lock_guard guard(GetMemoryHistoryMutex()); MemoryHistoryInstances &instances = GetMemoryHistoryInstances (); MemoryHistoryInstances::iterator pos, end = instances.end(); @@ -2296,7 +2296,7 @@ MemoryHistoryCreateInstance PluginManager::GetMemoryHistoryCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetMemoryHistoryMutex ()); + std::lock_guard guard(GetMemoryHistoryMutex()); MemoryHistoryInstances &instances = GetMemoryHistoryInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -2308,7 +2308,7 @@ { if (name) { - Mutex::Locker locker (GetMemoryHistoryMutex ()); + std::lock_guard guard(GetMemoryHistoryMutex()); MemoryHistoryInstances &instances = GetMemoryHistoryInstances (); MemoryHistoryInstances::iterator pos, end = instances.end(); @@ -2340,10 +2340,10 @@ typedef std::vector InstrumentationRuntimeInstances; -static Mutex & -GetInstrumentationRuntimeMutex () +static std::recursive_mutex & +GetInstrumentationRuntimeMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -2369,7 +2369,7 @@ instance.description = description; instance.create_callback = create_callback; instance.get_type_callback = get_type_callback; - Mutex::Locker locker (GetInstrumentationRuntimeMutex ()); + std::lock_guard guard(GetInstrumentationRuntimeMutex()); GetInstrumentationRuntimeInstances ().push_back (instance); } return false; @@ -2380,7 +2380,7 @@ { if (create_callback) { - Mutex::Locker locker (GetInstrumentationRuntimeMutex ()); + std::lock_guard guard(GetInstrumentationRuntimeMutex()); InstrumentationRuntimeInstances &instances = GetInstrumentationRuntimeInstances (); InstrumentationRuntimeInstances::iterator pos, end = instances.end(); @@ -2399,7 +2399,7 @@ InstrumentationRuntimeGetType PluginManager::GetInstrumentationRuntimeGetTypeCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetInstrumentationRuntimeMutex ()); + std::lock_guard guard(GetInstrumentationRuntimeMutex()); InstrumentationRuntimeInstances &instances = GetInstrumentationRuntimeInstances (); if (idx < instances.size()) return instances[idx].get_type_callback; @@ -2409,7 +2409,7 @@ InstrumentationRuntimeCreateInstance PluginManager::GetInstrumentationRuntimeCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetInstrumentationRuntimeMutex ()); + std::lock_guard guard(GetInstrumentationRuntimeMutex()); InstrumentationRuntimeInstances &instances = GetInstrumentationRuntimeInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -2421,7 +2421,7 @@ { if (name) { - Mutex::Locker locker (GetInstrumentationRuntimeMutex ()); + std::lock_guard guard(GetInstrumentationRuntimeMutex()); InstrumentationRuntimeInstances &instances = GetInstrumentationRuntimeInstances (); InstrumentationRuntimeInstances::iterator pos, end = instances.end(); @@ -2453,10 +2453,10 @@ typedef std::vector TypeSystemInstances; -static Mutex & -GetTypeSystemMutex () +static std::recursive_mutex & +GetTypeSystemMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -2482,7 +2482,7 @@ instance.description = description; instance.create_callback = create_callback; instance.enumerate_callback = enumerate_supported_languages_callback; - Mutex::Locker locker (GetTypeSystemMutex ()); + std::lock_guard guard(GetTypeSystemMutex()); GetTypeSystemInstances ().push_back (instance); } return false; @@ -2493,7 +2493,7 @@ { if (create_callback) { - Mutex::Locker locker (GetTypeSystemMutex ()); + std::lock_guard guard(GetTypeSystemMutex()); TypeSystemInstances &instances = GetTypeSystemInstances (); TypeSystemInstances::iterator pos, end = instances.end(); @@ -2512,7 +2512,7 @@ TypeSystemCreateInstance PluginManager::GetTypeSystemCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetTypeSystemMutex ()); + std::lock_guard guard(GetTypeSystemMutex()); TypeSystemInstances &instances = GetTypeSystemInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -2524,7 +2524,7 @@ { if (name) { - Mutex::Locker locker (GetTypeSystemMutex ()); + std::lock_guard guard(GetTypeSystemMutex()); TypeSystemInstances &instances = GetTypeSystemInstances (); TypeSystemInstances::iterator pos, end = instances.end(); @@ -2540,7 +2540,7 @@ TypeSystemEnumerateSupportedLanguages PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetTypeSystemMutex ()); + std::lock_guard guard(GetTypeSystemMutex()); TypeSystemInstances &instances = GetTypeSystemInstances (); if (idx < instances.size()) return instances[idx].enumerate_callback; @@ -2552,7 +2552,7 @@ { if (name) { - Mutex::Locker locker (GetTypeSystemMutex ()); + std::lock_guard guard(GetTypeSystemMutex()); TypeSystemInstances &instances = GetTypeSystemInstances (); TypeSystemInstances::iterator pos, end = instances.end(); @@ -2584,10 +2584,10 @@ typedef std::vector REPLInstances; -static Mutex & -GetREPLMutex () +static std::recursive_mutex & +GetREPLMutex() { - static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_instances_mutex; return g_instances_mutex; } @@ -2613,7 +2613,7 @@ instance.description = description; instance.create_callback = create_callback; instance.enumerate_languages_callback = enumerate_languages_callback; - Mutex::Locker locker (GetREPLMutex ()); + std::lock_guard guard(GetREPLMutex()); GetREPLInstances ().push_back (instance); } return false; @@ -2624,7 +2624,7 @@ { if (create_callback) { - Mutex::Locker locker (GetREPLMutex ()); + std::lock_guard guard(GetREPLMutex()); REPLInstances &instances = GetREPLInstances (); REPLInstances::iterator pos, end = instances.end(); @@ -2643,7 +2643,7 @@ REPLCreateInstance PluginManager::GetREPLCreateCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetREPLMutex ()); + std::lock_guard guard(GetREPLMutex()); REPLInstances &instances = GetREPLInstances (); if (idx < instances.size()) return instances[idx].create_callback; @@ -2655,7 +2655,7 @@ { if (name) { - Mutex::Locker locker (GetREPLMutex ()); + std::lock_guard guard(GetREPLMutex()); REPLInstances &instances = GetREPLInstances (); REPLInstances::iterator pos, end = instances.end(); @@ -2671,7 +2671,7 @@ REPLEnumerateSupportedLanguages PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx) { - Mutex::Locker locker (GetREPLMutex ()); + std::lock_guard guard(GetREPLMutex()); REPLInstances &instances = GetREPLInstances (); if (idx < instances.size()) return instances[idx].enumerate_languages_callback; @@ -2683,7 +2683,7 @@ { if (name) { - Mutex::Locker locker (GetREPLMutex ()); + std::lock_guard guard(GetREPLMutex()); REPLInstances &instances = GetREPLInstances (); REPLInstances::iterator pos, end = instances.end(); @@ -2703,7 +2703,7 @@ { // Initialize the DynamicLoader plugins { - Mutex::Locker locker (GetDynamicLoaderMutex ()); + std::lock_guard guard(GetDynamicLoaderMutex()); DynamicLoaderInstances &instances = GetDynamicLoaderInstances (); DynamicLoaderInstances::iterator pos, end = instances.end(); @@ -2716,7 +2716,7 @@ // Initialize the JITLoader plugins { - Mutex::Locker locker (GetJITLoaderMutex ()); + std::lock_guard guard(GetJITLoaderMutex()); JITLoaderInstances &instances = GetJITLoaderInstances (); JITLoaderInstances::iterator pos, end = instances.end(); @@ -2729,7 +2729,7 @@ // Initialize the Platform plugins { - Mutex::Locker locker (GetPlatformInstancesMutex ()); + std::lock_guard guard(GetPlatformInstancesMutex()); PlatformInstances &instances = GetPlatformInstances (); PlatformInstances::iterator pos, end = instances.end(); @@ -2742,7 +2742,7 @@ // Initialize the Process plugins { - Mutex::Locker locker (GetProcessMutex()); + std::lock_guard guard(GetProcessMutex()); ProcessInstances &instances = GetProcessInstances(); ProcessInstances::iterator pos, end = instances.end(); @@ -2755,7 +2755,7 @@ // Initialize the SymbolFile plugins { - Mutex::Locker locker (GetSymbolFileMutex()); + std::lock_guard guard(GetSymbolFileMutex()); for (auto& sym_file: GetSymbolFileInstances()) { if (sym_file.debugger_init_callback) @@ -2765,7 +2765,7 @@ // Initialize the OperatingSystem plugins { - Mutex::Locker locker(GetOperatingSystemMutex()); + std::lock_guard guard(GetOperatingSystemMutex()); for (auto &os : GetOperatingSystemInstances()) { if (os.debugger_init_callback) Index: source/Core/StreamCallback.cpp =================================================================== --- source/Core/StreamCallback.cpp +++ source/Core/StreamCallback.cpp @@ -18,13 +18,8 @@ using namespace lldb; using namespace lldb_private; - -StreamCallback::StreamCallback (lldb::LogOutputCallback callback, void *baton) : - Stream (0, 4, eByteOrderBig), - m_callback (callback), - m_baton (baton), - m_accumulated_data (), - m_collection_mutex () +StreamCallback::StreamCallback(lldb::LogOutputCallback callback, void *baton) + : Stream(0, 4, eByteOrderBig), m_callback(callback), m_baton(baton), m_accumulated_data(), m_collection_mutex() { } @@ -35,7 +30,7 @@ StreamString & StreamCallback::FindStreamForThread(lldb::tid_t cur_tid) { - Mutex::Locker locker(m_collection_mutex); + std::lock_guard guard(m_collection_mutex); collection::iterator iter = m_accumulated_data.find (cur_tid); if (iter == m_accumulated_data.end()) { Index: source/Core/Timer.cpp =================================================================== --- source/Core/Timer.cpp +++ source/Core/Timer.cpp @@ -9,11 +9,11 @@ #include "lldb/Core/Timer.h" #include +#include #include #include #include "lldb/Core/Stream.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/Host.h" #include @@ -52,11 +52,10 @@ return *g_file_mutex_ptr; } - -static Mutex & +static std::mutex & GetCategoryMutex() { - static Mutex g_category_mutex(Mutex::eMutexTypeNormal); + static std::mutex g_category_mutex; return g_category_mutex; } @@ -169,7 +168,7 @@ } // Keep total results for each category so we can dump results. - Mutex::Locker locker (GetCategoryMutex()); + std::lock_guard guard(GetCategoryMutex()); TimerCategoryMap &category_map = GetCategoryMap(); category_map[m_category] += timer_nsec_uint; } @@ -240,7 +239,7 @@ void Timer::ResetCategoryTimes () { - Mutex::Locker locker (GetCategoryMutex()); + std::lock_guard guard(GetCategoryMutex()); TimerCategoryMap &category_map = GetCategoryMap(); category_map.clear(); } @@ -248,7 +247,7 @@ void Timer::DumpCategoryTimes (Stream *s) { - Mutex::Locker locker (GetCategoryMutex()); + std::lock_guard guard(GetCategoryMutex()); TimerCategoryMap &category_map = GetCategoryMap(); std::vector sorted_iterators; TimerCategoryMap::const_iterator pos, end = category_map.end(); Index: source/DataFormatters/FormatCache.cpp =================================================================== --- source/DataFormatters/FormatCache.cpp +++ source/DataFormatters/FormatCache.cpp @@ -158,11 +158,13 @@ m_validator_sp = validator_sp; } -FormatCache::FormatCache () : -m_map(), -m_mutex (Mutex::eMutexTypeRecursive) +FormatCache::FormatCache() + : m_map(), + m_mutex() #ifdef LLDB_CONFIGURATION_DEBUG -,m_cache_hits(0),m_cache_misses(0) + , + m_cache_hits(0), + m_cache_misses(0) #endif { } @@ -181,7 +183,7 @@ bool FormatCache::GetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard guard(m_mutex); auto entry = GetEntry(type); if (entry.IsFormatCached()) { @@ -201,7 +203,7 @@ bool FormatCache::GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard guard(m_mutex); auto entry = GetEntry(type); if (entry.IsSummaryCached()) { @@ -221,7 +223,7 @@ bool FormatCache::GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard guard(m_mutex); auto entry = GetEntry(type); if (entry.IsSyntheticCached()) { @@ -241,7 +243,7 @@ bool FormatCache::GetValidator (const ConstString& type,lldb::TypeValidatorImplSP& validator_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard guard(m_mutex); auto entry = GetEntry(type); if (entry.IsValidatorCached()) { @@ -261,35 +263,35 @@ void FormatCache::SetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard guard(m_mutex); GetEntry(type).SetFormat(format_sp); } void FormatCache::SetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard guard(m_mutex); GetEntry(type).SetSummary(summary_sp); } void FormatCache::SetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard guard(m_mutex); GetEntry(type).SetSynthetic(synthetic_sp); } void FormatCache::SetValidator (const ConstString& type,lldb::TypeValidatorImplSP& validator_sp) { - Mutex::Locker lock(m_mutex); + std::lock_guard guard(m_mutex); GetEntry(type).SetValidator(validator_sp); } void FormatCache::Clear () { - Mutex::Locker lock(m_mutex); + std::lock_guard guard(m_mutex); m_map.clear(); } Index: source/DataFormatters/FormatManager.cpp =================================================================== --- source/DataFormatters/FormatManager.cpp +++ source/DataFormatters/FormatManager.cpp @@ -128,7 +128,7 @@ { ++m_last_revision; m_format_cache.Clear (); - Mutex::Locker lang_locker(m_language_categories_mutex); + std::lock_guard guard(m_language_categories_mutex); for (auto& iter : m_language_categories_map) { if (iter.second) @@ -181,7 +181,7 @@ FormatManager::EnableAllCategories () { m_categories_map.EnableAllCategories (); - Mutex::Locker lang_locker(m_language_categories_mutex); + std::lock_guard guard(m_language_categories_mutex); for (auto& iter : m_language_categories_map) { if (iter.second) @@ -193,7 +193,7 @@ FormatManager::DisableAllCategories () { m_categories_map.DisableAllCategories (); - Mutex::Locker lang_locker(m_language_categories_mutex); + std::lock_guard guard(m_language_categories_mutex); for (auto& iter : m_language_categories_map) { if (iter.second) @@ -502,7 +502,7 @@ FormatManager::ForEachCategory(TypeCategoryMap::ForEachCallback callback) { m_categories_map.ForEach(callback); - Mutex::Locker locker(m_language_categories_mutex); + std::lock_guard guard(m_language_categories_mutex); for (const auto& entry : m_language_categories_map) { if (auto category_sp = entry.second->GetCategory()) @@ -712,7 +712,7 @@ LanguageCategory* FormatManager::GetCategoryForLanguage (lldb::LanguageType lang_type) { - Mutex::Locker locker(m_language_categories_mutex); + std::lock_guard guard(m_language_categories_mutex); auto iter = m_language_categories_map.find(lang_type), end = m_language_categories_map.end(); if (iter != end) return iter->second.get(); @@ -1055,22 +1055,22 @@ return retval_sp; } -FormatManager::FormatManager() : - m_last_revision(0), - m_format_cache(), - m_language_categories_mutex(Mutex::eMutexTypeRecursive), - m_language_categories_map(), - m_named_summaries_map(this), - m_categories_map(this), - m_default_category_name(ConstString("default")), - m_system_category_name(ConstString("system")), - m_vectortypes_category_name(ConstString("VectorTypes")) +FormatManager::FormatManager() + : m_last_revision(0), + m_format_cache(), + m_language_categories_mutex(), + m_language_categories_map(), + m_named_summaries_map(this), + m_categories_map(this), + m_default_category_name(ConstString("default")), + m_system_category_name(ConstString("system")), + m_vectortypes_category_name(ConstString("VectorTypes")) { LoadSystemFormatters(); LoadVectorFormatters(); - - EnableCategory(m_vectortypes_category_name,TypeCategoryMap::Last, lldb::eLanguageTypeObjC_plus_plus); - EnableCategory(m_system_category_name,TypeCategoryMap::Last, lldb::eLanguageTypeObjC_plus_plus); + + EnableCategory(m_vectortypes_category_name, TypeCategoryMap::Last, lldb::eLanguageTypeObjC_plus_plus); + EnableCategory(m_system_category_name, TypeCategoryMap::Last, lldb::eLanguageTypeObjC_plus_plus); } void Index: source/DataFormatters/TypeCategory.cpp =================================================================== --- source/DataFormatters/TypeCategory.cpp +++ source/DataFormatters/TypeCategory.cpp @@ -18,21 +18,20 @@ using namespace lldb; using namespace lldb_private; -TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener* clist, - ConstString name, - std::initializer_list langs) : -m_format_cont("format","regex-format",clist), -m_summary_cont("summary","regex-summary",clist), -m_filter_cont("filter","regex-filter",clist), +TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener *clist, ConstString name, + std::initializer_list langs) + : m_format_cont("format", "regex-format", clist), + m_summary_cont("summary", "regex-summary", clist), + m_filter_cont("filter", "regex-filter", clist), #ifndef LLDB_DISABLE_PYTHON -m_synth_cont("synth","regex-synth",clist), + m_synth_cont("synth", "regex-synth", clist), #endif -m_validator_cont("validator","regex-validator",clist), -m_enabled(false), -m_change_listener(clist), -m_mutex(Mutex::eMutexTypeRecursive), -m_name(name), -m_languages() + m_validator_cont("validator", "regex-validator", clist), + m_enabled(false), + m_change_listener(clist), + m_mutex(), + m_name(name), + m_languages() { for (const lldb::LanguageType lang : langs) AddLanguage(lang); @@ -673,7 +672,7 @@ void TypeCategoryImpl::Enable (bool value, uint32_t position) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if ( (m_enabled = value) ) m_enabled_position = position; if (m_change_listener) Index: source/DataFormatters/TypeCategoryMap.cpp =================================================================== --- source/DataFormatters/TypeCategoryMap.cpp +++ source/DataFormatters/TypeCategoryMap.cpp @@ -20,22 +20,19 @@ using namespace lldb; using namespace lldb_private; -TypeCategoryMap::TypeCategoryMap (IFormatChangeListener* lst) : -m_map_mutex(Mutex::eMutexTypeRecursive), -listener(lst), -m_map(), -m_active_categories() +TypeCategoryMap::TypeCategoryMap(IFormatChangeListener *lst) + : m_map_mutex(), listener(lst), m_map(), m_active_categories() { ConstString default_cs("default"); lldb::TypeCategoryImplSP default_sp = lldb::TypeCategoryImplSP(new TypeCategoryImpl(listener, default_cs)); - Add(default_cs,default_sp); - Enable(default_cs,First); + Add(default_cs, default_sp); + Enable(default_cs, First); } void TypeCategoryMap::Add (KeyType name, const ValueSP& entry) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); m_map[name] = entry; if (listener) listener->Changed(); @@ -44,7 +41,7 @@ bool TypeCategoryMap::Delete (KeyType name) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); MapIterator iter = m_map.find(name); if (iter == m_map.end()) return false; @@ -58,7 +55,7 @@ bool TypeCategoryMap::Enable (KeyType category_name, Position pos) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); ValueSP category; if (!Get(category_name,category)) return false; @@ -68,7 +65,7 @@ bool TypeCategoryMap::Disable (KeyType category_name) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); ValueSP category; if (!Get(category_name,category)) return false; @@ -78,7 +75,7 @@ bool TypeCategoryMap::Enable (ValueSP category, Position pos) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); if (category.get()) { Position pos_w = pos; @@ -107,7 +104,7 @@ bool TypeCategoryMap::Disable (ValueSP category) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); if (category.get()) { m_active_categories.remove_if(delete_matching_categories(category)); @@ -120,7 +117,7 @@ void TypeCategoryMap::EnableAllCategories () { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); std::vector sorted_categories(m_map.size(), ValueSP()); MapType::iterator iter = m_map.begin(), end = m_map.end(); for (; iter != end; ++iter) @@ -148,7 +145,7 @@ void TypeCategoryMap::DisableAllCategories () { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); Position p = First; for (; false == m_active_categories.empty(); p++) { @@ -160,7 +157,7 @@ void TypeCategoryMap::Clear () { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); m_map.clear(); m_active_categories.clear(); if (listener) @@ -170,7 +167,7 @@ bool TypeCategoryMap::Get (KeyType name, ValueSP& entry) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); MapIterator iter = m_map.find(name); if (iter == m_map.end()) return false; @@ -181,7 +178,7 @@ bool TypeCategoryMap::Get (uint32_t pos, ValueSP& entry) { - Mutex::Locker locker(m_map_mutex); + std::lock_guard guard(m_map_mutex); MapIterator iter = m_map.begin(); MapIterator end = m_map.end(); while (pos > 0) @@ -202,8 +199,8 @@ const char** matching_category, TypeCategoryImpl::FormatCategoryItems* matching_type) { - Mutex::Locker locker(m_map_mutex); - + std::lock_guard guard(m_map_mutex); + MapIterator pos, end = m_map.end(); for (pos = m_map.begin(); pos != end; pos++) { @@ -220,8 +217,8 @@ lldb::TypeFormatImplSP TypeCategoryMap::GetFormat (FormattersMatchData& match_data) { - Mutex::Locker locker(m_map_mutex); - + std::lock_guard guard(m_map_mutex); + uint32_t reason_why; ActiveCategoriesIterator begin, end = m_active_categories.end(); @@ -258,8 +255,8 @@ lldb::TypeSummaryImplSP TypeCategoryMap::GetSummaryFormat (FormattersMatchData& match_data) { - Mutex::Locker locker(m_map_mutex); - + std::lock_guard guard(m_map_mutex); + uint32_t reason_why; ActiveCategoriesIterator begin, end = m_active_categories.end(); @@ -297,8 +294,8 @@ lldb::SyntheticChildrenSP TypeCategoryMap::GetSyntheticChildren (FormattersMatchData& match_data) { - Mutex::Locker locker(m_map_mutex); - + std::lock_guard guard(m_map_mutex); + uint32_t reason_why; ActiveCategoriesIterator begin, end = m_active_categories.end(); @@ -337,8 +334,8 @@ lldb::TypeValidatorImplSP TypeCategoryMap::GetValidator (FormattersMatchData& match_data) { - Mutex::Locker locker(m_map_mutex); - + std::lock_guard guard(m_map_mutex); + uint32_t reason_why; ActiveCategoriesIterator begin, end = m_active_categories.end(); @@ -377,8 +374,8 @@ { if (callback) { - Mutex::Locker locker(m_map_mutex); - + std::lock_guard guard(m_map_mutex); + // loop through enabled categories in respective order { ActiveCategoriesIterator begin, end = m_active_categories.end(); @@ -408,8 +405,8 @@ TypeCategoryImplSP TypeCategoryMap::GetAtIndex (uint32_t index) { - Mutex::Locker locker(m_map_mutex); - + std::lock_guard guard(m_map_mutex); + if (index < m_map.size()) { MapIterator pos, end = m_map.end(); Index: source/Expression/IRExecutionUnit.cpp =================================================================== --- source/Expression/IRExecutionUnit.cpp +++ source/Expression/IRExecutionUnit.cpp @@ -247,7 +247,7 @@ { lldb::ProcessSP process_sp(GetProcessWP().lock()); - static Mutex s_runnable_info_mutex(Mutex::Type::eMutexTypeRecursive); + static std::recursive_mutex s_runnable_info_mutex; func_addr = LLDB_INVALID_ADDRESS; func_end = LLDB_INVALID_ADDRESS; @@ -267,7 +267,7 @@ return; }; - Mutex::Locker runnable_info_mutex_locker(s_runnable_info_mutex); + std::lock_guard guard(s_runnable_info_mutex); m_did_jit = true; Index: source/Host/common/Editline.cpp =================================================================== --- source/Host/common/Editline.cpp +++ source/Host/common/Editline.cpp @@ -19,7 +19,6 @@ #include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" -#include "lldb/Host/Mutex.h" #include "lldb/Utility/LLDBAssert.h" using namespace lldb_private; @@ -227,9 +226,9 @@ GetHistory (const std::string &prefix) { typedef std::map WeakHistoryMap; - static Mutex g_mutex (Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_mutex; static WeakHistoryMap g_weak_map; - Mutex::Locker locker (g_mutex); + std::lock_guard guard(g_mutex); WeakHistoryMap::const_iterator pos = g_weak_map.find (prefix); EditlineHistorySP history_sp; if (pos != g_weak_map.end()) @@ -587,9 +586,9 @@ // (blocking operation), so we do not hold the mutex indefinitely. This gives a chance // for someone to interrupt us. After Read returns, immediately lock the mutex again and // check if we were interrupted. - m_output_mutex.Unlock(); + m_output_mutex.unlock(); int read_count = m_input_connection.Read(&ch, 1, UINT32_MAX, status, NULL); - m_output_mutex.Lock(); + m_output_mutex.lock(); if (m_editor_status == EditorStatus::Interrupted) { while (read_count > 0 && status == lldb::eConnectionStatusSuccess) @@ -1284,7 +1283,7 @@ Editline::Interrupt() { bool result = true; - Mutex::Locker locker(m_output_mutex); + std::lock_guard guard(m_output_mutex); if (m_editor_status == EditorStatus::Editing) { fprintf(m_output_file, "^C\n"); result = m_input_connection.InterruptRead(); @@ -1297,7 +1296,7 @@ Editline::Cancel() { bool result = true; - Mutex::Locker locker(m_output_mutex); + std::lock_guard guard(m_output_mutex); if (m_editor_status == EditorStatus::Editing) { MoveCursor(CursorLocation::EditingCursor, CursorLocation::BlockStart); fprintf(m_output_file, ANSI_CLEAR_BELOW); @@ -1338,8 +1337,8 @@ ConfigureEditor (false); m_input_lines = std::vector(); m_input_lines.insert (m_input_lines.begin(), EditLineConstString("")); - - Mutex::Locker locker(m_output_mutex); + + std::lock_guard guard(m_output_mutex); lldbassert(m_editor_status != EditorStatus::Editing); if (m_editor_status == EditorStatus::Interrupted) @@ -1392,8 +1391,8 @@ SetBaseLineNumber (first_line_number); m_input_lines = std::vector(); m_input_lines.insert (m_input_lines.begin(), EditLineConstString("")); - - Mutex::Locker locker(m_output_mutex); + + std::lock_guard guard(m_output_mutex); // Begin the line editing loop DisplayInput(); SetCurrentLine (0); @@ -1427,7 +1426,7 @@ void Editline::PrintAsync (Stream *stream, const char *s, size_t len) { - Mutex::Locker locker(m_output_mutex); + std::lock_guard guard(m_output_mutex); if (m_editor_status == EditorStatus::Editing) { MoveCursor(CursorLocation::EditingCursor, CursorLocation::BlockStart); Index: source/Host/common/NativeBreakpointList.cpp =================================================================== --- source/Host/common/NativeBreakpointList.cpp +++ source/Host/common/NativeBreakpointList.cpp @@ -17,8 +17,7 @@ using namespace lldb; using namespace lldb_private; -NativeBreakpointList::NativeBreakpointList () : - m_mutex (Mutex::eMutexTypeRecursive) +NativeBreakpointList::NativeBreakpointList() : m_mutex() { } @@ -29,7 +28,7 @@ if (log) log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64 ", size_hint = %lu, hardware = %s", __FUNCTION__, addr, size_hint, hardware ? "true" : "false"); - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); // Check if the breakpoint is already set. auto iter = m_breakpoints.find (addr); @@ -72,7 +71,7 @@ if (log) log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr); - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); // Check if the breakpoint is already set. auto iter = m_breakpoints.find (addr); @@ -136,7 +135,7 @@ if (log) log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr); - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); // Ensure we have said breakpoint. auto iter = m_breakpoints.find (addr); @@ -159,7 +158,7 @@ if (log) log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr); - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); // Ensure we have said breakpoint. auto iter = m_breakpoints.find (addr); @@ -182,7 +181,7 @@ if (log) log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr); - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); // Ensure we have said breakpoint. auto iter = m_breakpoints.find (addr); Index: source/Host/common/NativeProcessProtocol.cpp =================================================================== --- source/Host/common/NativeProcessProtocol.cpp +++ source/Host/common/NativeProcessProtocol.cpp @@ -26,22 +26,22 @@ // NativeProcessProtocol Members // ----------------------------------------------------------------------------- -NativeProcessProtocol::NativeProcessProtocol (lldb::pid_t pid) : - m_pid (pid), - m_threads (), - m_current_thread_id (LLDB_INVALID_THREAD_ID), - m_threads_mutex (Mutex::eMutexTypeRecursive), - m_state (lldb::eStateInvalid), - m_state_mutex (Mutex::eMutexTypeRecursive), - m_exit_type (eExitTypeInvalid), - m_exit_status (0), - m_exit_description (), - m_delegates_mutex (Mutex::eMutexTypeRecursive), - m_delegates (), - m_breakpoint_list (), - m_watchpoint_list (), - m_terminal_fd (-1), - m_stop_id (0) +NativeProcessProtocol::NativeProcessProtocol(lldb::pid_t pid) + : m_pid(pid), + m_threads(), + m_current_thread_id(LLDB_INVALID_THREAD_ID), + m_threads_mutex(), + m_state(lldb::eStateInvalid), + m_state_mutex(), + m_exit_type(eExitTypeInvalid), + m_exit_status(0), + m_exit_description(), + m_delegates_mutex(), + m_delegates(), + m_breakpoint_list(), + m_watchpoint_list(), + m_terminal_fd(-1), + m_stop_id(0) { } @@ -117,7 +117,7 @@ NativeThreadProtocolSP NativeProcessProtocol::GetThreadAtIndex (uint32_t idx) { - Mutex::Locker locker (m_threads_mutex); + std::lock_guard guard(m_threads_mutex); if (idx < m_threads.size ()) return m_threads[idx]; return NativeThreadProtocolSP (); @@ -137,7 +137,7 @@ NativeThreadProtocolSP NativeProcessProtocol::GetThreadByID (lldb::tid_t tid) { - Mutex::Locker locker (m_threads_mutex); + std::lock_guard guard(m_threads_mutex); return GetThreadByIDUnlocked (tid); } @@ -221,7 +221,7 @@ // conceivable that if there are more threads than hardware // watchpoints available, some of the threads will fail to set // hardware watchpoints while software ones may be available. - Mutex::Locker locker (m_threads_mutex); + std::lock_guard guard(m_threads_mutex); for (auto thread_sp : m_threads) { assert (thread_sp && "thread list should not have a NULL thread!"); @@ -276,7 +276,7 @@ Error overall_error; - Mutex::Locker locker (m_threads_mutex); + std::lock_guard guard(m_threads_mutex); for (auto thread_sp : m_threads) { assert (thread_sp && "thread list should not have a NULL thread!"); @@ -300,7 +300,7 @@ bool NativeProcessProtocol::RegisterNativeDelegate (NativeDelegate &native_delegate) { - Mutex::Locker locker (m_delegates_mutex); + std::lock_guard guard(m_delegates_mutex); if (std::find (m_delegates.begin (), m_delegates.end (), &native_delegate) != m_delegates.end ()) return false; @@ -312,7 +312,7 @@ bool NativeProcessProtocol::UnregisterNativeDelegate (NativeDelegate &native_delegate) { - Mutex::Locker locker (m_delegates_mutex); + std::lock_guard guard(m_delegates_mutex); const auto initial_size = m_delegates.size (); m_delegates.erase (remove (m_delegates.begin (), m_delegates.end (), &native_delegate), m_delegates.end ()); @@ -327,7 +327,7 @@ { Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); - Mutex::Locker locker (m_delegates_mutex); + std::lock_guard guard(m_delegates_mutex); for (auto native_delegate: m_delegates) native_delegate->ProcessStateChanged (this, state); @@ -354,7 +354,7 @@ log->Printf ("NativeProcessProtocol::%s - preparing to call delegates", __FUNCTION__); { - Mutex::Locker locker (m_delegates_mutex); + std::lock_guard guard(m_delegates_mutex); for (auto native_delegate: m_delegates) native_delegate->DidExec (this); } @@ -394,14 +394,14 @@ lldb::StateType NativeProcessProtocol::GetState () const { - Mutex::Locker locker (m_state_mutex); + std::lock_guard guard(m_state_mutex); return m_state; } void NativeProcessProtocol::SetState (lldb::StateType state, bool notify_delegates) { - Mutex::Locker locker (m_state_mutex); + std::lock_guard guard(m_state_mutex); if (state == m_state) return; @@ -426,8 +426,8 @@ uint32_t NativeProcessProtocol::GetStopID () const { - Mutex::Locker locker (m_state_mutex); - return m_stop_id; + std::lock_guard guard(m_state_mutex); + return m_stop_id; } void Index: source/Host/common/SoftwareBreakpoint.cpp =================================================================== --- source/Host/common/SoftwareBreakpoint.cpp +++ source/Host/common/SoftwareBreakpoint.cpp @@ -12,7 +12,6 @@ #include "lldb/Core/Error.h" #include "lldb/Core/Log.h" #include "lldb/Host/Debug.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/common/NativeProcessProtocol.h" Index: source/Host/macosx/Host.mm =================================================================== --- source/Host/macosx/Host.mm +++ source/Host/macosx/Host.mm @@ -556,10 +556,10 @@ // On MacOSX CrashReporter will display a string for each shared library if // the shared library has an exported symbol named "__crashreporter_info__". -static Mutex& -GetCrashReporterMutex () +static std::mutex & +GetCrashReporterMutex() { - static Mutex g_mutex; + static std::mutex g_mutex; return g_mutex; } @@ -573,8 +573,8 @@ Host::SetCrashDescriptionWithFormat (const char *format, ...) { static StreamString g_crash_description; - Mutex::Locker locker (GetCrashReporterMutex ()); - + std::lock_guard guard(GetCrashReporterMutex()); + if (format) { va_list args; @@ -593,7 +593,7 @@ void Host::SetCrashDescription (const char *cstr) { - Mutex::Locker locker (GetCrashReporterMutex ()); + std::lock_guard guard(GetCrashReporterMutex()); static std::string g_crash_description; if (cstr) { Index: source/Host/posix/ConnectionFileDescriptorPosix.cpp =================================================================== --- source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -79,12 +79,12 @@ } ConnectionFileDescriptor::ConnectionFileDescriptor(bool child_processes_inherit) - : Connection() - , m_pipe() - , m_mutex(Mutex::eMutexTypeRecursive) - , m_shutting_down(false) - , m_waiting_for_accept(false) - , m_child_processes_inherit(child_processes_inherit) + : Connection(), + m_pipe(), + m_mutex(), + m_shutting_down(false), + m_waiting_for_accept(false), + m_child_processes_inherit(child_processes_inherit) { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT)); if (log) @@ -92,30 +92,30 @@ } ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, bool owns_fd) - : Connection() - , m_pipe() - , m_mutex(Mutex::eMutexTypeRecursive) - , m_shutting_down(false) - , m_waiting_for_accept(false) - , m_child_processes_inherit(false) + : Connection(), + m_pipe(), + m_mutex(), + m_shutting_down(false), + m_waiting_for_accept(false), + m_child_processes_inherit(false) { m_write_sp.reset(new File(fd, owns_fd)); m_read_sp.reset(new File(fd, false)); Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT)); if (log) - log->Printf("%p ConnectionFileDescriptor::ConnectionFileDescriptor (fd = %i, owns_fd = %i)", static_cast(this), fd, - owns_fd); + log->Printf("%p ConnectionFileDescriptor::ConnectionFileDescriptor (fd = %i, owns_fd = %i)", + static_cast(this), fd, owns_fd); OpenCommandPipe(); } -ConnectionFileDescriptor::ConnectionFileDescriptor(Socket* socket) - : Connection() - , m_pipe() - , m_mutex(Mutex::eMutexTypeRecursive) - , m_shutting_down(false) - , m_waiting_for_accept(false) - , m_child_processes_inherit(false) +ConnectionFileDescriptor::ConnectionFileDescriptor(Socket *socket) + : Connection(), + m_pipe(), + m_mutex(), + m_shutting_down(false), + m_waiting_for_accept(false), + m_child_processes_inherit(false) { InitializeSocket(socket); } @@ -170,7 +170,7 @@ ConnectionStatus ConnectionFileDescriptor::Connect(const char *s, Error *error_ptr) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); if (log) log->Printf("%p ConnectionFileDescriptor::Connect (url = '%s')", static_cast(this), s); @@ -374,10 +374,8 @@ m_shutting_down = true; - Mutex::Locker locker; - bool got_lock = locker.TryLock(m_mutex); - - if (!got_lock) + std::unique_lock locker(m_mutex, std::defer_lock); + if (!locker.try_lock()) { if (m_pipe.CanWrite()) { @@ -392,7 +390,7 @@ log->Printf("%p ConnectionFileDescriptor::Disconnect(): Couldn't get the lock, but no command pipe is available.", static_cast(this)); } - locker.Lock(m_mutex); + locker.lock(); } Error error = m_read_sp->Close(); @@ -415,9 +413,8 @@ { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); - Mutex::Locker locker; - bool got_lock = locker.TryLock(m_mutex); - if (!got_lock) + std::unique_lock locker(m_mutex, std::defer_lock); + if (!locker.try_lock()) { if (log) log->Printf("%p ConnectionFileDescriptor::Read () failed to get the connection lock.", static_cast(this)); Index: source/Initialization/SystemLifetimeManager.cpp =================================================================== --- source/Initialization/SystemLifetimeManager.cpp +++ source/Initialization/SystemLifetimeManager.cpp @@ -10,16 +10,13 @@ #include "lldb/Initialization/SystemLifetimeManager.h" #include "lldb/Core/Debugger.h" -#include "lldb/Host/Mutex.h" #include "lldb/Initialization/SystemInitializer.h" #include using namespace lldb_private; -SystemLifetimeManager::SystemLifetimeManager() - : m_mutex(Mutex::eMutexTypeRecursive) - , m_initialized(false) +SystemLifetimeManager::SystemLifetimeManager() : m_mutex(), m_initialized(false) { } @@ -32,7 +29,7 @@ SystemLifetimeManager::Initialize(std::unique_ptr initializer, LoadPluginCallbackType plugin_callback) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (!m_initialized) { assert(!m_initializer && @@ -48,7 +45,7 @@ void SystemLifetimeManager::Terminate() { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (m_initialized) { Index: source/Interpreter/CommandHistory.cpp =================================================================== --- source/Interpreter/CommandHistory.cpp +++ source/Interpreter/CommandHistory.cpp @@ -15,10 +15,7 @@ using namespace lldb; using namespace lldb_private; - -CommandHistory::CommandHistory () : - m_mutex(Mutex::eMutexTypeRecursive), - m_history() +CommandHistory::CommandHistory() : m_mutex(), m_history() {} CommandHistory::~CommandHistory () @@ -27,21 +24,21 @@ size_t CommandHistory::GetSize () const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return m_history.size(); } bool CommandHistory::IsEmpty () const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return m_history.empty(); } const char* CommandHistory::FindString (const char* input_str) const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (!input_str) return nullptr; if (input_str[0] != g_repeat_char) @@ -80,7 +77,7 @@ const char* CommandHistory::GetStringAtIndex (size_t idx) const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (idx < m_history.size()) return m_history[idx].c_str(); return nullptr; @@ -95,7 +92,7 @@ const char* CommandHistory::GetRecentmostString () const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (m_history.empty()) return nullptr; return m_history.back().c_str(); @@ -105,7 +102,7 @@ CommandHistory::AppendString (const std::string& str, bool reject_if_dupe) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (reject_if_dupe) { if (!m_history.empty()) @@ -120,7 +117,7 @@ void CommandHistory::Clear () { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); m_history.clear(); } @@ -129,7 +126,7 @@ size_t start_idx, size_t stop_idx) const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); stop_idx = std::min(stop_idx + 1, m_history.size()); for (size_t counter = start_idx; counter < stop_idx; Index: source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h =================================================================== --- source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h +++ source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include +#include #include // 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 @@ 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 @@ { 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 m_disasm_ap; Index: source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h =================================================================== --- source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h +++ source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h @@ -12,6 +12,7 @@ // C Includes // C++ Includes +#include #include #include @@ -21,7 +22,6 @@ #include "lldb/Host/FileSpec.h" #include "lldb/Host/TimeValue.h" #include "lldb/Core/UUID.h" -#include "lldb/Host/Mutex.h" #include "lldb/Target/Process.h" class DynamicLoaderDarwinKernel : public lldb_private::DynamicLoader @@ -361,7 +361,7 @@ lldb_private::Address m_kext_summary_header_addr; OSKextLoadedKextSummaryHeader m_kext_summary_header; KextImageInfo::collection m_known_kexts; - mutable lldb_private::Mutex m_mutex; + mutable std::recursive_mutex m_mutex; lldb::user_id_t m_break_id; private: Index: source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp =================================================================== --- source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -452,16 +452,16 @@ //---------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------- -DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel (Process* process, lldb::addr_t kernel_addr) : - DynamicLoader(process), - m_kernel_load_address (kernel_addr), - m_kernel(), - m_kext_summary_header_ptr_addr (), - m_kext_summary_header_addr (), - m_kext_summary_header (), - m_known_kexts (), - m_mutex(Mutex::eMutexTypeRecursive), - m_break_id (LLDB_INVALID_BREAK_ID) +DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel(Process *process, lldb::addr_t kernel_addr) + : DynamicLoader(process), + m_kernel_load_address(kernel_addr), + m_kernel(), + m_kext_summary_header_ptr_addr(), + m_kext_summary_header_addr(), + m_kext_summary_header(), + m_known_kexts(), + m_mutex(), + m_break_id(LLDB_INVALID_BREAK_ID) { Error error; PlatformSP platform_sp(Platform::Create(PlatformDarwinKernel::GetPluginNameStatic(), error)); @@ -470,7 +470,7 @@ // shouldn't be done if kext loading is explicitly disabled. if (platform_sp.get() && GetGlobalProperties()->GetLoadKexts()) { - process->GetTarget().SetPlatform (platform_sp); + process->GetTarget().SetPlatform(platform_sp); } } @@ -521,7 +521,7 @@ void DynamicLoaderDarwinKernel::Clear (bool clear_process) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (m_process->IsAlive() && LLDB_BREAK_ID_IS_VALID(m_break_id)) m_process->ClearBreakpointSiteByID(m_break_id); @@ -1131,7 +1131,7 @@ bool DynamicLoaderDarwinKernel::ReadKextSummaryHeader () { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); // the all image infos is already valid for this process stop ID @@ -1216,8 +1216,8 @@ Log *log(GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER)); if (log) log->Printf ("Kexts-changed breakpoint hit, there are %d kexts currently.\n", count); - - Mutex::Locker locker(m_mutex); + + std::lock_guard guard(m_mutex); if (!ReadKextSummaries (kext_summary_addr, count, kext_summaries)) return false; @@ -1438,8 +1438,8 @@ bool DynamicLoaderDarwinKernel::ReadAllKextSummaries () { - Mutex::Locker locker(m_mutex); - + std::lock_guard guard(m_mutex); + if (ReadKextSummaryHeader ()) { if (m_kext_summary_header.entry_count > 0 && m_kext_summary_header_addr.IsValid()) @@ -1508,7 +1508,7 @@ if (log == NULL) return; - Mutex::Locker locker(m_mutex); + std::lock_guard 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, Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h @@ -12,6 +12,7 @@ // C Includes // C++ Includes +#include #include // Other libraries and framework includes @@ -20,7 +21,6 @@ #include "lldb/Host/FileSpec.h" #include "lldb/Core/StructuredData.h" #include "lldb/Core/UUID.h" -#include "lldb/Host/Mutex.h" #include "lldb/Target/Process.h" #include "lldb/Utility/SafeMachO.h" @@ -374,7 +374,7 @@ lldb::user_id_t m_break_id; DYLDImageInfo::collection m_dyld_image_infos; // Current shared libraries information uint32_t m_dyld_image_infos_stop_id; // The process stop ID that "m_dyld_image_infos" is valid for - mutable lldb_private::Mutex m_mutex; + mutable std::recursive_mutex m_mutex; lldb_private::Process::Notifications m_notification_callbacks; bool m_process_image_addr_is_all_images_infos; Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -138,18 +138,18 @@ //---------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------- -DynamicLoaderMacOSXDYLD::DynamicLoaderMacOSXDYLD (Process* process) : - DynamicLoader(process), - m_dyld(), - m_dyld_module_wp(), - m_dyld_all_image_infos_addr(LLDB_INVALID_ADDRESS), - m_dyld_all_image_infos(), - m_dyld_all_image_infos_stop_id (UINT32_MAX), - m_break_id(LLDB_INVALID_BREAK_ID), - m_dyld_image_infos(), - m_dyld_image_infos_stop_id (UINT32_MAX), - m_mutex(Mutex::eMutexTypeRecursive), - m_process_image_addr_is_all_images_infos (false) +DynamicLoaderMacOSXDYLD::DynamicLoaderMacOSXDYLD(Process *process) + : DynamicLoader(process), + m_dyld(), + m_dyld_module_wp(), + m_dyld_all_image_infos_addr(LLDB_INVALID_ADDRESS), + m_dyld_all_image_infos(), + m_dyld_all_image_infos_stop_id(UINT32_MAX), + m_break_id(LLDB_INVALID_BREAK_ID), + m_dyld_image_infos(), + m_dyld_image_infos_stop_id(UINT32_MAX), + m_mutex(), + m_process_image_addr_is_all_images_infos(false) { } @@ -244,7 +244,7 @@ void DynamicLoaderMacOSXDYLD::Clear (bool clear_process) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (LLDB_BREAK_ID_IS_VALID(m_break_id)) m_process->GetTarget().RemoveBreakpointByID (m_break_id); @@ -683,7 +683,7 @@ bool DynamicLoaderMacOSXDYLD::ReadAllImageInfosStructure () { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); // the all image infos is already valid for this process stop ID if (m_process->GetStopID() == m_dyld_all_image_infos_stop_id) @@ -974,8 +974,8 @@ Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER)); if (log) log->Printf ("Adding %d modules.\n", image_infos_count); - - Mutex::Locker locker(m_mutex); + + std::lock_guard guard(m_mutex); if (m_process->GetStopID() == m_dyld_image_infos_stop_id) return true; @@ -1097,8 +1097,8 @@ { DYLDImageInfo::collection image_infos; Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER)); - - Mutex::Locker locker(m_mutex); + + std::lock_guard guard(m_mutex); if (m_process->GetStopID() == m_dyld_image_infos_stop_id) return true; @@ -1239,8 +1239,8 @@ DynamicLoaderMacOSXDYLD::InitializeFromAllImageInfos () { Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER)); - - Mutex::Locker locker(m_mutex); + + std::lock_guard guard(m_mutex); if (m_process->GetStopID() == m_dyld_image_infos_stop_id || m_dyld_image_infos.size() != 0) return false; @@ -1678,7 +1678,7 @@ if (log == NULL) return; - Mutex::Locker locker(m_mutex); + std::lock_guard 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, Index: source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h =================================================================== --- source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h +++ 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 Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h @@ -12,10 +12,11 @@ // C Includes // C++ Includes +#include + // 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: bool m_filled; std::vector m_ivars; - Mutex m_mutex; + std::recursive_mutex m_mutex; }; // The constructor should only be invoked by the runtime as it builds its caches Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp @@ -499,11 +499,9 @@ 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 @@ { if (m_filled) return; - Mutex::Locker lock(m_mutex); + std::lock_guard 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(" +#include #include // Other libraries and framework includes @@ -353,11 +354,11 @@ std::unique_ptr 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 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 m_decl_vendor_ap; lldb::addr_t m_isa_hash_table_ptr; Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -379,27 +379,27 @@ } } -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 @@ if (class_infos_addr == LLDB_INVALID_ADDRESS) return false; - - Mutex::Locker locker(m_get_class_info_args_mutex); + + std::lock_guard guard(m_get_class_info_args_mutex); // Fill in our function argument values arguments.GetValueAtIndex(0)->GetScalar() = hash_table.GetTableLoadAddress(); @@ -1735,9 +1735,9 @@ if (class_infos_addr == LLDB_INVALID_ADDRESS) return DescriptorMapUpdateResult::Fail(); - - Mutex::Locker locker(m_get_shared_cache_class_info_args_mutex); - + + std::lock_guard 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; Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h @@ -13,12 +13,12 @@ // C Includes // C++ Includes #include +#include #include // 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 @@ lldb::ProcessWP m_process_wp; lldb::ModuleSP m_objc_module_sp; std::unique_ptr 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; Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -751,8 +751,8 @@ // Scope for mutex locker: { - Mutex::Locker locker(m_impl_function_mutex); - + std::lock_guard guard(m_impl_function_mutex); + // First stage is to make the ClangUtility to hold our injected function: if (!m_impl_code.get()) Index: source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h =================================================================== --- source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h +++ source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h @@ -12,6 +12,8 @@ // C Includes // C++ Includes +#include + // Other libraries and framework includes // Project includes #include "lldb/Symbol/ObjectContainer.h" @@ -138,8 +140,8 @@ static Map & GetArchiveCache (); - static lldb_private::Mutex & - GetArchiveCacheMutex (); + static std::recursive_mutex & + GetArchiveCacheMutex(); static Archive::shared_ptr FindCachedArchive (const lldb_private::FileSpec &file, Index: source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp =================================================================== --- source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -35,7 +35,6 @@ #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::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 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 @@ const size_t num_objects = archive_sp->ParseObjects (); if (num_objects > 0) { - Mutex::Locker locker(Archive::GetArchiveCacheMutex ()); + std::lock_guard guard(Archive::GetArchiveCacheMutex()); Archive::GetArchiveCache().insert(std::make_pair(file, archive_sp)); } else @@ -299,14 +298,13 @@ 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() { Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp =================================================================== --- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2938,7 +2938,7 @@ return NULL; uint64_t symbol_id = 0; - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard 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 @@ return; } - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); s->Printf("%p: ", static_cast(this)); s->Indent(); s->PutCString("ObjectFileELF"); Index: source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp =================================================================== --- source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp +++ source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp @@ -158,7 +158,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_symtab_ap.get() == NULL) { m_symtab_ap.reset(new Symtab(this)); @@ -200,7 +200,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); s->Printf("%p: ", static_cast(this)); s->Indent(); s->PutCString("ObjectFileJIT"); Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h =================================================================== --- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h +++ 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" //---------------------------------------------------------------------- Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp =================================================================== --- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1217,7 +1217,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); bool can_parse = false; lldb::offset_t offset = 0; m_data.SetByteOrder (endian::InlHostByteOrder()); @@ -1457,7 +1457,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_symtab_ap.get() == NULL) { m_symtab_ap.reset(new Symtab(this)); @@ -4755,7 +4755,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); s->Printf("%p: ", static_cast(this)); s->Indent(); if (m_header.magic == MH_MAGIC_64 || m_header.magic == MH_CIGAM_64) @@ -4911,7 +4911,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic); return GetUUID (m_header, m_data, offset, *uuid); } @@ -4925,7 +4925,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); struct load_command load_cmd; lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic); std::vector rpath_paths; @@ -5053,7 +5053,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); struct load_command load_cmd; lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic); uint32_t i; @@ -5203,7 +5203,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (!m_thread_context_offsets_valid) { m_thread_context_offsets_valid = true; @@ -5237,7 +5237,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (!m_thread_context_offsets_valid) GetNumThreadContexts (); @@ -5373,7 +5373,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard 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 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); return GetArchitecture (m_header, m_data, MachHeaderSizeFromMagic(m_header.magic), arch); } return false; Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp =================================================================== --- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -212,7 +212,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); m_sect_headers.clear(); m_data.SetByteOrder (eByteOrderLittle); lldb::offset_t offset = 0; @@ -534,7 +534,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_symtab_ap.get() == NULL) { SectionList *sect_list = GetSectionList(); @@ -689,7 +689,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); const uint32_t nsects = m_sect_headers.size(); ModuleSP module_sp (GetModule()); for (uint32_t idx = 0; idxGetMutex()); + std::lock_guard guard(module_sp->GetMutex()); s->Printf("%p: ", static_cast(this)); s->Indent(); s->PutCString("ObjectFilePECOFF"); Index: source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp +++ source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp @@ -252,7 +252,7 @@ PlatformAppleSimulator::GetCoreSimulatorPath() { #if defined(__APPLE__) - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (!m_core_simulator_framework_path.hasValue()) { const char *developer_dir = GetDeveloperDirectory(); Index: source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp +++ source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp @@ -304,7 +304,7 @@ const char * PlatformAppleTVSimulator::GetSDKDirectoryAsCString() { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (m_sdk_directory.empty()) { const char *developer_dir = GetDeveloperDirectory(); Index: source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp +++ source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp @@ -304,7 +304,7 @@ const char * PlatformAppleWatchSimulator::GetSDKDirectoryAsCString() { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (m_sdk_directory.empty()) { const char *developer_dir = GetDeveloperDirectory(); Index: source/Plugins/Platform/MacOSX/PlatformDarwin.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -1015,7 +1015,7 @@ const char * PlatformDarwin::GetDeveloperDirectory() { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (m_developer_directory.empty()) { bool developer_dir_path_valid = false; @@ -1572,10 +1572,10 @@ FileSpec sysroot_spec; // Scope for mutex locker below { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); sysroot_spec = GetSDKDirectoryForModules(sdk_type); } - + if (sysroot_spec.IsDirectory()) { options.push_back("-isysroot"); Index: source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp +++ source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp @@ -308,7 +308,7 @@ const char * PlatformiOSSimulator::GetSDKDirectoryAsCString() { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (m_sdk_directory.empty()) { const char *developer_dir = GetDeveloperDirectory(); Index: source/Plugins/Process/FreeBSD/ProcessFreeBSD.h =================================================================== --- source/Plugins/Process/FreeBSD/ProcessFreeBSD.h +++ source/Plugins/Process/FreeBSD/ProcessFreeBSD.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes +#include #include #include @@ -212,7 +213,7 @@ 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 m_message_queue; /// Drive any exit events to completion. Index: source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp =================================================================== --- source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -229,7 +229,7 @@ void ProcessFreeBSD::SendMessage(const ProcessMessage &message) { - Mutex::Locker lock(m_message_mutex); + std::lock_guard guard(m_message_mutex); switch (message.GetKind()) { @@ -274,7 +274,7 @@ 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 @@ 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 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 Index: source/Plugins/Process/FreeBSD/ProcessMonitor.h =================================================================== --- source/Plugins/Process/FreeBSD/ProcessMonitor.h +++ source/Plugins/Process/FreeBSD/ProcessMonitor.h @@ -15,11 +15,12 @@ #include // C++ Includes +#include + // 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 @@ // 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. Index: source/Plugins/Process/FreeBSD/ProcessMonitor.cpp =================================================================== --- source/Plugins/Process/FreeBSD/ProcessMonitor.cpp +++ source/Plugins/Process/FreeBSD/ProcessMonitor.cpp @@ -1348,7 +1348,7 @@ void ProcessMonitor::DoOperation(Operation *op) { - Mutex::Locker lock(m_operation_mutex); + std::lock_guard guard(m_operation_mutex); m_operation = op; Index: source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp =================================================================== --- source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -284,8 +284,8 @@ 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 guard(m_bytes_mutex); + Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS)); if (src && src_len > 0) Index: source/Plugins/Process/Utility/HistoryThread.h =================================================================== --- source/Plugins/Process/Utility/HistoryThread.h +++ source/Plugins/Process/Utility/HistoryThread.h @@ -12,10 +12,11 @@ // C Includes // C++ Includes +#include + // 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 @@ virtual lldb::StackFrameListSP GetStackFrameList (); - mutable Mutex m_framelist_mutex; + mutable std::mutex m_framelist_mutex; lldb::StackFrameListSP m_framelist; std::vector m_pcs; uint32_t m_stop_id; Index: source/Plugins/Process/Utility/HistoryThread.cpp =================================================================== --- source/Plugins/Process/Utility/HistoryThread.cpp +++ source/Plugins/Process/Utility/HistoryThread.cpp @@ -22,28 +22,24 @@ // Constructor -HistoryThread::HistoryThread (lldb_private::Process &process, - lldb::tid_t tid, - std::vector 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 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(this)); + log->Printf("%p HistoryThread::HistoryThread", static_cast(this)); } // Destructor @@ -78,7 +74,9 @@ 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 lock(m_framelist_mutex); + lock.release(); if (m_framelist.get() == NULL) { m_framelist.reset (new StackFrameList (*this, StackFrameListSP(), true)); Index: source/Plugins/Process/Utility/HistoryUnwind.h =================================================================== --- source/Plugins/Process/Utility/HistoryUnwind.h +++ 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 { Index: source/Plugins/Process/Utility/HistoryUnwind.cpp =================================================================== --- source/Plugins/Process/Utility/HistoryUnwind.cpp +++ source/Plugins/Process/Utility/HistoryUnwind.cpp @@ -40,7 +40,7 @@ void HistoryUnwind::DoClear () { - Mutex::Locker locker(m_unwind_mutex); + std::lock_guard guard(m_unwind_mutex); m_pcs.clear(); m_stop_id_is_valid = false; } @@ -64,7 +64,9 @@ 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 guard(m_unwind_mutex); + guard.release(); if (frame_idx < m_pcs.size()) { cfa = frame_idx; Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -793,8 +793,8 @@ 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 guard(m_bytes_mutex); + Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); if (src && src_len > 0) Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include +#include #include #include @@ -631,7 +632,7 @@ // 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 m_async_packet_predicate; std::string m_async_packet; PacketResult m_async_result; Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -55,79 +55,79 @@ //---------------------------------------------------------------------- // 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 @@ { if (IsRunning()) { - Mutex::Locker async_locker (m_async_mutex); + std::lock_guard 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 @@ bool GDBRemoteCommunicationClient::SendAsyncSignal (int signo) { - Mutex::Locker async_locker (m_async_mutex); + std::lock_guard guard(m_async_mutex); m_async_signal = signo; bool timed_out = false; Mutex::Locker locker; Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h +++ 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" Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h @@ -12,12 +12,12 @@ // C Includes // C++ Includes +#include #include // 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 @@ 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 @@ 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 m_saved_registers_map; uint32_t m_next_saved_registers_id; bool m_handshake_completed : 1; Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -76,23 +76,22 @@ //---------------------------------------------------------------------- // 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 @@ Error error; { - Mutex::Locker locker (m_debugged_process_mutex); + std::lock_guard 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 @@ // Save the register data buffer under the save id. { - Mutex::Locker locker (m_saved_registers_mutex); + std::lock_guard guard(m_saved_registers_mutex); m_saved_registers_map[save_id] = register_data_sp; } @@ -2643,7 +2642,7 @@ // Retrieve register state buffer, then remove from the list. DataBufferSP register_data_sp; { - Mutex::Locker locker (m_saved_registers_mutex); + std::lock_guard 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 @@ uint32_t GDBRemoteCommunicationServerLLGS::GetNextSavedRegistersID () { - Mutex::Locker locker (m_saved_registers_mutex); + std::lock_guard guard(m_saved_registers_mutex); return m_next_saved_registers_id++; } Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include +#include #include // Other libraries and framework includes @@ -82,7 +83,7 @@ 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 m_spawned_pids; lldb::PlatformSP m_platform_sp; Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -48,14 +48,14 @@ // 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::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 @@ pid = debugserver_launch_info.GetProcessID(); if (pid != LLDB_INVALID_PROCESS_ID) { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard guard(m_spawned_pids_mutex); m_spawned_pids.insert(pid); if (port > 0) AssociatePortWithProcess(port, pid); @@ -261,7 +257,7 @@ // verify that we know anything about this pid. // Scope for locker { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard 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 @@ { // make sure we know about this process { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard guard(m_spawned_pids_mutex); if (m_spawned_pids.find(pid) == m_spawned_pids.end()) return false; } @@ -293,7 +289,7 @@ for (size_t i=0; i<10; ++i) { { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard guard(m_spawned_pids_mutex); if (m_spawned_pids.find(pid) == m_spawned_pids.end()) { // it is now killed @@ -305,7 +301,7 @@ // check one more time after the final usleep { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard guard(m_spawned_pids_mutex); if (m_spawned_pids.find(pid) == m_spawned_pids.end()) return true; } @@ -317,7 +313,7 @@ for (size_t i=0; i<10; ++i) { { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard guard(m_spawned_pids_mutex); if (m_spawned_pids.find(pid) == m_spawned_pids.end()) { // it is now killed @@ -330,7 +326,7 @@ // check one more time after the final usleep // Scope for locker { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard guard(m_spawned_pids_mutex); if (m_spawned_pids.find(pid) == m_spawned_pids.end()) return true; } @@ -444,7 +440,7 @@ bool GDBRemoteCommunicationServerPlatform::DebugserverProcessReaped (lldb::pid_t pid) { - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard guard(m_spawned_pids_mutex); FreePortForProcess(pid); m_spawned_pids.erase(pid); return true; @@ -479,7 +475,7 @@ if (pid != LLDB_INVALID_PROCESS_ID) { // add to spawned pids - Mutex::Locker locker (m_spawned_pids_mutex); + std::lock_guard guard(m_spawned_pids_mutex); m_spawned_pids.insert(pid); } Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.h =================================================================== --- source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -14,6 +14,7 @@ // C++ Includes #include #include +#include #include #include @@ -279,12 +280,12 @@ GDBRemoteCommunicationClient m_gdb_comm; std::atomic m_debugserver_pid; std::vector 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 tid_collection; typedef std::vector< std::pair > tid_sig_collection; typedef std::map MMapMap; Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp =================================================================== --- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -267,39 +267,39 @@ //---------------------------------------------------------------------- // 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 @@ 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 @@ // 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 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 @@ // 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 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 @@ // Scope the lock { // Lock the thread stack while we access it - Mutex::Locker stop_stack_lock(m_last_stop_packet_mutex); + std::lock_guard 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 @@ if (log) log->Printf ("ProcessGDBRemote::%s ()", __FUNCTION__); - Mutex::Locker start_locker(m_async_thread_state_mutex); + std::lock_guard 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 @@ if (log) log->Printf ("ProcessGDBRemote::%s ()", __FUNCTION__); - Mutex::Locker start_locker(m_async_thread_state_mutex); + std::lock_guard guard(m_async_thread_state_mutex); if (m_async_thread.IsJoinable()) { m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncThreadShouldExit); Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2069,7 +2069,7 @@ { SymbolFileDWARF *dwarf = die.GetDWARF(); - lldb_private::Mutex::Locker locker(dwarf->GetObjectFile()->GetModule()->GetMutex()); + std::lock_guard guard(dwarf->GetObjectFile()->GetModule()->GetMutex()); // Disable external storage for this type so we don't get anymore // clang::ExternalASTSource queries for this type. Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1619,7 +1619,7 @@ bool SymbolFileDWARF::CompleteType (CompilerType &compiler_type) { - lldb_private::Mutex::Locker locker(GetObjectFile()->GetModule()->GetMutex()); + std::lock_guard guard(GetObjectFile()->GetModule()->GetMutex()); ClangASTContext *clang_type_system = llvm::dyn_cast_or_null(compiler_type.GetTypeSystem()); if (clang_type_system) Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -208,7 +208,7 @@ ObjectFile *oso_objfile = GetObjectFile (); if (oso_objfile) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); SymbolVendor* symbol_vendor = Module::GetSymbolVendor(can_create, feedback_strm); if (symbol_vendor) { Index: source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h =================================================================== --- source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h +++ source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h @@ -13,13 +13,14 @@ // C Includes // C++ Includes #include +#include #include + // 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,10 +106,10 @@ lldb_private::Process *m_process; std::unique_ptr 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; }; Index: source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp =================================================================== --- source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp +++ source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp @@ -96,12 +96,12 @@ } \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 @@ } 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 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 @@ // Scope for mutex locker: { - Mutex::Locker locker(m_get_item_info_function_mutex); - + std::lock_guard 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 @@ 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 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); Index: source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h =================================================================== --- source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h +++ source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h @@ -13,12 +13,13 @@ // C Includes // C++ Includes #include +#include #include + // 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 @@ lldb_private::Process *m_process; std::unique_ptr 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 Index: source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp =================================================================== --- source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp +++ source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp @@ -100,12 +100,12 @@ } \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 @@ } 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 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 @@ // Scope for mutex locker: { - Mutex::Locker locker(m_get_pending_items_function_mutex); - + std::lock_guard 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 @@ 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 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); Index: source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h =================================================================== --- source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h +++ source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h @@ -13,12 +13,13 @@ // C Includes // C++ Includes #include +#include #include + // 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,10 +105,10 @@ lldb_private::Process *m_process; std::unique_ptr 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; }; Index: source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp =================================================================== --- source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp +++ source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp @@ -96,12 +96,12 @@ } \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 @@ } 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 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 @@ // Scope for mutex locker: { - Mutex::Locker locker(m_get_queues_function_mutex); - + std::lock_guard 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 @@ 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 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); Index: source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h =================================================================== --- source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h +++ source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h @@ -13,12 +13,13 @@ // C Includes // C++ Includes #include +#include #include + // 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 @@ lldb_private::Process *m_process; std::unique_ptr 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 Index: source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp =================================================================== --- source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp +++ source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp @@ -103,12 +103,12 @@ } \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 @@ } 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 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 @@ // Scope for mutex locker: { - Mutex::Locker locker(m_get_thread_item_info_function_mutex); - + std::lock_guard 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 @@ 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 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); Index: source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h =================================================================== --- source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h +++ source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h @@ -12,6 +12,7 @@ // C Includes // C++ Includes +#include #include #include @@ -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 @@ protected: lldb::user_id_t m_break_id; - mutable lldb_private::Mutex m_mutex; + mutable std::recursive_mutex m_mutex; private: struct libBacktraceRecording_info { Index: source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp =================================================================== --- source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp +++ source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp @@ -83,25 +83,25 @@ //---------------------------------------------------------------------- // 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 @@ void SystemRuntimeMacOSX::Clear (bool clear_process) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (m_process->IsAlive() && LLDB_BREAK_ID_IS_VALID(m_break_id)) m_process->ClearBreakpointSiteByID(m_break_id); Index: source/Symbol/FuncUnwinders.cpp =================================================================== --- source/Symbol/FuncUnwinders.cpp +++ source/Symbol/FuncUnwinders.cpp @@ -30,27 +30,27 @@ /// constructor //------------------------------------------------ -FuncUnwinders::FuncUnwinders (UnwindTable& unwind_table, AddressRange range) : - m_unwind_table (unwind_table), - m_range (range), - m_mutex (Mutex::eMutexTypeRecursive), - m_unwind_plan_assembly_sp (), - m_unwind_plan_eh_frame_sp (), - m_unwind_plan_eh_frame_augmented_sp (), - m_unwind_plan_compact_unwind (), - m_unwind_plan_arm_unwind_sp (), - m_unwind_plan_fast_sp (), - m_unwind_plan_arch_default_sp (), - m_unwind_plan_arch_default_at_func_entry_sp (), - m_tried_unwind_plan_assembly (false), - m_tried_unwind_plan_eh_frame (false), - m_tried_unwind_plan_eh_frame_augmented (false), - m_tried_unwind_plan_compact_unwind (false), - m_tried_unwind_plan_arm_unwind (false), - m_tried_unwind_fast (false), - m_tried_unwind_arch_default (false), - m_tried_unwind_arch_default_at_func_entry (false), - m_first_non_prologue_insn () +FuncUnwinders::FuncUnwinders(UnwindTable &unwind_table, AddressRange range) + : m_unwind_table(unwind_table), + m_range(range), + m_mutex(), + m_unwind_plan_assembly_sp(), + m_unwind_plan_eh_frame_sp(), + m_unwind_plan_eh_frame_augmented_sp(), + m_unwind_plan_compact_unwind(), + m_unwind_plan_arm_unwind_sp(), + m_unwind_plan_fast_sp(), + m_unwind_plan_arch_default_sp(), + m_unwind_plan_arch_default_at_func_entry_sp(), + m_tried_unwind_plan_assembly(false), + m_tried_unwind_plan_eh_frame(false), + m_tried_unwind_plan_eh_frame_augmented(false), + m_tried_unwind_plan_compact_unwind(false), + m_tried_unwind_plan_arm_unwind(false), + m_tried_unwind_fast(false), + m_tried_unwind_arch_default(false), + m_tried_unwind_arch_default_at_func_entry(false), + m_first_non_prologue_insn() { } @@ -65,7 +65,7 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanAtCallSite (Target &target, int current_offset) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); UnwindPlanSP unwind_plan_sp = GetEHFrameUnwindPlan (target, current_offset); if (unwind_plan_sp) @@ -90,7 +90,7 @@ if (m_tried_unwind_plan_compact_unwind) return UnwindPlanSP(); - Mutex::Locker lock (m_mutex); + std::lock_guard guard(m_mutex); m_tried_unwind_plan_compact_unwind = true; if (m_range.GetBaseAddress().IsValid()) { @@ -117,7 +117,7 @@ if (m_unwind_plan_eh_frame_sp.get() || m_tried_unwind_plan_eh_frame) return m_unwind_plan_eh_frame_sp; - Mutex::Locker lock (m_mutex); + std::lock_guard guard(m_mutex); m_tried_unwind_plan_eh_frame = true; if (m_range.GetBaseAddress().IsValid()) { @@ -141,7 +141,7 @@ if (m_unwind_plan_arm_unwind_sp.get() || m_tried_unwind_plan_arm_unwind) return m_unwind_plan_arm_unwind_sp; - Mutex::Locker lock (m_mutex); + std::lock_guard guard(m_mutex); m_tried_unwind_plan_arm_unwind = true; if (m_range.GetBaseAddress().IsValid()) { @@ -175,7 +175,7 @@ return m_unwind_plan_eh_frame_augmented_sp; } - Mutex::Locker lock (m_mutex); + std::lock_guard guard(m_mutex); m_tried_unwind_plan_eh_frame_augmented = true; UnwindPlanSP eh_frame_plan = GetEHFrameUnwindPlan (target, current_offset); @@ -213,7 +213,7 @@ return m_unwind_plan_assembly_sp; } - Mutex::Locker lock (m_mutex); + std::lock_guard guard(m_mutex); m_tried_unwind_plan_assembly = true; UnwindAssemblySP assembly_profiler_sp (GetUnwindAssemblyProfiler(target)); @@ -246,7 +246,7 @@ if (m_unwind_plan_fast_sp.get() || m_tried_unwind_fast) return m_unwind_plan_fast_sp; - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_tried_unwind_fast = true; UnwindAssemblySP assembly_profiler_sp (GetUnwindAssemblyProfiler(target)); @@ -267,7 +267,7 @@ if (m_unwind_plan_arch_default_sp.get() || m_tried_unwind_arch_default) return m_unwind_plan_arch_default_sp; - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_tried_unwind_arch_default = true; Address current_pc; @@ -294,7 +294,7 @@ if (m_unwind_plan_arch_default_at_func_entry_sp.get() || m_tried_unwind_arch_default_at_func_entry) return m_unwind_plan_arch_default_at_func_entry_sp; - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_tried_unwind_arch_default_at_func_entry = true; Address current_pc; @@ -322,7 +322,7 @@ if (m_first_non_prologue_insn.IsValid()) return m_first_non_prologue_insn; - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); ExecutionContext exe_ctx (target.shared_from_this(), false); UnwindAssemblySP assembly_profiler_sp (GetUnwindAssemblyProfiler(target)); if (assembly_profiler_sp) Index: source/Symbol/ObjectFile.cpp =================================================================== --- source/Symbol/ObjectFile.cpp +++ source/Symbol/ObjectFile.cpp @@ -600,7 +600,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); if (log) log->Printf ("%p ObjectFile::ClearSymtab () symtab = %p", @@ -620,7 +620,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); CreateSections(*module_sp->GetUnifiedSectionList()); } } Index: source/Symbol/SymbolVendor.cpp =================================================================== --- source/Symbol/SymbolVendor.cpp +++ source/Symbol/SymbolVendor.cpp @@ -85,7 +85,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (objfile_sp) { m_objfile_sp = objfile_sp; @@ -100,7 +100,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); const size_t num_compile_units = GetNumCompileUnits(); if (idx < num_compile_units) { @@ -129,7 +129,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_compile_units.empty()) { if (m_sym_file_ap.get()) @@ -151,7 +151,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->ParseCompileUnitLanguage(sc); } @@ -165,7 +165,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->ParseCompileUnitFunctions(sc); } @@ -178,7 +178,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->ParseCompileUnitLineTable(sc); } @@ -191,7 +191,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->ParseCompileUnitDebugMacros(sc); } @@ -203,7 +203,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->ParseCompileUnitSupportFiles(sc, support_files); } @@ -217,7 +217,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->ParseImportedModules(sc, imported_modules); } @@ -231,7 +231,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->ParseFunctionBlocks(sc); } @@ -244,7 +244,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->ParseTypes(sc); } @@ -257,7 +257,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->ParseVariablesForContext(sc); } @@ -270,7 +270,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->ResolveTypeUID(type_uid); } @@ -284,7 +284,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->ResolveSymbolContext(so_addr, resolve_scope, sc); } @@ -297,7 +297,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->ResolveSymbolContext(file_spec, line, check_inlines, resolve_scope, sc_list); } @@ -310,7 +310,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->FindGlobalVariables(name, parent_decl_ctx, append, max_matches, variables); } @@ -323,7 +323,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->FindGlobalVariables(regex, append, max_matches, variables); } @@ -336,7 +336,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->FindFunctions(name, parent_decl_ctx, name_type_mask, include_inlines, append, sc_list); } @@ -349,7 +349,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->FindFunctions(regex, include_inlines, append, sc_list); } @@ -363,7 +363,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->FindTypes(sc, name, parent_decl_ctx, append, max_matches, searched_symbol_files, types); } @@ -378,7 +378,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->FindTypes(context, append, types); } @@ -395,7 +395,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) return m_sym_file_ap->GetTypes (sc_scope, type_mask, type_list); } @@ -409,7 +409,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); if (m_sym_file_ap.get()) namespace_decl_ctx = m_sym_file_ap->FindNamespace (sc, name, parent_decl_ctx); } @@ -422,7 +422,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); bool show_context = false; @@ -467,7 +467,7 @@ ModuleSP module_sp(GetModule()); if (module_sp) { - lldb_private::Mutex::Locker locker(module_sp->GetMutex()); + std::lock_guard guard(module_sp->GetMutex()); const size_t num_compile_units = GetNumCompileUnits(); if (idx < num_compile_units) { Index: source/Target/JITLoaderList.cpp =================================================================== --- source/Target/JITLoaderList.cpp +++ source/Target/JITLoaderList.cpp @@ -14,8 +14,7 @@ using namespace lldb; using namespace lldb_private; -JITLoaderList::JITLoaderList() - : m_jit_loaders_vec(), m_jit_loaders_mutex(Mutex::eMutexTypeRecursive) +JITLoaderList::JITLoaderList() : m_jit_loaders_vec(), m_jit_loaders_mutex() { } @@ -26,14 +25,14 @@ void JITLoaderList::Append (const JITLoaderSP &jit_loader_sp) { - Mutex::Locker locker(m_jit_loaders_mutex); + std::lock_guard guard(m_jit_loaders_mutex); m_jit_loaders_vec.push_back(jit_loader_sp); } void JITLoaderList::Remove (const JITLoaderSP &jit_loader_sp) { - Mutex::Locker locker(m_jit_loaders_mutex); + std::lock_guard guard(m_jit_loaders_mutex); m_jit_loaders_vec.erase(std::remove(m_jit_loaders_vec.begin(), m_jit_loaders_vec.end(), jit_loader_sp), m_jit_loaders_vec.end()); @@ -48,14 +47,14 @@ JITLoaderSP JITLoaderList::GetLoaderAtIndex (size_t idx) { - Mutex::Locker locker(m_jit_loaders_mutex); + std::lock_guard guard(m_jit_loaders_mutex); return m_jit_loaders_vec[idx]; } void JITLoaderList::DidLaunch() { - Mutex::Locker locker(m_jit_loaders_mutex); + std::lock_guard guard(m_jit_loaders_mutex); for (auto const &jit_loader : m_jit_loaders_vec) jit_loader->DidLaunch(); } @@ -63,7 +62,7 @@ void JITLoaderList::DidAttach() { - Mutex::Locker locker(m_jit_loaders_mutex); + std::lock_guard guard(m_jit_loaders_mutex); for (auto const &jit_loader : m_jit_loaders_vec) jit_loader->DidAttach(); } @@ -71,7 +70,7 @@ void JITLoaderList::ModulesDidLoad(ModuleList &module_list) { - Mutex::Locker locker(m_jit_loaders_mutex); + std::lock_guard guard(m_jit_loaders_mutex); for (auto const &jit_loader : m_jit_loaders_vec) jit_loader->ModulesDidLoad(module_list); } Index: source/Target/Language.cpp =================================================================== --- source/Target/Language.cpp +++ source/Target/Language.cpp @@ -36,23 +36,23 @@ return *g_map; } -static Mutex& -GetLanguagesMutex () +static std::mutex & +GetLanguagesMutex() { - static Mutex *g_mutex = nullptr; + static std::mutex *g_mutex = nullptr; static std::once_flag g_initialize; - + std::call_once(g_initialize, [] { - g_mutex = new Mutex(); // NOTE: INTENTIONAL LEAK due to global destructor chain + g_mutex = new std::mutex(); // NOTE: INTENTIONAL LEAK due to global destructor chain }); - + return *g_mutex; } Language* Language::FindPlugin (lldb::LanguageType language) { - Mutex::Locker locker(GetLanguagesMutex()); + std::lock_guard guard(GetLanguagesMutex()); LanguagesMap& map(GetLanguagesMap()); auto iter = map.find(language), end = map.end(); if (iter != end) @@ -80,7 +80,7 @@ void Language::ForEach (std::function callback) { - Mutex::Locker locker(GetLanguagesMutex()); + std::lock_guard guard(GetLanguagesMutex()); LanguagesMap& map(GetLanguagesMap()); for (const auto& entry : map) { Index: source/Target/Platform.cpp =================================================================== --- source/Target/Platform.cpp +++ source/Target/Platform.cpp @@ -162,10 +162,10 @@ return g_platform_list; } -static Mutex & -GetPlatformListMutex () +static std::recursive_mutex & +GetPlatformListMutex() { - static Mutex g_mutex(Mutex::eMutexTypeRecursive); + static std::recursive_mutex g_mutex; return g_mutex; } @@ -182,7 +182,7 @@ { if (--g_initialize_count == 0) { - Mutex::Locker locker(GetPlatformListMutex ()); + std::lock_guard guard(GetPlatformListMutex()); GetPlatformList().clear(); } } @@ -204,7 +204,7 @@ if (platform_sp) { - Mutex::Locker locker(GetPlatformListMutex ()); + std::lock_guard guard(GetPlatformListMutex()); GetPlatformList().push_back(platform_sp); } } @@ -309,7 +309,7 @@ if (name == g_host_platform_name) return GetHostPlatform(); - Mutex::Locker locker(GetPlatformListMutex ()); + std::lock_guard guard(GetPlatformListMutex()); for (const auto &platform_sp : GetPlatformList()) { if (platform_sp->GetName() == name) @@ -341,7 +341,7 @@ if (platform_sp) { - Mutex::Locker locker(GetPlatformListMutex ()); + std::lock_guard guard(GetPlatformListMutex()); GetPlatformList().push_back(platform_sp); } @@ -357,7 +357,7 @@ // Scope for locker { // First try exact arch matches across all platforms already created - Mutex::Locker locker(GetPlatformListMutex ()); + std::lock_guard guard(GetPlatformListMutex()); for (const auto &platform_sp : GetPlatformList()) { if (platform_sp->IsCompatibleArchitecture(arch, true, platform_arch_ptr)) @@ -382,7 +382,7 @@ platform_sp = create_callback(false, &arch); if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, true, platform_arch_ptr)) { - Mutex::Locker locker(GetPlatformListMutex ()); + std::lock_guard guard(GetPlatformListMutex()); GetPlatformList().push_back(platform_sp); return platform_sp; } @@ -396,7 +396,7 @@ platform_sp = create_callback(false, &arch); if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, false, platform_arch_ptr)) { - Mutex::Locker locker(GetPlatformListMutex ()); + std::lock_guard guard(GetPlatformListMutex()); GetPlatformList().push_back(platform_sp); return platform_sp; } @@ -414,37 +414,37 @@ //------------------------------------------------------------------ /// Default Constructor //------------------------------------------------------------------ -Platform::Platform (bool is_host) : - m_is_host (is_host), - m_os_version_set_while_connected (false), - m_system_arch_set_while_connected (false), - m_sdk_sysroot (), - m_sdk_build (), - m_working_dir (), - m_remote_url (), - m_name (), - m_major_os_version (UINT32_MAX), - m_minor_os_version (UINT32_MAX), - m_update_os_version (UINT32_MAX), - m_system_arch(), - m_mutex (Mutex::eMutexTypeRecursive), - m_uid_map(), - m_gid_map(), - m_max_uid_name_len (0), - m_max_gid_name_len (0), - m_supports_rsync (false), - m_rsync_opts (), - m_rsync_prefix (), - m_supports_ssh (false), - m_ssh_opts (), - m_ignores_remote_hostname (false), - m_trap_handlers(), - m_calculated_trap_handlers (false), - m_module_cache (llvm::make_unique ()) -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); +Platform::Platform(bool is_host) + : m_is_host(is_host), + m_os_version_set_while_connected(false), + m_system_arch_set_while_connected(false), + m_sdk_sysroot(), + m_sdk_build(), + m_working_dir(), + m_remote_url(), + m_name(), + m_major_os_version(UINT32_MAX), + m_minor_os_version(UINT32_MAX), + m_update_os_version(UINT32_MAX), + m_system_arch(), + m_mutex(), + m_uid_map(), + m_gid_map(), + m_max_uid_name_len(0), + m_max_gid_name_len(0), + m_supports_rsync(false), + m_rsync_opts(), + m_rsync_prefix(), + m_supports_ssh(false), + m_ssh_opts(), + m_ignores_remote_hostname(false), + m_trap_handlers(), + m_calculated_trap_handlers(false), + m_module_cache(llvm::make_unique()) +{ + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT)); if (log) - log->Printf ("%p Platform::Platform()", static_cast(this)); + log->Printf("%p Platform::Platform()", static_cast(this)); } //------------------------------------------------------------------ @@ -528,7 +528,7 @@ uint32_t &update, Process *process) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); bool success = m_major_os_version != UINT32_MAX; if (IsHost()) @@ -1741,7 +1741,7 @@ { if (!m_calculated_trap_handlers) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (!m_calculated_trap_handlers) { CalculateTrapHandlerSymbolNames(); Index: source/Target/Process.cpp =================================================================== --- source/Target/Process.cpp +++ source/Target/Process.cpp @@ -1795,7 +1795,7 @@ log->Printf("Process::SetPrivateState (%s)", StateAsCString(new_state)); Mutex::Locker thread_locker(m_thread_list.GetMutex()); - Mutex::Locker locker(m_private_state.GetMutex()); + std::lock_guard guard(m_private_state.GetMutex()); const StateType old_state = m_private_state.GetValueNoLock (); state_changed = old_state != new_state; Index: source/Target/SectionLoadHistory.cpp =================================================================== --- source/Target/SectionLoadHistory.cpp +++ source/Target/SectionLoadHistory.cpp @@ -23,21 +23,21 @@ bool SectionLoadHistory::IsEmpty() const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return m_stop_id_to_section_load_list.empty(); } void SectionLoadHistory::Clear () { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); m_stop_id_to_section_load_list.clear(); } uint32_t SectionLoadHistory::GetLastStopID() const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (m_stop_id_to_section_load_list.empty()) return 0; else @@ -108,7 +108,7 @@ SectionLoadHistory::GetCurrentSectionLoadList () { const bool read_only = true; - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); SectionLoadList *section_load_list = GetSectionLoadListForStopID (eStopIDNow, read_only); assert(section_load_list != NULL); return *section_load_list; @@ -117,7 +117,7 @@ addr_t SectionLoadHistory::GetSectionLoadAddress (uint32_t stop_id, const lldb::SectionSP §ion_sp) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); const bool read_only = true; SectionLoadList *section_load_list = GetSectionLoadListForStopID (stop_id, read_only); return section_load_list->GetSectionLoadAddress(section_sp); @@ -127,7 +127,7 @@ SectionLoadHistory::ResolveLoadAddress (uint32_t stop_id, addr_t load_addr, Address &so_addr) { // First find the top level section that this load address exists in - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); const bool read_only = true; SectionLoadList *section_load_list = GetSectionLoadListForStopID (stop_id, read_only); return section_load_list->ResolveLoadAddress (load_addr, so_addr); @@ -139,7 +139,7 @@ addr_t load_addr, bool warn_multiple) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); const bool read_only = false; SectionLoadList *section_load_list = GetSectionLoadListForStopID (stop_id, read_only); return section_load_list->SetSectionLoadAddress(section_sp, load_addr, warn_multiple); @@ -148,7 +148,7 @@ size_t SectionLoadHistory::SetSectionUnloaded (uint32_t stop_id, const lldb::SectionSP §ion_sp) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); const bool read_only = false; SectionLoadList *section_load_list = GetSectionLoadListForStopID (stop_id, read_only); return section_load_list->SetSectionUnloaded (section_sp); @@ -157,7 +157,7 @@ bool SectionLoadHistory::SetSectionUnloaded (uint32_t stop_id, const lldb::SectionSP §ion_sp, addr_t load_addr) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); const bool read_only = false; SectionLoadList *section_load_list = GetSectionLoadListForStopID (stop_id, read_only); return section_load_list->SetSectionUnloaded (section_sp, load_addr); @@ -166,7 +166,7 @@ void SectionLoadHistory::Dump (Stream &s, Target *target) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); StopIDToSectionLoadList::iterator pos, end = m_stop_id_to_section_load_list.end(); for (pos = m_stop_id_to_section_load_list.begin(); pos != end; ++pos) { Index: source/Target/SectionLoadList.cpp =================================================================== --- source/Target/SectionLoadList.cpp +++ source/Target/SectionLoadList.cpp @@ -24,13 +24,9 @@ using namespace lldb; using namespace lldb_private; - -SectionLoadList::SectionLoadList (const SectionLoadList& rhs) : - m_addr_to_sect(), - m_sect_to_addr(), - m_mutex (Mutex::eMutexTypeRecursive) +SectionLoadList::SectionLoadList(const SectionLoadList &rhs) : m_addr_to_sect(), m_sect_to_addr(), m_mutex() { - Mutex::Locker locker(rhs.m_mutex); + std::lock_guard guard(rhs.m_mutex); m_addr_to_sect = rhs.m_addr_to_sect; m_sect_to_addr = rhs.m_sect_to_addr; } @@ -38,8 +34,8 @@ void SectionLoadList::operator=(const SectionLoadList &rhs) { - Mutex::Locker lhs_locker (m_mutex); - Mutex::Locker rhs_locker (rhs.m_mutex); + std::lock_guard lhs_guard(m_mutex); + std::lock_guard rhs_guard(rhs.m_mutex); m_addr_to_sect = rhs.m_addr_to_sect; m_sect_to_addr = rhs.m_sect_to_addr; } @@ -47,14 +43,14 @@ bool SectionLoadList::IsEmpty() const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return m_addr_to_sect.empty(); } void SectionLoadList::Clear () { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); m_addr_to_sect.clear(); m_sect_to_addr.clear(); } @@ -66,7 +62,7 @@ addr_t section_load_addr = LLDB_INVALID_ADDRESS; if (section) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); sect_to_addr_collection::const_iterator pos = m_sect_to_addr.find (section.get()); if (pos != m_sect_to_addr.end()) @@ -98,7 +94,7 @@ return false; // No change // Fill in the section -> load_addr map - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); sect_to_addr_collection::iterator sta_pos = m_sect_to_addr.find(section.get()); if (sta_pos != m_sect_to_addr.end()) { @@ -185,7 +181,7 @@ section_sp->GetName().AsCString()); } - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); sect_to_addr_collection::iterator sta_pos = m_sect_to_addr.find(section_sp.get()); if (sta_pos != m_sect_to_addr.end()) @@ -222,7 +218,7 @@ section_sp->GetName().AsCString(), load_addr); } bool erased = false; - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); sect_to_addr_collection::iterator sta_pos = m_sect_to_addr.find(section_sp.get()); if (sta_pos != m_sect_to_addr.end()) { @@ -245,7 +241,7 @@ SectionLoadList::ResolveLoadAddress (addr_t load_addr, Address &so_addr) const { // First find the top level section that this load address exists in - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (!m_addr_to_sect.empty()) { addr_to_sect_collection::const_iterator pos = m_addr_to_sect.lower_bound (load_addr); @@ -289,7 +285,7 @@ void SectionLoadList::Dump (Stream &s, Target *target) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); addr_to_sect_collection::const_iterator pos, end; for (pos = m_addr_to_sect.begin(), end = m_addr_to_sect.end(); pos != end; ++pos) { Index: source/Target/Target.cpp =================================================================== --- source/Target/Target.cpp +++ source/Target/Target.cpp @@ -2611,11 +2611,11 @@ ClangModulesDeclVendor * Target::GetClangModulesDeclVendor () { - static Mutex s_clang_modules_decl_vendor_mutex; // If this is contended we can make it per-target - + static std::mutex s_clang_modules_decl_vendor_mutex; // If this is contended we can make it per-target + { - Mutex::Locker clang_modules_decl_vendor_locker(s_clang_modules_decl_vendor_mutex); - + std::lock_guard guard(s_clang_modules_decl_vendor_mutex); + if (!m_clang_modules_decl_vendor_ap) { m_clang_modules_decl_vendor_ap.reset(ClangModulesDeclVendor::Create(*this)); Index: source/Target/TargetList.cpp =================================================================== --- source/Target/TargetList.cpp +++ source/Target/TargetList.cpp @@ -42,11 +42,11 @@ //---------------------------------------------------------------------- // TargetList constructor //---------------------------------------------------------------------- -TargetList::TargetList(Debugger &debugger) : - Broadcaster(debugger.GetBroadcasterManager(), TargetList::GetStaticBroadcasterClass().AsCString()), - m_target_list(), - m_target_list_mutex (Mutex::eMutexTypeRecursive), - m_selected_target_idx (0) +TargetList::TargetList(Debugger &debugger) + : Broadcaster(debugger.GetBroadcasterManager(), TargetList::GetStaticBroadcasterClass().AsCString()), + m_target_list(), + m_target_list_mutex(), + m_selected_target_idx(0) { CheckInWithManager(); } @@ -56,7 +56,7 @@ //---------------------------------------------------------------------- TargetList::~TargetList() { - Mutex::Locker locker(m_target_list_mutex); + std::lock_guard guard(m_target_list_mutex); m_target_list.clear(); } @@ -515,7 +515,7 @@ // Don't put the dummy target in the target list, it's held separately. if (!is_dummy_target) { - Mutex::Locker locker(m_target_list_mutex); + std::lock_guard guard(m_target_list_mutex); m_selected_target_idx = m_target_list.size(); m_target_list.push_back(target_sp); // Now prime this from the dummy target: @@ -533,7 +533,7 @@ bool TargetList::DeleteTarget (TargetSP &target_sp) { - Mutex::Locker locker(m_target_list_mutex); + std::lock_guard guard(m_target_list_mutex); collection::iterator pos, end = m_target_list.end(); for (pos = m_target_list.begin(); pos != end; ++pos) @@ -551,7 +551,7 @@ TargetList::FindTargetWithExecutableAndArchitecture(const FileSpec &exe_file_spec, const ArchSpec *exe_arch_ptr) const { - Mutex::Locker locker (m_target_list_mutex); + std::lock_guard guard(m_target_list_mutex); TargetSP target_sp; bool full_match = (bool)exe_file_spec.GetDirectory(); @@ -580,7 +580,7 @@ TargetSP TargetList::FindTargetWithProcessID (lldb::pid_t pid) const { - Mutex::Locker locker(m_target_list_mutex); + std::lock_guard guard(m_target_list_mutex); TargetSP target_sp; collection::const_iterator pos, end = m_target_list.end(); for (pos = m_target_list.begin(); pos != end; ++pos) @@ -601,7 +601,7 @@ TargetSP target_sp; if (process) { - Mutex::Locker locker(m_target_list_mutex); + std::lock_guard guard(m_target_list_mutex); collection::const_iterator pos, end = m_target_list.end(); for (pos = m_target_list.begin(); pos != end; ++pos) { @@ -621,7 +621,7 @@ TargetSP target_sp; if (target) { - Mutex::Locker locker(m_target_list_mutex); + std::lock_guard guard(m_target_list_mutex); collection::const_iterator pos, end = m_target_list.end(); for (pos = m_target_list.begin(); pos != end; ++pos) { @@ -671,7 +671,7 @@ if (pid == LLDB_INVALID_PROCESS_ID) { // Signal all processes with signal - Mutex::Locker locker(m_target_list_mutex); + std::lock_guard guard(m_target_list_mutex); collection::iterator pos, end = m_target_list.end(); for (pos = m_target_list.begin(); pos != end; ++pos) { @@ -709,7 +709,7 @@ int TargetList::GetNumTargets () const { - Mutex::Locker locker (m_target_list_mutex); + std::lock_guard guard(m_target_list_mutex); return m_target_list.size(); } @@ -717,7 +717,7 @@ TargetList::GetTargetAtIndex (uint32_t idx) const { TargetSP target_sp; - Mutex::Locker locker (m_target_list_mutex); + std::lock_guard guard(m_target_list_mutex); if (idx < m_target_list.size()) target_sp = m_target_list[idx]; return target_sp; @@ -726,7 +726,7 @@ uint32_t TargetList::GetIndexOfTarget (lldb::TargetSP target_sp) const { - Mutex::Locker locker (m_target_list_mutex); + std::lock_guard guard(m_target_list_mutex); size_t num_targets = m_target_list.size(); for (size_t idx = 0; idx < num_targets; idx++) { @@ -739,7 +739,7 @@ uint32_t TargetList::SetSelectedTarget (Target* target) { - Mutex::Locker locker (m_target_list_mutex); + std::lock_guard guard(m_target_list_mutex); collection::const_iterator pos, begin = m_target_list.begin(), end = m_target_list.end(); @@ -758,7 +758,7 @@ lldb::TargetSP TargetList::GetSelectedTarget () { - Mutex::Locker locker (m_target_list_mutex); + std::lock_guard guard(m_target_list_mutex); if (m_selected_target_idx >= m_target_list.size()) m_selected_target_idx = 0; return GetTargetAtIndex (m_selected_target_idx); Index: source/Target/Thread.cpp =================================================================== --- source/Target/Thread.cpp +++ source/Target/Thread.cpp @@ -9,7 +9,6 @@ // C Includes // C++ Includes -#include // Other libraries and framework includes // Project includes #include "lldb/Breakpoint/BreakpointLocation.h" @@ -271,36 +270,36 @@ return class_name; } -Thread::Thread (Process &process, lldb::tid_t tid, bool use_invalid_index_id) : - ThreadProperties (false), - UserID (tid), - Broadcaster(process.GetTarget().GetDebugger().GetBroadcasterManager(), Thread::GetStaticBroadcasterClass().AsCString()), - m_process_wp (process.shared_from_this()), - m_stop_info_sp (), - m_stop_info_stop_id (0), - m_stop_info_override_stop_id (0), - m_index_id (use_invalid_index_id ? LLDB_INVALID_INDEX32 : process.GetNextThreadIndexID(tid)), - m_reg_context_sp (), - m_state (eStateUnloaded), - m_state_mutex (Mutex::eMutexTypeRecursive), - m_plan_stack (), - m_completed_plan_stack(), - m_frame_mutex (Mutex::eMutexTypeRecursive), - m_curr_frames_sp (), - m_prev_frames_sp (), - m_resume_signal (LLDB_INVALID_SIGNAL_NUMBER), - m_resume_state (eStateRunning), - m_temporary_resume_state (eStateRunning), - m_unwinder_ap (), - m_destroy_called (false), - m_override_should_notify (eLazyBoolCalculate), - m_extended_info_fetched (false), - m_extended_info () -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); +Thread::Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id) + : ThreadProperties(false), + UserID(tid), + Broadcaster(process.GetTarget().GetDebugger().GetBroadcasterManager(), + Thread::GetStaticBroadcasterClass().AsCString()), + m_process_wp(process.shared_from_this()), + m_stop_info_sp(), + m_stop_info_stop_id(0), + m_stop_info_override_stop_id(0), + m_index_id(use_invalid_index_id ? LLDB_INVALID_INDEX32 : process.GetNextThreadIndexID(tid)), + m_reg_context_sp(), + m_state(eStateUnloaded), + m_state_mutex(), + m_plan_stack(), + m_completed_plan_stack(), + m_frame_mutex(), + m_curr_frames_sp(), + m_prev_frames_sp(), + m_resume_signal(LLDB_INVALID_SIGNAL_NUMBER), + m_resume_state(eStateRunning), + m_temporary_resume_state(eStateRunning), + m_unwinder_ap(), + m_destroy_called(false), + m_override_should_notify(eLazyBoolCalculate), + m_extended_info_fetched(false), + m_extended_info() +{ + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT)); if (log) - log->Printf ("%p Thread::Thread(tid = 0x%4.4" PRIx64 ")", - static_cast(this), GetID()); + log->Printf("%p Thread::Thread(tid = 0x%4.4" PRIx64 ")", static_cast(this), GetID()); CheckInWithManager(); QueueFundamentalPlan(true); @@ -345,7 +344,7 @@ m_stop_info_sp.reset(); m_reg_context_sp.reset(); m_unwinder_ap.reset(); - Mutex::Locker locker(m_frame_mutex); + std::lock_guard guard(m_frame_mutex); m_curr_frames_sp.reset(); m_prev_frames_sp.reset(); } @@ -645,14 +644,14 @@ Thread::GetState() const { // If any other threads access this we will need a mutex for it - Mutex::Locker locker(m_state_mutex); + std::lock_guard guard(m_state_mutex); return m_state; } void Thread::SetState(StateType state) { - Mutex::Locker locker(m_state_mutex); + std::lock_guard guard(m_state_mutex); m_state = state; } @@ -1823,7 +1822,7 @@ Thread::GetStackFrameList () { StackFrameListSP frame_list_sp; - Mutex::Locker locker(m_frame_mutex); + std::lock_guard guard(m_frame_mutex); if (m_curr_frames_sp) { frame_list_sp = m_curr_frames_sp; @@ -1839,7 +1838,7 @@ void Thread::ClearStackFrames () { - Mutex::Locker locker(m_frame_mutex); + std::lock_guard guard(m_frame_mutex); Unwind *unwinder = GetUnwinder (); if (unwinder) Index: source/Target/ThreadPlan.cpp =================================================================== --- source/Target/ThreadPlan.cpp +++ source/Target/ThreadPlan.cpp @@ -27,21 +27,21 @@ //---------------------------------------------------------------------- // ThreadPlan constructor //---------------------------------------------------------------------- -ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread, Vote stop_vote, Vote run_vote) : - m_thread (thread), - m_stop_vote (stop_vote), - m_run_vote (run_vote), - m_kind (kind), - m_name (name), - m_plan_complete_mutex (Mutex::eMutexTypeRecursive), - m_cached_plan_explains_stop (eLazyBoolCalculate), - m_plan_complete (false), - m_plan_private (false), - m_okay_to_discard (true), - m_is_master_plan (false), - m_plan_succeeded(true) +ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread, Vote stop_vote, Vote run_vote) + : m_thread(thread), + m_stop_vote(stop_vote), + m_run_vote(run_vote), + m_kind(kind), + m_name(name), + m_plan_complete_mutex(), + m_cached_plan_explains_stop(eLazyBoolCalculate), + m_plan_complete(false), + m_plan_private(false), + m_okay_to_discard(true), + m_is_master_plan(false), + m_plan_succeeded(true) { - SetID (GetNextID()); + SetID(GetNextID()); } //---------------------------------------------------------------------- @@ -67,14 +67,14 @@ bool ThreadPlan::IsPlanComplete () { - Mutex::Locker locker(m_plan_complete_mutex); + std::lock_guard guard(m_plan_complete_mutex); return m_plan_complete; } void ThreadPlan::SetPlanComplete (bool success) { - Mutex::Locker locker(m_plan_complete_mutex); + std::lock_guard guard(m_plan_complete_mutex); m_plan_complete = true; m_plan_succeeded = success; } @@ -82,7 +82,7 @@ bool ThreadPlan::MischiefManaged () { - Mutex::Locker locker(m_plan_complete_mutex); + std::lock_guard guard(m_plan_complete_mutex); // Mark the plan is complete, but don't override the success flag. m_plan_complete = true; return true; Index: source/Utility/SharingPtr.cpp =================================================================== --- source/Utility/SharingPtr.cpp +++ source/Utility/SharingPtr.cpp @@ -14,12 +14,12 @@ // If ENABLE_SP_LOGGING is defined, then log all shared pointer assignments // and allow them to be queried using a pointer by a call to: #include -#include #include -#include "lldb/Host/Mutex.h" #include "llvm/ADT/STLExtras.h" +#include +#include #include class Backtrace @@ -70,8 +70,8 @@ { typedef std::pair PtrBacktracePair; typedef std::map PtrToBacktraceMap; - static lldb_private::Mutex g_mutex(lldb_private::Mutex::eMutexTypeNormal); - lldb_private::Mutex::Locker locker (g_mutex); + static std::mutex g_mutex; + std::lock_guard guard(g_mutex); static PtrToBacktraceMap g_map; if (sp_this)