Index: include/lldb/Breakpoint/BreakpointList.h =================================================================== --- include/lldb/Breakpoint/BreakpointList.h +++ include/lldb/Breakpoint/BreakpointList.h @@ -13,10 +13,11 @@ // C Includes // C++ Includes #include +#include + // Other libraries and framework includes // Project includes #include "lldb/Breakpoint/Breakpoint.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -116,7 +117,7 @@ size_t GetSize() const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return m_breakpoints.size(); } @@ -193,7 +194,7 @@ /// The locker object that is set. //------------------------------------------------------------------ void - GetListMutex (lldb_private::Mutex::Locker &locker); + GetListMutex(std::unique_lock &lock); protected: typedef std::list bp_collection; @@ -204,19 +205,20 @@ bp_collection::const_iterator GetBreakpointIDConstIterator(lldb::break_id_t breakID) const; - Mutex & - GetMutex () const + std::recursive_mutex & + GetMutex() const { return m_mutex; } - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; bp_collection m_breakpoints; // The breakpoint list, currently a list. lldb::break_id_t m_next_break_id; bool m_is_internal; public: - typedef LockingAdaptedIterable BreakpointIterable; + typedef LockingAdaptedIterable + BreakpointIterable; BreakpointIterable Breakpoints() { Index: include/lldb/Breakpoint/BreakpointLocation.h =================================================================== --- include/lldb/Breakpoint/BreakpointLocation.h +++ include/lldb/Breakpoint/BreakpointLocation.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include +#include // Other libraries and framework includes // Project includes @@ -20,7 +21,6 @@ #include "lldb/Breakpoint/StoppointLocation.h" #include "lldb/Core/Address.h" #include "lldb/Core/UserID.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -460,7 +460,8 @@ std::unique_ptr m_options_ap; ///< Breakpoint options pointer, nullptr if we're using our breakpoint's options. lldb::BreakpointSiteSP m_bp_site_sp; ///< Our breakpoint site (it may be shared by more than one location.) lldb::UserExpressionSP m_user_expression_sp; ///< The compiled expression to use in testing our condition. - Mutex m_condition_mutex; ///< Guards parsing and evaluation of the condition, which could be evaluated by multiple processes. + std::mutex m_condition_mutex; ///< Guards parsing and evaluation of the condition, which could be evaluated by + /// multiple processes. size_t m_condition_hash; ///< For testing whether the condition source code changed. void Index: include/lldb/Breakpoint/WatchpointList.h =================================================================== --- include/lldb/Breakpoint/WatchpointList.h +++ include/lldb/Breakpoint/WatchpointList.h @@ -13,12 +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" namespace lldb_private { @@ -217,7 +218,7 @@ size_t GetSize() const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); return m_watchpoints.size(); } @@ -250,7 +251,7 @@ /// The locker object that is set. //------------------------------------------------------------------ void - GetListMutex (lldb_private::Mutex::Locker &locker); + GetListMutex(std::unique_lock &lock); protected: typedef std::list wp_collection; @@ -266,7 +267,7 @@ GetIDConstIterator(lldb::watch_id_t watchID) const; wp_collection m_watchpoints; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; lldb::watch_id_t m_next_wp_id; }; Index: include/lldb/Core/IOHandler.h =================================================================== --- include/lldb/Core/IOHandler.h +++ include/lldb/Core/IOHandler.h @@ -29,7 +29,6 @@ #include "lldb/Core/Stream.h" #include "lldb/Core/StringList.h" #include "lldb/Core/ValueObjectList.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/Predicate.h" namespace curses Index: include/lldb/Core/ModuleList.h =================================================================== --- include/lldb/Core/ModuleList.h +++ include/lldb/Core/ModuleList.h @@ -14,12 +14,12 @@ // 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/Utility/Iterable.h" #include "llvm/ADT/DenseSet.h" @@ -164,13 +164,13 @@ void LogUUIDAndPaths (Log *log, const char *prefix_cstr); - - Mutex & - GetMutex () const + + std::recursive_mutex & + GetMutex() const { return m_modules_mutex; } - + size_t GetIndexForModule (const Module *module) const; @@ -593,12 +593,12 @@ // Member variables. //------------------------------------------------------------------ collection m_modules; ///< The collection of modules. - mutable Mutex m_modules_mutex; + mutable std::recursive_mutex m_modules_mutex; Notifier* m_notifier; public: - typedef LockingAdaptedIterable ModuleIterable; + typedef LockingAdaptedIterable ModuleIterable; ModuleIterable Modules() { Index: include/lldb/Host/OptionParser.h =================================================================== --- include/lldb/Host/OptionParser.h +++ include/lldb/Host/OptionParser.h @@ -10,8 +10,8 @@ #ifndef liblldb_OptionParser_h_ #define liblldb_OptionParser_h_ +#include #include -#include "lldb/Host/Mutex.h" struct option; @@ -39,7 +39,8 @@ eOptionalArgument }; - static void Prepare(Mutex::Locker &locker); + static void + Prepare(std::unique_lock &lock); static void EnableError(bool error); Index: include/lldb/Interpreter/CommandObject.h =================================================================== --- include/lldb/Interpreter/CommandObject.h +++ include/lldb/Interpreter/CommandObject.h @@ -23,7 +23,6 @@ #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Core/StringList.h" #include "lldb/Core/Flags.h" -#include "lldb/Host/Mutex.h" #include "lldb/Target/ExecutionContext.h" namespace lldb_private { @@ -517,7 +516,7 @@ CommandInterpreter &m_interpreter; ExecutionContext m_exe_ctx; - Mutex::Locker m_api_locker; + std::unique_lock m_api_locker; std::string m_cmd_name; std::string m_cmd_help_short; std::string m_cmd_help_long; Index: include/lldb/Symbol/CompactUnwindInfo.h =================================================================== --- include/lldb/Symbol/CompactUnwindInfo.h +++ include/lldb/Symbol/CompactUnwindInfo.h @@ -10,11 +10,11 @@ #ifndef liblldb_CompactUnwindInfo_h_ #define liblldb_CompactUnwindInfo_h_ +#include #include #include "lldb/Core/DataExtractor.h" #include "lldb/Core/RangeMap.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/lldb-private.h" @@ -137,7 +137,7 @@ lldb::SectionSP m_section_sp; lldb::DataBufferSP m_section_contents_if_encrypted; // if the binary is encrypted, read the sect contents // out of live memory and cache them here - Mutex m_mutex; + std::mutex m_mutex; std::vector m_indexes; LazyBool m_indexes_computed; // eLazyBoolYes once we've tried to parse the unwind info Index: include/lldb/Symbol/DWARFCallFrameInfo.h =================================================================== --- include/lldb/Symbol/DWARFCallFrameInfo.h +++ include/lldb/Symbol/DWARFCallFrameInfo.h @@ -11,6 +11,7 @@ #define liblldb_DWARFCallFrameInfo_h_ #include +#include #include "lldb/Core/AddressRange.h" #include "lldb/Core/DataExtractor.h" @@ -18,7 +19,6 @@ #include "lldb/Core/RangeMap.h" #include "lldb/Core/VMRange.h" #include "lldb/Core/dwarf.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/lldb-private.h" @@ -155,7 +155,7 @@ FDEEntryMap m_fde_index; bool m_fde_index_initialized; // only scan the section for FDEs once - Mutex m_fde_index_mutex; // and isolate the thread that does it + std::mutex m_fde_index_mutex; // and isolate the thread that does it bool m_is_eh_frame; Index: include/lldb/Symbol/Symtab.h =================================================================== --- include/lldb/Symbol/Symtab.h +++ include/lldb/Symbol/Symtab.h @@ -11,12 +11,12 @@ #ifndef liblldb_Symtab_h_ #define liblldb_Symtab_h_ +#include #include #include "lldb/lldb-private.h" #include "lldb/Core/RangeMap.h" #include "lldb/Core/UniqueCStringMap.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/Symbol.h" namespace lldb_private { @@ -50,10 +50,11 @@ void Dump(Stream *s, Target *target, SortOrder sort_type); void Dump(Stream *s, Target *target, std::vector& indexes) const; uint32_t GetIndexForSymbol (const Symbol *symbol) const; - Mutex & GetMutex () - { - return m_mutex; - } + std::recursive_mutex & + GetMutex() + { + return m_mutex; + } Symbol * FindSymbolByID (lldb::user_id_t uid) const; Symbol * SymbolAtIndex (size_t idx); const Symbol * SymbolAtIndex (size_t idx) const; @@ -124,7 +125,7 @@ UniqueCStringMap m_basename_to_index; UniqueCStringMap m_method_to_index; UniqueCStringMap m_selector_to_index; - mutable Mutex m_mutex; // Provide thread safety for this symbol table + mutable std::recursive_mutex m_mutex; // Provide thread safety for this symbol table bool m_file_addr_to_index_computed:1, m_name_indexes_computed:1; private: Index: include/lldb/Symbol/TypeSystem.h =================================================================== --- include/lldb/Symbol/TypeSystem.h +++ include/lldb/Symbol/TypeSystem.h @@ -14,6 +14,7 @@ // C++ Includes #include #include +#include #include // Other libraries and framework includes @@ -24,7 +25,6 @@ #include "lldb/lldb-private.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Expression/Expression.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/CompilerDecl.h" #include "lldb/Symbol/CompilerDeclContext.h" @@ -617,7 +617,7 @@ AddToMap (lldb::LanguageType language, lldb::TypeSystemSP const &type_system_sp); typedef std::map collection; - mutable Mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments. + mutable std::mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments. collection m_map; bool m_clear_in_progress; }; Index: include/lldb/Symbol/UnwindTable.h =================================================================== --- include/lldb/Symbol/UnwindTable.h +++ include/lldb/Symbol/UnwindTable.h @@ -12,9 +12,9 @@ #define liblldb_UnwindTable_h #include +#include #include "lldb/lldb-private.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -69,7 +69,7 @@ collection m_unwinds; bool m_initialized; // delay some initialization until ObjectFile is set up - Mutex m_mutex; + std::mutex m_mutex; std::unique_ptr m_eh_frame_up; std::unique_ptr m_compact_unwind_up; Index: include/lldb/Target/ExecutionContext.h =================================================================== --- include/lldb/Target/ExecutionContext.h +++ include/lldb/Target/ExecutionContext.h @@ -12,11 +12,12 @@ // C Includes // C++ Includes +#include + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" #include "lldb/Target/StackID.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -412,8 +413,8 @@ // These two variants take in a locker, and grab the target, lock the API mutex into locker, then // fill in the rest of the shared pointers. - ExecutionContext (const ExecutionContextRef &exe_ctx_ref, Mutex::Locker &locker); - ExecutionContext (const ExecutionContextRef *exe_ctx_ref, Mutex::Locker &locker); + ExecutionContext(const ExecutionContextRef &exe_ctx_ref, std::unique_lock &locker); + ExecutionContext(const ExecutionContextRef *exe_ctx_ref, std::unique_lock &locker); //------------------------------------------------------------------ // Create execution contexts from execution context scopes //------------------------------------------------------------------ Index: include/lldb/Target/Memory.h =================================================================== --- include/lldb/Target/Memory.h +++ include/lldb/Target/Memory.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include +#include #include // Other libraries and framework includes @@ -20,7 +21,6 @@ // Project includes #include "lldb/lldb-private.h" #include "lldb/Core/RangeMap.h" -#include "lldb/Host/Mutex.h" namespace lldb_private { //---------------------------------------------------------------------- @@ -75,7 +75,7 @@ //------------------------------------------------------------------ // Classes that inherit from MemoryCache can see and modify these //------------------------------------------------------------------ - Mutex m_mutex; + std::recursive_mutex m_mutex; BlockMap m_L1_cache; // A first level memory cache whose chunk sizes vary that will be used only if the memory read fits entirely in a chunk BlockMap m_L2_cache; // A memory cache of fixed size chinks (m_L2_cache_line_byte_size bytes in size each) InvalidRanges m_invalid_ranges; @@ -192,7 +192,7 @@ // Classes that inherit from MemoryCache can see and modify these //------------------------------------------------------------------ Process &m_process; - Mutex m_mutex; + std::recursive_mutex m_mutex; typedef std::multimap PermissionsToBlockMap; PermissionsToBlockMap m_memory_map; Index: include/lldb/Target/Process.h =================================================================== --- include/lldb/Target/Process.h +++ include/lldb/Target/Process.h @@ -3351,8 +3351,9 @@ std::map m_thread_id_to_index_id_map; int m_exit_status; ///< The exit status of the process, or -1 if not set. std::string m_exit_string; ///< A textual description of why a process exited. - Mutex m_exit_status_mutex; ///< Mutex so m_exit_status m_exit_string can be safely accessed from multiple threads - Mutex m_thread_mutex; + std::mutex + m_exit_status_mutex; ///< Mutex so m_exit_status m_exit_string can be safely accessed from multiple threads + std::recursive_mutex m_thread_mutex; ThreadList m_thread_list_real; ///< The threads for this process as are known to the protocol we are debugging with ThreadList m_thread_list; ///< The threads for this process as the user will see them. This is usually the same as ///< m_thread_list_real, but might be different if there is an OS plug-in creating memory threads @@ -3373,11 +3374,11 @@ lldb::ABISP m_abi_sp; lldb::IOHandlerSP m_process_input_reader; Communication m_stdio_communication; - Mutex m_stdio_communication_mutex; + std::recursive_mutex m_stdio_communication_mutex; bool m_stdin_forward; /// Remember if stdin must be forwarded to remote debug server std::string m_stdout_data; std::string m_stderr_data; - Mutex m_profile_data_comm_mutex; + std::recursive_mutex m_profile_data_comm_mutex; std::vector m_profile_data; Predicate m_iohandler_sync; MemoryCache m_memory_cache; Index: include/lldb/Target/QueueList.h =================================================================== --- include/lldb/Target/QueueList.h +++ include/lldb/Target/QueueList.h @@ -10,6 +10,7 @@ #ifndef liblldb_QueueList_h_ #define liblldb_QueueList_h_ +#include #include #include "lldb/lldb-private.h" @@ -60,7 +61,7 @@ GetQueueAtIndex (uint32_t idx); typedef std::vector collection; - typedef LockingAdaptedIterable QueueIterable; + typedef LockingAdaptedIterable QueueIterable; //------------------------------------------------------------------ /// Iterate over the list of queues @@ -119,8 +120,8 @@ lldb::QueueSP FindQueueByIndexID (uint32_t index_id); - lldb_private::Mutex & - GetMutex (); + std::mutex & + GetMutex(); protected: @@ -130,7 +131,7 @@ Process *m_process; ///< The process that manages this queue list. uint32_t m_stop_id; ///< The process stop ID that this queue list is valid for. collection m_queues; ///< The queues for this process. - Mutex m_mutex; + std::mutex m_mutex; private: QueueList (); Index: include/lldb/Target/StackFrame.h =================================================================== --- include/lldb/Target/StackFrame.h +++ include/lldb/Target/StackFrame.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include +#include // Other libraries and framework includes // Project includes @@ -537,7 +538,7 @@ lldb::VariableListSP m_variable_list_sp; ValueObjectList m_variable_list_value_objects; // Value objects for each variable in m_variable_list_sp StreamString m_disassembly; - Mutex m_mutex; + std::recursive_mutex m_mutex; DISALLOW_COPY_AND_ASSIGN (StackFrame); }; Index: include/lldb/Target/StackFrameList.h =================================================================== --- include/lldb/Target/StackFrameList.h +++ include/lldb/Target/StackFrameList.h @@ -13,11 +13,11 @@ // C Includes // C++ Includes #include +#include #include // Other libraries and framework includes // Project includes -#include "lldb/Host/Mutex.h" #include "lldb/Target/StackFrame.h" namespace lldb_private { @@ -135,7 +135,7 @@ Thread &m_thread; lldb::StackFrameListSP m_prev_frames_sp; - mutable Mutex m_mutex; + mutable std::recursive_mutex m_mutex; collection m_frames; uint32_t m_selected_frame_idx; uint32_t m_concrete_frames_fetched; Index: include/lldb/Target/Target.h =================================================================== --- include/lldb/Target/Target.h +++ include/lldb/Target/Target.h @@ -713,8 +713,8 @@ static const lldb::TargetPropertiesSP & GetGlobalProperties(); - Mutex & - GetAPIMutex () + std::recursive_mutex & + GetAPIMutex() { return m_mutex; } @@ -1594,7 +1594,8 @@ //------------------------------------------------------------------ Debugger & m_debugger; lldb::PlatformSP m_platform_sp; ///< The platform for this target. - Mutex m_mutex; ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe + std::recursive_mutex + m_mutex; ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe ArchSpec m_arch; ModuleList m_images; ///< The list of images for this process (shared libraries and anything dynamically loaded). SectionLoadHistory m_section_load_history; Index: include/lldb/Target/ThreadCollection.h =================================================================== --- include/lldb/Target/ThreadCollection.h +++ include/lldb/Target/ThreadCollection.h @@ -10,10 +10,10 @@ #ifndef liblldb_ThreadCollection_h_ #define liblldb_ThreadCollection_h_ +#include #include #include "lldb/lldb-private.h" -#include "lldb/Host/Mutex.h" #include "lldb/Utility/Iterable.h" namespace lldb_private { @@ -22,8 +22,8 @@ { public: typedef std::vector collection; - typedef LockingAdaptedIterable ThreadIterable; - + typedef LockingAdaptedIterable ThreadIterable; + ThreadCollection(); ThreadCollection(collection threads); @@ -53,16 +53,16 @@ { return ThreadIterable(m_threads, GetMutex()); } - - virtual Mutex & + + virtual std::recursive_mutex & GetMutex() { return m_mutex; } - + protected: collection m_threads; - Mutex m_mutex; + std::recursive_mutex m_mutex; }; } // namespace lldb_private Index: include/lldb/Target/ThreadList.h =================================================================== --- include/lldb/Target/ThreadList.h +++ include/lldb/Target/ThreadList.h @@ -10,6 +10,7 @@ #ifndef liblldb_ThreadList_h_ #define liblldb_ThreadList_h_ +#include #include #include "lldb/lldb-private.h" @@ -164,9 +165,9 @@ void SetStopID (uint32_t stop_id); - Mutex & + std::recursive_mutex & GetMutex() override; - + void Update (ThreadList &rhs); Index: include/lldb/Utility/Iterable.h =================================================================== --- include/lldb/Utility/Iterable.h +++ include/lldb/Utility/Iterable.h @@ -16,7 +16,6 @@ // Other libraries and framework includes // Project includes -#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -207,36 +206,33 @@ return AdaptedConstIterator(m_container.end()); } }; - -template class LockingAdaptedIterable : public AdaptedIterable + +template +class LockingAdaptedIterable : public AdaptedIterable { public: - LockingAdaptedIterable (C &container, Mutex &mutex) : - AdaptedIterable(container), - m_mutex(&mutex) + LockingAdaptedIterable(C &container, MutexType &mutex) : AdaptedIterable(container), m_mutex(&mutex) { - m_mutex->Lock(); + m_mutex->lock(); } - - LockingAdaptedIterable (LockingAdaptedIterable &&rhs) : - AdaptedIterable(rhs), - m_mutex(rhs.m_mutex) + + LockingAdaptedIterable(LockingAdaptedIterable &&rhs) : AdaptedIterable(rhs), m_mutex(rhs.m_mutex) { rhs.m_mutex = nullptr; } - - ~LockingAdaptedIterable () + + ~LockingAdaptedIterable() { if (m_mutex) - m_mutex->Unlock(); + m_mutex->unlock(); } - + private: - Mutex *m_mutex = nullptr; + MutexType *m_mutex = nullptr; DISALLOW_COPY_AND_ASSIGN(LockingAdaptedIterable); }; - + } // namespace lldb_private #endif // liblldb_Iterable_h_ Index: source/API/SBAddress.cpp =================================================================== --- source/API/SBAddress.cpp +++ source/API/SBAddress.cpp @@ -15,7 +15,6 @@ #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamString.h" -#include "lldb/Host/Mutex.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Target/Target.h" @@ -125,7 +124,7 @@ { if (m_opaque_ap->IsValid()) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); addr = m_opaque_ap->GetLoadAddress (target_sp.get()); } } Index: source/API/SBBreakpoint.cpp =================================================================== --- source/API/SBBreakpoint.cpp +++ source/API/SBBreakpoint.cpp @@ -149,7 +149,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->ClearAllBreakpointSites (); } } @@ -163,7 +163,7 @@ { if (vm_addr != LLDB_INVALID_ADDRESS) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); Address address; Target &target = m_opaque_sp->GetTarget(); if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) @@ -183,7 +183,7 @@ if (m_opaque_sp && vm_addr != LLDB_INVALID_ADDRESS) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); Address address; Target &target = m_opaque_sp->GetTarget(); if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) @@ -203,7 +203,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); sb_bp_location.SetLocation (m_opaque_sp->FindLocationByID (bp_loc_id)); } @@ -217,7 +217,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); sb_bp_location.SetLocation (m_opaque_sp->GetLocationAtIndex (index)); } @@ -235,7 +235,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetEnabled (enable); } } @@ -245,7 +245,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->IsEnabled(); } else @@ -263,7 +263,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetOneShot (one_shot); } } @@ -273,7 +273,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->IsOneShot(); } else @@ -285,7 +285,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->IsInternal(); } else @@ -303,7 +303,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetIgnoreCount (count); } } @@ -313,7 +313,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetCondition (condition); } } @@ -323,7 +323,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetConditionText (); } return nullptr; @@ -335,7 +335,7 @@ uint32_t count = 0; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); count = m_opaque_sp->GetHitCount(); } @@ -353,7 +353,7 @@ uint32_t count = 0; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); count = m_opaque_sp->GetIgnoreCount(); } @@ -370,7 +370,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetThreadID (tid); } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -385,7 +385,7 @@ tid_t tid = LLDB_INVALID_THREAD_ID; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); tid = m_opaque_sp->GetThreadID(); } @@ -405,7 +405,7 @@ static_cast(m_opaque_sp.get()), index); if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex (index); } } @@ -416,7 +416,7 @@ uint32_t thread_idx = UINT32_MAX; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); if (thread_spec != nullptr) thread_idx = thread_spec->GetIndex(); @@ -439,7 +439,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->GetOptions()->GetThreadSpec()->SetName (thread_name); } } @@ -450,7 +450,7 @@ const char *name = nullptr; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); if (thread_spec != nullptr) name = thread_spec->GetName(); @@ -472,7 +472,7 @@ static_cast(m_opaque_sp.get()), queue_name); if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName (queue_name); } } @@ -483,7 +483,7 @@ const char *name = nullptr; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); if (thread_spec) name = thread_spec->GetQueueName(); @@ -502,7 +502,7 @@ size_t num_resolved = 0; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); num_resolved = m_opaque_sp->GetNumResolvedLocations(); } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -519,7 +519,7 @@ size_t num_locs = 0; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); num_locs = m_opaque_sp->GetNumLocations(); } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -535,7 +535,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID()); m_opaque_sp->GetResolverDescription (s.get()); m_opaque_sp->GetFilterDescription (s.get()); @@ -598,7 +598,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); BatonSP baton_sp(new SBBreakpointCallbackBaton (callback, baton)); m_opaque_sp->SetCallback (SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, false); } @@ -616,7 +616,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); BreakpointOptions *bp_options = m_opaque_sp->GetOptions(); m_opaque_sp->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallbackFunction (bp_options, callback_function_name); @@ -635,7 +635,7 @@ SBError sb_error; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); BreakpointOptions *bp_options = m_opaque_sp->GetOptions(); Error error = m_opaque_sp->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options, callback_body_text); @@ -659,7 +659,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); Error error; // Think I'm just going to swallow the error here, it's probably more annoying to have to provide it. return m_opaque_sp->AddName(new_name, error); } @@ -679,7 +679,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->RemoveName(name_to_remove); } } @@ -696,7 +696,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->MatchesName(name); } @@ -714,7 +714,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); std::vector names_vec; m_opaque_sp->GetNames(names_vec); for (std::string name : names_vec) Index: source/API/SBBreakpointLocation.cpp =================================================================== --- source/API/SBBreakpointLocation.cpp +++ source/API/SBBreakpointLocation.cpp @@ -92,7 +92,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); ret_addr = m_opaque_sp->GetLoadAddress(); } @@ -104,7 +104,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetEnabled (enabled); } } @@ -114,7 +114,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->IsEnabled(); } else @@ -126,7 +126,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetIgnoreCount(); } else @@ -138,7 +138,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetIgnoreCount (n); } } @@ -148,7 +148,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetCondition (condition); } } @@ -158,7 +158,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetConditionText (); } return NULL; @@ -176,7 +176,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); BreakpointOptions *bp_options = m_opaque_sp->GetLocationOptions(); m_opaque_sp->GetBreakpoint().GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallbackFunction (bp_options, callback_function_name); @@ -195,7 +195,7 @@ SBError sb_error; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); BreakpointOptions *bp_options = m_opaque_sp->GetLocationOptions(); Error error = m_opaque_sp->GetBreakpoint().GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options, callback_body_text); @@ -212,7 +212,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetThreadID (thread_id); } } @@ -223,7 +223,7 @@ tid_t tid = LLDB_INVALID_THREAD_ID; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetThreadID(); } return tid; @@ -234,7 +234,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetThreadIndex (index); } } @@ -245,7 +245,7 @@ uint32_t thread_idx = UINT32_MAX; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetThreadIndex(); } return thread_idx; @@ -257,7 +257,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetThreadName (thread_name); } } @@ -267,7 +267,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetThreadName(); } return NULL; @@ -278,7 +278,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetQueueName (queue_name); } } @@ -288,7 +288,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->GetQueueName (); } return NULL; @@ -299,7 +299,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->IsResolved(); } return false; @@ -319,7 +319,7 @@ if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->GetDescription (&strm, level); strm.EOL(); } @@ -334,7 +334,7 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetID (); } else @@ -352,7 +352,7 @@ SBBreakpoint sb_bp; if (m_opaque_sp) { - Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + std::lock_guard guard(m_opaque_sp->GetTarget().GetAPIMutex()); *sb_bp = m_opaque_sp->GetBreakpoint ().shared_from_this(); } Index: source/API/SBCommandInterpreter.cpp =================================================================== --- source/API/SBCommandInterpreter.cpp +++ source/API/SBCommandInterpreter.cpp @@ -398,7 +398,7 @@ TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); if (target_sp) { - Mutex::Locker api_locker(target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); process_sp = target_sp->GetProcessSP(); sb_process.SetSP(process_sp); } @@ -483,9 +483,9 @@ if (IsValid()) { TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); - Mutex::Locker api_locker; + std::unique_lock lock; if (target_sp) - api_locker.Lock(target_sp->GetAPIMutex()); + lock = std::unique_lock(target_sp->GetAPIMutex()); m_opaque_ptr->SourceInitFile (false, result.ref()); } else @@ -508,9 +508,9 @@ if (IsValid()) { TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); - Mutex::Locker api_locker; + std::unique_lock lock; if (target_sp) - api_locker.Lock(target_sp->GetAPIMutex()); + lock = std::unique_lock(target_sp->GetAPIMutex()); m_opaque_ptr->SourceInitFile (true, result.ref()); } else Index: source/API/SBDebugger.cpp =================================================================== --- source/API/SBDebugger.cpp +++ source/API/SBDebugger.cpp @@ -411,9 +411,9 @@ if (m_opaque_sp) { TargetSP target_sp (m_opaque_sp->GetSelectedTarget()); - Mutex::Locker api_locker; + std::unique_lock lock; if (target_sp) - api_locker.Lock(target_sp->GetAPIMutex()); + lock = std::unique_lock(target_sp->GetAPIMutex()); SBCommandInterpreter sb_interpreter(GetCommandInterpreter ()); SBCommandReturnObject result; @@ -474,8 +474,8 @@ char stdio_buffer[1024]; size_t len; - Mutex::Locker api_locker (target_sp->GetAPIMutex()); - + std::lock_guard guard(target_sp->GetAPIMutex()); + if (event_type & (Process::eBroadcastBitSTDOUT | Process::eBroadcastBitStateChanged)) { // Drain stdout when we stop just in case we have any bytes Index: source/API/SBFrame.cpp =================================================================== --- source/API/SBFrame.cpp +++ source/API/SBFrame.cpp @@ -105,8 +105,8 @@ bool SBFrame::IsValid() const { - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); @@ -126,8 +126,8 @@ { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBSymbolContext sb_sym_ctx; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -169,8 +169,8 @@ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBModule sb_module; ModuleSP module_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -212,8 +212,8 @@ { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBCompileUnit sb_comp_unit; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -253,8 +253,8 @@ { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBFunction sb_function; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -294,8 +294,8 @@ { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBSymbol sb_symbol; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -334,8 +334,8 @@ { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBlock sb_block; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -374,8 +374,8 @@ SBFrame::GetFrameBlock () const { SBBlock sb_block; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -415,8 +415,8 @@ { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBLineEntry sb_line_entry; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -482,8 +482,8 @@ { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); addr_t addr = LLDB_INVALID_ADDRESS; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -523,8 +523,8 @@ { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); bool ret_val = false; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -564,8 +564,8 @@ { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); addr_t addr = LLDB_INVALID_ADDRESS; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -604,8 +604,8 @@ { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); addr_t addr = LLDB_INVALID_ADDRESS; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -644,8 +644,8 @@ { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBAddress sb_addr; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = exe_ctx.GetFramePtr(); Target *target = exe_ctx.GetTargetPtr(); @@ -704,7 +704,6 @@ SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dynamic) { SBValue sb_value; - Mutex::Locker api_locker; Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (var_path == nullptr || var_path[0] == '\0') { @@ -712,8 +711,9 @@ log->Printf ("SBFrame::GetValueForVariablePath called with empty variable path."); return sb_value; } - - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -780,8 +780,8 @@ } ValueObjectSP value_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -869,8 +869,8 @@ } ValueObjectSP value_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -1048,8 +1048,8 @@ { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); const char *disassembly = nullptr; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -1138,8 +1138,8 @@ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBValueList value_list; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -1253,8 +1253,8 @@ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBValueList value_list; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -1305,8 +1305,8 @@ SBValue result; ValueObjectSP value_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); @@ -1364,8 +1364,8 @@ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); Stream &strm = description.ref(); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame; Target *target = exe_ctx.GetTargetPtr(); @@ -1477,8 +1477,8 @@ ValueObjectSP expr_value_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBFrame()::EvaluateExpression (expr=\"%s\")...", expr); Index: source/API/SBFunction.cpp =================================================================== --- source/API/SBFunction.cpp +++ source/API/SBFunction.cpp @@ -156,12 +156,12 @@ SBInstructionList sb_instructions; if (m_opaque_ptr) { - Mutex::Locker api_locker; ExecutionContext exe_ctx; TargetSP target_sp (target.GetSP()); + std::unique_lock lock; if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex()); + lock = std::unique_lock(target_sp->GetAPIMutex()); target_sp->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target_sp->GetProcessSP()); } Index: source/API/SBInstruction.cpp =================================================================== --- source/API/SBInstruction.cpp +++ source/API/SBInstruction.cpp @@ -75,12 +75,13 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker; ExecutionContext exe_ctx; TargetSP target_sp (target.GetSP()); + std::unique_lock lock; if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex()); + lock = std::unique_lock(target_sp->GetAPIMutex()); + target_sp->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target_sp->GetProcessSP()); } @@ -94,12 +95,13 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker; ExecutionContext exe_ctx; TargetSP target_sp (target.GetSP()); + std::unique_lock lock; if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex()); + lock = std::unique_lock(target_sp->GetAPIMutex()); + target_sp->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target_sp->GetProcessSP()); } @@ -113,12 +115,13 @@ { if (m_opaque_sp) { - Mutex::Locker api_locker; ExecutionContext exe_ctx; TargetSP target_sp (target.GetSP()); + std::unique_lock lock; if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex()); + lock = std::unique_lock(target_sp->GetAPIMutex()); + target_sp->CalculateExecutionContext (exe_ctx); exe_ctx.SetProcessSP(target_sp->GetProcessSP()); } Index: source/API/SBProcess.cpp =================================================================== --- source/API/SBProcess.cpp +++ source/API/SBProcess.cpp @@ -163,7 +163,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); if (process_sp->GetState() == eStateConnected) { if (stop_at_entry) @@ -209,7 +209,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); if (process_sp->GetState() == eStateConnected) { ProcessAttachInfo attach_info; @@ -251,7 +251,7 @@ Process::StopLocker stop_locker; const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); num_threads = process_sp->GetThreadList().GetSize(can_update); } @@ -272,7 +272,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); thread_sp = process_sp->GetThreadList().GetSelectedThread(); sb_thread.SetThread (thread_sp); } @@ -295,7 +295,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); thread_sp = process_sp->CreateOSPluginThread(tid, context); sb_thread.SetThread (thread_sp); } @@ -465,7 +465,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); return process_sp->GetThreadList().SetSelectedThreadByID (thread.GetThreadID()); } return false; @@ -480,7 +480,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); ret_val = process_sp->GetThreadList().SetSelectedThreadByID (tid); } @@ -501,7 +501,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); ret_val = process_sp->GetThreadList().SetSelectedThreadByIndexID (index_id); } @@ -525,7 +525,7 @@ { Process::StopLocker stop_locker; const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, can_update); sb_thread.SetThread (thread_sp); } @@ -550,7 +550,7 @@ { Process::StopLocker stop_locker; - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); num_queues = process_sp->GetQueueList().GetSize(); } @@ -572,7 +572,7 @@ if (process_sp) { Process::StopLocker stop_locker; - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); queue_sp = process_sp->GetQueueList().GetQueueAtIndex(index); sb_queue.SetQueue (queue_sp); } @@ -593,7 +593,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); if (include_expression_stops) return process_sp->GetStopID(); else @@ -612,7 +612,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); event_sp = process_sp->GetStopEventForStopID(stop_id); sb_event.reset(event_sp); } @@ -634,7 +634,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); ret_val = process_sp->GetState(); } @@ -655,7 +655,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); exit_status = process_sp->GetExitStatus (); } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -674,7 +674,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); exit_desc = process_sp->GetExitDescription (); } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -760,7 +760,7 @@ if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); if (process_sp->GetTarget().GetDebugger().GetAsyncExecution ()) sb_error.ref() = process_sp->Resume (); @@ -790,7 +790,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); sb_error.SetError(process_sp->Destroy(false)); } else @@ -817,7 +817,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); sb_error.SetError (process_sp->Halt()); } else @@ -843,7 +843,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); sb_error.SetError (process_sp->Destroy(true)); } else @@ -877,7 +877,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); sb_error.SetError (process_sp->Detach(keep_stopped)); } else @@ -893,7 +893,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); sb_error.SetError (process_sp->Signal (signo)); } else @@ -939,7 +939,7 @@ { Process::StopLocker stop_locker; const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); thread_sp = process_sp->GetThreadList().FindThreadByID (tid, can_update); sb_thread.SetThread (thread_sp); } @@ -963,7 +963,7 @@ { Process::StopLocker stop_locker; const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); thread_sp = process_sp->GetThreadList().FindThreadByIndexID (index_id, can_update); sb_thread.SetThread (thread_sp); } @@ -1080,7 +1080,7 @@ Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); bytes_read = process_sp->ReadMemory (addr, dst, dst_len, sb_error.ref()); } else @@ -1120,7 +1120,7 @@ Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); bytes_read = process_sp->ReadCStringFromMemory (addr, (char *)buf, size, sb_error.ref()); } else @@ -1149,7 +1149,7 @@ Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); value = process_sp->ReadUnsignedIntegerFromMemory (addr, byte_size, 0, sb_error.ref()); } else @@ -1178,7 +1178,7 @@ Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); ptr = process_sp->ReadPointerFromMemory (addr, sb_error.ref()); } else @@ -1218,7 +1218,7 @@ Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); bytes_written = process_sp->WriteMemory (addr, src, src_len, sb_error.ref()); } else @@ -1282,7 +1282,7 @@ ProcessSP process_sp(GetSP()); if (process_sp) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); sb_error.SetError(process_sp->GetWatchpointSupportInfo (num)); if (log) log->Printf ("SBProcess(%p)::GetNumSupportedHardwareWatchpoints () => %u", @@ -1312,7 +1312,7 @@ Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); PlatformSP platform_sp = process_sp->GetTarget().GetPlatform(); return platform_sp->LoadImage (process_sp.get(), *sb_local_image_spec, @@ -1341,7 +1341,7 @@ Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); PlatformSP platform_sp = process_sp->GetTarget().GetPlatform(); sb_error.SetError (platform_sp->UnloadImage (process_sp.get(), image_token)); } @@ -1369,7 +1369,7 @@ Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { - Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); sb_error.SetError (process_sp->SendEventData (event_data)); } else @@ -1459,7 +1459,7 @@ return error; } - Mutex::Locker api_locker(process_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(process_sp->GetTarget().GetAPIMutex()); if (process_sp->GetState() != eStateStopped) { Index: source/API/SBSymbol.cpp =================================================================== --- source/API/SBSymbol.cpp +++ source/API/SBSymbol.cpp @@ -141,12 +141,13 @@ SBInstructionList sb_instructions; if (m_opaque_ptr) { - Mutex::Locker api_locker; ExecutionContext exe_ctx; TargetSP target_sp (target.GetSP()); + std::unique_lock lock; if (target_sp) { - api_locker.Lock (target_sp->GetAPIMutex()); + lock = std::unique_lock(target_sp->GetAPIMutex()); + target_sp->CalculateExecutionContext (exe_ctx); } if (m_opaque_ptr->ValueIsAddress()) Index: source/API/SBTarget.cpp =================================================================== --- source/API/SBTarget.cpp +++ source/API/SBTarget.cpp @@ -77,7 +77,7 @@ Error AttachToProcess (ProcessAttachInfo &attach_info, Target &target) { - Mutex::Locker api_locker (target.GetAPIMutex ()); + std::lock_guard guard(target.GetAPIMutex()); auto process_sp = target.GetProcessSP (); if (process_sp) @@ -267,7 +267,7 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); sb_error.ref() = target_sp->Install(NULL); } return sb_error; @@ -307,7 +307,7 @@ if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); if (stop_at_entry) launch_flags |= eLaunchFlagStopAtEntry; @@ -394,7 +394,7 @@ if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); StateType state = eStateInvalid; { ProcessSP process_sp = target_sp->GetProcessSP(); @@ -622,7 +622,7 @@ if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); if (listener.IsValid()) process_sp = target_sp->CreateProcess (listener.m_opaque_sp, plugin_name, NULL); else @@ -706,7 +706,7 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); if (target_sp->ResolveLoadAddress (vm_addr, addr)) return sb_addr; } @@ -725,7 +725,7 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); if (target_sp->ResolveFileAddress (file_addr, addr)) return sb_addr; } @@ -742,7 +742,7 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); if (target_sp->ResolveLoadAddress (vm_addr, addr)) return sb_addr; } @@ -778,7 +778,7 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); bytes_read = target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref()); } else @@ -814,7 +814,7 @@ TargetSP target_sp(GetSP()); if (target_sp && line != 0) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); const LazyBool check_inlines = eLazyBoolCalculate; const LazyBool skip_prologue = eLazyBoolCalculate; @@ -856,7 +856,7 @@ TargetSP target_sp(GetSP()); if (target_sp.get()) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); const bool internal = false; const bool hardware = false; @@ -916,7 +916,7 @@ const bool internal = false; const bool hardware = false; const LazyBool skip_prologue = eLazyBoolCalculate; - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); *sb_bp = target_sp->CreateBreakpoint (module_list.get(), comp_unit_list.get(), symbol_name, @@ -972,7 +972,7 @@ TargetSP target_sp(GetSP()); if (target_sp && num_names > 0) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); const bool internal = false; const bool hardware = false; const LazyBool skip_prologue = eLazyBoolCalculate; @@ -1045,7 +1045,7 @@ TargetSP target_sp(GetSP()); if (target_sp && symbol_name_regex && symbol_name_regex[0]) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); RegularExpression regexp(symbol_name_regex); const bool internal = false; const bool hardware = false; @@ -1071,7 +1071,7 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); const bool hardware = false; *sb_bp = target_sp->CreateBreakpoint (address, false, hardware); } @@ -1102,7 +1102,7 @@ if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); const bool hardware = false; *sb_bp = target_sp->CreateBreakpoint (sb_address.ref(), false, hardware); } @@ -1162,7 +1162,7 @@ TargetSP target_sp(GetSP()); if (target_sp && source_regex && source_regex[0]) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); const bool hardware = false; const LazyBool move_to_nearest_code = eLazyBoolCalculate; RegularExpression regexp(source_regex); @@ -1200,7 +1200,7 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); const bool hardware = false; *sb_bp = target_sp->CreateExceptionBreakpoint (language, catch_bp, throw_bp, hardware); } @@ -1249,7 +1249,7 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); result = target_sp->RemoveBreakpointByID (bp_id); } @@ -1270,7 +1270,7 @@ TargetSP target_sp(GetSP()); if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); *sb_breakpoint = target_sp->GetBreakpointByID (bp_id); } @@ -1289,7 +1289,7 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); target_sp->EnableAllBreakpoints (); return true; } @@ -1302,7 +1302,7 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); target_sp->DisableAllBreakpoints (); return true; } @@ -1315,7 +1315,7 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); target_sp->RemoveAllBreakpoints (); return true; } @@ -1356,9 +1356,9 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); - Mutex::Locker locker; - target_sp->GetWatchpointList().GetListMutex(locker); + std::lock_guard guard(target_sp->GetAPIMutex()); + std::unique_lock lock; + target_sp->GetWatchpointList().GetListMutex(lock); result = target_sp->RemoveWatchpointByID (wp_id); } @@ -1380,9 +1380,9 @@ TargetSP target_sp(GetSP()); if (target_sp && wp_id != LLDB_INVALID_WATCH_ID) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); - Mutex::Locker locker; - target_sp->GetWatchpointList().GetListMutex(locker); + std::lock_guard guard(target_sp->GetAPIMutex()); + std::unique_lock lock; + target_sp->GetWatchpointList().GetListMutex(lock); watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id); sb_watchpoint.SetSP (watchpoint_sp); } @@ -1406,7 +1406,7 @@ TargetSP target_sp(GetSP()); if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS && size > 0) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); uint32_t watch_type = 0; if (read) watch_type |= LLDB_WATCH_TYPE_READ; @@ -1442,9 +1442,9 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); - Mutex::Locker locker; - target_sp->GetWatchpointList().GetListMutex(locker); + std::lock_guard guard(target_sp->GetAPIMutex()); + std::unique_lock lock; + target_sp->GetWatchpointList().GetListMutex(lock); target_sp->EnableAllWatchpoints (); return true; } @@ -1457,9 +1457,9 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); - Mutex::Locker locker; - target_sp->GetWatchpointList().GetListMutex(locker); + std::lock_guard guard(target_sp->GetAPIMutex()); + std::unique_lock lock; + target_sp->GetWatchpointList().GetListMutex(lock); target_sp->DisableAllWatchpoints (); return true; } @@ -1551,9 +1551,9 @@ TargetSP target_sp(GetSP()); if (target_sp) { - Mutex::Locker api_locker (target_sp->GetAPIMutex()); - Mutex::Locker locker; - target_sp->GetWatchpointList().GetListMutex(locker); + std::lock_guard guard(target_sp->GetAPIMutex()); + std::unique_lock lock; + target_sp->GetWatchpointList().GetListMutex(lock); target_sp->RemoveAllWatchpoints (); return true; } @@ -2431,7 +2431,7 @@ return expr_result; } - Mutex::Locker api_locker (target_sp->GetAPIMutex()); + std::lock_guard guard(target_sp->GetAPIMutex()); ExecutionContext exe_ctx (m_opaque_sp.get()); if (log) Index: source/API/SBThread.cpp =================================================================== --- source/API/SBThread.cpp +++ source/API/SBThread.cpp @@ -96,8 +96,8 @@ { SBQueue sb_queue; QueueSP queue_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (exe_ctx.HasThreadScope()) @@ -130,8 +130,8 @@ bool SBThread::IsValid() const { - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); @@ -158,8 +158,8 @@ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); StopReason reason = eStopReasonInvalid; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -187,8 +187,8 @@ size_t SBThread::GetStopReasonDataCount () { - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -247,8 +247,8 @@ uint64_t SBThread::GetStopReasonDataAtIndex (uint32_t idx) { - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -369,8 +369,8 @@ { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -501,8 +501,8 @@ { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); ValueObjectSP return_valobj_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -562,8 +562,8 @@ { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); const char *name = NULL; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -592,8 +592,8 @@ SBThread::GetQueueName () const { const char *name = NULL; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (exe_ctx.HasThreadScope()) @@ -623,8 +623,8 @@ SBThread::GetQueueID () const { queue_id_t id = LLDB_INVALID_QUEUE_ID; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (exe_ctx.HasThreadScope()) @@ -654,8 +654,8 @@ { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); bool success = false; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -760,9 +760,8 @@ { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBThread(%p)::StepOver (stop_other_threads='%s')", @@ -819,8 +818,8 @@ { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBThread(%p)::StepInto (target_name='%s', stop_other_threads='%s')", @@ -874,8 +873,8 @@ { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBThread(%p)::StepOut ()", @@ -908,8 +907,8 @@ { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (!sb_frame.IsValid()) { @@ -961,10 +960,8 @@ { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - - + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBThread(%p)::StepInstruction (step_over=%i)", @@ -985,9 +982,8 @@ { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBThread(%p)::RunToAddress (addr=0x%" PRIx64 ")", @@ -1020,8 +1016,8 @@ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); char path[PATH_MAX]; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrameSP frame_sp (sb_frame.GetFrameSP()); @@ -1164,8 +1160,8 @@ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBError sb_error; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) { @@ -1204,8 +1200,8 @@ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBError sb_error; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBThread(%p)::JumpToLine (file+line = %s:%u)", @@ -1232,9 +1228,8 @@ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (log) log->Printf ("SBThread(%p)::ReturnFromFrame (frame=%d)", @@ -1355,8 +1350,8 @@ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); uint32_t num_frames = 0; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -1387,8 +1382,8 @@ SBFrame sb_frame; StackFrameSP frame_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -1426,8 +1421,8 @@ SBFrame sb_frame; StackFrameSP frame_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -1465,8 +1460,8 @@ SBFrame sb_frame; StackFrameSP frame_sp; - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (exe_ctx.HasThreadScope()) { @@ -1569,8 +1564,8 @@ SBThread::GetExtendedBacktraceThread (const char *type) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - Mutex::Locker api_locker; - ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + std::unique_lock lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); SBThread sb_origin_thread; if (exe_ctx.HasThreadScope()) Index: source/API/SBValue.cpp =================================================================== --- source/API/SBValue.cpp +++ source/API/SBValue.cpp @@ -127,7 +127,7 @@ } lldb::ValueObjectSP - GetSP (Process::StopLocker &stop_locker, Mutex::Locker &api_locker, Error &error) + GetSP(Process::StopLocker &stop_locker, std::unique_lock &lock, Error &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (!m_valobj_sp) @@ -139,11 +139,11 @@ lldb::ValueObjectSP value_sp = m_valobj_sp; Target *target = value_sp->GetTargetSP().get(); - if (target) - api_locker.Lock(target->GetAPIMutex()); - else + if (!target) return ValueObjectSP(); + lock = std::unique_lock(target->GetAPIMutex()); + ProcessSP process_sp(value_sp->GetProcessSP()); if (process_sp && !stop_locker.TryLock (&process_sp->GetRunLock())) { @@ -255,13 +255,13 @@ ValueLocker () { } - + ValueObjectSP GetLockedSP(ValueImpl &in_value) { - return in_value.GetSP(m_stop_locker, m_api_locker, m_lock_error); + return in_value.GetSP(m_stop_locker, m_lock, m_lock_error); } - + Error & GetError() { @@ -270,9 +270,8 @@ private: Process::StopLocker m_stop_locker; - Mutex::Locker m_api_locker; + std::unique_lock m_lock; Error m_lock_error; - }; SBValue::SBValue () : Index: source/API/SBWatchpoint.cpp =================================================================== --- source/API/SBWatchpoint.cpp +++ source/API/SBWatchpoint.cpp @@ -115,7 +115,7 @@ lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(watchpoint_sp->GetTarget().GetAPIMutex()); hw_index = watchpoint_sp->GetHardwareIndex(); } @@ -130,7 +130,7 @@ lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(watchpoint_sp->GetTarget().GetAPIMutex()); ret_addr = watchpoint_sp->GetLoadAddress(); } @@ -145,7 +145,7 @@ lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(watchpoint_sp->GetTarget().GetAPIMutex()); watch_size = watchpoint_sp->GetByteSize(); } @@ -158,7 +158,7 @@ lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(watchpoint_sp->GetTarget().GetAPIMutex()); watchpoint_sp->GetTarget().DisableWatchpointByID(watchpoint_sp->GetID()); } } @@ -169,7 +169,7 @@ lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(watchpoint_sp->GetTarget().GetAPIMutex()); return watchpoint_sp->IsEnabled(); } else @@ -183,7 +183,7 @@ lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(watchpoint_sp->GetTarget().GetAPIMutex()); count = watchpoint_sp->GetHitCount(); } @@ -201,7 +201,7 @@ lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(watchpoint_sp->GetTarget().GetAPIMutex()); return watchpoint_sp->GetIgnoreCount(); } else @@ -214,7 +214,7 @@ lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(watchpoint_sp->GetTarget().GetAPIMutex()); watchpoint_sp->SetIgnoreCount (n); } } @@ -225,7 +225,7 @@ lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(watchpoint_sp->GetTarget().GetAPIMutex()); return watchpoint_sp->GetConditionText (); } return NULL; @@ -237,7 +237,7 @@ lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(watchpoint_sp->GetTarget().GetAPIMutex()); watchpoint_sp->SetCondition (condition); } } @@ -250,7 +250,7 @@ lldb::WatchpointSP watchpoint_sp(GetSP()); if (watchpoint_sp) { - Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex()); + std::lock_guard guard(watchpoint_sp->GetTarget().GetAPIMutex()); watchpoint_sp->GetDescription (&strm, level); strm.EOL(); } Index: source/Breakpoint/Breakpoint.cpp =================================================================== --- source/Breakpoint/Breakpoint.cpp +++ source/Breakpoint/Breakpoint.cpp @@ -410,8 +410,8 @@ if (log) log->Printf ("Breakpoint::ModulesChanged: num_modules: %zu load: %i delete_locations: %i\n", module_list.GetSize(), load, delete_locations); - - Mutex::Locker modules_mutex(module_list.GetMutex()); + + std::lock_guard guard(module_list.GetMutex()); if (load) { // The logic for handling new modules is: Index: source/Breakpoint/BreakpointList.cpp =================================================================== --- source/Breakpoint/BreakpointList.cpp +++ source/Breakpoint/BreakpointList.cpp @@ -18,11 +18,8 @@ using namespace lldb; using namespace lldb_private; -BreakpointList::BreakpointList (bool is_internal) : - m_mutex (Mutex::eMutexTypeRecursive), - m_breakpoints(), - m_next_break_id (0), - m_is_internal (is_internal) +BreakpointList::BreakpointList(bool is_internal) + : m_mutex(), m_breakpoints(), m_next_break_id(0), m_is_internal(is_internal) { } @@ -34,7 +31,7 @@ break_id_t BreakpointList::Add (BreakpointSP &bp_sp, bool notify) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); // Internal breakpoint IDs are negative, normal ones are positive bp_sp->SetID (m_is_internal ? --m_next_break_id : ++m_next_break_id); @@ -51,7 +48,7 @@ bool BreakpointList::Remove (break_id_t break_id, bool notify) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); bp_collection::iterator pos = GetBreakpointIDIterator(break_id); // Predicate if (pos != m_breakpoints.end()) { @@ -71,7 +68,7 @@ void BreakpointList::RemoveInvalidLocations (const ArchSpec &arch) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); for (const auto &bp_sp : m_breakpoints) bp_sp->RemoveInvalidLocations(arch); } @@ -80,7 +77,7 @@ void BreakpointList::SetEnabledAll (bool enabled) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); for (const auto &bp_sp : m_breakpoints) bp_sp->SetEnabled (enabled); } @@ -89,7 +86,7 @@ void BreakpointList::RemoveAll (bool notify) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); ClearAllBreakpointSites (); if (notify) @@ -142,7 +139,7 @@ BreakpointSP BreakpointList::FindBreakpointByID (break_id_t break_id) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); BreakpointSP stop_sp; bp_collection::iterator pos = GetBreakpointIDIterator(break_id); if (pos != m_breakpoints.end()) @@ -154,7 +151,7 @@ const BreakpointSP BreakpointList::FindBreakpointByID (break_id_t break_id) const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); BreakpointSP stop_sp; bp_collection::const_iterator pos = GetBreakpointIDConstIterator(break_id); if (pos != m_breakpoints.end()) @@ -166,7 +163,7 @@ void BreakpointList::Dump (Stream *s) const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); s->Printf("%p: ", static_cast(this)); s->Indent(); s->Printf("BreakpointList with %u Breakpoints:\n", (uint32_t)m_breakpoints.size()); @@ -180,7 +177,7 @@ BreakpointSP BreakpointList::GetBreakpointAtIndex (size_t i) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); BreakpointSP stop_sp; bp_collection::iterator end = m_breakpoints.end(); bp_collection::iterator pos; @@ -196,7 +193,7 @@ const BreakpointSP BreakpointList::GetBreakpointAtIndex (size_t i) const { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); BreakpointSP stop_sp; bp_collection::const_iterator end = m_breakpoints.end(); bp_collection::const_iterator pos; @@ -212,7 +209,7 @@ void BreakpointList::UpdateBreakpoints (ModuleList& module_list, bool added, bool delete_locations) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); for (const auto &bp_sp : m_breakpoints) bp_sp->ModulesChanged (module_list, added, delete_locations); @@ -221,7 +218,7 @@ void BreakpointList::UpdateBreakpointsWhenModuleIsReplaced (ModuleSP old_module_sp, ModuleSP new_module_sp) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); for (const auto &bp_sp : m_breakpoints) bp_sp->ModuleReplaced (old_module_sp, new_module_sp); @@ -230,14 +227,14 @@ void BreakpointList::ClearAllBreakpointSites () { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); for (const auto &bp_sp : m_breakpoints) bp_sp->ClearAllBreakpointSites (); } void -BreakpointList::GetListMutex (Mutex::Locker &locker) +BreakpointList::GetListMutex(std::unique_lock &lock) { - return locker.Lock (m_mutex); + lock = std::unique_lock(m_mutex); } Index: source/Breakpoint/BreakpointLocation.cpp =================================================================== --- source/Breakpoint/BreakpointLocation.cpp +++ source/Breakpoint/BreakpointLocation.cpp @@ -33,36 +33,29 @@ using namespace lldb; using namespace lldb_private; -BreakpointLocation::BreakpointLocation -( - break_id_t loc_id, - Breakpoint &owner, - const Address &addr, - lldb::tid_t tid, - bool hardware, - bool check_for_resolver -) : - StoppointLocation (loc_id, addr.GetOpcodeLoadAddress(&owner.GetTarget()), hardware), - m_being_created(true), - m_should_resolve_indirect_functions (false), - m_is_reexported (false), - m_is_indirect (false), - m_address (addr), - m_owner (owner), - m_options_ap (), - m_bp_site_sp (), - m_condition_mutex () +BreakpointLocation::BreakpointLocation(break_id_t loc_id, Breakpoint &owner, const Address &addr, lldb::tid_t tid, + bool hardware, bool check_for_resolver) + : StoppointLocation(loc_id, addr.GetOpcodeLoadAddress(&owner.GetTarget()), hardware), + m_being_created(true), + m_should_resolve_indirect_functions(false), + m_is_reexported(false), + m_is_indirect(false), + m_address(addr), + m_owner(owner), + m_options_ap(), + m_bp_site_sp(), + m_condition_mutex() { if (check_for_resolver) { Symbol *symbol = m_address.CalculateSymbolContextSymbol(); if (symbol && symbol->IsIndirect()) { - SetShouldResolveIndirectFunctions (true); + SetShouldResolveIndirectFunctions(true); } } - - SetThreadID (tid); + + SetThreadID(tid); m_being_created = false; } @@ -267,9 +260,9 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error) { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); - - Mutex::Locker evaluation_locker(m_condition_mutex); - + + std::lock_guard guard(m_condition_mutex); + size_t condition_hash; const char *condition_text = GetConditionText(&condition_hash); Index: source/Breakpoint/WatchpointList.cpp =================================================================== --- source/Breakpoint/WatchpointList.cpp +++ source/Breakpoint/WatchpointList.cpp @@ -18,10 +18,7 @@ using namespace lldb; using namespace lldb_private; -WatchpointList::WatchpointList() : - m_watchpoints (), - m_mutex (Mutex::eMutexTypeRecursive), - m_next_wp_id (0) +WatchpointList::WatchpointList() : m_watchpoints(), m_mutex(), m_next_wp_id(0) { } @@ -33,7 +30,7 @@ lldb::watch_id_t WatchpointList::Add (const WatchpointSP &wp_sp, bool notify) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); wp_sp->SetID(++m_next_wp_id); m_watchpoints.push_back(wp_sp); if (notify) @@ -54,7 +51,7 @@ void WatchpointList::DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); s->Printf("%p: ", static_cast(this)); //s->Indent(); s->Printf("WatchpointList with %" PRIu64 " Watchpoints:\n", @@ -70,7 +67,7 @@ WatchpointList::FindByAddress (lldb::addr_t addr) const { WatchpointSP wp_sp; - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (!m_watchpoints.empty()) { wp_collection::const_iterator pos, end = m_watchpoints.end(); @@ -93,7 +90,7 @@ WatchpointList::FindBySpec (std::string spec) const { WatchpointSP wp_sp; - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (!m_watchpoints.empty()) { wp_collection::const_iterator pos, end = m_watchpoints.end(); @@ -142,7 +139,7 @@ WatchpointList::FindByID (lldb::watch_id_t watch_id) const { WatchpointSP wp_sp; - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); wp_collection::const_iterator pos = GetIDConstIterator(watch_id); if (pos != m_watchpoints.end()) wp_sp = *pos; @@ -175,7 +172,7 @@ WatchpointSP WatchpointList::GetByIndex (uint32_t i) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); WatchpointSP wp_sp; if (i < m_watchpoints.size()) { @@ -189,7 +186,7 @@ const WatchpointSP WatchpointList::GetByIndex (uint32_t i) const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); WatchpointSP wp_sp; if (i < m_watchpoints.size()) { @@ -213,7 +210,7 @@ bool WatchpointList::Remove (lldb::watch_id_t watch_id, bool notify) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); wp_collection::iterator pos = GetIDIterator(watch_id); if (pos != m_watchpoints.end()) { @@ -234,7 +231,7 @@ WatchpointList::GetHitCount () const { uint32_t hit_count = 0; - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); wp_collection::const_iterator pos, end = m_watchpoints.end(); for (pos = m_watchpoints.begin(); pos != end; ++pos) hit_count += (*pos)->GetHitCount(); @@ -261,7 +258,7 @@ void WatchpointList::GetDescription (Stream *s, lldb::DescriptionLevel level) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); wp_collection::iterator pos, end = m_watchpoints.end(); for (pos = m_watchpoints.begin(); pos != end; ++pos) @@ -274,7 +271,7 @@ void WatchpointList::SetEnabledAll (bool enabled) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); wp_collection::iterator pos, end = m_watchpoints.end(); for (pos = m_watchpoints.begin(); pos != end; ++pos) @@ -284,7 +281,7 @@ void WatchpointList::RemoveAll (bool notify) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (notify) { @@ -305,7 +302,7 @@ } void -WatchpointList::GetListMutex (Mutex::Locker &locker) +WatchpointList::GetListMutex(std::unique_lock &lock) { - return locker.Lock (m_mutex); + lock = std::unique_lock(m_mutex); } Index: source/Commands/CommandObjectBreakpoint.cpp =================================================================== --- source/Commands/CommandObjectBreakpoint.cpp +++ source/Commands/CommandObjectBreakpoint.cpp @@ -1092,9 +1092,9 @@ return false; } - Mutex::Locker locker; - target->GetBreakpointList().GetListMutex(locker); - + std::unique_lock lock; + target->GetBreakpointList().GetListMutex(lock); + BreakpointIDList valid_bp_ids; CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (command, target, result, &valid_bp_ids); @@ -1222,8 +1222,8 @@ return false; } - Mutex::Locker locker; - target->GetBreakpointList().GetListMutex(locker); + std::unique_lock lock; + target->GetBreakpointList().GetListMutex(lock); const BreakpointList &breakpoints = target->GetBreakpointList(); @@ -1339,8 +1339,8 @@ return false; } - Mutex::Locker locker; - target->GetBreakpointList().GetListMutex(locker); + std::unique_lock lock; + target->GetBreakpointList().GetListMutex(lock); const BreakpointList &breakpoints = target->GetBreakpointList(); size_t num_breakpoints = breakpoints.GetSize(); @@ -1523,8 +1523,8 @@ } const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal); - Mutex::Locker locker; - target->GetBreakpointList(m_options.m_internal).GetListMutex(locker); + std::unique_lock lock; + target->GetBreakpointList(m_options.m_internal).GetListMutex(lock); size_t num_breakpoints = breakpoints.GetSize(); @@ -1713,8 +1713,8 @@ if (m_options.m_line_num != 0) break_type = eClearTypeFileAndLine; - Mutex::Locker locker; - target->GetBreakpointList().GetListMutex(locker); + std::unique_lock lock; + target->GetBreakpointList().GetListMutex(lock); BreakpointList &breakpoints = target->GetBreakpointList(); size_t num_breakpoints = breakpoints.GetSize(); @@ -1901,9 +1901,9 @@ return false; } - Mutex::Locker locker; - target->GetBreakpointList().GetListMutex(locker); - + std::unique_lock lock; + target->GetBreakpointList().GetListMutex(lock); + const BreakpointList &breakpoints = target->GetBreakpointList(); size_t num_breakpoints = breakpoints.GetSize(); @@ -2118,9 +2118,9 @@ return false; } - Mutex::Locker locker; - target->GetBreakpointList().GetListMutex(locker); - + std::unique_lock lock; + target->GetBreakpointList().GetListMutex(lock); + const BreakpointList &breakpoints = target->GetBreakpointList(); size_t num_breakpoints = breakpoints.GetSize(); @@ -2211,9 +2211,9 @@ return false; } - Mutex::Locker locker; - target->GetBreakpointList().GetListMutex(locker); - + std::unique_lock lock; + target->GetBreakpointList().GetListMutex(lock); + const BreakpointList &breakpoints = target->GetBreakpointList(); size_t num_breakpoints = breakpoints.GetSize(); @@ -2292,9 +2292,9 @@ if (m_name_options.m_name.OptionWasSet()) { const char *name = m_name_options.m_name.GetCurrentValue(); - Mutex::Locker locker; - target->GetBreakpointList().GetListMutex(locker); - + std::unique_lock lock; + target->GetBreakpointList().GetListMutex(lock); + BreakpointList &breakpoints = target->GetBreakpointList(); for (BreakpointSP bp_sp : breakpoints.Breakpoints()) { Index: source/Commands/CommandObjectProcess.cpp =================================================================== --- source/Commands/CommandObjectProcess.cpp +++ source/Commands/CommandObjectProcess.cpp @@ -733,7 +733,7 @@ } { // Scope for thread list mutex: - Mutex::Locker locker (process->GetThreadList().GetMutex()); + std::lock_guard guard(process->GetThreadList().GetMutex()); const uint32_t num_threads = process->GetThreadList().GetSize(); // Set the actions that the threads should each take when resuming Index: source/Commands/CommandObjectTarget.cpp =================================================================== --- source/Commands/CommandObjectTarget.cpp +++ source/Commands/CommandObjectTarget.cpp @@ -1548,7 +1548,7 @@ DumpModuleObjfileHeaders(Stream &strm, ModuleList &module_list) { size_t num_dumped = 0; - Mutex::Locker modules_locker(module_list.GetMutex()); + std::lock_guard guard(module_list.GetMutex()); const size_t num_modules = module_list.GetSize(); if (num_modules > 0) { @@ -2302,7 +2302,7 @@ if (command.GetArgumentCount() == 0) { // Dump all sections for all modules images - Mutex::Locker modules_locker(target->GetImages().GetMutex()); + std::lock_guard guard(target->GetImages().GetMutex()); const size_t num_modules = target->GetImages().GetSize(); if (num_modules > 0) { @@ -2532,7 +2532,7 @@ { // Dump all sections for all modules images const ModuleList &target_modules = target->GetImages(); - Mutex::Locker modules_locker (target_modules.GetMutex()); + std::lock_guard guard(target_modules.GetMutex()); const size_t num_modules = target_modules.GetSize(); if (num_modules > 0) { @@ -2633,7 +2633,7 @@ FileSpec file_spec(arg_cstr, false); const ModuleList &target_modules = target->GetImages(); - Mutex::Locker modules_locker(target_modules.GetMutex()); + std::lock_guard guard(target_modules.GetMutex()); const size_t num_modules = target_modules.GetSize(); if (num_modules > 0) { @@ -3296,7 +3296,6 @@ // 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(); @@ -3333,10 +3332,11 @@ module_list_ptr = &module_list; } + std::unique_lock lock; if (module_list_ptr != nullptr) { - assert(use_global_module_list == false && "locking violation"); - locker.Lock(module_list_ptr->GetMutex()); + lock = std::unique_lock(module_list_ptr->GetMutex()); + num_modules = module_list_ptr->GetSize(); } @@ -4239,7 +4239,7 @@ // Dump all sections for all other modules const ModuleList &target_modules = target->GetImages(); - Mutex::Locker modules_locker(target_modules.GetMutex()); + std::lock_guard guard(target_modules.GetMutex()); const size_t num_modules = target_modules.GetSize(); if (num_modules > 0) { Index: source/Commands/CommandObjectThread.cpp =================================================================== --- source/Commands/CommandObjectThread.cpp +++ source/Commands/CommandObjectThread.cpp @@ -87,7 +87,7 @@ const size_t num_args = command.GetArgumentCount(); Process *process = m_exe_ctx.GetProcessPtr(); - Mutex::Locker locker (process->GetThreadList().GetMutex()); + std::lock_guard guard(process->GetThreadList().GetMutex()); for (size_t i = 0; i < num_args; i++) { @@ -859,7 +859,7 @@ // These two lines appear at the beginning of both blocks in // this if..else, but that is because we need to release the // lock before calling process->Resume below. - Mutex::Locker locker (process->GetThreadList().GetMutex()); + std::lock_guard guard(process->GetThreadList().GetMutex()); const uint32_t num_threads = process->GetThreadList().GetSize(); std::vector resume_threads; for (uint32_t i = 0; i < argc; ++i) @@ -932,7 +932,7 @@ // These two lines appear at the beginning of both blocks in // this if..else, but that is because we need to release the // lock before calling process->Resume below. - Mutex::Locker locker (process->GetThreadList().GetMutex()); + std::lock_guard guard(process->GetThreadList().GetMutex()); const uint32_t num_threads = process->GetThreadList().GetSize(); Thread *current_thread = GetDefaultThread(); if (current_thread == nullptr) Index: source/Commands/CommandObjectWatchpoint.cpp =================================================================== --- source/Commands/CommandObjectWatchpoint.cpp +++ source/Commands/CommandObjectWatchpoint.cpp @@ -265,8 +265,9 @@ } const WatchpointList &watchpoints = target->GetWatchpointList(); - Mutex::Locker locker; - target->GetWatchpointList().GetListMutex(locker); + + std::unique_lock lock; + target->GetWatchpointList().GetListMutex(lock); size_t num_watchpoints = watchpoints.GetSize(); @@ -369,8 +370,8 @@ if (!CheckTargetForWatchpointOperations(target, result)) return false; - Mutex::Locker locker; - target->GetWatchpointList().GetListMutex(locker); + std::unique_lock lock; + target->GetWatchpointList().GetListMutex(lock); const WatchpointList &watchpoints = target->GetWatchpointList(); @@ -444,8 +445,8 @@ if (!CheckTargetForWatchpointOperations(target, result)) return false; - Mutex::Locker locker; - target->GetWatchpointList().GetListMutex(locker); + std::unique_lock lock; + target->GetWatchpointList().GetListMutex(lock); const WatchpointList &watchpoints = target->GetWatchpointList(); size_t num_watchpoints = watchpoints.GetSize(); @@ -525,9 +526,9 @@ if (!CheckTargetForWatchpointOperations(target, result)) return false; - Mutex::Locker locker; - target->GetWatchpointList().GetListMutex(locker); - + std::unique_lock lock; + target->GetWatchpointList().GetListMutex(lock); + const WatchpointList &watchpoints = target->GetWatchpointList(); size_t num_watchpoints = watchpoints.GetSize(); @@ -666,9 +667,9 @@ if (!CheckTargetForWatchpointOperations(target, result)) return false; - Mutex::Locker locker; - target->GetWatchpointList().GetListMutex(locker); - + std::unique_lock lock; + target->GetWatchpointList().GetListMutex(lock); + const WatchpointList &watchpoints = target->GetWatchpointList(); size_t num_watchpoints = watchpoints.GetSize(); @@ -819,9 +820,9 @@ if (!CheckTargetForWatchpointOperations(target, result)) return false; - Mutex::Locker locker; - target->GetWatchpointList().GetListMutex(locker); - + std::unique_lock lock; + target->GetWatchpointList().GetListMutex(lock); + const WatchpointList &watchpoints = target->GetWatchpointList(); size_t num_watchpoints = watchpoints.GetSize(); Index: source/Core/IOHandler.cpp =================================================================== --- source/Core/IOHandler.cpp +++ source/Core/IOHandler.cpp @@ -3330,7 +3330,7 @@ if (thread_sp) { ThreadList &thread_list = thread_sp->GetProcess()->GetThreadList(); - Mutex::Locker locker (thread_list.GetMutex()); + std::lock_guard guard(thread_list.GetMutex()); ThreadSP selected_thread_sp = thread_list.GetSelectedThread(); if (selected_thread_sp->GetID() != thread_sp->GetID()) { @@ -3412,7 +3412,7 @@ TreeItem t (&item, *m_thread_delegate_sp, false); ThreadList &threads = process_sp->GetThreadList(); - Mutex::Locker locker (threads.GetMutex()); + std::lock_guard guard(threads.GetMutex()); size_t num_threads = threads.GetSize(); item.Resize (num_threads, t); for (size_t i = 0; i < num_threads; ++i) @@ -4431,7 +4431,7 @@ submenus.erase (submenus.begin() + 8, submenus.end()); ThreadList &threads = process->GetThreadList(); - Mutex::Locker locker (threads.GetMutex()); + std::lock_guard guard(threads.GetMutex()); size_t num_threads = threads.GetSize(); for (size_t i = 0; i < num_threads; ++i) { Index: source/Core/ModuleList.cpp =================================================================== --- source/Core/ModuleList.cpp +++ source/Core/ModuleList.cpp @@ -28,27 +28,18 @@ using namespace lldb; using namespace lldb_private; -ModuleList::ModuleList() : - m_modules(), - m_modules_mutex (Mutex::eMutexTypeRecursive), - m_notifier(nullptr) +ModuleList::ModuleList() : m_modules(), m_modules_mutex(), m_notifier(nullptr) { } -ModuleList::ModuleList(const ModuleList& rhs) : - m_modules(), - m_modules_mutex (Mutex::eMutexTypeRecursive), - m_notifier(nullptr) +ModuleList::ModuleList(const ModuleList &rhs) : m_modules(), m_modules_mutex(), m_notifier(nullptr) { - Mutex::Locker lhs_locker(m_modules_mutex); - Mutex::Locker rhs_locker(rhs.m_modules_mutex); + std::lock_guard lhs_guard(m_modules_mutex); + std::lock_guard rhs_guard(rhs.m_modules_mutex); m_modules = rhs.m_modules; } -ModuleList::ModuleList (ModuleList::Notifier* notifier) : - m_modules(), - m_modules_mutex (Mutex::eMutexTypeRecursive), - m_notifier(notifier) +ModuleList::ModuleList(ModuleList::Notifier *notifier) : m_modules(), m_modules_mutex(), m_notifier(notifier) { } @@ -69,14 +60,14 @@ // avoids priority inversion. if (uintptr_t(this) > uintptr_t(&rhs)) { - Mutex::Locker lhs_locker(m_modules_mutex); - Mutex::Locker rhs_locker(rhs.m_modules_mutex); + std::lock_guard lhs_guard(m_modules_mutex); + std::lock_guard rhs_guard(rhs.m_modules_mutex); m_modules = rhs.m_modules; } else { - Mutex::Locker rhs_locker(rhs.m_modules_mutex); - Mutex::Locker lhs_locker(m_modules_mutex); + std::lock_guard lhs_guard(m_modules_mutex); + std::lock_guard rhs_guard(rhs.m_modules_mutex); m_modules = rhs.m_modules; } } @@ -90,7 +81,7 @@ { if (module_sp) { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); m_modules.push_back(module_sp); if (use_notifier && m_notifier) m_notifier->ModuleAdded(*this, module_sp); @@ -108,7 +99,7 @@ { if (module_sp) { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); // First remove any equivalent modules. Equivalent modules are modules // whose path, platform path and architecture match. @@ -134,7 +125,7 @@ { if (module_sp) { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -172,7 +163,7 @@ { if (module_sp) { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -220,7 +211,7 @@ { if (module_ptr) { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -242,16 +233,16 @@ size_t ModuleList::RemoveOrphans (bool mandatory) { - Mutex::Locker locker; - + std::unique_lock lock(m_modules_mutex, std::defer_lock); + if (mandatory) { - locker.Lock (m_modules_mutex); + lock.lock(); } else { // Not mandatory, remove orphans if we can get the mutex - if (!locker.TryLock(m_modules_mutex)) + if (!lock.try_lock()) return 0; } collection::iterator pos = m_modules.begin(); @@ -274,7 +265,7 @@ size_t ModuleList::Remove (ModuleList &module_list) { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); size_t num_removed = 0; collection::iterator pos, end = module_list.m_modules.end(); for (pos = module_list.m_modules.begin(); pos != end; ++pos) @@ -301,7 +292,7 @@ void ModuleList::ClearImpl (bool use_notifier) { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); if (use_notifier && m_notifier) m_notifier->WillClearList(*this); m_modules.clear(); @@ -310,7 +301,7 @@ Module* ModuleList::GetModulePointerAtIndex (size_t idx) const { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); return GetModulePointerAtIndexUnlocked(idx); } @@ -325,7 +316,7 @@ ModuleSP ModuleList::GetModuleAtIndex(size_t idx) const { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); return GetModuleAtIndexUnlocked(idx); } @@ -361,8 +352,8 @@ lookup_name, lookup_name_type_mask, match_name_after_lookup); - - Mutex::Locker locker(m_modules_mutex); + + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -398,7 +389,7 @@ } else { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -425,8 +416,8 @@ lookup_name, lookup_name_type_mask, match_name_after_lookup); - - Mutex::Locker locker(m_modules_mutex); + + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -458,7 +449,7 @@ } else { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -478,7 +469,7 @@ { const size_t old_size = sc_list.GetSize(); - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -495,8 +486,8 @@ { if (!append) sc_list.Clear(); - - Mutex::Locker locker(m_modules_mutex); + + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -513,7 +504,7 @@ VariableList& variable_list) const { size_t initial_size = variable_list.GetSize(); - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -529,7 +520,7 @@ VariableList& variable_list) const { size_t initial_size = variable_list.GetSize(); - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -544,7 +535,7 @@ SymbolContextList &sc_list, bool append) const { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); if (!append) sc_list.Clear(); size_t initial_size = sc_list.GetSize(); @@ -561,7 +552,7 @@ SymbolContextList &sc_list, bool append) const { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); if (!append) sc_list.Clear(); size_t initial_size = sc_list.GetSize(); @@ -577,7 +568,7 @@ { size_t existing_matches = matching_module_list.GetSize(); - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -595,7 +586,7 @@ // Scope for "locker" { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) @@ -617,7 +608,7 @@ if (uuid.IsValid()) { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) @@ -635,7 +626,7 @@ size_t ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool name_is_fully_qualified, size_t max_matches, llvm::DenseSet &searched_symbol_files, TypeList& types) const { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); size_t total_matches = 0; collection::const_iterator pos, end = m_modules.end(); @@ -677,7 +668,7 @@ bool ModuleList::FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -693,7 +684,7 @@ Function *function, std::vector
&output_local, std::vector
&output_extern) { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -705,7 +696,7 @@ ModuleList::FindFirstModule (const ModuleSpec &module_spec) const { ModuleSP module_sp; - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -722,7 +713,7 @@ { size_t size = 0; { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); size = m_modules.size(); } return size; @@ -731,11 +722,11 @@ void ModuleList::Dump(Stream *s) const { -// s.Printf("%.*p: ", (int)sizeof(void*) * 2, this); -// s.Indent(); -// s << "ModuleList\n"; + // s.Printf("%.*p: ", (int)sizeof(void*) * 2, this); + // s.Indent(); + // s << "ModuleList\n"; - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -747,8 +738,8 @@ ModuleList::LogUUIDAndPaths (Log *log, const char *prefix_cstr) { if (log != nullptr) - { - Mutex::Locker locker(m_modules_mutex); + { + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, begin = m_modules.begin(), end = m_modules.end(); for (pos = begin; pos != end; ++pos) { @@ -767,7 +758,7 @@ bool ModuleList::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr) const { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -792,7 +783,7 @@ } else { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -821,7 +812,7 @@ uint32_t ModuleList::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) const { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { @@ -836,7 +827,7 @@ { if (module) { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); collection::const_iterator pos; collection::const_iterator begin = m_modules.begin(); collection::const_iterator end = m_modules.end(); @@ -896,7 +887,7 @@ bool always_create) { ModuleList &shared_module_list = GetSharedModuleList (); - Mutex::Locker locker(shared_module_list.m_modules_mutex); + std::lock_guard guard(shared_module_list.m_modules_mutex); char path[PATH_MAX]; Error error; @@ -1175,7 +1166,7 @@ { if (!target) return false; - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); for (auto module : m_modules) { Error error; @@ -1202,7 +1193,7 @@ void ModuleList::ForEach (std::function const &callback) const { - Mutex::Locker locker(m_modules_mutex); + std::lock_guard guard(m_modules_mutex); for (const auto &module : m_modules) { // If the callback returns false, then stop iterating and break out Index: source/Core/SearchFilter.cpp =================================================================== --- source/Core/SearchFilter.cpp +++ source/Core/SearchFilter.cpp @@ -130,7 +130,7 @@ searcher.SearchCallback(*this, empty_sc, nullptr, false); else { - Mutex::Locker modules_locker(modules.GetMutex()); + std::lock_guard guard(modules.GetMutex()); const size_t numModules = modules.GetSize(); for (size_t i = 0; i < numModules; i++) @@ -172,8 +172,8 @@ else { const ModuleList &target_images = m_target_sp->GetImages(); - Mutex::Locker modules_locker(target_images.GetMutex()); - + std::lock_guard guard(target_images.GetMutex()); + size_t n_modules = target_images.GetSize(); for (size_t i = 0; i < n_modules; i++) { @@ -363,8 +363,8 @@ // find the ones that match the file name. const ModuleList &target_modules = m_target_sp->GetImages(); - Mutex::Locker modules_locker (target_modules.GetMutex()); - + std::lock_guard guard(target_modules.GetMutex()); + const size_t num_modules = target_modules.GetSize (); for (size_t i = 0; i < num_modules; i++) { @@ -502,8 +502,8 @@ // find the ones that match the file name. const ModuleList &target_modules = m_target_sp->GetImages(); - Mutex::Locker modules_locker (target_modules.GetMutex()); - + std::lock_guard guard(target_modules.GetMutex()); + const size_t num_modules = target_modules.GetSize (); for (size_t i = 0; i < num_modules; i++) { @@ -656,8 +656,8 @@ ModuleList matching_modules; const ModuleList &target_images = m_target_sp->GetImages(); - Mutex::Locker modules_locker(target_images.GetMutex()); - + std::lock_guard guard(target_images.GetMutex()); + const size_t num_modules = target_images.GetSize (); bool no_modules_in_filter = m_module_spec_list.GetSize() == 0; for (size_t i = 0; i < num_modules; i++) Index: source/Host/common/OptionParser.cpp =================================================================== --- source/Host/common/OptionParser.cpp +++ source/Host/common/OptionParser.cpp @@ -16,10 +16,10 @@ using namespace lldb_private; void -OptionParser::Prepare(Mutex::Locker &locker) +OptionParser::Prepare(std::unique_lock &lock) { - static Mutex g_mutex(Mutex::eMutexTypeNormal); - locker.Lock(g_mutex); + static std::mutex g_mutex; + lock = std::unique_lock(g_mutex); #ifdef __GLIBC__ optind = 0; #else Index: source/Interpreter/Args.cpp =================================================================== --- source/Interpreter/Args.cpp +++ source/Interpreter/Args.cpp @@ -575,8 +575,8 @@ } } } - Mutex::Locker options_locker(NULL); - OptionParser::Prepare(options_locker); + std::unique_lock lock; + OptionParser::Prepare(lock); int val; while (1) { @@ -1218,8 +1218,8 @@ } } - Mutex::Locker options_locker(NULL); - OptionParser::Prepare(options_locker); + std::unique_lock lock; + OptionParser::Prepare(lock); int val; while (1) { @@ -1396,8 +1396,8 @@ } } - Mutex::Locker options_locker(NULL); - OptionParser::Prepare(options_locker); + std::unique_lock lock; + OptionParser::Prepare(lock); OptionParser::EnableError(false); int val; Index: source/Interpreter/CommandObject.cpp =================================================================== --- source/Interpreter/CommandObject.cpp +++ source/Interpreter/CommandObject.cpp @@ -276,7 +276,7 @@ { Target *target = m_exe_ctx.GetTargetPtr(); if (target) - m_api_locker.Lock (target->GetAPIMutex()); + m_api_locker = std::unique_lock(target->GetAPIMutex()); } } @@ -336,7 +336,7 @@ CommandObject::Cleanup () { m_exe_ctx.Clear(); - m_api_locker.Unlock(); + m_api_locker.unlock(); } int Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -1275,8 +1275,8 @@ Target &target = m_process->GetTarget(); const ModuleList &target_modules = target.GetImages(); ModuleList not_loaded_modules; - Mutex::Locker modules_locker(target_modules.GetMutex()); - + std::lock_guard guard(target_modules.GetMutex()); + size_t num_modules = target_modules.GetSize(); for (size_t i = 0; i < num_modules; i++) { Index: source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp =================================================================== --- source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp +++ source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp @@ -102,8 +102,8 @@ // Disable JIT for static dynamic loader targets m_process->SetCanJIT(false); - Mutex::Locker mutex_locker(module_list.GetMutex()); - + std::lock_guard guard(module_list.GetMutex()); + const size_t num_modules = module_list.GetSize(); for (uint32_t idx = 0; idx < num_modules; ++idx) { Index: source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -708,7 +708,7 @@ else { const ModuleList &target_images = m_target->GetImages(); - Mutex::Locker modules_locker (target_images.GetMutex()); + std::lock_guard guard(target_images.GetMutex()); for (size_t i = 0, e = target_images.GetSize(); i < e; ++i) { @@ -1826,7 +1826,7 @@ else { const ModuleList &target_images = m_target->GetImages(); - Mutex::Locker modules_locker(target_images.GetMutex()); + std::lock_guard guard(target_images.GetMutex()); CompilerDeclContext null_namespace_decl; Index: source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp =================================================================== --- source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp +++ source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp @@ -98,8 +98,8 @@ Activate(); return; } - - Mutex::Locker modules_locker(module_list.GetMutex()); + + std::lock_guard guard(module_list.GetMutex()); const size_t num_modules = module_list.GetSize(); for (size_t i = 0; i < num_modules; ++i) { Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -394,8 +394,8 @@ return ObjCRuntimeVersions::eObjC_VersionUnknown; const ModuleList &target_modules = target.GetImages(); - Mutex::Locker modules_locker(target_modules.GetMutex()); - + std::lock_guard gaurd(target_modules.GetMutex()); + size_t num_images = target_modules.GetSize(); for (size_t i = 0; i < num_images; i++) { @@ -524,7 +524,7 @@ { if (!HasReadObjCLibrary ()) { - Mutex::Locker locker (module_list.GetMutex ()); + std::lock_guard guard(module_list.GetMutex()); size_t num_modules = module_list.GetSize(); for (size_t i = 0; i < num_modules; i++) Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -462,7 +462,7 @@ Target &target = process_sp->GetTarget(); const ModuleList &target_modules = target.GetImages(); - Mutex::Locker modules_locker(target_modules.GetMutex()); + std::lock_guard guard(target_modules.GetMutex()); size_t num_modules = target_modules.GetSize(); if (!m_objc_module_sp) { Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp =================================================================== --- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -871,7 +871,7 @@ void RenderScriptRuntime::ModulesDidLoad(const ModuleList &module_list) { - Mutex::Locker locker(module_list.GetMutex()); + std::lock_guard guard(module_list.GetMutex()); size_t num_modules = module_list.GetSize(); for (size_t i = 0; i < num_modules; i++) Index: source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp =================================================================== --- source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp +++ source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp @@ -38,7 +38,7 @@ Target & target = process_sp->GetTarget(); const ModuleList &target_modules = target.GetImages(); - Mutex::Locker modules_locker(target_modules.GetMutex()); + std::lock_guard guard(target_modules.GetMutex()); const size_t num_modules = target_modules.GetSize(); for (size_t i = 0; i < num_modules; ++i) { Index: source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp =================================================================== --- source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp +++ source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp @@ -162,7 +162,7 @@ if (m_symtab_ap.get() == NULL) { m_symtab_ap.reset(new Symtab(this)); - Mutex::Locker symtab_locker (m_symtab_ap->GetMutex()); + std::lock_guard symtab_guard(m_symtab_ap->GetMutex()); ObjectFileJITDelegateSP delegate_sp (m_delegate_wp.lock()); if (delegate_sp) delegate_sp->PopulateSymtab(this, *m_symtab_ap); Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp =================================================================== --- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1461,7 +1461,7 @@ if (m_symtab_ap.get() == NULL) { m_symtab_ap.reset(new Symtab(this)); - Mutex::Locker symtab_locker (m_symtab_ap->GetMutex()); + std::lock_guard symtab_guard(m_symtab_ap->GetMutex()); ParseSymtab (); m_symtab_ap->Finalize (); } Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp =================================================================== --- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -539,8 +539,8 @@ { SectionList *sect_list = GetSectionList(); m_symtab_ap.reset(new Symtab(this)); - Mutex::Locker symtab_locker (m_symtab_ap->GetMutex()); - + std::lock_guard guard(m_symtab_ap->GetMutex()); + const uint32_t num_syms = m_coff_header.nsyms; if (num_syms > 0 && m_coff_header.symoff > 0) Index: source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp =================================================================== --- source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp +++ source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp @@ -197,7 +197,7 @@ if (!target_sp) return nullptr; ModuleList &module_list = target_sp->GetImages(); - Mutex::Locker modules_locker(module_list.GetMutex()); + std::lock_guard guard(module_list.GetMutex()); const size_t num_modules = module_list.GetSize(); bool found_go_runtime = false; for (size_t i = 0; i < num_modules; ++i) Index: source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp =================================================================== --- source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -183,9 +183,9 @@ // This is a recursive lock so we can grant it to any Python code called on // the stack below us. Target &target = m_process->GetTarget(); - Mutex::Locker api_locker; - api_locker.TryLock(target.GetAPIMutex()); - + std::unique_lock lock(target.GetAPIMutex(), std::defer_lock); + lock.try_lock(); + if (log) log->Printf ("OperatingSystemPython::UpdateThreadList() fetching thread data from python for pid %" PRIu64, m_process->GetID()); @@ -324,7 +324,7 @@ // content of the process, and we're going to use python, which requires the API lock to do it. // So get & hold that. This is a recursive lock so we can grant it to any Python code called on the stack below us. Target &target = m_process->GetTarget(); - Mutex::Locker api_locker (target.GetAPIMutex()); + std::lock_guard guard(target.GetAPIMutex()); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD)); @@ -399,8 +399,8 @@ // content of the process, and we're going to use python, which requires the API lock to do it. // So get & hold that. This is a recursive lock so we can grant it to any Python code called on the stack below us. Target &target = m_process->GetTarget(); - Mutex::Locker api_locker (target.GetAPIMutex()); - + std::lock_guard guard(target.GetAPIMutex()); + auto lock = m_interpreter->AcquireInterpreterLock(); // to make sure thread_info_dict stays alive StructuredData::DictionarySP thread_info_dict = m_interpreter->OSPlugin_CreateThread(m_python_object_sp, tid, context); std::vector core_used_map; Index: source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp =================================================================== --- source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -143,7 +143,7 @@ SetPrivateState(eStateRunning); - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard guard(m_thread_list.GetMutex()); bool do_step = false; for (tid_collection::const_iterator t_pos = m_run_tids.begin(), t_end = m_run_tids.end(); t_pos != t_end; ++t_pos) @@ -630,7 +630,7 @@ if (log) log->Printf ("ProcessFreeBSD::%s() removing thread, tid = %" PRIi64, __FUNCTION__, tid); - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard guard(m_thread_list.GetMutex()); ThreadSP thread_sp = m_thread_list.RemoveThreadByID(tid, false); thread_sp.reset(); @@ -801,7 +801,7 @@ // Try to find a vacant watchpoint slot in the inferiors' main thread uint32_t wp_hw_index = LLDB_INVALID_INDEX32; - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard guard(m_thread_list.GetMutex()); FreeBSDThread *thread = static_cast( m_thread_list.GetThreadAtIndex(0, false).get()); @@ -871,7 +871,7 @@ if (wp->IsHardware()) { bool wp_disabled = true; - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard guard(m_thread_list.GetMutex()); uint32_t thread_count = m_thread_list.GetSize(false); for (uint32_t i = 0; i < thread_count; ++i) { @@ -901,7 +901,7 @@ ProcessFreeBSD::GetWatchpointSupportInfo(uint32_t &num) { Error error; - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard guard(m_thread_list.GetMutex()); FreeBSDThread *thread = static_cast( m_thread_list.GetThreadAtIndex(0, false).get()); if (thread) @@ -924,7 +924,7 @@ uint32_t ProcessFreeBSD::UpdateThreadListIfNeeded() { - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard guard(m_thread_list.GetMutex()); // Do not allow recursive updates. return m_thread_list.GetSize(false); } @@ -1015,7 +1015,7 @@ ProcessFreeBSD::IsAThreadRunning() { bool is_running = false; - Mutex::Locker lock(m_thread_list.GetMutex()); + std::lock_guard guard(m_thread_list.GetMutex()); uint32_t thread_count = m_thread_list.GetSize(false); for (uint32_t i = 0; i < thread_count; ++i) { Index: source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h =================================================================== --- source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h +++ source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include +#include #include // Other libraries and framework includes @@ -21,7 +22,6 @@ #include "lldb/Core/Communication.h" #include "lldb/Core/Listener.h" #include "lldb/Core/StreamBuffer.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/Predicate.h" #include "lldb/Host/TimeValue.h" @@ -109,7 +109,7 @@ uint32_t usec); bool - GetSequenceMutex(lldb_private::Mutex::Locker& locker); + GetSequenceMutex(std::unique_lock &lock); bool CheckForPacket (const uint8_t *src, @@ -324,7 +324,7 @@ uint32_t m_addr_byte_size; lldb::ByteOrder m_byte_order; uint32_t m_packet_timeout; - lldb_private::Mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time + std::recursive_mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time lldb_private::Predicate m_is_running; uint32_t m_session_key; uint8_t m_request_sequence_id; Index: source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp =================================================================== --- source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -37,21 +37,21 @@ //---------------------------------------------------------------------- // CommunicationKDP constructor //---------------------------------------------------------------------- -CommunicationKDP::CommunicationKDP (const char *comm_name) : - Communication(comm_name), - m_addr_byte_size (4), - m_byte_order (eByteOrderLittle), - m_packet_timeout (5), - m_sequence_mutex (Mutex::eMutexTypeRecursive), - m_is_running (false), - m_session_key (0u), - m_request_sequence_id (0u), - m_exception_sequence_id (0u), - m_kdp_version_version (0u), - m_kdp_version_feature (0u), - m_kdp_hostinfo_cpu_mask (0u), - m_kdp_hostinfo_cpu_type (0u), - m_kdp_hostinfo_cpu_subtype (0u) +CommunicationKDP::CommunicationKDP(const char *comm_name) + : Communication(comm_name), + m_addr_byte_size(4), + m_byte_order(eByteOrderLittle), + m_packet_timeout(5), + m_sequence_mutex(), + m_is_running(false), + m_session_key(0u), + m_request_sequence_id(0u), + m_exception_sequence_id(0u), + m_kdp_version_version(0u), + m_kdp_version_feature(0u), + m_kdp_hostinfo_cpu_mask(0u), + m_kdp_hostinfo_cpu_type(0u), + m_kdp_hostinfo_cpu_subtype(0u) { } @@ -69,7 +69,7 @@ bool CommunicationKDP::SendRequestPacket (const PacketStreamType &request_packet) { - Mutex::Locker locker(m_sequence_mutex); + std::lock_guard guard(m_sequence_mutex); return SendRequestPacketNoLock (request_packet); } @@ -111,7 +111,7 @@ return false; } - Mutex::Locker locker(m_sequence_mutex); + std::lock_guard guard(m_sequence_mutex); #ifdef LLDB_CONFIGURATION_DEBUG // NOTE: this only works for packets that are in native endian byte order assert (request_packet.GetSize() == *((uint16_t *)(request_packet.GetData() + 2))); @@ -205,9 +205,9 @@ } bool -CommunicationKDP::GetSequenceMutex (Mutex::Locker& locker) +CommunicationKDP::GetSequenceMutex(std::unique_lock &lock) { - return locker.TryLock (m_sequence_mutex); + return (lock = std::unique_lock(m_sequence_mutex, std::try_to_lock)).owns_lock(); } @@ -220,7 +220,7 @@ size_t CommunicationKDP::WaitForPacketWithTimeoutMicroSeconds (DataExtractor &packet, uint32_t timeout_usec) { - Mutex::Locker locker(m_sequence_mutex); + std::lock_guard guard(m_sequence_mutex); return WaitForPacketWithTimeoutMicroSecondsNoLock (packet, timeout_usec); } Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp =================================================================== --- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1646,7 +1646,7 @@ void ProcessGDBRemote::ClearThreadIDList () { - Mutex::Locker locker(m_thread_list_real.GetMutex()); + std::lock_guard guard(m_thread_list_real.GetMutex()); m_thread_ids.clear(); m_thread_pcs.clear(); } @@ -1696,7 +1696,7 @@ bool ProcessGDBRemote::UpdateThreadIDList () { - Mutex::Locker locker(m_thread_list_real.GetMutex()); + std::lock_guard guard(m_thread_list_real.GetMutex()); if (m_jthreadsinfo_sp) { @@ -1944,7 +1944,7 @@ // m_thread_list_real does have its own mutex, but we need to // hold onto the mutex between the call to m_thread_list_real.FindThreadByID(...) // and the m_thread_list_real.AddThread(...) so it doesn't change on us - Mutex::Locker locker (m_thread_list_real.GetMutex ()); + std::lock_guard guard(m_thread_list_real.GetMutex()); thread_sp = m_thread_list_real.FindThreadByProtocolID(tid, false); if (!thread_sp) @@ -2440,7 +2440,8 @@ } else if (key.compare("threads") == 0) { - Mutex::Locker locker(m_thread_list_real.GetMutex()); + std::lock_guard guard(m_thread_list_real.GetMutex()); + m_thread_ids.clear(); // A comma separated list of all threads in the current // process that includes the thread for this stop reply @@ -2663,7 +2664,8 @@ void ProcessGDBRemote::RefreshStateAfterStop () { - Mutex::Locker locker(m_thread_list_real.GetMutex()); + std::lock_guard guard(m_thread_list_real.GetMutex()); + m_thread_ids.clear(); m_thread_pcs.clear(); // Set the thread stop info. It might have a "threads" key whose value is @@ -2818,7 +2820,7 @@ ThreadList &threads = GetThreadList(); { - Mutex::Locker locker(threads.GetMutex()); + std::lock_guard guard(threads.GetMutex()); size_t num_threads = threads.GetSize(); for (size_t i = 0; i < num_threads; i++) @@ -2853,7 +2855,7 @@ // have to run the risk of letting those threads proceed a bit. { - Mutex::Locker locker(threads.GetMutex()); + std::lock_guard guard(threads.GetMutex()); size_t num_threads = threads.GetSize(); for (size_t i = 0; i < num_threads; i++) Index: source/Symbol/ClangExternalASTSourceCommon.cpp =================================================================== --- source/Symbol/ClangExternalASTSourceCommon.cpp +++ source/Symbol/ClangExternalASTSourceCommon.cpp @@ -9,7 +9,6 @@ #include "lldb/Symbol/ClangExternalASTSourceCommon.h" #include "lldb/Core/Stream.h" -#include "lldb/Host/Mutex.h" using namespace lldb_private; Index: source/Symbol/CompactUnwindInfo.cpp =================================================================== --- source/Symbol/CompactUnwindInfo.cpp +++ source/Symbol/CompactUnwindInfo.cpp @@ -130,19 +130,17 @@ // constructor //---------------------- - -CompactUnwindInfo::CompactUnwindInfo(ObjectFile& objfile, SectionSP& section_sp) : - m_objfile (objfile), - m_section_sp (section_sp), - m_section_contents_if_encrypted (), - m_mutex (), - m_indexes (), - m_indexes_computed (eLazyBoolCalculate), - m_unwindinfo_data (), - m_unwindinfo_data_computed (false), - m_unwind_header () +CompactUnwindInfo::CompactUnwindInfo(ObjectFile &objfile, SectionSP §ion_sp) + : m_objfile(objfile), + m_section_sp(section_sp), + m_section_contents_if_encrypted(), + m_mutex(), + m_indexes(), + m_indexes_computed(eLazyBoolCalculate), + m_unwindinfo_data(), + m_unwindinfo_data_computed(false), + m_unwind_header() { - } //---------------------- @@ -223,7 +221,7 @@ void CompactUnwindInfo::ScanIndex (const ProcessSP &process_sp) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (m_indexes_computed == eLazyBoolYes && m_unwindinfo_data_computed) return; Index: source/Symbol/DWARFCallFrameInfo.cpp =================================================================== --- source/Symbol/DWARFCallFrameInfo.cpp +++ source/Symbol/DWARFCallFrameInfo.cpp @@ -308,9 +308,9 @@ if (m_fde_index_initialized) return; - - Mutex::Locker locker(m_fde_index_mutex); - + + std::lock_guard guard(m_fde_index_mutex); + if (m_fde_index_initialized) // if two threads hit the locker return; Index: source/Symbol/Symtab.cpp =================================================================== --- source/Symbol/Symtab.cpp +++ source/Symbol/Symtab.cpp @@ -25,16 +25,14 @@ using namespace lldb; using namespace lldb_private; - - -Symtab::Symtab(ObjectFile *objfile) : - m_objfile (objfile), - m_symbols (), - m_file_addr_to_index (), - m_name_to_index (), - m_mutex (Mutex::eMutexTypeRecursive), - m_file_addr_to_index_computed (false), - m_name_indexes_computed (false) +Symtab::Symtab(ObjectFile *objfile) + : m_objfile(objfile), + m_symbols(), + m_file_addr_to_index(), + m_name_to_index(), + m_mutex(), + m_file_addr_to_index_computed(false), + m_name_indexes_computed(false) { } @@ -76,7 +74,7 @@ size_t Symtab::GetNumSymbols() const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); return m_symbols.size(); } @@ -90,9 +88,9 @@ void Symtab::Dump (Stream *s, Target *target, SortOrder sort_order) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); -// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + // s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); const FileSpec &file_spec = m_objfile->GetFileSpec(); const char * object_name = nullptr; @@ -171,7 +169,7 @@ void Symtab::Dump(Stream *s, Target *target, std::vector& indexes) const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); const size_t num_symbols = GetNumSymbols(); //s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); @@ -224,7 +222,7 @@ Symbol * Symtab::FindSymbolByID (lldb::user_id_t symbol_uid) const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); Symbol *symbol = (Symbol*)::bsearch (&symbol_uid, &m_symbols[0], @@ -474,7 +472,7 @@ if (add_demangled || add_mangled) { Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); // Create the name index vector to be able to quickly search by name NameToIndexMap::Entry entry; @@ -506,7 +504,7 @@ uint32_t Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, std::vector& indexes, uint32_t start_idx, uint32_t end_index) const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); uint32_t prev_size = indexes.size(); @@ -524,7 +522,7 @@ uint32_t Symtab::AppendSymbolIndexesWithTypeAndFlagsValue (SymbolType symbol_type, uint32_t flags_value, std::vector& indexes, uint32_t start_idx, uint32_t end_index) const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); uint32_t prev_size = indexes.size(); @@ -542,7 +540,7 @@ uint32_t Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& indexes, uint32_t start_idx, uint32_t end_index) const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); uint32_t prev_size = indexes.size(); @@ -632,7 +630,7 @@ void Symtab::SortSymbolIndexesByValue (std::vector& indexes, bool remove_duplicates) const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); Timer scoped_timer (__PRETTY_FUNCTION__,__PRETTY_FUNCTION__); // No need to sort if we have zero or one items... @@ -657,7 +655,7 @@ uint32_t Symtab::AppendSymbolIndexesWithName (const ConstString& symbol_name, std::vector& indexes) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); if (symbol_name) @@ -674,7 +672,7 @@ uint32_t Symtab::AppendSymbolIndexesWithName (const ConstString& symbol_name, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& indexes) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); if (symbol_name) @@ -700,7 +698,7 @@ uint32_t Symtab::AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, SymbolType symbol_type, std::vector& indexes) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (AppendSymbolIndexesWithName(symbol_name, indexes) > 0) { @@ -719,7 +717,7 @@ uint32_t Symtab::AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& indexes) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (AppendSymbolIndexesWithName(symbol_name, symbol_debug_type, symbol_visibility, indexes) > 0) { @@ -739,7 +737,7 @@ uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType (const RegularExpression ®exp, SymbolType symbol_type, std::vector& indexes) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); uint32_t prev_size = indexes.size(); uint32_t sym_end = m_symbols.size(); @@ -763,7 +761,7 @@ uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType (const RegularExpression ®exp, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& indexes) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); uint32_t prev_size = indexes.size(); uint32_t sym_end = m_symbols.size(); @@ -790,7 +788,7 @@ Symbol * Symtab::FindSymbolWithType (SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t& start_idx) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); const size_t count = m_symbols.size(); for (size_t idx = start_idx; idx < count; ++idx) @@ -810,7 +808,7 @@ size_t Symtab::FindAllSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, std::vector& symbol_indexes) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); // Initialize all of the lookup by name indexes before converting NAME @@ -830,7 +828,7 @@ size_t Symtab::FindAllSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& symbol_indexes) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); // Initialize all of the lookup by name indexes before converting NAME @@ -850,7 +848,7 @@ size_t Symtab::FindAllSymbolsMatchingRexExAndType (const RegularExpression ®ex, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& symbol_indexes) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); AppendSymbolIndexesMatchingRegExAndType(regex, symbol_type, symbol_debug_type, symbol_visibility, symbol_indexes); return symbol_indexes.size(); @@ -859,7 +857,7 @@ Symbol * Symtab::FindFirstSymbolWithNameAndType (const ConstString &name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); if (!m_name_indexes_computed) @@ -1026,7 +1024,7 @@ void Symtab::CalculateSymbolSizes () { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (!m_symbols.empty()) { @@ -1060,7 +1058,7 @@ Symbol * Symtab::FindSymbolAtFileAddress (addr_t file_addr) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (!m_file_addr_to_index_computed) InitAddressIndexes(); @@ -1077,7 +1075,7 @@ Symbol * Symtab::FindSymbolContainingFileAddress (addr_t file_addr) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (!m_file_addr_to_index_computed) InitAddressIndexes(); @@ -1095,7 +1093,7 @@ void Symtab::ForEachSymbolContainingFileAddress(addr_t file_addr, std::function const &callback) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (!m_file_addr_to_index_computed) InitAddressIndexes(); @@ -1159,7 +1157,7 @@ unsigned temp_symbol_indexes_size = temp_symbol_indexes.size(); if (temp_symbol_indexes_size > 0) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); for (unsigned i = 0; i < temp_symbol_indexes_size; i++) { SymbolContext sym_ctx; Index: source/Symbol/TypeSystem.cpp =================================================================== --- source/Symbol/TypeSystem.cpp +++ source/Symbol/TypeSystem.cpp @@ -163,10 +163,7 @@ #pragma mark TypeSystemMap -TypeSystemMap::TypeSystemMap() : - m_mutex (), - m_map (), - m_clear_in_progress(false) +TypeSystemMap::TypeSystemMap() : m_mutex(), m_map(), m_clear_in_progress(false) { } @@ -179,7 +176,7 @@ { collection map; { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); map = m_map; m_clear_in_progress = true; } @@ -195,7 +192,7 @@ } map.clear(); { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_map.clear(); m_clear_in_progress = false; } @@ -205,7 +202,7 @@ void TypeSystemMap::ForEach (std::function const &callback) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); // Use a std::set so we only call the callback once for each unique // TypeSystem instance std::set visited; @@ -224,7 +221,7 @@ TypeSystem * TypeSystemMap::GetTypeSystemForLanguage (lldb::LanguageType language, Module *module, bool can_create) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); collection::iterator pos = m_map.find(language); if (pos != m_map.end()) return pos->second.get(); @@ -252,7 +249,7 @@ TypeSystem * TypeSystemMap::GetTypeSystemForLanguage (lldb::LanguageType language, Target *target, bool can_create) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); collection::iterator pos = m_map.find(language); if (pos != m_map.end()) return pos->second.get(); Index: source/Symbol/UnwindTable.cpp =================================================================== --- source/Symbol/UnwindTable.cpp +++ source/Symbol/UnwindTable.cpp @@ -27,14 +27,14 @@ using namespace lldb; using namespace lldb_private; -UnwindTable::UnwindTable (ObjectFile& objfile) : - m_object_file (objfile), - m_unwinds (), - m_initialized (false), - m_mutex (), - m_eh_frame_up (), - m_compact_unwind_up (), - m_arm_unwind_up () +UnwindTable::UnwindTable(ObjectFile &objfile) + : m_object_file(objfile), + m_unwinds(), + m_initialized(false), + m_mutex(), + m_eh_frame_up(), + m_compact_unwind_up(), + m_arm_unwind_up() { } @@ -47,7 +47,7 @@ if (m_initialized) return; - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (m_initialized) // check again once we've acquired the lock return; @@ -90,7 +90,7 @@ Initialize(); - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); // There is an UnwindTable per object file, so we can safely use file handles addr_t file_addr = addr.GetFileAddress(); @@ -152,7 +152,7 @@ void UnwindTable::Dump (Stream &s) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); s.Printf("UnwindTable for '%s':\n", m_object_file.GetFileSpec().GetPath().c_str()); const_iterator begin = m_unwinds.begin(); const_iterator end = m_unwinds.end(); Index: source/Target/ExecutionContext.cpp =================================================================== --- source/Target/ExecutionContext.cpp +++ source/Target/ExecutionContext.cpp @@ -186,18 +186,17 @@ } } -ExecutionContext::ExecutionContext (const ExecutionContextRef *exe_ctx_ref_ptr, Mutex::Locker &locker) : - m_target_sp (), - m_process_sp (), - m_thread_sp (), - m_frame_sp () +ExecutionContext::ExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr, + std::unique_lock &lock) + : m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp() { if (exe_ctx_ref_ptr) { - m_target_sp = exe_ctx_ref_ptr->GetTargetSP(); + m_target_sp = exe_ctx_ref_ptr->GetTargetSP(); if (m_target_sp) { - locker.Lock(m_target_sp->GetAPIMutex()); + lock = std::unique_lock(m_target_sp->GetAPIMutex()); + m_process_sp = exe_ctx_ref_ptr->GetProcessSP(); m_thread_sp = exe_ctx_ref_ptr->GetThreadSP(); m_frame_sp = exe_ctx_ref_ptr->GetFrameSP(); @@ -205,18 +204,16 @@ } } -ExecutionContext::ExecutionContext (const ExecutionContextRef &exe_ctx_ref, Mutex::Locker &locker) : - m_target_sp (exe_ctx_ref.GetTargetSP()), - m_process_sp (), - m_thread_sp (), - m_frame_sp () +ExecutionContext::ExecutionContext(const ExecutionContextRef &exe_ctx_ref, std::unique_lock &lock) + : m_target_sp(exe_ctx_ref.GetTargetSP()), m_process_sp(), m_thread_sp(), m_frame_sp() { if (m_target_sp) { - locker.Lock(m_target_sp->GetAPIMutex()); + lock = std::unique_lock(m_target_sp->GetAPIMutex()); + m_process_sp = exe_ctx_ref.GetProcessSP(); - m_thread_sp = exe_ctx_ref.GetThreadSP(); - m_frame_sp = exe_ctx_ref.GetFrameSP(); + m_thread_sp = exe_ctx_ref.GetThreadSP(); + m_frame_sp = exe_ctx_ref.GetFrameSP(); } } Index: source/Target/Language.cpp =================================================================== --- source/Target/Language.cpp +++ source/Target/Language.cpp @@ -13,7 +13,6 @@ #include "lldb/Target/Language.h" -#include "lldb/Host/Mutex.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Stream.h" Index: source/Target/Memory.cpp =================================================================== --- source/Target/Memory.cpp +++ source/Target/Memory.cpp @@ -25,13 +25,13 @@ //---------------------------------------------------------------------- // MemoryCache constructor //---------------------------------------------------------------------- -MemoryCache::MemoryCache(Process &process) : - m_mutex (Mutex::eMutexTypeRecursive), - m_L1_cache (), - m_L2_cache (), - m_invalid_ranges (), - m_process (process), - m_L2_cache_line_byte_size (process.GetMemoryCacheLineSize()) +MemoryCache::MemoryCache(Process &process) + : m_mutex(), + m_L1_cache(), + m_L2_cache(), + m_invalid_ranges(), + m_process(process), + m_L2_cache_line_byte_size(process.GetMemoryCacheLineSize()) { } @@ -45,7 +45,7 @@ void MemoryCache::Clear(bool clear_invalid_ranges) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_L1_cache.clear(); m_L2_cache.clear(); if (clear_invalid_ranges) @@ -62,7 +62,7 @@ void MemoryCache::AddL1CacheData(lldb::addr_t addr, const DataBufferSP &data_buffer_sp) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_L1_cache[addr] = data_buffer_sp; } @@ -72,7 +72,7 @@ if (size == 0) return; - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); // Erase any blocks from the L1 cache that intersect with the flush range if (!m_L1_cache.empty()) @@ -123,7 +123,7 @@ { if (byte_size > 0) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); InvalidRanges::Entry range (base_addr, byte_size); m_invalid_ranges.Append(range); m_invalid_ranges.Sort(); @@ -135,7 +135,7 @@ { if (byte_size > 0) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); const uint32_t idx = m_invalid_ranges.FindEntryIndexThatContains(base_addr); if (idx != UINT32_MAX) { @@ -164,7 +164,7 @@ // m_L2_cache_line_byte_size bytes in size, so we don't try anything // tricky when reading from them (no partial reads from the L1 cache). - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (!m_L1_cache.empty()) { AddrRange read_range(addr, dst_len); @@ -436,11 +436,7 @@ return success; } - -AllocatedMemoryCache::AllocatedMemoryCache (Process &process) : - m_process (process), - m_mutex (Mutex::eMutexTypeRecursive), - m_memory_map() +AllocatedMemoryCache::AllocatedMemoryCache(Process &process) : m_process(process), m_mutex(), m_memory_map() { } @@ -452,7 +448,7 @@ void AllocatedMemoryCache::Clear() { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (m_process.IsAlive()) { PermissionsToBlockMap::iterator pos, end = m_memory_map.end(); @@ -498,8 +494,8 @@ uint32_t permissions, Error &error) { - Mutex::Locker locker (m_mutex); - + std::lock_guard guard(m_mutex); + addr_t addr = LLDB_INVALID_ADDRESS; std::pair range = m_memory_map.equal_range (permissions); @@ -526,7 +522,7 @@ bool AllocatedMemoryCache::DeallocateMemory (lldb::addr_t addr) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); PermissionsToBlockMap::iterator pos, end = m_memory_map.end(); bool success = false; Index: source/Target/Process.cpp =================================================================== --- source/Target/Process.cpp +++ source/Target/Process.cpp @@ -716,105 +716,99 @@ // defaulting to using the Host's UnixSignals. } -Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp, const UnixSignalsSP &unix_signals_sp) : - ProcessProperties (this), - UserID (LLDB_INVALID_PROCESS_ID), - Broadcaster ((target_sp->GetDebugger().GetBroadcasterManager()), Process::GetStaticBroadcasterClass().AsCString()), - m_target_sp (target_sp), - m_public_state (eStateUnloaded), - m_private_state (eStateUnloaded), - m_private_state_broadcaster(nullptr, "lldb.process.internal_state_broadcaster"), - m_private_state_control_broadcaster(nullptr, "lldb.process.internal_state_control_broadcaster"), - m_private_state_listener_sp (Listener::MakeListener("lldb.process.internal_state_listener")), - m_mod_id (), - m_process_unique_id(0), - m_thread_index_id (0), - m_thread_id_to_index_id_map (), - m_exit_status (-1), - m_exit_string (), - m_exit_status_mutex(), - m_thread_mutex (Mutex::eMutexTypeRecursive), - m_thread_list_real (this), - m_thread_list (this), - m_extended_thread_list (this), - m_extended_thread_stop_id (0), - m_queue_list (this), - m_queue_list_stop_id (0), - m_notifications (), - m_image_tokens (), - m_listener_sp (listener_sp), - m_breakpoint_site_list (), - m_dynamic_checkers_ap (), - m_unix_signals_sp (unix_signals_sp), - m_abi_sp (), - m_process_input_reader (), - m_stdio_communication ("process.stdio"), - m_stdio_communication_mutex (Mutex::eMutexTypeRecursive), - m_stdin_forward (false), - m_stdout_data (), - m_stderr_data (), - m_profile_data_comm_mutex (Mutex::eMutexTypeRecursive), - m_profile_data (), - m_iohandler_sync (0), - m_memory_cache (*this), - m_allocated_memory_cache (*this), - m_should_detach (false), - m_next_event_action_ap(), - m_public_run_lock (), - m_private_run_lock (), - m_stop_info_override_callback(nullptr), - m_finalizing (false), - m_finalize_called (false), - m_clear_thread_plans_on_stop (false), - m_force_next_event_delivery (false), - m_last_broadcast_state (eStateInvalid), - m_destroy_in_process (false), - m_can_interpret_function_calls(false), - m_warnings_issued (), - m_can_jit(eCanJITDontKnow) -{ - CheckInWithManager (); - - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); +Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp, const UnixSignalsSP &unix_signals_sp) + : ProcessProperties(this), + UserID(LLDB_INVALID_PROCESS_ID), + Broadcaster((target_sp->GetDebugger().GetBroadcasterManager()), Process::GetStaticBroadcasterClass().AsCString()), + m_target_sp(target_sp), + m_public_state(eStateUnloaded), + m_private_state(eStateUnloaded), + m_private_state_broadcaster(nullptr, "lldb.process.internal_state_broadcaster"), + m_private_state_control_broadcaster(nullptr, "lldb.process.internal_state_control_broadcaster"), + m_private_state_listener_sp(Listener::MakeListener("lldb.process.internal_state_listener")), + m_mod_id(), + m_process_unique_id(0), + m_thread_index_id(0), + m_thread_id_to_index_id_map(), + m_exit_status(-1), + m_exit_string(), + m_exit_status_mutex(), + m_thread_mutex(), + m_thread_list_real(this), + m_thread_list(this), + m_extended_thread_list(this), + m_extended_thread_stop_id(0), + m_queue_list(this), + m_queue_list_stop_id(0), + m_notifications(), + m_image_tokens(), + m_listener_sp(listener_sp), + m_breakpoint_site_list(), + m_dynamic_checkers_ap(), + m_unix_signals_sp(unix_signals_sp), + m_abi_sp(), + m_process_input_reader(), + m_stdio_communication("process.stdio"), + m_stdio_communication_mutex(), + m_stdin_forward(false), + m_stdout_data(), + m_stderr_data(), + m_profile_data_comm_mutex(), + m_profile_data(), + m_iohandler_sync(0), + m_memory_cache(*this), + m_allocated_memory_cache(*this), + m_should_detach(false), + m_next_event_action_ap(), + m_public_run_lock(), + m_private_run_lock(), + m_stop_info_override_callback(nullptr), + m_finalizing(false), + m_finalize_called(false), + m_clear_thread_plans_on_stop(false), + m_force_next_event_delivery(false), + m_last_broadcast_state(eStateInvalid), + m_destroy_in_process(false), + m_can_interpret_function_calls(false), + m_warnings_issued(), + m_can_jit(eCanJITDontKnow) +{ + CheckInWithManager(); + + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT)); if (log) - log->Printf ("%p Process::Process()", static_cast(this)); + log->Printf("%p Process::Process()", static_cast(this)); if (!m_unix_signals_sp) m_unix_signals_sp = std::make_shared(); - SetEventName (eBroadcastBitStateChanged, "state-changed"); - SetEventName (eBroadcastBitInterrupt, "interrupt"); - SetEventName (eBroadcastBitSTDOUT, "stdout-available"); - SetEventName (eBroadcastBitSTDERR, "stderr-available"); - SetEventName (eBroadcastBitProfileData, "profile-data-available"); + SetEventName(eBroadcastBitStateChanged, "state-changed"); + SetEventName(eBroadcastBitInterrupt, "interrupt"); + SetEventName(eBroadcastBitSTDOUT, "stdout-available"); + SetEventName(eBroadcastBitSTDERR, "stderr-available"); + SetEventName(eBroadcastBitProfileData, "profile-data-available"); - m_private_state_control_broadcaster.SetEventName (eBroadcastInternalStateControlStop , "control-stop" ); - m_private_state_control_broadcaster.SetEventName (eBroadcastInternalStateControlPause , "control-pause" ); - m_private_state_control_broadcaster.SetEventName (eBroadcastInternalStateControlResume, "control-resume"); + m_private_state_control_broadcaster.SetEventName(eBroadcastInternalStateControlStop, "control-stop"); + m_private_state_control_broadcaster.SetEventName(eBroadcastInternalStateControlPause, "control-pause"); + m_private_state_control_broadcaster.SetEventName(eBroadcastInternalStateControlResume, "control-resume"); - m_listener_sp->StartListeningForEvents (this, - eBroadcastBitStateChanged | - eBroadcastBitInterrupt | - eBroadcastBitSTDOUT | - eBroadcastBitSTDERR | - eBroadcastBitProfileData); + m_listener_sp->StartListeningForEvents(this, eBroadcastBitStateChanged | eBroadcastBitInterrupt | + eBroadcastBitSTDOUT | eBroadcastBitSTDERR | + eBroadcastBitProfileData); m_private_state_listener_sp->StartListeningForEvents(&m_private_state_broadcaster, - eBroadcastBitStateChanged | - eBroadcastBitInterrupt); + eBroadcastBitStateChanged | eBroadcastBitInterrupt); - m_private_state_listener_sp->StartListeningForEvents(&m_private_state_control_broadcaster, - eBroadcastInternalStateControlStop | - eBroadcastInternalStateControlPause | - eBroadcastInternalStateControlResume); + m_private_state_listener_sp->StartListeningForEvents( + &m_private_state_control_broadcaster, eBroadcastInternalStateControlStop | eBroadcastInternalStateControlPause | + eBroadcastInternalStateControlResume); // We need something valid here, even if just the default UnixSignalsSP. - assert (m_unix_signals_sp && "null m_unix_signals_sp after initialization"); + assert(m_unix_signals_sp && "null m_unix_signals_sp after initialization"); // Allow the platform to override the default cache line size - OptionValueSP value_sp = - m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertyMemCacheLineSize)->GetValue(); + OptionValueSP value_sp = m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertyMemCacheLineSize)->GetValue(); uint32_t platform_cache_line_size = target_sp->GetPlatform()->GetDefaultMemoryCacheLineSize(); - if (! value_sp->OptionWasSet() && platform_cache_line_size != 0) + if (!value_sp->OptionWasSet() && platform_cache_line_size != 0) value_sp->SetUInt64Value(platform_cache_line_size); } @@ -1153,7 +1147,7 @@ // Lock the thread list so it doesn't change on us, this is the scope for the locker: { ThreadList &thread_list = process_sp->GetThreadList(); - Mutex::Locker locker (thread_list.GetMutex()); + std::lock_guard guard(thread_list.GetMutex()); ThreadSP curr_thread (thread_list.GetSelectedThread()); ThreadSP thread; @@ -1422,7 +1416,7 @@ int Process::GetExitStatus () { - Mutex::Locker locker (m_exit_status_mutex); + std::lock_guard guard(m_exit_status_mutex); if (m_public_state.GetValue() == eStateExited) return m_exit_status; @@ -1432,7 +1426,7 @@ const char * Process::GetExitDescription () { - Mutex::Locker locker (m_exit_status_mutex); + std::lock_guard guard(m_exit_status_mutex); if (m_public_state.GetValue() == eStateExited && !m_exit_string.empty()) return m_exit_string.c_str(); @@ -1443,7 +1437,7 @@ Process::SetExitStatus (int status, const char *cstr) { // Use a mutex to protect setting the exit status. - Mutex::Locker locker (m_exit_status_mutex); + std::lock_guard guard(m_exit_status_mutex); Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STATE | LIBLLDB_LOG_PROCESS)); if (log) @@ -1550,7 +1544,7 @@ const StateType state = GetPrivateState(); if (StateIsStoppedState (state, true)) { - Mutex::Locker locker (m_thread_list.GetMutex ()); + std::lock_guard guard(m_thread_list.GetMutex()); // m_thread_list does have its own mutex, but we need to // hold onto the mutex between the call to UpdateThreadList(...) // and the os->UpdateThreadList(...) so it doesn't change on us @@ -1794,7 +1788,7 @@ if (log) log->Printf("Process::SetPrivateState (%s)", StateAsCString(new_state)); - Mutex::Locker thread_locker(m_thread_list.GetMutex()); + std::lock_guard thread_guard(m_thread_list.GetMutex()); std::lock_guard guard(m_private_state.GetMutex()); const StateType old_state = m_private_state.GetValueNoLock (); @@ -3461,7 +3455,7 @@ m_os_ap.reset(OperatingSystem::FindPlugin(this, nullptr)); // Figure out which one is the executable, and set that in our target: const ModuleList &target_modules = GetTarget().GetImages(); - Mutex::Locker modules_locker(target_modules.GetMutex()); + std::lock_guard guard(target_modules.GetMutex()); size_t num_modules = target_modules.GetSize(); ModuleSP new_executable_module_sp; @@ -4783,7 +4777,7 @@ void Process::AppendSTDOUT (const char * s, size_t len) { - Mutex::Locker locker (m_stdio_communication_mutex); + std::lock_guard guard(m_stdio_communication_mutex); m_stdout_data.append (s, len); BroadcastEventIfUnique (eBroadcastBitSTDOUT, new ProcessEventData (shared_from_this(), GetState())); } @@ -4791,7 +4785,7 @@ void Process::AppendSTDERR (const char * s, size_t len) { - Mutex::Locker locker (m_stdio_communication_mutex); + std::lock_guard guard(m_stdio_communication_mutex); m_stderr_data.append (s, len); BroadcastEventIfUnique (eBroadcastBitSTDERR, new ProcessEventData (shared_from_this(), GetState())); } @@ -4799,7 +4793,7 @@ void Process::BroadcastAsyncProfileData(const std::string &one_profile_data) { - Mutex::Locker locker (m_profile_data_comm_mutex); + std::lock_guard guard(m_profile_data_comm_mutex); m_profile_data.push_back(one_profile_data); BroadcastEventIfUnique (eBroadcastBitProfileData, new ProcessEventData (shared_from_this(), GetState())); } @@ -4807,7 +4801,7 @@ size_t Process::GetAsyncProfileData (char *buf, size_t buf_size, Error &error) { - Mutex::Locker locker(m_profile_data_comm_mutex); + std::lock_guard guard(m_profile_data_comm_mutex); if (m_profile_data.empty()) return 0; @@ -4842,7 +4836,7 @@ size_t Process::GetSTDOUT (char *buf, size_t buf_size, Error &error) { - Mutex::Locker locker(m_stdio_communication_mutex); + std::lock_guard guard(m_stdio_communication_mutex); size_t bytes_available = m_stdout_data.size(); if (bytes_available > 0) { @@ -4869,7 +4863,7 @@ size_t Process::GetSTDERR (char *buf, size_t buf_size, Error &error) { - Mutex::Locker locker(m_stdio_communication_mutex); + std::lock_guard gaurd(m_stdio_communication_mutex); size_t bytes_available = m_stderr_data.size(); if (bytes_available > 0) { @@ -6105,7 +6099,7 @@ if (GetThreadList().SetSelectedThreadByIndexID (selected_tid) && selected_stack_id.IsValid()) { // We were able to restore the selected thread, now restore the frame: - Mutex::Locker lock(GetThreadList().GetMutex()); + std::lock_guard guard(GetThreadList().GetMutex()); StackFrameSP old_frame_sp = GetThreadList().GetSelectedThread()->GetFrameWithStackID(selected_stack_id); if (old_frame_sp) GetThreadList().GetSelectedThread()->SetSelectedFrame(old_frame_sp.get()); @@ -6210,7 +6204,7 @@ std::vector thread_id_array; //Scope for thread list locker; { - Mutex::Locker locker (GetThreadList().GetMutex()); + std::lock_guard guard(GetThreadList().GetMutex()); ThreadList &curr_thread_list = GetThreadList(); num_threads = curr_thread_list.GetSize(); uint32_t idx; Index: source/Target/QueueList.cpp =================================================================== --- source/Target/QueueList.cpp +++ source/Target/QueueList.cpp @@ -14,11 +14,7 @@ using namespace lldb; using namespace lldb_private; -QueueList::QueueList (Process *process) : - m_process (process), - m_stop_id (0), - m_queues (), - m_mutex () +QueueList::QueueList(Process *process) : m_process(process), m_stop_id(0), m_queues(), m_mutex() { } @@ -30,14 +26,14 @@ uint32_t QueueList::GetSize () { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); return m_queues.size(); } lldb::QueueSP QueueList::GetQueueAtIndex (uint32_t idx) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (idx < m_queues.size()) { return m_queues[idx]; @@ -51,14 +47,14 @@ void QueueList::Clear () { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_queues.clear(); } void QueueList::AddQueue (QueueSP queue_sp) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (queue_sp.get ()) { m_queues.push_back (queue_sp); @@ -95,8 +91,8 @@ return ret; } -lldb_private::Mutex & -QueueList::GetMutex () +std::mutex & +QueueList::GetMutex() { return m_mutex; } Index: source/Target/StackFrame.cpp =================================================================== --- source/Target/StackFrame.cpp +++ source/Target/StackFrame.cpp @@ -44,135 +44,119 @@ #define RESOLVED_VARIABLES (GOT_FRAME_BASE << 1) #define RESOLVED_GLOBAL_VARIABLES (RESOLVED_VARIABLES << 1) -StackFrame::StackFrame (const ThreadSP &thread_sp, - user_id_t frame_idx, - user_id_t unwind_frame_index, - addr_t cfa, - bool cfa_is_valid, - addr_t pc, - uint32_t stop_id, - bool stop_id_is_valid, - bool is_history_frame, - const SymbolContext *sc_ptr) : - m_thread_wp (thread_sp), - m_frame_index (frame_idx), - m_concrete_frame_index (unwind_frame_index), - m_reg_context_sp (), - m_id(pc, cfa, nullptr), - m_frame_code_addr (pc), - m_sc (), - m_flags (), - m_frame_base (), - m_frame_base_error (), - m_cfa_is_valid (cfa_is_valid), - m_stop_id (stop_id), - m_stop_id_is_valid (stop_id_is_valid), - m_is_history_frame (is_history_frame), - m_variable_list_sp (), - m_variable_list_value_objects (), - m_disassembly (), - m_mutex (Mutex::eMutexTypeRecursive) +StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx, user_id_t unwind_frame_index, addr_t cfa, + bool cfa_is_valid, addr_t pc, uint32_t stop_id, bool stop_id_is_valid, bool is_history_frame, + const SymbolContext *sc_ptr) + : m_thread_wp(thread_sp), + m_frame_index(frame_idx), + m_concrete_frame_index(unwind_frame_index), + m_reg_context_sp(), + m_id(pc, cfa, nullptr), + m_frame_code_addr(pc), + m_sc(), + m_flags(), + m_frame_base(), + m_frame_base_error(), + m_cfa_is_valid(cfa_is_valid), + m_stop_id(stop_id), + m_stop_id_is_valid(stop_id_is_valid), + m_is_history_frame(is_history_frame), + m_variable_list_sp(), + m_variable_list_value_objects(), + m_disassembly(), + m_mutex() { // If we don't have a CFA value, use the frame index for our StackID so that recursive // functions properly aren't confused with one another on a history stack. if (m_is_history_frame && !m_cfa_is_valid) { - m_id.SetCFA (m_frame_index); + m_id.SetCFA(m_frame_index); } if (sc_ptr != nullptr) { m_sc = *sc_ptr; - m_flags.Set(m_sc.GetResolvedMask ()); + m_flags.Set(m_sc.GetResolvedMask()); } } -StackFrame::StackFrame (const ThreadSP &thread_sp, - user_id_t frame_idx, - user_id_t unwind_frame_index, - const RegisterContextSP ®_context_sp, - addr_t cfa, - addr_t pc, - const SymbolContext *sc_ptr) : - m_thread_wp (thread_sp), - m_frame_index (frame_idx), - m_concrete_frame_index (unwind_frame_index), - m_reg_context_sp (reg_context_sp), - m_id(pc, cfa, nullptr), - m_frame_code_addr (pc), - m_sc (), - m_flags (), - m_frame_base (), - m_frame_base_error (), - m_cfa_is_valid (true), - m_stop_id (0), - m_stop_id_is_valid (false), - m_is_history_frame (false), - m_variable_list_sp (), - m_variable_list_value_objects (), - m_disassembly (), - m_mutex (Mutex::eMutexTypeRecursive) +StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx, user_id_t unwind_frame_index, + const RegisterContextSP ®_context_sp, addr_t cfa, addr_t pc, const SymbolContext *sc_ptr) + : m_thread_wp(thread_sp), + m_frame_index(frame_idx), + m_concrete_frame_index(unwind_frame_index), + m_reg_context_sp(reg_context_sp), + m_id(pc, cfa, nullptr), + m_frame_code_addr(pc), + m_sc(), + m_flags(), + m_frame_base(), + m_frame_base_error(), + m_cfa_is_valid(true), + m_stop_id(0), + m_stop_id_is_valid(false), + m_is_history_frame(false), + m_variable_list_sp(), + m_variable_list_value_objects(), + m_disassembly(), + m_mutex() { if (sc_ptr != nullptr) { m_sc = *sc_ptr; - m_flags.Set(m_sc.GetResolvedMask ()); + m_flags.Set(m_sc.GetResolvedMask()); } - + if (reg_context_sp && !m_sc.target_sp) { m_sc.target_sp = reg_context_sp->CalculateTarget(); if (m_sc.target_sp) - m_flags.Set (eSymbolContextTarget); + m_flags.Set(eSymbolContextTarget); } } -StackFrame::StackFrame (const ThreadSP &thread_sp, - user_id_t frame_idx, - user_id_t unwind_frame_index, - const RegisterContextSP ®_context_sp, - addr_t cfa, - const Address& pc_addr, - const SymbolContext *sc_ptr) : - m_thread_wp (thread_sp), - m_frame_index (frame_idx), - m_concrete_frame_index (unwind_frame_index), - m_reg_context_sp (reg_context_sp), - m_id(pc_addr.GetLoadAddress(thread_sp->CalculateTarget().get()), cfa, nullptr), - m_frame_code_addr (pc_addr), - m_sc (), - m_flags (), - m_frame_base (), - m_frame_base_error (), - m_cfa_is_valid (true), - m_stop_id (0), - m_stop_id_is_valid (false), - m_is_history_frame (false), - m_variable_list_sp (), - m_variable_list_value_objects (), - m_disassembly (), - m_mutex (Mutex::eMutexTypeRecursive) +StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx, user_id_t unwind_frame_index, + const RegisterContextSP ®_context_sp, addr_t cfa, const Address &pc_addr, + const SymbolContext *sc_ptr) + : m_thread_wp(thread_sp), + m_frame_index(frame_idx), + m_concrete_frame_index(unwind_frame_index), + m_reg_context_sp(reg_context_sp), + m_id(pc_addr.GetLoadAddress(thread_sp->CalculateTarget().get()), cfa, nullptr), + m_frame_code_addr(pc_addr), + m_sc(), + m_flags(), + m_frame_base(), + m_frame_base_error(), + m_cfa_is_valid(true), + m_stop_id(0), + m_stop_id_is_valid(false), + m_is_history_frame(false), + m_variable_list_sp(), + m_variable_list_value_objects(), + m_disassembly(), + m_mutex() { if (sc_ptr != nullptr) { m_sc = *sc_ptr; - m_flags.Set(m_sc.GetResolvedMask ()); + m_flags.Set(m_sc.GetResolvedMask()); } - + if (!m_sc.target_sp && reg_context_sp) { m_sc.target_sp = reg_context_sp->CalculateTarget(); if (m_sc.target_sp) - m_flags.Set (eSymbolContextTarget); + m_flags.Set(eSymbolContextTarget); } - - ModuleSP pc_module_sp (pc_addr.GetModule()); + + ModuleSP pc_module_sp(pc_addr.GetModule()); if (!m_sc.module_sp || m_sc.module_sp != pc_module_sp) { if (pc_module_sp) { m_sc.module_sp = pc_module_sp; - m_flags.Set (eSymbolContextModule); + m_flags.Set(eSymbolContextModule); } else { @@ -186,7 +170,7 @@ StackID& StackFrame::GetStackID() { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); // Make sure we have resolved the StackID object's symbol context scope if // we already haven't looked it up. @@ -233,7 +217,7 @@ void StackFrame::SetSymbolContextScope (SymbolContextScope *symbol_scope) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE); m_id.SetSymbolContextScope (symbol_scope); } @@ -241,7 +225,7 @@ const Address& StackFrame::GetFrameCodeAddress() { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR) && !m_frame_code_addr.IsSectionOffset()) { m_flags.Set (RESOLVED_FRAME_CODE_ADDR); @@ -272,7 +256,7 @@ bool StackFrame::ChangePC (addr_t pc) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); // We can't change the pc value of a history stack frame - it is immutable. if (m_is_history_frame) return false; @@ -288,7 +272,7 @@ const char * StackFrame::Disassemble () { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (m_disassembly.GetSize() == 0) { ExecutionContext exe_ctx (shared_from_this()); @@ -348,7 +332,7 @@ const SymbolContext& StackFrame::GetSymbolContext (uint32_t resolve_scope) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); // Copy our internal symbol context into "sc". if ((m_flags.Get() & resolve_scope) != resolve_scope) { @@ -521,7 +505,7 @@ VariableList * StackFrame::GetVariableList (bool get_file_globals) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (m_flags.IsClear(RESOLVED_VARIABLES)) { m_flags.Set(RESOLVED_VARIABLES); @@ -566,7 +550,7 @@ VariableListSP StackFrame::GetInScopeVariableList (bool get_file_globals, bool must_have_valid_location) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); // We can't fetch variable information for a history stack frame. if (m_is_history_frame) return VariableListSP(); @@ -1197,7 +1181,7 @@ bool StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (!m_cfa_is_valid) { m_frame_base_error.SetErrorString("No frame base available for this historical stack frame."); @@ -1255,7 +1239,7 @@ RegisterContextSP StackFrame::GetRegisterContext () { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (!m_reg_context_sp) { ThreadSP thread_sp (GetThread()); @@ -1275,7 +1259,7 @@ ValueObjectSP StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); ValueObjectSP valobj_sp; if (m_is_history_frame) { @@ -1311,7 +1295,7 @@ ValueObjectSP StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); if (m_is_history_frame) return ValueObjectSP(); @@ -1471,7 +1455,7 @@ void StackFrame::UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); assert (GetStackID() == prev_frame.GetStackID()); // TODO: remove this after some testing m_variable_list_sp = prev_frame.m_variable_list_sp; m_variable_list_value_objects.Swap (prev_frame.m_variable_list_value_objects); @@ -1482,7 +1466,7 @@ void StackFrame::UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame) { - Mutex::Locker locker(m_mutex); + std::lock_guard guard(m_mutex); assert (GetStackID() == curr_frame.GetStackID()); // TODO: remove this after some testing m_id.SetPC (curr_frame.m_id.GetPC()); // Update the Stack ID PC value assert (GetThread() == curr_frame.GetThread()); Index: source/Target/StackFrameList.cpp =================================================================== --- source/Target/StackFrameList.cpp +++ source/Target/StackFrameList.cpp @@ -36,26 +36,21 @@ //---------------------------------------------------------------------- // StackFrameList constructor //---------------------------------------------------------------------- -StackFrameList::StackFrameList -( - Thread &thread, - const lldb::StackFrameListSP &prev_frames_sp, - bool show_inline_frames -) : - m_thread (thread), - m_prev_frames_sp (prev_frames_sp), - m_mutex (Mutex::eMutexTypeRecursive), - m_frames (), - m_selected_frame_idx (0), - m_concrete_frames_fetched (0), - m_current_inlined_depth (UINT32_MAX), - m_current_inlined_pc (LLDB_INVALID_ADDRESS), - m_show_inlined_frames (show_inline_frames) +StackFrameList::StackFrameList(Thread &thread, const lldb::StackFrameListSP &prev_frames_sp, bool show_inline_frames) + : m_thread(thread), + m_prev_frames_sp(prev_frames_sp), + m_mutex(), + m_frames(), + m_selected_frame_idx(0), + m_concrete_frames_fetched(0), + m_current_inlined_depth(UINT32_MAX), + m_current_inlined_pc(LLDB_INVALID_ADDRESS), + m_show_inlined_frames(show_inline_frames) { if (prev_frames_sp) { m_current_inlined_depth = prev_frames_sp->m_current_inlined_depth; - m_current_inlined_pc = prev_frames_sp->m_current_inlined_pc; + m_current_inlined_pc = prev_frames_sp->m_current_inlined_pc; } } @@ -101,7 +96,7 @@ void StackFrameList::ResetCurrentInlinedDepth () { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (m_show_inlined_frames) { @@ -485,7 +480,7 @@ uint32_t StackFrameList::GetNumFrames (bool can_create) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (can_create) GetFramesUpTo (UINT32_MAX); @@ -502,7 +497,8 @@ { if (s == nullptr) return; - Mutex::Locker locker (m_mutex); + + std::lock_guard guard(m_mutex); const_iterator pos, begin = m_frames.begin(), end = m_frames.end(); for (pos = begin; pos != end; ++pos) @@ -525,7 +521,7 @@ StackFrameList::GetFrameAtIndex (uint32_t idx) { StackFrameSP frame_sp; - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); uint32_t original_idx = idx; uint32_t inlined_depth = GetCurrentInlinedDepth(); @@ -634,7 +630,7 @@ if (stack_id.IsValid()) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); uint32_t frame_idx = 0; // Do a binary search in case the stack frame is already in our cache collection::const_iterator begin = m_frames.begin(); @@ -680,14 +676,14 @@ uint32_t StackFrameList::GetSelectedFrameIndex () const { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); return m_selected_frame_idx; } uint32_t StackFrameList::SetSelectedFrame (lldb_private::StackFrame *frame) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); const_iterator pos; const_iterator begin = m_frames.begin(); const_iterator end = m_frames.end(); @@ -711,7 +707,7 @@ bool StackFrameList::SetSelectedFrameByIndex (uint32_t idx) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); StackFrameSP frame_sp (GetFrameAtIndex (idx)); if (frame_sp) { @@ -743,7 +739,7 @@ void StackFrameList::Clear () { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_frames.clear(); m_concrete_frames_fetched = 0; } @@ -751,7 +747,7 @@ void StackFrameList::InvalidateFrames (uint32_t start_idx) { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); if (m_show_inlined_frames) { Clear(); @@ -770,8 +766,11 @@ void StackFrameList::Merge (std::unique_ptr& curr_ap, lldb::StackFrameListSP& prev_sp) { - Mutex::Locker curr_locker(curr_ap ? &curr_ap->m_mutex : nullptr); - Mutex::Locker prev_locker(prev_sp ? &prev_sp->m_mutex : nullptr); + std::unique_lock current_lock, previous_lock; + if (curr_ap) + current_lock = std::unique_lock(curr_ap->m_mutex); + if (prev_sp) + previous_lock = std::unique_lock(prev_sp->m_mutex); #if defined (DEBUG_STACK_FRAMES) StreamFile s(stdout, false); Index: source/Target/Target.cpp =================================================================== --- source/Target/Target.cpp +++ source/Target/Target.cpp @@ -68,45 +68,47 @@ return class_name; } -Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp, bool is_dummy_target) : - TargetProperties (this), - Broadcaster (debugger.GetBroadcasterManager(), Target::GetStaticBroadcasterClass().AsCString()), - ExecutionContextScope (), - m_debugger (debugger), - m_platform_sp (platform_sp), - m_mutex (Mutex::eMutexTypeRecursive), - m_arch (target_arch), - m_images (this), - m_section_load_history (), - m_breakpoint_list (false), - m_internal_breakpoint_list (true), - m_watchpoint_list (), - m_process_sp (), - m_search_filter_sp (), - m_image_search_paths (ImageSearchPathsChanged, this), - m_ast_importer_sp (), - m_source_manager_ap(), - m_stop_hooks (), - m_stop_hook_next_id (0), - m_valid (true), - m_suppress_stop_hooks (false), - m_is_dummy_target(is_dummy_target) - -{ - SetEventName (eBroadcastBitBreakpointChanged, "breakpoint-changed"); - SetEventName (eBroadcastBitModulesLoaded, "modules-loaded"); - SetEventName (eBroadcastBitModulesUnloaded, "modules-unloaded"); - SetEventName (eBroadcastBitWatchpointChanged, "watchpoint-changed"); - SetEventName (eBroadcastBitSymbolsLoaded, "symbols-loaded"); +Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp, + bool is_dummy_target) + : TargetProperties(this), + Broadcaster(debugger.GetBroadcasterManager(), Target::GetStaticBroadcasterClass().AsCString()), + ExecutionContextScope(), + m_debugger(debugger), + m_platform_sp(platform_sp), + m_mutex(), + m_arch(target_arch), + m_images(this), + m_section_load_history(), + m_breakpoint_list(false), + m_internal_breakpoint_list(true), + m_watchpoint_list(), + m_process_sp(), + m_search_filter_sp(), + m_image_search_paths(ImageSearchPathsChanged, this), + m_ast_importer_sp(), + m_source_manager_ap(), + m_stop_hooks(), + m_stop_hook_next_id(0), + m_valid(true), + m_suppress_stop_hooks(false), + m_is_dummy_target(is_dummy_target) + +{ + SetEventName(eBroadcastBitBreakpointChanged, "breakpoint-changed"); + SetEventName(eBroadcastBitModulesLoaded, "modules-loaded"); + SetEventName(eBroadcastBitModulesUnloaded, "modules-unloaded"); + SetEventName(eBroadcastBitWatchpointChanged, "watchpoint-changed"); + SetEventName(eBroadcastBitSymbolsLoaded, "symbols-loaded"); CheckInWithManager(); - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT)); if (log) - log->Printf ("%p Target::Target()", static_cast(this)); + log->Printf("%p Target::Target()", static_cast(this)); if (m_arch.IsValid()) { - LogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET, "Target::Target created with architecture %s (%s)", m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str()); + LogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET, "Target::Target created with architecture %s (%s)", + m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str()); } } @@ -169,8 +171,8 @@ m_breakpoint_list.ClearAllBreakpointSites(); m_internal_breakpoint_list.ClearAllBreakpointSites(); // Disable watchpoints just on the debugger side. - Mutex::Locker locker; - this->GetWatchpointList().GetListMutex(locker); + std::unique_lock lock; + this->GetWatchpointList().GetListMutex(lock); DisableAllWatchpoints(false); ClearAllWatchpointHitCounts(); ClearAllWatchpointHistoricValues(); @@ -273,7 +275,7 @@ void Target::Destroy() { - Mutex::Locker locker (m_mutex); + std::lock_guard guard(m_mutex); m_valid = false; DeleteCurrentProcess (); m_platform_sp.reset(); @@ -753,8 +755,8 @@ // Grab the list mutex while doing operations. const bool notify = false; // Don't notify about all the state changes we do on creating the watchpoint. - Mutex::Locker locker; - this->GetWatchpointList().GetListMutex(locker); + std::unique_lock lock; + this->GetWatchpointList().GetListMutex(lock); WatchpointSP matched_sp = m_watchpoint_list.FindByAddress(addr); if (matched_sp) { Index: source/Target/ThreadCollection.cpp =================================================================== --- source/Target/ThreadCollection.cpp +++ source/Target/ThreadCollection.cpp @@ -30,14 +30,14 @@ void ThreadCollection::AddThread (const ThreadSP &thread_sp) { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); m_threads.push_back (thread_sp); } void ThreadCollection::InsertThread (const lldb::ThreadSP &thread_sp, uint32_t idx) { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); if (idx < m_threads.size()) m_threads.insert(m_threads.begin() + idx, thread_sp); else @@ -47,14 +47,14 @@ uint32_t ThreadCollection::GetSize () { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); return m_threads.size(); } ThreadSP ThreadCollection::GetThreadAtIndex (uint32_t idx) { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); ThreadSP thread_sp; if (idx < m_threads.size()) thread_sp = m_threads[idx]; Index: source/Target/ThreadList.cpp =================================================================== --- source/Target/ThreadList.cpp +++ source/Target/ThreadList.cpp @@ -53,7 +53,8 @@ { // Lock both mutexes to make sure neither side changes anyone on us // while the assignment occurs - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); + m_process = rhs.m_process; m_stop_id = rhs.m_stop_id; m_threads = rhs.m_threads; @@ -111,7 +112,8 @@ uint32_t ThreadList::GetSize (bool can_update) { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); + if (can_update) m_process->UpdateThreadListIfNeeded(); return m_threads.size(); @@ -120,7 +122,8 @@ ThreadSP ThreadList::GetThreadAtIndex (uint32_t idx, bool can_update) { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); + if (can_update) m_process->UpdateThreadListIfNeeded(); @@ -133,7 +136,7 @@ ThreadSP ThreadList::FindThreadByID (lldb::tid_t tid, bool can_update) { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); if (can_update) m_process->UpdateThreadListIfNeeded(); @@ -155,8 +158,8 @@ ThreadSP ThreadList::FindThreadByProtocolID (lldb::tid_t tid, bool can_update) { - Mutex::Locker locker(GetMutex()); - + std::lock_guard guard(GetMutex()); + if (can_update) m_process->UpdateThreadListIfNeeded(); @@ -178,8 +181,8 @@ ThreadSP ThreadList::RemoveThreadByID (lldb::tid_t tid, bool can_update) { - Mutex::Locker locker(GetMutex()); - + std::lock_guard guard(GetMutex()); + if (can_update) m_process->UpdateThreadListIfNeeded(); @@ -201,8 +204,8 @@ ThreadSP ThreadList::RemoveThreadByProtocolID (lldb::tid_t tid, bool can_update) { - Mutex::Locker locker(GetMutex()); - + std::lock_guard guard(GetMutex()); + if (can_update) m_process->UpdateThreadListIfNeeded(); @@ -227,7 +230,7 @@ ThreadSP thread_sp; if (thread_ptr) { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); uint32_t idx = 0; const uint32_t num_threads = m_threads.size(); @@ -248,7 +251,7 @@ ThreadSP ThreadList::FindThreadByIndexID (uint32_t index_id, bool can_update) { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); if (can_update) m_process->UpdateThreadListIfNeeded(); @@ -284,7 +287,7 @@ collection threads_copy; { // Scope for locker - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); m_process->UpdateThreadListIfNeeded(); for (lldb::ThreadSP thread_sp : m_threads) @@ -395,7 +398,7 @@ Vote ThreadList::ShouldReportStop (Event *event_ptr) { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); Vote result = eVoteNoOpinion; m_process->UpdateThreadListIfNeeded(); @@ -446,7 +449,8 @@ void ThreadList::SetShouldReportStop (Vote vote) { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); + m_process->UpdateThreadListIfNeeded(); collection::iterator pos, end = m_threads.end(); for (pos = m_threads.begin(); pos != end; ++pos) @@ -460,7 +464,7 @@ ThreadList::ShouldReportRun (Event *event_ptr) { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); Vote result = eVoteNoOpinion; m_process->UpdateThreadListIfNeeded(); @@ -499,7 +503,7 @@ void ThreadList::Clear() { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); m_stop_id = 0; m_threads.clear(); m_selected_tid = LLDB_INVALID_THREAD_ID; @@ -508,7 +512,7 @@ void ThreadList::Destroy() { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); const uint32_t num_threads = m_threads.size(); for (uint32_t idx = 0; idx < num_threads; ++idx) { @@ -519,7 +523,7 @@ void ThreadList::RefreshStateAfterStop () { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); m_process->UpdateThreadListIfNeeded(); @@ -537,7 +541,7 @@ { // You don't need to update the thread list here, because only threads // that you currently know about have any thread plans. - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); collection::iterator pos, end = m_threads.end(); for (pos = m_threads.begin(); pos != end; ++pos) @@ -552,7 +556,7 @@ // But we only do this for threads that are running, user suspended // threads stay where they are. - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); m_process->UpdateThreadListIfNeeded(); collection::iterator pos, end = m_threads.end(); @@ -700,7 +704,7 @@ void ThreadList::DidResume () { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); collection::iterator pos, end = m_threads.end(); for (pos = m_threads.begin(); pos != end; ++pos) { @@ -715,7 +719,7 @@ void ThreadList::DidStop () { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); collection::iterator pos, end = m_threads.end(); for (pos = m_threads.begin(); pos != end; ++pos) { @@ -736,7 +740,7 @@ ThreadSP ThreadList::GetSelectedThread () { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); ThreadSP thread_sp = FindThreadByID(m_selected_tid); if (!thread_sp.get()) { @@ -751,7 +755,7 @@ bool ThreadList::SetSelectedThreadByID (lldb::tid_t tid, bool notify) { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); ThreadSP selected_thread_sp(FindThreadByID(tid)); if (selected_thread_sp) { @@ -770,7 +774,7 @@ bool ThreadList::SetSelectedThreadByIndexID (uint32_t index_id, bool notify) { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); ThreadSP selected_thread_sp (FindThreadByIndexID(index_id)); if (selected_thread_sp.get()) { @@ -802,7 +806,8 @@ { // Lock both mutexes to make sure neither side changes anyone on us // while the assignment occurs - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); + m_process = rhs.m_process; m_stop_id = rhs.m_stop_id; m_threads.swap(rhs.m_threads); @@ -840,14 +845,14 @@ void ThreadList::Flush () { - Mutex::Locker locker(GetMutex()); + std::lock_guard guard(GetMutex()); collection::iterator pos, end = m_threads.end(); for (pos = m_threads.begin(); pos != end; ++pos) (*pos)->Flush (); } -Mutex & -ThreadList::GetMutex () +std::recursive_mutex & +ThreadList::GetMutex() { return m_process->m_thread_mutex; }