remove use of Mutex in favour of std::{,recursive_}mutex

This is a pretty straightforward first pass over removing a number of uses of
Mutex in favor of std::mutex or std::recursive_mutex. The problem is that there
are interfaces which take Mutex::Locker & to lock internal locks. This patch
cleans up most of the easy cases. The only non-trivial change is in
CommandObjectTarget.cpp where a Mutex::Locker was split into two.

llvm-svn: 269877
This commit is contained in:
Saleem Abdulrasool 2016-05-18 01:59:10 +00:00
parent a36a61d46a
commit 16ff860469
139 changed files with 1675 additions and 1801 deletions

View File

@ -13,13 +13,13 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <map> #include <map>
#include <mutex>
#include <vector> #include <vector>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/lldb-private.h" #include "lldb/lldb-private.h"
#include "lldb/Core/Address.h" #include "lldb/Core/Address.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Utility/Iterable.h" #include "lldb/Utility/Iterable.h"
namespace lldb_private { namespace lldb_private {
@ -270,7 +270,7 @@ protected:
Breakpoint &m_owner; Breakpoint &m_owner;
collection m_locations; // Vector of locations, sorted by ID collection m_locations; // Vector of locations, sorted by ID
addr_map m_address_to_location; addr_map m_address_to_location;
mutable Mutex m_mutex; mutable std::recursive_mutex m_mutex;
lldb::break_id_t m_next_id; lldb::break_id_t m_next_id;
BreakpointLocationCollection *m_new_location_recorder; BreakpointLocationCollection *m_new_location_recorder;

View File

@ -14,12 +14,12 @@
// C++ Includes // C++ Includes
#include <list> #include <list>
#include <mutex>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/lldb-forward.h" #include "lldb/lldb-forward.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Core/UserID.h" #include "lldb/Core/UserID.h"
#include "lldb/Breakpoint/StoppointLocation.h" #include "lldb/Breakpoint/StoppointLocation.h"
#include "lldb/Breakpoint/BreakpointLocationCollection.h" #include "lldb/Breakpoint/BreakpointLocationCollection.h"
@ -297,7 +297,7 @@ private:
// Consider adding an optimization where if there is only one // Consider adding an optimization where if there is only one
// owner, we don't store a list. The usual case will be only one owner... // owner, we don't store a list. The usual case will be only one owner...
BreakpointLocationCollection m_owners; ///< This has the BreakpointLocations that share this breakpoint site. BreakpointLocationCollection m_owners; ///< This has the BreakpointLocations that share this breakpoint site.
Mutex m_owners_mutex; ///< This mutex protects the owners collection. std::recursive_mutex m_owners_mutex; ///< This mutex protects the owners collection.
static lldb::break_id_t static lldb::break_id_t
GetNextID(); GetNextID();

View File

@ -12,12 +12,13 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <map>
#include <functional> #include <functional>
#include <map>
#include <mutex>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/Breakpoint/BreakpointSite.h" #include "lldb/Breakpoint/BreakpointSite.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private { namespace lldb_private {
@ -189,16 +190,17 @@ public:
size_t size_t
GetSize() const GetSize() const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_bp_site_list.size(); return m_bp_site_list.size();
} }
bool bool
IsEmpty() const IsEmpty() const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_bp_site_list.empty(); return m_bp_site_list.empty();
} }
protected: protected:
typedef std::map<lldb::addr_t, lldb::BreakpointSiteSP> collection; typedef std::map<lldb::addr_t, lldb::BreakpointSiteSP> collection;
@ -208,7 +210,7 @@ protected:
collection::const_iterator collection::const_iterator
GetIDConstIterator(lldb::break_id_t breakID) const; GetIDConstIterator(lldb::break_id_t breakID) const;
mutable Mutex m_mutex; mutable std::recursive_mutex m_mutex;
collection m_bp_site_list; // The breakpoint site list. collection m_bp_site_list; // The breakpoint site list.
}; };

View File

@ -15,6 +15,7 @@
#include <functional> #include <functional>
#include <list> #include <list>
#include <map> #include <map>
#include <mutex>
#include <string> #include <string>
#include <vector> #include <vector>
@ -22,7 +23,6 @@
// Project includes // Project includes
#include "lldb/lldb-private.h" #include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h" #include "lldb/Core/ConstString.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private { namespace lldb_private {
@ -127,7 +127,7 @@ private:
collection m_event_map; collection m_event_map;
listener_collection m_listeners; listener_collection m_listeners;
Mutex m_manager_mutex; mutable std::recursive_mutex m_manager_mutex;
// A couple of comparator classes for find_if: // A couple of comparator classes for find_if:
@ -625,7 +625,7 @@ protected:
Broadcaster &m_broadcaster; ///< The broadcsater that this implements Broadcaster &m_broadcaster; ///< The broadcsater that this implements
event_names_map m_event_names; ///< Optionally define event names for readability and logging for each event bit event_names_map m_event_names; ///< Optionally define event names for readability and logging for each event bit
collection m_listeners; ///< A list of Listener / event_mask pairs that are listening to this broadcaster. collection m_listeners; ///< A list of Listener / event_mask pairs that are listening to this broadcaster.
Mutex m_listeners_mutex; ///< A mutex that protects \a m_listeners. std::recursive_mutex m_listeners_mutex; ///< A mutex that protects \a m_listeners.
std::vector<lldb::ListenerSP> m_hijacking_listeners; // A simple mechanism to intercept events from a broadcaster std::vector<lldb::ListenerSP> m_hijacking_listeners; // A simple mechanism to intercept events from a broadcaster
std::vector<uint32_t> m_hijacking_masks; // At some point we may want to have a stack or Listener std::vector<uint32_t> m_hijacking_masks; // At some point we may want to have a stack or Listener
// collections, but for now this is just for private hijacking. // collections, but for now this is just for private hijacking.

View File

@ -13,6 +13,7 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <atomic> #include <atomic>
#include <mutex>
#include <string> #include <string>
// Other libraries and framework includes // Other libraries and framework includes
@ -21,7 +22,6 @@
#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Error.h" #include "lldb/Core/Error.h"
#include "lldb/Host/HostThread.h" #include "lldb/Host/HostThread.h"
#include "lldb/Host/Mutex.h"
#include "lldb/lldb-private.h" #include "lldb/lldb-private.h"
namespace lldb_private { namespace lldb_private {
@ -358,10 +358,10 @@ protected:
HostThread m_read_thread; ///< The read thread handle in case we need to cancel the thread. HostThread m_read_thread; ///< The read thread handle in case we need to cancel the thread.
std::atomic<bool> m_read_thread_enabled; std::atomic<bool> m_read_thread_enabled;
std::atomic<bool> m_read_thread_did_exit; std::atomic<bool> m_read_thread_did_exit;
std::string m_bytes; ///< A buffer to cache bytes read in the ReadThread function. std::string m_bytes; ///< A buffer to cache bytes read in the ReadThread function.
Mutex m_bytes_mutex; ///< A mutex to protect multi-threaded access to the cached bytes. std::recursive_mutex m_bytes_mutex; ///< A mutex to protect multi-threaded access to the cached bytes.
Mutex m_write_mutex; ///< Don't let multiple threads write at the same time... std::mutex m_write_mutex; ///< Don't let multiple threads write at the same time...
Mutex m_synchronize_mutex; std::mutex m_synchronize_mutex;
ReadThreadBytesReceived m_callback; ReadThreadBytesReceived m_callback;
void *m_callback_baton; void *m_callback_baton;
bool m_close_on_eof; bool m_close_on_eof;

View File

@ -14,13 +14,13 @@
#include <stdint.h> #include <stdint.h>
// C++ Includes // C++ Includes
#include <mutex>
#include <stack> #include <stack>
#include <string> #include <string>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/lldb-public.h" #include "lldb/lldb-public.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private { namespace lldb_private {
@ -34,11 +34,7 @@ class HistorySource
public: public:
typedef const void * HistoryEvent; typedef const void * HistoryEvent;
HistorySource () : HistorySource() : m_mutex(), m_events() {}
m_mutex (Mutex::eMutexTypeRecursive),
m_events ()
{
}
virtual virtual
~HistorySource() ~HistorySource()
@ -78,7 +74,7 @@ public:
private: private:
typedef std::stack<HistoryEvent> collection; typedef std::stack<HistoryEvent> collection;
Mutex m_mutex; std::recursive_mutex m_mutex;
collection m_events; collection m_events;
DISALLOW_COPY_AND_ASSIGN (HistorySource); DISALLOW_COPY_AND_ASSIGN (HistorySource);

View File

@ -15,6 +15,7 @@
// C++ Includes // C++ Includes
#include <memory> #include <memory>
#include <mutex>
#include <string> #include <string>
#include <vector> #include <vector>
@ -709,48 +710,43 @@ namespace lldb_private {
class IOHandlerStack class IOHandlerStack
{ {
public: public:
IOHandlerStack () : IOHandlerStack() : m_stack(), m_mutex(), m_top(nullptr) {}
m_stack(),
m_mutex(Mutex::eMutexTypeRecursive),
m_top (nullptr)
{
}
~IOHandlerStack() = default; ~IOHandlerStack() = default;
size_t size_t
GetSize () const GetSize() const
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_stack.size(); return m_stack.size();
} }
void void
Push (const lldb::IOHandlerSP& sp) Push(const lldb::IOHandlerSP &sp)
{ {
if (sp) if (sp)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
sp->SetPopped (false); sp->SetPopped(false);
m_stack.push_back (sp); m_stack.push_back(sp);
// Set m_top the non-locking IsTop() call // Set m_top the non-locking IsTop() call
m_top = sp.get(); m_top = sp.get();
} }
} }
bool bool
IsEmpty () const IsEmpty() const
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_stack.empty(); return m_stack.empty();
} }
lldb::IOHandlerSP lldb::IOHandlerSP
Top () Top()
{ {
lldb::IOHandlerSP sp; lldb::IOHandlerSP sp;
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_stack.empty()) if (!m_stack.empty())
sp = m_stack.back(); sp = m_stack.back();
} }
@ -758,21 +754,21 @@ namespace lldb_private {
} }
void void
Pop () Pop()
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_stack.empty()) if (!m_stack.empty())
{ {
lldb::IOHandlerSP sp (m_stack.back()); lldb::IOHandlerSP sp(m_stack.back());
m_stack.pop_back(); m_stack.pop_back();
sp->SetPopped (true); sp->SetPopped(true);
} }
// Set m_top the non-locking IsTop() call // Set m_top the non-locking IsTop() call
m_top = (m_stack.empty() ? nullptr : m_stack.back().get()); m_top = (m_stack.empty() ? nullptr : m_stack.back().get());
} }
Mutex & std::recursive_mutex &
GetMutex() GetMutex()
{ {
return m_mutex; return m_mutex;
@ -785,13 +781,12 @@ namespace lldb_private {
} }
bool bool
CheckTopIOHandlerTypes (IOHandler::Type top_type, IOHandler::Type second_top_type) CheckTopIOHandlerTypes(IOHandler::Type top_type, IOHandler::Type second_top_type)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
const size_t num_io_handlers = m_stack.size(); const size_t num_io_handlers = m_stack.size();
return (num_io_handlers >= 2 && return (num_io_handlers >= 2 && m_stack[num_io_handlers - 1]->GetType() == top_type &&
m_stack[num_io_handlers-1]->GetType() == top_type && m_stack[num_io_handlers - 2]->GetType() == second_top_type);
m_stack[num_io_handlers-2]->GetType() == second_top_type);
} }
ConstString ConstString
@ -818,7 +813,7 @@ namespace lldb_private {
protected: protected:
typedef std::vector<lldb::IOHandlerSP> collection; typedef std::vector<lldb::IOHandlerSP> collection;
collection m_stack; collection m_stack;
mutable Mutex m_mutex; mutable std::recursive_mutex m_mutex;
IOHandler *m_top; IOHandler *m_top;
private: private:

View File

@ -14,6 +14,7 @@
// C++ Includes // C++ Includes
#include <list> #include <list>
#include <map> #include <map>
#include <mutex>
#include <string> #include <string>
#include <vector> #include <vector>
@ -175,7 +176,7 @@ private:
std::string m_name; std::string m_name;
broadcaster_collection m_broadcasters; broadcaster_collection m_broadcasters;
Mutex m_broadcasters_mutex; // Protects m_broadcasters std::recursive_mutex m_broadcasters_mutex; // Protects m_broadcasters
event_collection m_events; event_collection m_events;
Mutex m_events_mutex; // Protects m_broadcasters and m_events Mutex m_events_mutex; // Protects m_broadcasters and m_events
Condition m_events_condition; Condition m_events_condition;

View File

@ -13,6 +13,7 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <atomic> #include <atomic>
#include <mutex>
#include <string> #include <string>
#include <vector> #include <vector>
@ -22,7 +23,6 @@
#include "lldb/Core/ArchSpec.h" #include "lldb/Core/ArchSpec.h"
#include "lldb/Core/UUID.h" #include "lldb/Core/UUID.h"
#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSpec.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/TimeValue.h" #include "lldb/Host/TimeValue.h"
#include "lldb/Symbol/SymbolContextScope.h" #include "lldb/Symbol/SymbolContextScope.h"
#include "lldb/Symbol/TypeSystem.h" #include "lldb/Symbol/TypeSystem.h"
@ -68,7 +68,7 @@ public:
static Module * static Module *
GetAllocatedModuleAtIndex (size_t idx); GetAllocatedModuleAtIndex (size_t idx);
static Mutex * static std::recursive_mutex &
GetAllocationModuleCollectionMutex(); GetAllocationModuleCollectionMutex();
//------------------------------------------------------------------ //------------------------------------------------------------------
@ -986,8 +986,8 @@ public:
// SymbolVendor, SymbolFile and ObjectFile member objects should // SymbolVendor, SymbolFile and ObjectFile member objects should
// lock the module mutex to avoid deadlocks. // lock the module mutex to avoid deadlocks.
//------------------------------------------------------------------ //------------------------------------------------------------------
Mutex & std::recursive_mutex &
GetMutex () const GetMutex() const
{ {
return m_mutex; return m_mutex;
} }
@ -1106,7 +1106,7 @@ protected:
//------------------------------------------------------------------ //------------------------------------------------------------------
// Member Variables // Member Variables
//------------------------------------------------------------------ //------------------------------------------------------------------
mutable Mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments. mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments.
TimeValue m_mod_time; ///< The modification time for this module when it was created. TimeValue m_mod_time; ///< The modification time for this module when it was created.
ArchSpec m_arch; ///< The architecture for this module. ArchSpec m_arch; ///< The architecture for this module.
UUID m_uuid; ///< Each module is assumed to have a unique identifier to help match it up to debug symbols. UUID m_uuid; ///< Each module is assumed to have a unique identifier to help match it up to debug symbols.

View File

@ -12,6 +12,7 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <mutex>
#include <vector> #include <vector>
// Other libraries and framework includes // Other libraries and framework includes
@ -20,7 +21,6 @@
#include "lldb/Core/Stream.h" #include "lldb/Core/Stream.h"
#include "lldb/Core/UUID.h" #include "lldb/Core/UUID.h"
#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSpec.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Target/PathMappingList.h" #include "lldb/Target/PathMappingList.h"
namespace lldb_private { namespace lldb_private {
@ -447,30 +447,24 @@ protected:
class ModuleSpecList class ModuleSpecList
{ {
public: public:
ModuleSpecList () : ModuleSpecList() : m_specs(), m_mutex() {}
m_specs(),
m_mutex(Mutex::eMutexTypeRecursive)
{
}
ModuleSpecList (const ModuleSpecList &rhs) : ModuleSpecList(const ModuleSpecList &rhs) : m_specs(), m_mutex()
m_specs(),
m_mutex(Mutex::eMutexTypeRecursive)
{ {
Mutex::Locker lhs_locker(m_mutex); std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
Mutex::Locker rhs_locker(rhs.m_mutex); std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
m_specs = rhs.m_specs; m_specs = rhs.m_specs;
} }
~ModuleSpecList() = default; ~ModuleSpecList() = default;
ModuleSpecList & ModuleSpecList &
operator = (const ModuleSpecList &rhs) operator=(const ModuleSpecList &rhs)
{ {
if (this != &rhs) if (this != &rhs)
{ {
Mutex::Locker lhs_locker(m_mutex); std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
Mutex::Locker rhs_locker(rhs.m_mutex); std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
m_specs = rhs.m_specs; m_specs = rhs.m_specs;
} }
return *this; return *this;
@ -479,29 +473,29 @@ public:
size_t size_t
GetSize() const GetSize() const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_specs.size(); return m_specs.size();
} }
void void
Clear () Clear()
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_specs.clear(); m_specs.clear();
} }
void void
Append (const ModuleSpec &spec) Append(const ModuleSpec &spec)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_specs.push_back (spec); m_specs.push_back(spec);
} }
void void
Append (const ModuleSpecList &rhs) Append(const ModuleSpecList &rhs)
{ {
Mutex::Locker lhs_locker(m_mutex); std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
Mutex::Locker rhs_locker(rhs.m_mutex); std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
m_specs.insert(m_specs.end(), rhs.m_specs.begin(), rhs.m_specs.end()); m_specs.insert(m_specs.end(), rhs.m_specs.begin(), rhs.m_specs.end());
} }
@ -514,9 +508,9 @@ public:
} }
bool bool
GetModuleSpecAtIndex (size_t i, ModuleSpec &module_spec) const GetModuleSpecAtIndex(size_t i, ModuleSpec &module_spec) const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (i < m_specs.size()) if (i < m_specs.size())
{ {
module_spec = m_specs[i]; module_spec = m_specs[i];
@ -527,11 +521,11 @@ public:
} }
bool bool
FindMatchingModuleSpec (const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const FindMatchingModuleSpec(const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
bool exact_arch_match = true; bool exact_arch_match = true;
for (auto spec: m_specs) for (auto spec : m_specs)
{ {
if (spec.Matches(module_spec, exact_arch_match)) if (spec.Matches(module_spec, exact_arch_match))
{ {
@ -544,7 +538,7 @@ public:
if (module_spec.GetArchitecturePtr()) if (module_spec.GetArchitecturePtr())
{ {
exact_arch_match = false; exact_arch_match = false;
for (auto spec: m_specs) for (auto spec : m_specs)
{ {
if (spec.Matches(module_spec, exact_arch_match)) if (spec.Matches(module_spec, exact_arch_match))
{ {
@ -558,39 +552,39 @@ public:
} }
size_t size_t
FindMatchingModuleSpecs (const ModuleSpec &module_spec, ModuleSpecList &matching_list) const FindMatchingModuleSpecs(const ModuleSpec &module_spec, ModuleSpecList &matching_list) const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
bool exact_arch_match = true; bool exact_arch_match = true;
const size_t initial_match_count = matching_list.GetSize(); const size_t initial_match_count = matching_list.GetSize();
for (auto spec: m_specs) for (auto spec : m_specs)
{ {
if (spec.Matches(module_spec, exact_arch_match)) if (spec.Matches(module_spec, exact_arch_match))
matching_list.Append (spec); matching_list.Append(spec);
} }
// If there was an architecture, retry with a compatible arch if no matches were found // If there was an architecture, retry with a compatible arch if no matches were found
if (module_spec.GetArchitecturePtr() && (initial_match_count == matching_list.GetSize())) if (module_spec.GetArchitecturePtr() && (initial_match_count == matching_list.GetSize()))
{ {
exact_arch_match = false; exact_arch_match = false;
for (auto spec: m_specs) for (auto spec : m_specs)
{ {
if (spec.Matches(module_spec, exact_arch_match)) if (spec.Matches(module_spec, exact_arch_match))
matching_list.Append (spec); matching_list.Append(spec);
} }
} }
return matching_list.GetSize() - initial_match_count; return matching_list.GetSize() - initial_match_count;
} }
void void
Dump (Stream &strm) Dump(Stream &strm)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
uint32_t idx = 0; uint32_t idx = 0;
for (auto spec: m_specs) for (auto spec : m_specs)
{ {
strm.Printf("[%u] ", idx); strm.Printf("[%u] ", idx);
spec.Dump (strm); spec.Dump(strm);
strm.EOL(); strm.EOL();
++idx; ++idx;
} }
@ -599,7 +593,7 @@ public:
protected: protected:
typedef std::vector<ModuleSpec> collection; ///< The module collection type. typedef std::vector<ModuleSpec> collection; ///< The module collection type.
collection m_specs; ///< The collection of modules. collection m_specs; ///< The collection of modules.
mutable Mutex m_mutex; mutable std::recursive_mutex m_mutex;
}; };
} // namespace lldb_private } // namespace lldb_private

View File

@ -10,11 +10,11 @@
#ifndef liblldb_StreamCallback_h_ #ifndef liblldb_StreamCallback_h_
#define liblldb_StreamCallback_h_ #define liblldb_StreamCallback_h_
#include <mutex>
#include <string> #include <string>
#include "lldb/Core/Stream.h" #include "lldb/Core/Stream.h"
#include "lldb/Core/StreamString.h" #include "lldb/Core/StreamString.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private { namespace lldb_private {
@ -37,7 +37,7 @@ private:
lldb::LogOutputCallback m_callback; lldb::LogOutputCallback m_callback;
void *m_baton; void *m_baton;
collection m_accumulated_data; collection m_accumulated_data;
Mutex m_collection_mutex; std::mutex m_collection_mutex;
StreamString &FindStreamForThread(lldb::tid_t cur_tid); StreamString &FindStreamForThread(lldb::tid_t cur_tid);
}; };

View File

@ -12,50 +12,37 @@
#include <limits.h> #include <limits.h>
#include <mutex>
#include "lldb/Core/Stream.h" #include "lldb/Core/Stream.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private { namespace lldb_private {
class StreamTee : public Stream class StreamTee : public Stream
{ {
public: public:
StreamTee () : StreamTee() : Stream(), m_streams_mutex(), m_streams() {}
Stream (),
m_streams_mutex (Mutex::eMutexTypeRecursive),
m_streams ()
{
}
StreamTee (lldb::StreamSP &stream_sp): StreamTee(lldb::StreamSP &stream_sp) : Stream(), m_streams_mutex(), m_streams()
Stream (),
m_streams_mutex (Mutex::eMutexTypeRecursive),
m_streams ()
{ {
// No need to lock mutex during construction // No need to lock mutex during construction
if (stream_sp) if (stream_sp)
m_streams.push_back (stream_sp); m_streams.push_back(stream_sp);
} }
StreamTee(lldb::StreamSP &stream_sp, lldb::StreamSP &stream_2_sp) : Stream(), m_streams_mutex(), m_streams()
StreamTee (lldb::StreamSP &stream_sp, lldb::StreamSP &stream_2_sp) :
Stream (),
m_streams_mutex (Mutex::eMutexTypeRecursive),
m_streams ()
{ {
// No need to lock mutex during construction // No need to lock mutex during construction
if (stream_sp) if (stream_sp)
m_streams.push_back (stream_sp); m_streams.push_back(stream_sp);
if (stream_2_sp) if (stream_2_sp)
m_streams.push_back (stream_2_sp); m_streams.push_back(stream_2_sp);
} }
StreamTee (const StreamTee &rhs) : StreamTee(const StreamTee &rhs) : Stream(rhs), m_streams_mutex(), m_streams()
Stream (rhs),
m_streams_mutex (Mutex::eMutexTypeRecursive),
m_streams() // Don't copy until we lock down "rhs"
{ {
Mutex::Locker locker (rhs.m_streams_mutex); // Don't copy until we lock down "rhs"
std::lock_guard<std::recursive_mutex> guard(rhs.m_streams_mutex);
m_streams = rhs.m_streams; m_streams = rhs.m_streams;
} }
@ -64,21 +51,22 @@ public:
} }
StreamTee & StreamTee &
operator = (const StreamTee &rhs) operator=(const StreamTee &rhs)
{ {
if (this != &rhs) { if (this != &rhs)
{
Stream::operator=(rhs); Stream::operator=(rhs);
Mutex::Locker lhs_locker (m_streams_mutex); std::lock_guard<std::recursive_mutex> lhs_locker(m_streams_mutex);
Mutex::Locker rhs_locker (rhs.m_streams_mutex); std::lock_guard<std::recursive_mutex> rhs_locker(rhs.m_streams_mutex);
m_streams = rhs.m_streams; m_streams = rhs.m_streams;
} }
return *this; return *this;
} }
void void
Flush () override Flush() override
{ {
Mutex::Locker locker (m_streams_mutex); std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
collection::iterator pos, end; collection::iterator pos, end;
for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos)
{ {
@ -88,14 +76,14 @@ public:
// to valid values. // to valid values.
Stream *strm = pos->get(); Stream *strm = pos->get();
if (strm) if (strm)
strm->Flush (); strm->Flush();
} }
} }
size_t size_t
Write (const void *s, size_t length) override Write(const void *s, size_t length) override
{ {
Mutex::Locker locker (m_streams_mutex); std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
if (m_streams.empty()) if (m_streams.empty())
return 0; return 0;
@ -110,7 +98,7 @@ public:
Stream *strm = pos->get(); Stream *strm = pos->get();
if (strm) if (strm)
{ {
const size_t bytes_written = strm->Write (s, length); const size_t bytes_written = strm->Write(s, length);
if (min_bytes_written > bytes_written) if (min_bytes_written > bytes_written)
min_bytes_written = bytes_written; min_bytes_written = bytes_written;
} }
@ -121,39 +109,39 @@ public:
} }
size_t size_t
AppendStream (const lldb::StreamSP &stream_sp) AppendStream(const lldb::StreamSP &stream_sp)
{ {
size_t new_idx = m_streams.size(); size_t new_idx = m_streams.size();
Mutex::Locker locker (m_streams_mutex); std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
m_streams.push_back (stream_sp); m_streams.push_back(stream_sp);
return new_idx; return new_idx;
} }
size_t size_t
GetNumStreams () const GetNumStreams() const
{ {
size_t result = 0; size_t result = 0;
{ {
Mutex::Locker locker (m_streams_mutex); std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
result = m_streams.size(); result = m_streams.size();
} }
return result; return result;
} }
lldb::StreamSP lldb::StreamSP
GetStreamAtIndex (uint32_t idx) GetStreamAtIndex(uint32_t idx)
{ {
lldb::StreamSP stream_sp; lldb::StreamSP stream_sp;
Mutex::Locker locker (m_streams_mutex); std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
if (idx < m_streams.size()) if (idx < m_streams.size())
stream_sp = m_streams[idx]; stream_sp = m_streams[idx];
return stream_sp; return stream_sp;
} }
void void
SetStreamAtIndex (uint32_t idx, const lldb::StreamSP& stream_sp) SetStreamAtIndex(uint32_t idx, const lldb::StreamSP &stream_sp)
{ {
Mutex::Locker locker (m_streams_mutex); std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
// Resize our stream vector as necessary to fit as many streams // Resize our stream vector as necessary to fit as many streams
// as needed. This also allows this class to be used with hard // as needed. This also allows this class to be used with hard
// coded indexes that can be used contain many streams, not all // coded indexes that can be used contain many streams, not all
@ -165,7 +153,7 @@ public:
protected: protected:
typedef std::vector<lldb::StreamSP> collection; typedef std::vector<lldb::StreamSP> collection;
mutable Mutex m_streams_mutex; mutable std::recursive_mutex m_streams_mutex;
collection m_streams; collection m_streams;
}; };

View File

@ -13,11 +13,11 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <map> #include <map>
#include <mutex>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/lldb-defines.h" #include "lldb/lldb-defines.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private { namespace lldb_private {
@ -31,11 +31,7 @@ public:
//------------------------------------------------------------------ //------------------------------------------------------------------
// Constructors and Destructors // Constructors and Destructors
//------------------------------------------------------------------ //------------------------------------------------------------------
ThreadSafeSTLMap() : ThreadSafeSTLMap() : m_collection(), m_mutex() {}
m_collection (),
m_mutex (Mutex::eMutexTypeRecursive)
{
}
~ThreadSafeSTLMap() ~ThreadSafeSTLMap()
{ {
@ -44,22 +40,22 @@ public:
bool bool
IsEmpty() const IsEmpty() const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_collection.empty(); return m_collection.empty();
} }
void void
Clear() Clear()
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_collection.clear(); return m_collection.clear();
} }
size_t size_t
Erase (const _Key& key) Erase(const _Key &key)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return EraseNoLock (key); return EraseNoLock(key);
} }
size_t size_t
@ -69,10 +65,10 @@ public:
} }
bool bool
GetValueForKey (const _Key& key, _Tp &value) const GetValueForKey(const _Key &key, _Tp &value) const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return GetValueForKeyNoLock (key, value); return GetValueForKeyNoLock(key, value);
} }
// Call this if you have already manually locked the mutex using the // Call this if you have already manually locked the mutex using the
@ -90,10 +86,10 @@ public:
} }
bool bool
GetFirstKeyForValue (const _Tp &value, _Key& key) const GetFirstKeyForValue(const _Tp &value, _Key &key) const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return GetFirstKeyForValueNoLock (value, key); return GetFirstKeyForValueNoLock(value, key);
} }
bool bool
@ -112,13 +108,10 @@ public:
} }
bool bool
LowerBound (const _Key& key, LowerBound(const _Key &key, _Key &match_key, _Tp &match_value, bool decrement_if_not_equal) const
_Key& match_key,
_Tp &match_value,
bool decrement_if_not_equal) const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return LowerBoundNoLock (key, match_key, match_value, decrement_if_not_equal); return LowerBoundNoLock(key, match_key, match_value, decrement_if_not_equal);
} }
bool bool
@ -149,10 +142,10 @@ public:
} }
void void
SetValueForKey (const _Key& key, const _Tp &value) SetValueForKey(const _Key &key, const _Tp &value)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
SetValueForKeyNoLock (key, value); SetValueForKeyNoLock(key, value);
} }
// Call this if you have already manually locked the mutex using the // Call this if you have already manually locked the mutex using the
@ -163,15 +156,15 @@ public:
m_collection[key] = value; m_collection[key] = value;
} }
Mutex & std::recursive_mutex &
GetMutex () GetMutex()
{ {
return m_mutex; return m_mutex;
} }
private: private:
collection m_collection; collection m_collection;
mutable Mutex m_mutex; mutable std::recursive_mutex m_mutex;
//------------------------------------------------------------------ //------------------------------------------------------------------
// For ThreadSafeSTLMap only // For ThreadSafeSTLMap only

View File

@ -11,10 +11,12 @@
#define liblldb_ThreadSafeValue_h_ #define liblldb_ThreadSafeValue_h_
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <mutex>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/Host/Mutex.h"
namespace lldb_private { namespace lldb_private {
@ -25,28 +27,20 @@ public:
//------------------------------------------------------------------ //------------------------------------------------------------------
// Constructors and Destructors // Constructors and Destructors
//------------------------------------------------------------------ //------------------------------------------------------------------
ThreadSafeValue() : ThreadSafeValue() : m_value(), m_mutex() {}
m_value (),
m_mutex (Mutex::eMutexTypeRecursive)
{
}
ThreadSafeValue(const T& value) : ThreadSafeValue(const T &value) : m_value(value), m_mutex() {}
m_value (value),
m_mutex (Mutex::eMutexTypeRecursive)
{
}
~ThreadSafeValue() ~ThreadSafeValue()
{ {
} }
T T
GetValue () const GetValue() const
{ {
T value; T value;
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
value = m_value; value = m_value;
} }
return value; return value;
@ -61,9 +55,9 @@ public:
} }
void void
SetValue (const T& value) SetValue(const T &value)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_value = value; m_value = value;
} }
@ -75,15 +69,15 @@ public:
m_value = value; m_value = value;
} }
Mutex & std::recursive_mutex &
GetMutex () GetMutex()
{ {
return m_mutex; return m_mutex;
} }
private: private:
T m_value; T m_value;
mutable Mutex m_mutex; mutable std::recursive_mutex m_mutex;
//------------------------------------------------------------------ //------------------------------------------------------------------
// For ThreadSafeValue only // For ThreadSafeValue only

View File

@ -24,7 +24,6 @@
#include "lldb/Core/StringList.h" #include "lldb/Core/StringList.h"
#include "lldb/Core/Stream.h" #include "lldb/Core/Stream.h"
#include "lldb/Core/StreamString.h" #include "lldb/Core/StreamString.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Interpreter/OptionValue.h" #include "lldb/Interpreter/OptionValue.h"
namespace lldb_private { namespace lldb_private {

View File

@ -1034,32 +1034,29 @@ protected:
class ChildrenManager class ChildrenManager
{ {
public: public:
ChildrenManager() : ChildrenManager() : m_mutex(), m_children(), m_children_count(0) {}
m_mutex(Mutex::eMutexTypeRecursive),
m_children(),
m_children_count(0)
{}
bool bool
HasChildAtIndex (size_t idx) HasChildAtIndex(size_t idx)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return (m_children.find(idx) != m_children.end()); return (m_children.find(idx) != m_children.end());
} }
ValueObject* ValueObject *
GetChildAtIndex (size_t idx) GetChildAtIndex(size_t idx)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
const auto iter = m_children.find(idx); const auto iter = m_children.find(idx);
return ((iter == m_children.end()) ? nullptr : iter->second); return ((iter == m_children.end()) ? nullptr : iter->second);
} }
void void
SetChildAtIndex (size_t idx, ValueObject* valobj) SetChildAtIndex(size_t idx, ValueObject *valobj)
{ {
ChildrenPair pair(idx,valobj); // we do not need to be mutex-protected to make a pair // we do not need to be mutex-protected to make a pair
Mutex::Locker locker(m_mutex); ChildrenPair pair(idx, valobj);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_children.insert(pair); m_children.insert(pair);
} }
@ -1078,7 +1075,7 @@ protected:
void void
Clear(size_t new_count = 0) Clear(size_t new_count = 0)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_children_count = new_count; m_children_count = new_count;
m_children.clear(); m_children.clear();
} }
@ -1087,7 +1084,7 @@ protected:
typedef std::map<size_t, ValueObject*> ChildrenMap; typedef std::map<size_t, ValueObject*> ChildrenMap;
typedef ChildrenMap::iterator ChildrenIterator; typedef ChildrenMap::iterator ChildrenIterator;
typedef ChildrenMap::value_type ChildrenPair; typedef ChildrenMap::value_type ChildrenPair;
Mutex m_mutex; std::recursive_mutex m_mutex;
ChildrenMap m_children; ChildrenMap m_children;
size_t m_children_count; size_t m_children_count;
}; };

View File

@ -13,12 +13,12 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <map> #include <map>
#include <mutex>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/lldb-public.h" #include "lldb/lldb-public.h"
#include "lldb/Core/ConstString.h" #include "lldb/Core/ConstString.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private { namespace lldb_private {
class FormatCache class FormatCache
@ -82,7 +82,7 @@ private:
}; };
typedef std::map<ConstString,Entry> CacheMap; typedef std::map<ConstString,Entry> CacheMap;
CacheMap m_map; CacheMap m_map;
Mutex m_mutex; std::recursive_mutex m_mutex;
uint64_t m_cache_hits; uint64_t m_cache_hits;
uint64_t m_cache_misses; uint64_t m_cache_misses;

View File

@ -15,6 +15,7 @@
#include <atomic> #include <atomic>
#include <initializer_list> #include <initializer_list>
#include <map> #include <map>
#include <mutex>
#include <vector> #include <vector>
// Other libraries and framework includes // Other libraries and framework includes
@ -289,7 +290,7 @@ private:
std::atomic<uint32_t> m_last_revision; std::atomic<uint32_t> m_last_revision;
FormatCache m_format_cache; FormatCache m_format_cache;
Mutex m_language_categories_mutex; std::recursive_mutex m_language_categories_mutex;
LanguageCategories m_language_categories_map; LanguageCategories m_language_categories_map;
NamedSummariesMap m_named_summaries_map; NamedSummariesMap m_named_summaries_map;
TypeCategoryMap m_categories_map; TypeCategoryMap m_categories_map;

View File

@ -15,6 +15,7 @@
#include <functional> #include <functional>
#include <map> #include <map>
#include <memory> #include <memory>
#include <mutex>
#include <string> #include <string>
// Other libraries and framework includes // Other libraries and framework includes
@ -82,32 +83,26 @@ public:
typedef typename MapType::iterator MapIterator; typedef typename MapType::iterator MapIterator;
typedef std::function<bool(KeyType, const ValueSP&)> ForEachCallback; typedef std::function<bool(KeyType, const ValueSP&)> ForEachCallback;
FormatMap(IFormatChangeListener* lst) : FormatMap(IFormatChangeListener *lst) : m_map(), m_map_mutex(), listener(lst) {}
m_map(),
m_map_mutex(Mutex::eMutexTypeRecursive),
listener(lst)
{
}
void void
Add(KeyType name, Add(KeyType name, const ValueSP &entry)
const ValueSP& entry)
{ {
if (listener) if (listener)
entry->GetRevision() = listener->GetCurrentRevision(); entry->GetRevision() = listener->GetCurrentRevision();
else else
entry->GetRevision() = 0; entry->GetRevision() = 0;
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
m_map[name] = entry; m_map[name] = entry;
if (listener) if (listener)
listener->Changed(); listener->Changed();
} }
bool bool
Delete (KeyType name) Delete(KeyType name)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
MapIterator iter = m_map.find(name); MapIterator iter = m_map.find(name);
if (iter == m_map.end()) if (iter == m_map.end())
return false; return false;
@ -118,19 +113,18 @@ public:
} }
void void
Clear () Clear()
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
m_map.clear(); m_map.clear();
if (listener) if (listener)
listener->Changed(); listener->Changed();
} }
bool bool
Get(KeyType name, Get(KeyType name, ValueSP &entry)
ValueSP& entry)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
MapIterator iter = m_map.find(name); MapIterator iter = m_map.find(name);
if (iter == m_map.end()) if (iter == m_map.end())
return false; return false;
@ -139,11 +133,11 @@ public:
} }
void void
ForEach (ForEachCallback callback) ForEach(ForEachCallback callback)
{ {
if (callback) if (callback)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
MapIterator pos, end = m_map.end(); MapIterator pos, end = m_map.end();
for (pos = m_map.begin(); pos != end; pos++) for (pos = m_map.begin(); pos != end; pos++)
{ {
@ -161,9 +155,9 @@ public:
} }
ValueSP ValueSP
GetValueAtIndex (size_t index) GetValueAtIndex(size_t index)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
MapIterator iter = m_map.begin(); MapIterator iter = m_map.begin();
MapIterator end = m_map.end(); MapIterator end = m_map.end();
while (index > 0) while (index > 0)
@ -177,9 +171,9 @@ public:
} }
KeyType KeyType
GetKeyAtIndex (size_t index) GetKeyAtIndex(size_t index)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
MapIterator iter = m_map.begin(); MapIterator iter = m_map.begin();
MapIterator end = m_map.end(); MapIterator end = m_map.end();
while (index > 0) while (index > 0)
@ -194,7 +188,7 @@ public:
protected: protected:
MapType m_map; MapType m_map;
Mutex m_map_mutex; std::recursive_mutex m_map_mutex;
IFormatChangeListener* listener; IFormatChangeListener* listener;
MapType& MapType&
@ -203,8 +197,8 @@ protected:
return m_map; return m_map;
} }
Mutex& std::recursive_mutex &
mutex () mutex()
{ {
return m_map_mutex; return m_map_mutex;
} }
@ -332,23 +326,22 @@ protected:
} }
bool bool
Delete_Impl (ConstString type, lldb::RegularExpressionSP *dummy) Delete_Impl(ConstString type, lldb::RegularExpressionSP *dummy)
{ {
Mutex& x_mutex = m_format_map.mutex(); std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
lldb_private::Mutex::Locker locker(x_mutex); MapIterator pos, end = m_format_map.map().end();
MapIterator pos, end = m_format_map.map().end(); for (pos = m_format_map.map().begin(); pos != end; pos++)
for (pos = m_format_map.map().begin(); pos != end; pos++) {
{ lldb::RegularExpressionSP regex = pos->first;
lldb::RegularExpressionSP regex = pos->first; if (::strcmp(type.AsCString(), regex->GetText()) == 0)
if ( ::strcmp(type.AsCString(),regex->GetText()) == 0) {
{ m_format_map.map().erase(pos);
m_format_map.map().erase(pos); if (m_format_map.listener)
if (m_format_map.listener) m_format_map.listener->Changed();
m_format_map.listener->Changed(); return true;
return true; }
} }
} return false;
return false;
} }
bool bool
@ -385,36 +378,34 @@ protected:
} }
bool bool
Get_Impl (ConstString key, MapValueType& value, lldb::RegularExpressionSP *dummy) Get_Impl(ConstString key, MapValueType &value, lldb::RegularExpressionSP *dummy)
{ {
const char* key_cstr = key.AsCString(); const char *key_cstr = key.AsCString();
if (!key_cstr) if (!key_cstr)
return false; return false;
Mutex& x_mutex = m_format_map.mutex(); std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
lldb_private::Mutex::Locker locker(x_mutex);
MapIterator pos, end = m_format_map.map().end();
for (pos = m_format_map.map().begin(); pos != end; pos++)
{
lldb::RegularExpressionSP regex = pos->first;
if (regex->Execute(key_cstr))
{
value = pos->second;
return true;
}
}
return false;
}
bool
GetExact_Impl (ConstString key, MapValueType& value, lldb::RegularExpressionSP *dummy)
{
Mutex& x_mutex = m_format_map.mutex();
lldb_private::Mutex::Locker locker(x_mutex);
MapIterator pos, end = m_format_map.map().end(); MapIterator pos, end = m_format_map.map().end();
for (pos = m_format_map.map().begin(); pos != end; pos++) for (pos = m_format_map.map().begin(); pos != end; pos++)
{ {
lldb::RegularExpressionSP regex = pos->first; lldb::RegularExpressionSP regex = pos->first;
if (strcmp(regex->GetText(),key.AsCString()) == 0) if (regex->Execute(key_cstr))
{
value = pos->second;
return true;
}
}
return false;
}
bool
GetExact_Impl(ConstString key, MapValueType &value, lldb::RegularExpressionSP *dummy)
{
std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
MapIterator pos, end = m_format_map.map().end();
for (pos = m_format_map.map().begin(); pos != end; pos++)
{
lldb::RegularExpressionSP regex = pos->first;
if (strcmp(regex->GetText(), key.AsCString()) == 0)
{ {
value = pos->second; value = pos->second;
return true; return true;

View File

@ -14,6 +14,7 @@
// C++ Includes // C++ Includes
#include <initializer_list> #include <initializer_list>
#include <memory> #include <memory>
#include <mutex>
#include <string> #include <string>
#include <vector> #include <vector>
@ -520,7 +521,7 @@ namespace lldb_private {
IFormatChangeListener* m_change_listener; IFormatChangeListener* m_change_listener;
Mutex m_mutex; std::recursive_mutex m_mutex;
ConstString m_name; ConstString m_name;

View File

@ -15,6 +15,7 @@
#include <functional> #include <functional>
#include <list> #include <list>
#include <map> #include <map>
#include <mutex>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
@ -132,7 +133,7 @@ namespace lldb_private {
} }
}; };
Mutex m_map_mutex; std::recursive_mutex m_map_mutex;
IFormatChangeListener* listener; IFormatChangeListener* listener;
MapType m_map; MapType m_map;
@ -148,7 +149,8 @@ namespace lldb_private {
return m_active_categories; return m_active_categories;
} }
Mutex& mutex () std::recursive_mutex &
mutex()
{ {
return m_map_mutex; return m_map_mutex;
} }

View File

@ -26,7 +26,6 @@
#include "lldb/lldb-private.h" #include "lldb/lldb-private.h"
#include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataBufferHeap.h"
#include "lldb/Expression/IRMemoryMap.h" #include "lldb/Expression/IRMemoryMap.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/SymbolContext.h"

View File

@ -50,13 +50,13 @@
#endif #endif
#endif #endif
#include <mutex>
#include <string> #include <string>
#include <vector> #include <vector>
#include "lldb/Host/Condition.h" #include "lldb/Host/Condition.h"
#include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSpec.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Predicate.h" #include "lldb/Host/Predicate.h"
namespace lldb_private { namespace lldb_private {
@ -359,7 +359,7 @@ namespace lldb_private {
CompleteCallbackType m_completion_callback = nullptr; CompleteCallbackType m_completion_callback = nullptr;
void * m_completion_callback_baton = nullptr; void * m_completion_callback_baton = nullptr;
Mutex m_output_mutex; std::mutex m_output_mutex;
}; };
} }

View File

@ -18,7 +18,6 @@
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/lldb-defines.h" #include "lldb/lldb-defines.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Condition.h" #include "lldb/Host/Condition.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -12,11 +12,11 @@
#include "lldb/lldb-private-forward.h" #include "lldb/lldb-private-forward.h"
#include "lldb/Core/Error.h" #include "lldb/Core/Error.h"
#include "lldb/Host/Mutex.h"
// #include "lldb/Host/NativeBreakpoint.h" // #include "lldb/Host/NativeBreakpoint.h"
#include <functional> #include <functional>
#include <map> #include <map>
#include <mutex>
namespace lldb_private namespace lldb_private
{ {
@ -48,7 +48,7 @@ namespace lldb_private
private: private:
typedef std::map<lldb::addr_t, NativeBreakpointSP> BreakpointMap; typedef std::map<lldb::addr_t, NativeBreakpointSP> BreakpointMap;
Mutex m_mutex; std::recursive_mutex m_mutex;
BreakpointMap m_breakpoints; BreakpointMap m_breakpoints;
}; };
} }

View File

@ -10,12 +10,12 @@
#ifndef liblldb_NativeProcessProtocol_h_ #ifndef liblldb_NativeProcessProtocol_h_
#define liblldb_NativeProcessProtocol_h_ #define liblldb_NativeProcessProtocol_h_
#include <mutex>
#include <vector> #include <vector>
#include "lldb/lldb-private-forward.h" #include "lldb/lldb-private-forward.h"
#include "lldb/lldb-types.h" #include "lldb/lldb-types.h"
#include "lldb/Core/Error.h" #include "lldb/Core/Error.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/MainLoop.h" #include "lldb/Host/MainLoop.h"
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
@ -364,15 +364,15 @@ namespace lldb_private
std::vector<NativeThreadProtocolSP> m_threads; std::vector<NativeThreadProtocolSP> m_threads;
lldb::tid_t m_current_thread_id; lldb::tid_t m_current_thread_id;
mutable Mutex m_threads_mutex; mutable std::recursive_mutex m_threads_mutex;
lldb::StateType m_state; lldb::StateType m_state;
mutable Mutex m_state_mutex; mutable std::recursive_mutex m_state_mutex;
lldb_private::ExitType m_exit_type; lldb_private::ExitType m_exit_type;
int m_exit_status; int m_exit_status;
std::string m_exit_description; std::string m_exit_description;
Mutex m_delegates_mutex; std::recursive_mutex m_delegates_mutex;
std::vector<NativeDelegate*> m_delegates; std::vector<NativeDelegate*> m_delegates;
NativeBreakpointList m_breakpoint_list; NativeBreakpointList m_breakpoint_list;
NativeWatchpointList m_watchpoint_list; NativeWatchpointList m_watchpoint_list;

View File

@ -13,13 +13,13 @@
// C++ Includes // C++ Includes
#include <atomic> #include <atomic>
#include <memory> #include <memory>
#include <mutex>
#include "lldb/lldb-forward.h" #include "lldb/lldb-forward.h"
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/Core/Connection.h" #include "lldb/Core/Connection.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Pipe.h" #include "lldb/Host/Pipe.h"
#include "lldb/Host/Predicate.h" #include "lldb/Host/Predicate.h"
#include "lldb/Host/IOObject.h" #include "lldb/Host/IOObject.h"
@ -105,7 +105,7 @@ class ConnectionFileDescriptor : public Connection
// the port number. // the port number.
Pipe m_pipe; Pipe m_pipe;
Mutex m_mutex; std::recursive_mutex m_mutex;
std::atomic<bool> m_shutting_down; // This marks that we are shutting down so if we get woken up from std::atomic<bool> m_shutting_down; // This marks that we are shutting down so if we get woken up from
// BytesAvailable to disconnect, we won't try to read again. // BytesAvailable to disconnect, we won't try to read again.
bool m_waiting_for_accept; bool m_waiting_for_accept;

View File

@ -11,9 +11,9 @@
#define LLDB_INITIALIZATION_SYSTEM_LIFETIME_MANAGER_H #define LLDB_INITIALIZATION_SYSTEM_LIFETIME_MANAGER_H
#include "lldb/lldb-private-types.h" #include "lldb/lldb-private-types.h"
#include "lldb/Host/Mutex.h"
#include <memory> #include <memory>
#include <mutex>
namespace lldb_private namespace lldb_private
{ {
@ -29,13 +29,14 @@ class SystemLifetimeManager
void Terminate(); void Terminate();
private: private:
Mutex m_mutex; std::recursive_mutex m_mutex;
std::unique_ptr<SystemInitializer> m_initializer; std::unique_ptr<SystemInitializer> m_initializer;
bool m_initialized; bool m_initialized;
// Noncopyable. // Noncopyable.
SystemLifetimeManager(const SystemLifetimeManager &other) = delete; SystemLifetimeManager(const SystemLifetimeManager &other) = delete;
SystemLifetimeManager &operator=(const SystemLifetimeManager &other) = delete; SystemLifetimeManager &
operator=(const SystemLifetimeManager &other) = delete;
}; };
} }

View File

@ -12,6 +12,7 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <mutex>
#include <string> #include <string>
#include <vector> #include <vector>
@ -19,7 +20,6 @@
// Project includes // Project includes
#include "lldb/lldb-private.h" #include "lldb/lldb-private.h"
#include "lldb/Core/Stream.h" #include "lldb/Core/Stream.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private { namespace lldb_private {
@ -66,7 +66,7 @@ private:
DISALLOW_COPY_AND_ASSIGN(CommandHistory); DISALLOW_COPY_AND_ASSIGN(CommandHistory);
typedef std::vector<std::string> History; typedef std::vector<std::string> History;
mutable Mutex m_mutex; mutable std::recursive_mutex m_mutex;
History m_history; History m_history;
}; };

View File

@ -14,7 +14,6 @@
#include "lldb/Core/DataExtractor.h" #include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RangeMap.h" #include "lldb/Core/RangeMap.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/ObjectFile.h"
#include "lldb/lldb-private.h" #include "lldb/lldb-private.h"

View File

@ -1,12 +1,12 @@
#ifndef liblldb_FuncUnwinders_h #ifndef liblldb_FuncUnwinders_h
#define liblldb_FuncUnwinders_h #define liblldb_FuncUnwinders_h
#include <mutex>
#include <vector> #include <vector>
#include "lldb/Core/AddressRange.h" #include "lldb/Core/AddressRange.h"
#include "lldb/Core/ArchSpec.h" #include "lldb/Core/ArchSpec.h"
#include "lldb/Core/AddressRange.h" #include "lldb/Core/AddressRange.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private { namespace lldb_private {
@ -119,7 +119,7 @@ private:
UnwindTable& m_unwind_table; UnwindTable& m_unwind_table;
AddressRange m_range; AddressRange m_range;
Mutex m_mutex; std::recursive_mutex m_mutex;
lldb::UnwindPlanSP m_unwind_plan_assembly_sp; lldb::UnwindPlanSP m_unwind_plan_assembly_sp;
lldb::UnwindPlanSP m_unwind_plan_eh_frame_sp; lldb::UnwindPlanSP m_unwind_plan_eh_frame_sp;

View File

@ -10,10 +10,10 @@
#ifndef liblldb_JITLoaderList_h_ #ifndef liblldb_JITLoaderList_h_
#define liblldb_JITLoaderList_h_ #define liblldb_JITLoaderList_h_
#include <mutex>
#include <vector> #include <vector>
#include "lldb/lldb-forward.h" #include "lldb/lldb-forward.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private { namespace lldb_private {
@ -52,7 +52,7 @@ public:
private: private:
std::vector<lldb::JITLoaderSP> m_jit_loaders_vec; std::vector<lldb::JITLoaderSP> m_jit_loaders_vec;
lldb_private::Mutex m_jit_loaders_mutex; std::recursive_mutex m_jit_loaders_mutex;
}; };
} // namespace lldb_private } // namespace lldb_private

View File

@ -15,6 +15,7 @@
#include <functional> #include <functional>
#include <map> #include <map>
#include <memory> #include <memory>
#include <mutex>
#include <string> #include <string>
#include <vector> #include <vector>
@ -28,7 +29,6 @@
#include "lldb/Core/UserSettingsController.h" #include "lldb/Core/UserSettingsController.h"
#include "lldb/Interpreter/Options.h" #include "lldb/Interpreter/Options.h"
#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSpec.h"
#include "lldb/Host/Mutex.h"
// TODO pull NativeDelegate class out of NativeProcessProtocol so we // TODO pull NativeDelegate class out of NativeProcessProtocol so we
// can just forward ref the NativeDelegate rather than include it here. // can just forward ref the NativeDelegate rather than include it here.
@ -1079,7 +1079,8 @@ class ModuleCache;
uint32_t m_update_os_version; uint32_t m_update_os_version;
ArchSpec m_system_arch; // The architecture of the kernel or the remote platform ArchSpec m_system_arch; // The architecture of the kernel or the remote platform
typedef std::map<uint32_t, ConstString> IDToNameMap; typedef std::map<uint32_t, ConstString> IDToNameMap;
Mutex m_mutex; // Mutex for modifying Platform data structures that should only be used for non-reentrant code // Mutex for modifying Platform data structures that should only be used for non-reentrant code
std::mutex m_mutex;
IDToNameMap m_uid_map; IDToNameMap m_uid_map;
IDToNameMap m_gid_map; IDToNameMap m_gid_map;
size_t m_max_uid_name_len; size_t m_max_uid_name_len;
@ -1112,9 +1113,9 @@ class ModuleCache;
CalculateTrapHandlerSymbolNames () = 0; CalculateTrapHandlerSymbolNames () = 0;
const char * const char *
GetCachedUserName (uint32_t uid) GetCachedUserName(uint32_t uid)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
// return the empty string if our string is NULL // return the empty string if our string is NULL
// so we can tell when things were in the negative // so we can tell when things were in the negative
// cached (didn't find a valid user name, don't keep // cached (didn't find a valid user name, don't keep
@ -1124,10 +1125,10 @@ class ModuleCache;
} }
const char * const char *
SetCachedUserName (uint32_t uid, const char *name, size_t name_len) SetCachedUserName(uint32_t uid, const char *name, size_t name_len)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
ConstString const_name (name); ConstString const_name(name);
m_uid_map[uid] = const_name; m_uid_map[uid] = const_name;
if (m_max_uid_name_len < name_len) if (m_max_uid_name_len < name_len)
m_max_uid_name_len = name_len; m_max_uid_name_len = name_len;
@ -1136,23 +1137,23 @@ class ModuleCache;
} }
void void
SetUserNameNotFound (uint32_t uid) SetUserNameNotFound(uint32_t uid)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
m_uid_map[uid] = ConstString(); m_uid_map[uid] = ConstString();
} }
void void
ClearCachedUserNames () ClearCachedUserNames()
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
m_uid_map.clear(); m_uid_map.clear();
} }
const char * const char *
GetCachedGroupName (uint32_t gid) GetCachedGroupName(uint32_t gid)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
// return the empty string if our string is NULL // return the empty string if our string is NULL
// so we can tell when things were in the negative // so we can tell when things were in the negative
// cached (didn't find a valid group name, don't keep // cached (didn't find a valid group name, don't keep
@ -1162,10 +1163,10 @@ class ModuleCache;
} }
const char * const char *
SetCachedGroupName (uint32_t gid, const char *name, size_t name_len) SetCachedGroupName(uint32_t gid, const char *name, size_t name_len)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
ConstString const_name (name); ConstString const_name(name);
m_gid_map[gid] = const_name; m_gid_map[gid] = const_name;
if (m_max_gid_name_len < name_len) if (m_max_gid_name_len < name_len)
m_max_gid_name_len = name_len; m_max_gid_name_len = name_len;
@ -1174,16 +1175,16 @@ class ModuleCache;
} }
void void
SetGroupNameNotFound (uint32_t gid) SetGroupNameNotFound(uint32_t gid)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
m_gid_map[gid] = ConstString(); m_gid_map[gid] = ConstString();
} }
void void
ClearCachedGroupNames () ClearCachedGroupNames()
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
m_gid_map.clear(); m_gid_map.clear();
} }
@ -1236,20 +1237,15 @@ class ModuleCache;
class PlatformList class PlatformList
{ {
public: public:
PlatformList() : PlatformList() : m_mutex(), m_platforms(), m_selected_platform_sp() {}
m_mutex (Mutex::eMutexTypeRecursive),
m_platforms (),
m_selected_platform_sp()
{
}
~PlatformList() = default; ~PlatformList() = default;
void void
Append (const lldb::PlatformSP &platform_sp, bool set_selected) Append(const lldb::PlatformSP &platform_sp, bool set_selected)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_platforms.push_back (platform_sp); m_platforms.push_back(platform_sp);
if (set_selected) if (set_selected)
m_selected_platform_sp = m_platforms.back(); m_selected_platform_sp = m_platforms.back();
} }
@ -1257,16 +1253,16 @@ class ModuleCache;
size_t size_t
GetSize() GetSize()
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_platforms.size(); return m_platforms.size();
} }
lldb::PlatformSP lldb::PlatformSP
GetAtIndex (uint32_t idx) GetAtIndex(uint32_t idx)
{ {
lldb::PlatformSP platform_sp; lldb::PlatformSP platform_sp;
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (idx < m_platforms.size()) if (idx < m_platforms.size())
platform_sp = m_platforms[idx]; platform_sp = m_platforms[idx];
} }
@ -1283,9 +1279,9 @@ class ModuleCache;
/// processes. /// processes.
//------------------------------------------------------------------ //------------------------------------------------------------------
lldb::PlatformSP lldb::PlatformSP
GetSelectedPlatform () GetSelectedPlatform()
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_selected_platform_sp && !m_platforms.empty()) if (!m_selected_platform_sp && !m_platforms.empty())
m_selected_platform_sp = m_platforms.front(); m_selected_platform_sp = m_platforms.front();
@ -1293,13 +1289,13 @@ class ModuleCache;
} }
void void
SetSelectedPlatform (const lldb::PlatformSP &platform_sp) SetSelectedPlatform(const lldb::PlatformSP &platform_sp)
{ {
if (platform_sp) if (platform_sp)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
const size_t num_platforms = m_platforms.size(); const size_t num_platforms = m_platforms.size();
for (size_t idx=0; idx<num_platforms; ++idx) for (size_t idx = 0; idx < num_platforms; ++idx)
{ {
if (m_platforms[idx].get() == platform_sp.get()) if (m_platforms[idx].get() == platform_sp.get())
{ {
@ -1307,14 +1303,14 @@ class ModuleCache;
return; return;
} }
} }
m_platforms.push_back (platform_sp); m_platforms.push_back(platform_sp);
m_selected_platform_sp = m_platforms.back(); m_selected_platform_sp = m_platforms.back();
} }
} }
protected: protected:
typedef std::vector<lldb::PlatformSP> collection; typedef std::vector<lldb::PlatformSP> collection;
mutable Mutex m_mutex; mutable std::recursive_mutex m_mutex;
collection m_platforms; collection m_platforms;
lldb::PlatformSP m_selected_platform_sp; lldb::PlatformSP m_selected_platform_sp;

View File

@ -13,10 +13,10 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <map> #include <map>
#include <mutex>
// Project includes // Project includes
#include "lldb/lldb-public.h" #include "lldb/lldb-public.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private { namespace lldb_private {
@ -31,11 +31,7 @@ public:
//------------------------------------------------------------------ //------------------------------------------------------------------
// Constructors and Destructors // Constructors and Destructors
//------------------------------------------------------------------ //------------------------------------------------------------------
SectionLoadHistory () : SectionLoadHistory() : m_stop_id_to_section_load_list(), m_mutex() {}
m_stop_id_to_section_load_list(),
m_mutex (Mutex::eMutexTypeRecursive)
{
}
~SectionLoadHistory() ~SectionLoadHistory()
{ {
@ -98,7 +94,7 @@ protected:
typedef std::map<uint32_t, lldb::SectionLoadListSP> StopIDToSectionLoadList; typedef std::map<uint32_t, lldb::SectionLoadListSP> StopIDToSectionLoadList;
StopIDToSectionLoadList m_stop_id_to_section_load_list; StopIDToSectionLoadList m_stop_id_to_section_load_list;
mutable Mutex m_mutex; mutable std::recursive_mutex m_mutex;
private: private:
DISALLOW_COPY_AND_ASSIGN (SectionLoadHistory); DISALLOW_COPY_AND_ASSIGN (SectionLoadHistory);

View File

@ -13,13 +13,13 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <map> #include <map>
#include <mutex>
// Other libraries and framework includes // Other libraries and framework includes
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
// Project includes // Project includes
#include "lldb/lldb-public.h" #include "lldb/lldb-public.h"
#include "lldb/Core/Section.h" #include "lldb/Core/Section.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private { namespace lldb_private {
@ -29,13 +29,7 @@ public:
//------------------------------------------------------------------ //------------------------------------------------------------------
// Constructors and Destructors // Constructors and Destructors
//------------------------------------------------------------------ //------------------------------------------------------------------
SectionLoadList () : SectionLoadList() : m_addr_to_sect(), m_sect_to_addr(), m_mutex() {}
m_addr_to_sect (),
m_sect_to_addr (),
m_mutex (Mutex::eMutexTypeRecursive)
{
}
SectionLoadList (const SectionLoadList& rhs); SectionLoadList (const SectionLoadList& rhs);
@ -84,7 +78,7 @@ protected:
typedef llvm::DenseMap<const Section *, lldb::addr_t> sect_to_addr_collection; typedef llvm::DenseMap<const Section *, lldb::addr_t> sect_to_addr_collection;
addr_to_sect_collection m_addr_to_sect; addr_to_sect_collection m_addr_to_sect;
sect_to_addr_collection m_sect_to_addr; sect_to_addr_collection m_sect_to_addr;
mutable Mutex m_mutex; mutable std::recursive_mutex m_mutex;
}; };
} // namespace lldb_private } // namespace lldb_private

View File

@ -12,12 +12,12 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <mutex>
#include <vector> #include <vector>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Broadcaster.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Target/Target.h" #include "lldb/Target/Target.h"
namespace lldb_private { namespace lldb_private {
@ -229,7 +229,7 @@ protected:
//------------------------------------------------------------------ //------------------------------------------------------------------
collection m_target_list; collection m_target_list;
lldb::TargetSP m_dummy_target_sp; lldb::TargetSP m_dummy_target_sp;
mutable Mutex m_target_list_mutex; mutable std::recursive_mutex m_target_list_mutex;
uint32_t m_selected_target_idx; uint32_t m_selected_target_idx;
private: private:

View File

@ -13,13 +13,13 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <memory> #include <memory>
#include <mutex>
#include <string> #include <string>
#include <vector> #include <vector>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/lldb-private.h" #include "lldb/lldb-private.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Event.h" #include "lldb/Core/Event.h"
#include "lldb/Core/StructuredData.h" #include "lldb/Core/StructuredData.h"
@ -1446,11 +1446,11 @@ protected:
const uint32_t m_index_id; ///< A unique 1 based index assigned to each thread for easy UI/command line access. const uint32_t m_index_id; ///< A unique 1 based index assigned to each thread for easy UI/command line access.
lldb::RegisterContextSP m_reg_context_sp; ///< The register context for this thread's current register state. lldb::RegisterContextSP m_reg_context_sp; ///< The register context for this thread's current register state.
lldb::StateType m_state; ///< The state of our process. lldb::StateType m_state; ///< The state of our process.
mutable Mutex m_state_mutex; ///< Multithreaded protection for m_state. mutable std::recursive_mutex m_state_mutex; ///< Multithreaded protection for m_state.
plan_stack m_plan_stack; ///< The stack of plans this thread is executing. plan_stack m_plan_stack; ///< The stack of plans this thread is executing.
plan_stack m_completed_plan_stack; ///< Plans that have been completed by this stop. They get deleted when the thread resumes. plan_stack m_completed_plan_stack; ///< Plans that have been completed by this stop. They get deleted when the thread resumes.
plan_stack m_discarded_plan_stack; ///< Plans that have been discarded by this stop. They get deleted when the thread resumes. plan_stack m_discarded_plan_stack; ///< Plans that have been discarded by this stop. They get deleted when the thread resumes.
mutable Mutex m_frame_mutex; ///< Multithreaded protection for m_state. mutable std::recursive_mutex m_frame_mutex; ///< Multithreaded protection for m_state.
lldb::StackFrameListSP m_curr_frames_sp; ///< The stack frames that get lazily populated after a thread stops. lldb::StackFrameListSP m_curr_frames_sp; ///< The stack frames that get lazily populated after a thread stops.
lldb::StackFrameListSP m_prev_frames_sp; ///< The previous stack frames from the last time this thread stopped. lldb::StackFrameListSP m_prev_frames_sp; ///< The previous stack frames from the last time this thread stopped.
int m_resume_signal; ///< The signal that should be used when continuing this thread. int m_resume_signal; ///< The signal that should be used when continuing this thread.

View File

@ -12,13 +12,13 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <mutex>
#include <string> #include <string>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/lldb-private.h" #include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h" #include "lldb/Core/UserID.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Target/Process.h" #include "lldb/Target/Process.h"
#include "lldb/Target/Target.h" #include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h" #include "lldb/Target/Thread.h"
@ -632,7 +632,7 @@ private:
ThreadPlanKind m_kind; ThreadPlanKind m_kind;
std::string m_name; std::string m_name;
Mutex m_plan_complete_mutex; std::recursive_mutex m_plan_complete_mutex;
LazyBool m_cached_plan_explains_stop; LazyBool m_cached_plan_explains_stop;
bool m_plan_complete; bool m_plan_complete;
bool m_plan_private; bool m_plan_private;

View File

@ -19,7 +19,6 @@
#include "lldb/lldb-private.h" #include "lldb/lldb-private.h"
#include "lldb/Core/StructuredData.h" #include "lldb/Core/StructuredData.h"
#include "lldb/Core/UserID.h" #include "lldb/Core/UserID.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Target/Process.h" #include "lldb/Target/Process.h"
#include "lldb/Target/Target.h" #include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h" #include "lldb/Target/Thread.h"

View File

@ -12,10 +12,11 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <mutex>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/lldb-private.h" #include "lldb/lldb-private.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private { namespace lldb_private {
@ -25,11 +26,7 @@ protected:
//------------------------------------------------------------------ //------------------------------------------------------------------
// Classes that inherit from Unwind can see and modify these // Classes that inherit from Unwind can see and modify these
//------------------------------------------------------------------ //------------------------------------------------------------------
Unwind(Thread &thread) : Unwind(Thread &thread) : m_thread(thread), m_unwind_mutex() {}
m_thread (thread),
m_unwind_mutex(Mutex::eMutexTypeRecursive)
{
}
public: public:
virtual virtual
@ -40,15 +37,14 @@ public:
void void
Clear() Clear()
{ {
Mutex::Locker locker(m_unwind_mutex); std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
DoClear(); DoClear();
} }
uint32_t uint32_t
GetFrameCount() GetFrameCount()
{ {
Mutex::Locker locker(m_unwind_mutex); std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
return DoGetFrameCount(); return DoGetFrameCount();
} }
@ -70,19 +66,17 @@ public:
} }
bool bool
GetFrameInfoAtIndex (uint32_t frame_idx, GetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa, lldb::addr_t &pc)
lldb::addr_t& cfa,
lldb::addr_t& pc)
{ {
Mutex::Locker locker(m_unwind_mutex); std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
return DoGetFrameInfoAtIndex (frame_idx, cfa, pc); return DoGetFrameInfoAtIndex(frame_idx, cfa, pc);
} }
lldb::RegisterContextSP lldb::RegisterContextSP
CreateRegisterContextForFrame (StackFrame *frame) CreateRegisterContextForFrame(StackFrame *frame)
{ {
Mutex::Locker locker(m_unwind_mutex); std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
return DoCreateRegisterContextForFrame (frame); return DoCreateRegisterContextForFrame(frame);
} }
Thread & Thread &
@ -110,7 +104,8 @@ protected:
DoCreateRegisterContextForFrame (StackFrame *frame) = 0; DoCreateRegisterContextForFrame (StackFrame *frame) = 0;
Thread &m_thread; Thread &m_thread;
Mutex m_unwind_mutex; std::recursive_mutex m_unwind_mutex;
private: private:
DISALLOW_COPY_AND_ASSIGN (Unwind); DISALLOW_COPY_AND_ASSIGN (Unwind);
}; };

View File

@ -11,7 +11,6 @@
#define utility_SharedCluster_h_ #define utility_SharedCluster_h_
#include "lldb/Utility/SharingPtr.h" #include "lldb/Utility/SharingPtr.h"
#include "lldb/Host/Mutex.h"
#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallPtrSet.h"
@ -46,14 +45,12 @@ template <class T>
class ClusterManager class ClusterManager
{ {
public: public:
ClusterManager () : ClusterManager() : m_objects(), m_external_ref(0), m_mutex() {}
m_objects(),
m_external_ref(0),
m_mutex(Mutex::eMutexTypeNormal) {}
~ClusterManager () ~ClusterManager()
{ {
for (typename llvm::SmallPtrSet<T *, 16>::iterator pos = m_objects.begin(), end = m_objects.end(); pos != end; ++pos) for (typename llvm::SmallPtrSet<T *, 16>::iterator pos = m_objects.begin(), end = m_objects.end(); pos != end;
++pos)
{ {
T *object = *pos; T *object = *pos;
delete object; delete object;
@ -62,42 +59,44 @@ public:
// Decrement refcount should have been called on this ClusterManager, // Decrement refcount should have been called on this ClusterManager,
// and it should have locked the mutex, now we will unlock it before // and it should have locked the mutex, now we will unlock it before
// we destroy it... // we destroy it...
m_mutex.Unlock(); m_mutex.unlock();
} }
void ManageObject (T *new_object) void
ManageObject(T *new_object)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
m_objects.insert (new_object); m_objects.insert(new_object);
} }
typename lldb_private::SharingPtr<T> GetSharedPointer(T *desired_object) typename lldb_private::SharingPtr<T>
GetSharedPointer(T *desired_object)
{ {
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
m_external_ref++; m_external_ref++;
assert (m_objects.count(desired_object)); assert(m_objects.count(desired_object));
} }
return typename lldb_private::SharingPtr<T> (desired_object, new imp::shared_ptr_refcount<ClusterManager> (this)); return typename lldb_private::SharingPtr<T>(desired_object, new imp::shared_ptr_refcount<ClusterManager>(this));
} }
private: private:
void
void DecrementRefCount () DecrementRefCount()
{ {
m_mutex.Lock(); m_mutex.lock();
m_external_ref--; m_external_ref--;
if (m_external_ref == 0) if (m_external_ref == 0)
delete this; delete this;
else else
m_mutex.Unlock(); m_mutex.unlock();
} }
friend class imp::shared_ptr_refcount<ClusterManager>; friend class imp::shared_ptr_refcount<ClusterManager>;
llvm::SmallPtrSet<T *, 16> m_objects; llvm::SmallPtrSet<T *, 16> m_objects;
int m_external_ref; int m_external_ref;
Mutex m_mutex; std::mutex m_mutex;
}; };
} // namespace lldb_private } // namespace lldb_private

View File

@ -191,8 +191,8 @@ SBDebugger::Create(bool source_init_files, lldb::LogOutputCallback callback, voi
// uses global collections and having two threads parsing the .lldbinit files can cause // uses global collections and having two threads parsing the .lldbinit files can cause
// mayhem. So to get around this for now we need to use a mutex to prevent bad things // mayhem. So to get around this for now we need to use a mutex to prevent bad things
// from happening. // from happening.
static Mutex g_mutex(Mutex::eMutexTypeRecursive); static std::recursive_mutex g_mutex;
Mutex::Locker locker(g_mutex); std::lock_guard<std::recursive_mutex> guard(g_mutex);
debugger.reset(Debugger::CreateInstance(callback, baton)); debugger.reset(Debugger::CreateInstance(callback, baton));

View File

@ -24,13 +24,8 @@
using namespace lldb; using namespace lldb;
using namespace lldb_private; using namespace lldb_private;
BreakpointLocationList::BreakpointLocationList(Breakpoint &owner) : BreakpointLocationList::BreakpointLocationList(Breakpoint &owner)
m_owner (owner), : m_owner(owner), m_locations(), m_address_to_location(), m_mutex(), m_next_id(0), m_new_location_recorder(nullptr)
m_locations(),
m_address_to_location (),
m_mutex (Mutex::eMutexTypeRecursive),
m_next_id (0),
m_new_location_recorder (nullptr)
{ {
} }
@ -39,7 +34,7 @@ BreakpointLocationList::~BreakpointLocationList() = default;
BreakpointLocationSP BreakpointLocationSP
BreakpointLocationList::Create (const Address &addr, bool resolve_indirect_symbols) BreakpointLocationList::Create (const Address &addr, bool resolve_indirect_symbols)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
// The location ID is just the size of the location list + 1 // The location ID is just the size of the location list + 1
lldb::break_id_t bp_loc_id = ++m_next_id; lldb::break_id_t bp_loc_id = ++m_next_id;
BreakpointLocationSP bp_loc_sp (new BreakpointLocation (bp_loc_id, m_owner, addr, LLDB_INVALID_THREAD_ID, m_owner.IsHardware(), resolve_indirect_symbols)); BreakpointLocationSP bp_loc_sp (new BreakpointLocation (bp_loc_id, m_owner, addr, LLDB_INVALID_THREAD_ID, m_owner.IsHardware(), resolve_indirect_symbols));
@ -84,7 +79,7 @@ Compare (BreakpointLocationSP lhs, lldb::break_id_t val)
BreakpointLocationSP BreakpointLocationSP
BreakpointLocationList::FindByID (lldb::break_id_t break_id) const BreakpointLocationList::FindByID (lldb::break_id_t break_id) const
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
collection::const_iterator end = m_locations.end(); collection::const_iterator end = m_locations.end();
collection::const_iterator pos = std::lower_bound(m_locations.begin(), end, break_id, Compare); collection::const_iterator pos = std::lower_bound(m_locations.begin(), end, break_id, Compare);
if (pos != end && (*pos)->GetID() == break_id) if (pos != end && (*pos)->GetID() == break_id)
@ -97,7 +92,7 @@ size_t
BreakpointLocationList::FindInModule (Module *module, BreakpointLocationList::FindInModule (Module *module,
BreakpointLocationCollection& bp_loc_list) BreakpointLocationCollection& bp_loc_list)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
const size_t orig_size = bp_loc_list.GetSize(); const size_t orig_size = bp_loc_list.GetSize();
collection::iterator pos, end = m_locations.end(); collection::iterator pos, end = m_locations.end();
@ -116,7 +111,7 @@ BreakpointLocationList::FindInModule (Module *module,
const BreakpointLocationSP const BreakpointLocationSP
BreakpointLocationList::FindByAddress (const Address &addr) const BreakpointLocationList::FindByAddress (const Address &addr) const
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
BreakpointLocationSP bp_loc_sp; BreakpointLocationSP bp_loc_sp;
if (!m_locations.empty()) if (!m_locations.empty())
{ {
@ -150,7 +145,7 @@ BreakpointLocationList::Dump (Stream *s) const
{ {
s->Printf("%p: ", static_cast<const void*>(this)); s->Printf("%p: ", static_cast<const void*>(this));
//s->Indent(); //s->Indent();
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
s->Printf("BreakpointLocationList with %" PRIu64 " BreakpointLocations:\n", (uint64_t)m_locations.size()); s->Printf("BreakpointLocationList with %" PRIu64 " BreakpointLocations:\n", (uint64_t)m_locations.size());
s->IndentMore(); s->IndentMore();
collection::const_iterator pos, end = m_locations.end(); collection::const_iterator pos, end = m_locations.end();
@ -162,7 +157,7 @@ BreakpointLocationList::Dump (Stream *s) const
BreakpointLocationSP BreakpointLocationSP
BreakpointLocationList::GetByIndex (size_t i) BreakpointLocationList::GetByIndex (size_t i)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
BreakpointLocationSP bp_loc_sp; BreakpointLocationSP bp_loc_sp;
if (i < m_locations.size()) if (i < m_locations.size())
bp_loc_sp = m_locations[i]; bp_loc_sp = m_locations[i];
@ -173,7 +168,7 @@ BreakpointLocationList::GetByIndex (size_t i)
const BreakpointLocationSP const BreakpointLocationSP
BreakpointLocationList::GetByIndex (size_t i) const BreakpointLocationList::GetByIndex (size_t i) const
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
BreakpointLocationSP bp_loc_sp; BreakpointLocationSP bp_loc_sp;
if (i < m_locations.size()) if (i < m_locations.size())
bp_loc_sp = m_locations[i]; bp_loc_sp = m_locations[i];
@ -184,7 +179,7 @@ BreakpointLocationList::GetByIndex (size_t i) const
void void
BreakpointLocationList::ClearAllBreakpointSites () BreakpointLocationList::ClearAllBreakpointSites ()
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
collection::iterator pos, end = m_locations.end(); collection::iterator pos, end = m_locations.end();
for (pos = m_locations.begin(); pos != end; ++pos) for (pos = m_locations.begin(); pos != end; ++pos)
(*pos)->ClearBreakpointSite(); (*pos)->ClearBreakpointSite();
@ -193,7 +188,7 @@ BreakpointLocationList::ClearAllBreakpointSites ()
void void
BreakpointLocationList::ResolveAllBreakpointSites () BreakpointLocationList::ResolveAllBreakpointSites ()
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
collection::iterator pos, end = m_locations.end(); collection::iterator pos, end = m_locations.end();
for (pos = m_locations.begin(); pos != end; ++pos) for (pos = m_locations.begin(); pos != end; ++pos)
@ -207,7 +202,7 @@ uint32_t
BreakpointLocationList::GetHitCount () const BreakpointLocationList::GetHitCount () const
{ {
uint32_t hit_count = 0; uint32_t hit_count = 0;
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
collection::const_iterator pos, end = m_locations.end(); collection::const_iterator pos, end = m_locations.end();
for (pos = m_locations.begin(); pos != end; ++pos) for (pos = m_locations.begin(); pos != end; ++pos)
hit_count += (*pos)->GetHitCount(); hit_count += (*pos)->GetHitCount();
@ -217,7 +212,7 @@ BreakpointLocationList::GetHitCount () const
size_t size_t
BreakpointLocationList::GetNumResolvedLocations() const BreakpointLocationList::GetNumResolvedLocations() const
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
size_t resolve_count = 0; size_t resolve_count = 0;
collection::const_iterator pos, end = m_locations.end(); collection::const_iterator pos, end = m_locations.end();
for (pos = m_locations.begin(); pos != end; ++pos) for (pos = m_locations.begin(); pos != end; ++pos)
@ -231,7 +226,7 @@ BreakpointLocationList::GetNumResolvedLocations() const
void void
BreakpointLocationList::GetDescription (Stream *s, lldb::DescriptionLevel level) BreakpointLocationList::GetDescription (Stream *s, lldb::DescriptionLevel level)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
collection::iterator pos, end = m_locations.end(); collection::iterator pos, end = m_locations.end();
for (pos = m_locations.begin(); pos != end; ++pos) for (pos = m_locations.begin(); pos != end; ++pos)
@ -244,7 +239,7 @@ BreakpointLocationList::GetDescription (Stream *s, lldb::DescriptionLevel level)
BreakpointLocationSP BreakpointLocationSP
BreakpointLocationList::AddLocation (const Address &addr, bool resolve_indirect_symbols, bool *new_location) BreakpointLocationList::AddLocation (const Address &addr, bool resolve_indirect_symbols, bool *new_location)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (new_location) if (new_location)
*new_location = false; *new_location = false;
@ -285,7 +280,7 @@ BreakpointLocationList::RemoveLocation (const lldb::BreakpointLocationSP &bp_loc
{ {
if (bp_loc_sp) if (bp_loc_sp)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_address_to_location.erase (bp_loc_sp->GetAddress()); m_address_to_location.erase (bp_loc_sp->GetAddress());
@ -305,7 +300,7 @@ BreakpointLocationList::RemoveLocation (const lldb::BreakpointLocationSP &bp_loc
void void
BreakpointLocationList::RemoveInvalidLocations (const ArchSpec &arch) BreakpointLocationList::RemoveInvalidLocations (const ArchSpec &arch)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
size_t idx = 0; size_t idx = 0;
// Don't cache m_location.size() as it will change since we might // Don't cache m_location.size() as it will change since we might
// remove locations from our vector... // remove locations from our vector...
@ -341,7 +336,7 @@ BreakpointLocationList::RemoveInvalidLocations (const ArchSpec &arch)
void void
BreakpointLocationList::StartRecordingNewLocations (BreakpointLocationCollection &new_locations) BreakpointLocationList::StartRecordingNewLocations (BreakpointLocationCollection &new_locations)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
assert(m_new_location_recorder == nullptr); assert(m_new_location_recorder == nullptr);
m_new_location_recorder = &new_locations; m_new_location_recorder = &new_locations;
} }
@ -349,7 +344,7 @@ BreakpointLocationList::StartRecordingNewLocations (BreakpointLocationCollection
void void
BreakpointLocationList::StopRecordingNewLocations () BreakpointLocationList::StopRecordingNewLocations ()
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_new_location_recorder = nullptr; m_new_location_recorder = nullptr;
} }

View File

@ -23,17 +23,15 @@
using namespace lldb; using namespace lldb;
using namespace lldb_private; using namespace lldb_private;
BreakpointSite::BreakpointSite(BreakpointSiteList *list, BreakpointSite::BreakpointSite(BreakpointSiteList *list, const BreakpointLocationSP &owner, lldb::addr_t addr,
const BreakpointLocationSP& owner, bool use_hardware)
lldb::addr_t addr, : StoppointLocation(GetNextID(), addr, 0, use_hardware),
bool use_hardware) : m_type(eSoftware), // Process subclasses need to set this correctly using SetType()
StoppointLocation(GetNextID(), addr, 0, use_hardware), m_saved_opcode(),
m_type (eSoftware), // Process subclasses need to set this correctly using SetType() m_trap_opcode(),
m_saved_opcode(), m_enabled(false), // Need to create it disabled, so the first enable turns it on.
m_trap_opcode(), m_owners(),
m_enabled(false), // Need to create it disabled, so the first enable turns it on. m_owners_mutex()
m_owners(),
m_owners_mutex(Mutex::eMutexTypeRecursive)
{ {
m_owners.Add(owner); m_owners.Add(owner);
} }
@ -61,7 +59,7 @@ BreakpointSite::GetNextID()
bool bool
BreakpointSite::ShouldStop (StoppointCallbackContext *context) BreakpointSite::ShouldStop (StoppointCallbackContext *context)
{ {
Mutex::Locker locker(m_owners_mutex); std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
IncrementHitCount(); IncrementHitCount();
return m_owners.ShouldStop (context); return m_owners.ShouldStop (context);
} }
@ -69,7 +67,7 @@ BreakpointSite::ShouldStop (StoppointCallbackContext *context)
bool bool
BreakpointSite::IsBreakpointAtThisSite (lldb::break_id_t bp_id) BreakpointSite::IsBreakpointAtThisSite (lldb::break_id_t bp_id)
{ {
Mutex::Locker locker(m_owners_mutex); std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
const size_t owner_count = m_owners.GetSize(); const size_t owner_count = m_owners.GetSize();
for (size_t i = 0; i < owner_count; i++) for (size_t i = 0; i < owner_count; i++)
{ {
@ -96,7 +94,7 @@ BreakpointSite::Dump(Stream *s) const
void void
BreakpointSite::GetDescription (Stream *s, lldb::DescriptionLevel level) BreakpointSite::GetDescription (Stream *s, lldb::DescriptionLevel level)
{ {
Mutex::Locker locker(m_owners_mutex); std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
if (level != lldb::eDescriptionLevelBrief) if (level != lldb::eDescriptionLevelBrief)
s->Printf ("breakpoint site: %d at 0x%8.8" PRIx64, GetID(), GetLoadAddress()); s->Printf ("breakpoint site: %d at 0x%8.8" PRIx64, GetID(), GetLoadAddress());
m_owners.GetDescription (s, level); m_owners.GetDescription (s, level);
@ -166,14 +164,14 @@ BreakpointSite::SetEnabled (bool enabled)
void void
BreakpointSite::AddOwner (const BreakpointLocationSP &owner) BreakpointSite::AddOwner (const BreakpointLocationSP &owner)
{ {
Mutex::Locker locker(m_owners_mutex); std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
m_owners.Add(owner); m_owners.Add(owner);
} }
size_t size_t
BreakpointSite::RemoveOwner (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) BreakpointSite::RemoveOwner (lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
{ {
Mutex::Locker locker(m_owners_mutex); std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
m_owners.Remove(break_id, break_loc_id); m_owners.Remove(break_id, break_loc_id);
return m_owners.GetSize(); return m_owners.GetSize();
} }
@ -181,28 +179,28 @@ BreakpointSite::RemoveOwner (lldb::break_id_t break_id, lldb::break_id_t break_l
size_t size_t
BreakpointSite::GetNumberOfOwners () BreakpointSite::GetNumberOfOwners ()
{ {
Mutex::Locker locker(m_owners_mutex); std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
return m_owners.GetSize(); return m_owners.GetSize();
} }
BreakpointLocationSP BreakpointLocationSP
BreakpointSite::GetOwnerAtIndex (size_t index) BreakpointSite::GetOwnerAtIndex (size_t index)
{ {
Mutex::Locker locker(m_owners_mutex); std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
return m_owners.GetByIndex (index); return m_owners.GetByIndex (index);
} }
bool bool
BreakpointSite::ValidForThisThread (Thread *thread) BreakpointSite::ValidForThisThread (Thread *thread)
{ {
Mutex::Locker locker(m_owners_mutex); std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
return m_owners.ValidForThisThread(thread); return m_owners.ValidForThisThread(thread);
} }
void void
BreakpointSite::BumpHitCounts() BreakpointSite::BumpHitCounts()
{ {
Mutex::Locker locker(m_owners_mutex); std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations()) for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations())
{ {
loc_sp->BumpHitCount(); loc_sp->BumpHitCount();
@ -255,7 +253,7 @@ BreakpointSite::IntersectsRange(lldb::addr_t addr, size_t size, lldb::addr_t *in
size_t size_t
BreakpointSite::CopyOwnersList (BreakpointLocationCollection &out_collection) BreakpointSite::CopyOwnersList (BreakpointLocationCollection &out_collection)
{ {
Mutex::Locker locker(m_owners_mutex); std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations()) for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations())
{ {
out_collection.Add(loc_sp); out_collection.Add(loc_sp);

View File

@ -19,9 +19,7 @@
using namespace lldb; using namespace lldb;
using namespace lldb_private; using namespace lldb_private;
BreakpointSiteList::BreakpointSiteList() : BreakpointSiteList::BreakpointSiteList() : m_mutex(), m_bp_site_list()
m_mutex (Mutex::eMutexTypeRecursive),
m_bp_site_list()
{ {
} }
@ -36,7 +34,7 @@ lldb::break_id_t
BreakpointSiteList::Add(const BreakpointSiteSP &bp) BreakpointSiteList::Add(const BreakpointSiteSP &bp)
{ {
lldb::addr_t bp_site_load_addr = bp->GetLoadAddress(); lldb::addr_t bp_site_load_addr = bp->GetLoadAddress();
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
collection::iterator iter = m_bp_site_list.find (bp_site_load_addr); collection::iterator iter = m_bp_site_list.find (bp_site_load_addr);
if (iter == m_bp_site_list.end()) if (iter == m_bp_site_list.end())
@ -81,7 +79,7 @@ BreakpointSiteList::FindIDByAddress (lldb::addr_t addr)
bool bool
BreakpointSiteList::Remove (lldb::break_id_t break_id) BreakpointSiteList::Remove (lldb::break_id_t break_id)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
collection::iterator pos = GetIDIterator(break_id); // Predicate collection::iterator pos = GetIDIterator(break_id); // Predicate
if (pos != m_bp_site_list.end()) if (pos != m_bp_site_list.end())
{ {
@ -94,7 +92,7 @@ BreakpointSiteList::Remove (lldb::break_id_t break_id)
bool bool
BreakpointSiteList::RemoveByAddress (lldb::addr_t address) BreakpointSiteList::RemoveByAddress (lldb::addr_t address)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
collection::iterator pos = m_bp_site_list.find(address); collection::iterator pos = m_bp_site_list.find(address);
if (pos != m_bp_site_list.end()) if (pos != m_bp_site_list.end())
{ {
@ -124,7 +122,7 @@ private:
BreakpointSiteList::collection::iterator BreakpointSiteList::collection::iterator
BreakpointSiteList::GetIDIterator (lldb::break_id_t break_id) BreakpointSiteList::GetIDIterator (lldb::break_id_t break_id)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return std::find_if(m_bp_site_list.begin(), m_bp_site_list.end(), // Search full range return std::find_if(m_bp_site_list.begin(), m_bp_site_list.end(), // Search full range
BreakpointSiteIDMatches(break_id)); // Predicate BreakpointSiteIDMatches(break_id)); // Predicate
} }
@ -132,7 +130,7 @@ BreakpointSiteList::GetIDIterator (lldb::break_id_t break_id)
BreakpointSiteList::collection::const_iterator BreakpointSiteList::collection::const_iterator
BreakpointSiteList::GetIDConstIterator (lldb::break_id_t break_id) const BreakpointSiteList::GetIDConstIterator (lldb::break_id_t break_id) const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return std::find_if(m_bp_site_list.begin(), m_bp_site_list.end(), // Search full range return std::find_if(m_bp_site_list.begin(), m_bp_site_list.end(), // Search full range
BreakpointSiteIDMatches(break_id)); // Predicate BreakpointSiteIDMatches(break_id)); // Predicate
} }
@ -140,7 +138,7 @@ BreakpointSiteList::GetIDConstIterator (lldb::break_id_t break_id) const
BreakpointSiteSP BreakpointSiteSP
BreakpointSiteList::FindByID (lldb::break_id_t break_id) BreakpointSiteList::FindByID (lldb::break_id_t break_id)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
BreakpointSiteSP stop_sp; BreakpointSiteSP stop_sp;
collection::iterator pos = GetIDIterator(break_id); collection::iterator pos = GetIDIterator(break_id);
if (pos != m_bp_site_list.end()) if (pos != m_bp_site_list.end())
@ -152,7 +150,7 @@ BreakpointSiteList::FindByID (lldb::break_id_t break_id)
const BreakpointSiteSP const BreakpointSiteSP
BreakpointSiteList::FindByID (lldb::break_id_t break_id) const BreakpointSiteList::FindByID (lldb::break_id_t break_id) const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
BreakpointSiteSP stop_sp; BreakpointSiteSP stop_sp;
collection::const_iterator pos = GetIDConstIterator(break_id); collection::const_iterator pos = GetIDConstIterator(break_id);
if (pos != m_bp_site_list.end()) if (pos != m_bp_site_list.end())
@ -165,7 +163,7 @@ BreakpointSiteSP
BreakpointSiteList::FindByAddress (lldb::addr_t addr) BreakpointSiteList::FindByAddress (lldb::addr_t addr)
{ {
BreakpointSiteSP found_sp; BreakpointSiteSP found_sp;
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
collection::iterator iter = m_bp_site_list.find(addr); collection::iterator iter = m_bp_site_list.find(addr);
if (iter != m_bp_site_list.end()) if (iter != m_bp_site_list.end())
found_sp = iter->second; found_sp = iter->second;
@ -175,7 +173,7 @@ BreakpointSiteList::FindByAddress (lldb::addr_t addr)
bool bool
BreakpointSiteList::BreakpointSiteContainsBreakpoint (lldb::break_id_t bp_site_id, lldb::break_id_t bp_id) BreakpointSiteList::BreakpointSiteContainsBreakpoint (lldb::break_id_t bp_site_id, lldb::break_id_t bp_id)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
collection::const_iterator pos = GetIDConstIterator(bp_site_id); collection::const_iterator pos = GetIDConstIterator(bp_site_id);
if (pos != m_bp_site_list.end()) if (pos != m_bp_site_list.end())
return pos->second->IsBreakpointAtThisSite (bp_id); return pos->second->IsBreakpointAtThisSite (bp_id);
@ -200,7 +198,7 @@ BreakpointSiteList::Dump (Stream *s) const
void void
BreakpointSiteList::ForEach (std::function <void(BreakpointSite *)> const &callback) BreakpointSiteList::ForEach (std::function <void(BreakpointSite *)> const &callback)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
for (auto pair : m_bp_site_list) for (auto pair : m_bp_site_list)
callback (pair.second.get()); callback (pair.second.get());
} }
@ -211,7 +209,7 @@ BreakpointSiteList::FindInRange (lldb::addr_t lower_bound, lldb::addr_t upper_bo
if (lower_bound > upper_bound) if (lower_bound > upper_bound)
return false; return false;
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
collection::const_iterator lower, upper, pos; collection::const_iterator lower, upper, pos;
lower = m_bp_site_list.lower_bound(lower_bound); lower = m_bp_site_list.lower_bound(lower_bound);
if (lower == m_bp_site_list.end() if (lower == m_bp_site_list.end()

View File

@ -1978,7 +1978,7 @@ FindModulesByName (Target *target,
if (check_global_list) if (check_global_list)
{ {
// Check the global list // Check the global list
Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex()); std::lock_guard<std::recursive_mutex> guard(Module::GetAllocationModuleCollectionMutex());
const size_t num_modules = Module::GetNumberAllocatedModules(); const size_t num_modules = Module::GetNumberAllocatedModules();
ModuleSP module_sp; ModuleSP module_sp;
for (size_t image_idx = 0; image_idx<num_modules; ++image_idx) for (size_t image_idx = 0; image_idx<num_modules; ++image_idx)
@ -2470,7 +2470,7 @@ protected:
else else
{ {
// Check the global list // Check the global list
Mutex::Locker locker(Module::GetAllocationModuleCollectionMutex()); std::lock_guard<std::recursive_mutex> guard(Module::GetAllocationModuleCollectionMutex());
result.AppendWarningWithFormat("Unable to find an image that matches '%s'.\n", arg_cstr); result.AppendWarningWithFormat("Unable to find an image that matches '%s'.\n", arg_cstr);
} }
@ -3291,16 +3291,20 @@ protected:
} }
size_t num_modules = 0; size_t num_modules = 0;
Mutex::Locker locker; // This locker will be locked on the mutex in module_list_ptr if it is non-nullptr.
// Otherwise it will lock the AllocationModuleCollectionMutex when accessing // This locker will be locked on the mutex in module_list_ptr if it is non-nullptr.
// the global module list directly. // Otherwise it will lock the AllocationModuleCollectionMutex when accessing
// the global module list directly.
std::unique_lock<std::recursive_mutex> guard(Module::GetAllocationModuleCollectionMutex(), std::defer_lock);
Mutex::Locker locker;
const ModuleList *module_list_ptr = nullptr; const ModuleList *module_list_ptr = nullptr;
const size_t argc = command.GetArgumentCount(); const size_t argc = command.GetArgumentCount();
if (argc == 0) if (argc == 0)
{ {
if (use_global_module_list) if (use_global_module_list)
{ {
locker.Lock (Module::GetAllocationModuleCollectionMutex()); guard.lock();
num_modules = Module::GetNumberAllocatedModules(); num_modules = Module::GetNumberAllocatedModules();
} }
else else
@ -3331,6 +3335,7 @@ protected:
if (module_list_ptr != nullptr) if (module_list_ptr != nullptr)
{ {
assert(use_global_module_list == false && "locking violation");
locker.Lock(module_list_ptr->GetMutex()); locker.Lock(module_list_ptr->GetMutex());
num_modules = module_list_ptr->GetSize(); num_modules = module_list_ptr->GetSize();
} }

View File

@ -32,12 +32,8 @@ Broadcaster::Broadcaster(BroadcasterManagerSP manager_sp, const char *name) :
static_cast<void*>(this), GetBroadcasterName().AsCString()); static_cast<void*>(this), GetBroadcasterName().AsCString());
} }
Broadcaster::BroadcasterImpl::BroadcasterImpl (Broadcaster &broadcaster) : Broadcaster::BroadcasterImpl::BroadcasterImpl(Broadcaster &broadcaster)
m_broadcaster(broadcaster), : m_broadcaster(broadcaster), m_listeners(), m_listeners_mutex(), m_hijacking_listeners(), m_hijacking_masks()
m_listeners (),
m_listeners_mutex (Mutex::eMutexTypeRecursive),
m_hijacking_listeners(),
m_hijacking_masks()
{ {
} }
@ -90,7 +86,7 @@ Broadcaster::BroadcasterImpl::ListenerIterator (std::function <bool (const lldb:
void void
Broadcaster::BroadcasterImpl::Clear() Broadcaster::BroadcasterImpl::Clear()
{ {
Mutex::Locker listeners_locker(m_listeners_mutex); std::lock_guard<std::recursive_mutex> guard(m_listeners_mutex);
// Make sure the listener forgets about this broadcaster. We do // Make sure the listener forgets about this broadcaster. We do
// this in the broadcaster in case the broadcaster object initiates // this in the broadcaster in case the broadcaster object initiates
@ -152,7 +148,7 @@ Broadcaster::BroadcasterImpl::AddListener (const lldb::ListenerSP &listener_sp,
if (!listener_sp) if (!listener_sp)
return 0; return 0;
Mutex::Locker locker(m_listeners_mutex); std::lock_guard<std::recursive_mutex> guard(m_listeners_mutex);
// See if we already have this listener, and if so, update its mask // See if we already have this listener, and if so, update its mask
@ -186,7 +182,7 @@ Broadcaster::BroadcasterImpl::AddListener (const lldb::ListenerSP &listener_sp,
bool bool
Broadcaster::BroadcasterImpl::EventTypeHasListeners (uint32_t event_type) Broadcaster::BroadcasterImpl::EventTypeHasListeners (uint32_t event_type)
{ {
Mutex::Locker locker (m_listeners_mutex); std::lock_guard<std::recursive_mutex> guard(m_listeners_mutex);
if (!m_hijacking_listeners.empty() && event_type & m_hijacking_masks.back()) if (!m_hijacking_listeners.empty() && event_type & m_hijacking_masks.back())
return true; return true;
@ -215,7 +211,7 @@ Broadcaster::BroadcasterImpl::RemoveListener (lldb_private::Listener *listener,
{ {
if (listener) if (listener)
{ {
Mutex::Locker locker(m_listeners_mutex); std::lock_guard<std::recursive_mutex> guard(m_listeners_mutex);
collection::iterator pos = m_listeners.begin(); collection::iterator pos = m_listeners.begin();
// See if we already have this listener, and if so, update its mask // See if we already have this listener, and if so, update its mask
while (pos != m_listeners.end()) while (pos != m_listeners.end())
@ -275,7 +271,7 @@ Broadcaster::BroadcasterImpl::PrivateBroadcastEvent (EventSP &event_sp, bool uni
const uint32_t event_type = event_sp->GetType(); const uint32_t event_type = event_sp->GetType();
Mutex::Locker locker(m_listeners_mutex); std::lock_guard<std::recursive_mutex> guard(m_listeners_mutex);
ListenerSP hijacking_listener_sp; ListenerSP hijacking_listener_sp;
@ -343,7 +339,7 @@ Broadcaster::BroadcasterImpl::BroadcastEventIfUnique (uint32_t event_type, Event
bool bool
Broadcaster::BroadcasterImpl::HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask) Broadcaster::BroadcasterImpl::HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask)
{ {
Mutex::Locker locker(m_listeners_mutex); std::lock_guard<std::recursive_mutex> guard(m_listeners_mutex);
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS)); Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EVENTS));
if (log) if (log)
@ -358,7 +354,7 @@ Broadcaster::BroadcasterImpl::HijackBroadcaster (const lldb::ListenerSP &listene
bool bool
Broadcaster::BroadcasterImpl::IsHijackedForEvent (uint32_t event_mask) Broadcaster::BroadcasterImpl::IsHijackedForEvent (uint32_t event_mask)
{ {
Mutex::Locker locker(m_listeners_mutex); std::lock_guard<std::recursive_mutex> guard(m_listeners_mutex);
if (!m_hijacking_listeners.empty()) if (!m_hijacking_listeners.empty())
return (event_mask & m_hijacking_masks.back()) != 0; return (event_mask & m_hijacking_masks.back()) != 0;
@ -381,7 +377,7 @@ Broadcaster::BroadcasterImpl::GetHijackingListenerName()
void void
Broadcaster::BroadcasterImpl::RestoreBroadcaster () Broadcaster::BroadcasterImpl::RestoreBroadcaster ()
{ {
Mutex::Locker locker(m_listeners_mutex); std::lock_guard<std::recursive_mutex> guard(m_listeners_mutex);
if (!m_hijacking_listeners.empty()) if (!m_hijacking_listeners.empty())
{ {
@ -425,8 +421,7 @@ BroadcastEventSpec::operator< (const BroadcastEventSpec &rhs) const
BroadcastEventSpec & BroadcastEventSpec &
BroadcastEventSpec::operator=(const BroadcastEventSpec &rhs) = default; BroadcastEventSpec::operator=(const BroadcastEventSpec &rhs) = default;
BroadcasterManager::BroadcasterManager() : BroadcasterManager::BroadcasterManager() : m_manager_mutex()
m_manager_mutex(Mutex::eMutexTypeRecursive)
{ {
} }
@ -439,7 +434,7 @@ BroadcasterManager::MakeBroadcasterManager()
uint32_t uint32_t
BroadcasterManager::RegisterListenerForEvents (const lldb::ListenerSP &listener_sp, BroadcastEventSpec event_spec) BroadcasterManager::RegisterListenerForEvents (const lldb::ListenerSP &listener_sp, BroadcastEventSpec event_spec)
{ {
Mutex::Locker locker(m_manager_mutex); std::lock_guard<std::recursive_mutex> guard(m_manager_mutex);
collection::iterator iter = m_event_map.begin(), end_iter = m_event_map.end(); collection::iterator iter = m_event_map.begin(), end_iter = m_event_map.end();
uint32_t available_bits = event_spec.GetEventBits(); uint32_t available_bits = event_spec.GetEventBits();
@ -463,7 +458,7 @@ BroadcasterManager::RegisterListenerForEvents (const lldb::ListenerSP &listener_
bool bool
BroadcasterManager::UnregisterListenerForEvents (const lldb::ListenerSP &listener_sp, BroadcastEventSpec event_spec) BroadcasterManager::UnregisterListenerForEvents (const lldb::ListenerSP &listener_sp, BroadcastEventSpec event_spec)
{ {
Mutex::Locker locker(m_manager_mutex); std::lock_guard<std::recursive_mutex> guard(m_manager_mutex);
bool removed_some = false; bool removed_some = false;
if (m_listeners.erase(listener_sp) == 0) if (m_listeners.erase(listener_sp) == 0)
@ -508,7 +503,7 @@ BroadcasterManager::UnregisterListenerForEvents (const lldb::ListenerSP &listene
ListenerSP ListenerSP
BroadcasterManager::GetListenerForEventSpec (BroadcastEventSpec event_spec) const BroadcasterManager::GetListenerForEventSpec (BroadcastEventSpec event_spec) const
{ {
Mutex::Locker locker(*(const_cast<Mutex *> (&m_manager_mutex))); std::lock_guard<std::recursive_mutex> guard(m_manager_mutex);
collection::const_iterator iter, end_iter = m_event_map.end(); collection::const_iterator iter, end_iter = m_event_map.end();
iter = find_if (m_event_map.begin(), end_iter, BroadcastEventSpecMatches (event_spec)); iter = find_if (m_event_map.begin(), end_iter, BroadcastEventSpecMatches (event_spec));
@ -521,7 +516,7 @@ BroadcasterManager::GetListenerForEventSpec (BroadcastEventSpec event_spec) cons
void void
BroadcasterManager::RemoveListener(Listener *listener) BroadcasterManager::RemoveListener(Listener *listener)
{ {
Mutex::Locker locker(m_manager_mutex); std::lock_guard<std::recursive_mutex> guard(m_manager_mutex);
ListenerMatchesPointer predicate (listener); ListenerMatchesPointer predicate (listener);
listener_collection::iterator iter = m_listeners.begin(), end_iter = m_listeners.end(); listener_collection::iterator iter = m_listeners.begin(), end_iter = m_listeners.end();
@ -543,7 +538,7 @@ BroadcasterManager::RemoveListener(Listener *listener)
void void
BroadcasterManager::RemoveListener (const lldb::ListenerSP &listener_sp) BroadcasterManager::RemoveListener (const lldb::ListenerSP &listener_sp)
{ {
Mutex::Locker locker(m_manager_mutex); std::lock_guard<std::recursive_mutex> guard(m_manager_mutex);
ListenerMatches predicate (listener_sp); ListenerMatches predicate (listener_sp);
if (m_listeners.erase (listener_sp) == 0) if (m_listeners.erase (listener_sp) == 0)
@ -563,7 +558,7 @@ BroadcasterManager::RemoveListener (const lldb::ListenerSP &listener_sp)
void void
BroadcasterManager::SignUpListenersForBroadcaster (Broadcaster &broadcaster) BroadcasterManager::SignUpListenersForBroadcaster (Broadcaster &broadcaster)
{ {
Mutex::Locker locker(m_manager_mutex); std::lock_guard<std::recursive_mutex> guard(m_manager_mutex);
collection::iterator iter = m_event_map.begin(), end_iter = m_event_map.end(); collection::iterator iter = m_event_map.begin(), end_iter = m_event_map.end();
@ -578,7 +573,7 @@ BroadcasterManager::SignUpListenersForBroadcaster (Broadcaster &broadcaster)
void void
BroadcasterManager::Clear () BroadcasterManager::Clear ()
{ {
Mutex::Locker locker(m_manager_mutex); std::lock_guard<std::recursive_mutex> guard(m_manager_mutex);
listener_collection::iterator end_iter = m_listeners.end(); listener_collection::iterator end_iter = m_listeners.end();
for (listener_collection::iterator iter = m_listeners.begin(); iter != end_iter; iter++) for (listener_collection::iterator iter = m_listeners.begin(); iter != end_iter; iter++)

View File

@ -33,30 +33,29 @@ Communication::GetStaticBroadcasterClass ()
return class_name; return class_name;
} }
Communication::Communication(const char *name) : Communication::Communication(const char *name)
Broadcaster(nullptr, name), : Broadcaster(nullptr, name),
m_connection_sp(), m_connection_sp(),
m_read_thread_enabled(false), m_read_thread_enabled(false),
m_read_thread_did_exit(false), m_read_thread_did_exit(false),
m_bytes(), m_bytes(),
m_bytes_mutex(Mutex::eMutexTypeRecursive), m_bytes_mutex(),
m_write_mutex(Mutex::eMutexTypeNormal), m_write_mutex(),
m_synchronize_mutex(Mutex::eMutexTypeNormal), m_synchronize_mutex(),
m_callback(nullptr), m_callback(nullptr),
m_callback_baton(nullptr), m_callback_baton(nullptr),
m_close_on_eof(true) m_close_on_eof(true)
{ {
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION, lldb_private::LogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_COMMUNICATION,
"%p Communication::Communication (name = %s)", "%p Communication::Communication (name = %s)", this, name);
this, name);
SetEventName (eBroadcastBitDisconnected, "disconnected"); SetEventName(eBroadcastBitDisconnected, "disconnected");
SetEventName (eBroadcastBitReadThreadGotBytes, "got bytes"); SetEventName(eBroadcastBitReadThreadGotBytes, "got bytes");
SetEventName (eBroadcastBitReadThreadDidExit, "read thread did exit"); SetEventName(eBroadcastBitReadThreadDidExit, "read thread did exit");
SetEventName (eBroadcastBitReadThreadShouldExit, "read thread should exit"); SetEventName(eBroadcastBitReadThreadShouldExit, "read thread should exit");
SetEventName (eBroadcastBitPacketAvailable, "packet available"); SetEventName(eBroadcastBitPacketAvailable, "packet available");
SetEventName (eBroadcastBitNoMorePendingInput, "no more pending input"); SetEventName(eBroadcastBitNoMorePendingInput, "no more pending input");
CheckInWithManager(); CheckInWithManager();
} }
@ -205,7 +204,7 @@ Communication::Write (const void *src, size_t src_len, ConnectionStatus &status,
{ {
lldb::ConnectionSP connection_sp (m_connection_sp); lldb::ConnectionSP connection_sp (m_connection_sp);
Mutex::Locker locker(m_write_mutex); std::lock_guard<std::mutex> guard(m_write_mutex);
lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION,
"%p Communication::Write (src = %p, src_len = %" PRIu64 ") connection = %p", "%p Communication::Write (src = %p, src_len = %" PRIu64 ") connection = %p",
this, this,
@ -277,7 +276,7 @@ Communication::JoinReadThread (Error *error_ptr)
size_t size_t
Communication::GetCachedBytes (void *dst, size_t dst_len) Communication::GetCachedBytes (void *dst, size_t dst_len)
{ {
Mutex::Locker locker(m_bytes_mutex); std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex);
if (!m_bytes.empty()) if (!m_bytes.empty())
{ {
// If DST is nullptr and we have a thread, then return the number // If DST is nullptr and we have a thread, then return the number
@ -311,7 +310,7 @@ Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broad
} }
else if (bytes != nullptr && len > 0) else if (bytes != nullptr && len > 0)
{ {
Mutex::Locker locker(m_bytes_mutex); std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex);
m_bytes.append ((const char *)bytes, len); m_bytes.append ((const char *)bytes, len);
if (broadcast) if (broadcast)
BroadcastEventIfUnique (eBroadcastBitReadThreadGotBytes); BroadcastEventIfUnique (eBroadcastBitReadThreadGotBytes);
@ -425,7 +424,7 @@ void
Communication::SynchronizeWithReadThread () Communication::SynchronizeWithReadThread ()
{ {
// Only one thread can do the synchronization dance at a time. // Only one thread can do the synchronization dance at a time.
Mutex::Locker locker(m_synchronize_mutex); std::lock_guard<std::mutex> guard(m_synchronize_mutex);
// First start listening for the synchronization event. // First start listening for the synchronization event.
ListenerSP listener_sp(Listener::MakeListener("Communication::SyncronizeWithReadThread")); ListenerSP listener_sp(Listener::MakeListener("Communication::SyncronizeWithReadThread"));

View File

@ -12,6 +12,7 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <map> #include <map>
#include <mutex>
// Other libraries and framework includes // Other libraries and framework includes
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
@ -67,10 +68,10 @@ static size_t g_debugger_event_thread_stack_bytes = 8 * 1024 * 1024;
#pragma mark Static Functions #pragma mark Static Functions
static Mutex & static std::recursive_mutex &
GetDebuggerListMutex () GetDebuggerListMutex()
{ {
static Mutex g_mutex(Mutex::eMutexTypeRecursive); static std::recursive_mutex g_mutex;
return g_mutex; return g_mutex;
} }
@ -469,7 +470,7 @@ Debugger::Terminate ()
assert(lldb_initialized && "Debugger::Terminate called without a matching Debugger::Initialize!"); assert(lldb_initialized && "Debugger::Terminate called without a matching Debugger::Initialize!");
// Clear our master list of debugger objects // Clear our master list of debugger objects
Mutex::Locker locker (GetDebuggerListMutex ()); std::lock_guard<std::recursive_mutex> guard(GetDebuggerListMutex());
auto& debuggers = GetDebuggerList(); auto& debuggers = GetDebuggerList();
for (const auto& debugger: debuggers) for (const auto& debugger: debuggers)
debugger->Clear(); debugger->Clear();
@ -605,7 +606,7 @@ Debugger::CreateInstance (lldb::LogOutputCallback log_callback, void *baton)
DebuggerSP debugger_sp (new Debugger(log_callback, baton)); DebuggerSP debugger_sp (new Debugger(log_callback, baton));
if (lldb_initialized) if (lldb_initialized)
{ {
Mutex::Locker locker (GetDebuggerListMutex ()); std::lock_guard<std::recursive_mutex> guard(GetDebuggerListMutex());
GetDebuggerList().push_back(debugger_sp); GetDebuggerList().push_back(debugger_sp);
} }
debugger_sp->InstanceInitialize (); debugger_sp->InstanceInitialize ();
@ -622,7 +623,7 @@ Debugger::Destroy (DebuggerSP &debugger_sp)
if (lldb_initialized) if (lldb_initialized)
{ {
Mutex::Locker locker (GetDebuggerListMutex ()); std::lock_guard<std::recursive_mutex> guard(GetDebuggerListMutex());
DebuggerList &debugger_list = GetDebuggerList (); DebuggerList &debugger_list = GetDebuggerList ();
DebuggerList::iterator pos, end = debugger_list.end(); DebuggerList::iterator pos, end = debugger_list.end();
for (pos = debugger_list.begin (); pos != end; ++pos) for (pos = debugger_list.begin (); pos != end; ++pos)
@ -642,7 +643,7 @@ Debugger::FindDebuggerWithInstanceName (const ConstString &instance_name)
DebuggerSP debugger_sp; DebuggerSP debugger_sp;
if (lldb_initialized) if (lldb_initialized)
{ {
Mutex::Locker locker (GetDebuggerListMutex ()); std::lock_guard<std::recursive_mutex> guard(GetDebuggerListMutex());
DebuggerList &debugger_list = GetDebuggerList(); DebuggerList &debugger_list = GetDebuggerList();
DebuggerList::iterator pos, end = debugger_list.end(); DebuggerList::iterator pos, end = debugger_list.end();
@ -664,7 +665,7 @@ Debugger::FindTargetWithProcessID (lldb::pid_t pid)
TargetSP target_sp; TargetSP target_sp;
if (lldb_initialized) if (lldb_initialized)
{ {
Mutex::Locker locker (GetDebuggerListMutex ()); std::lock_guard<std::recursive_mutex> guard(GetDebuggerListMutex());
DebuggerList &debugger_list = GetDebuggerList(); DebuggerList &debugger_list = GetDebuggerList();
DebuggerList::iterator pos, end = debugger_list.end(); DebuggerList::iterator pos, end = debugger_list.end();
for (pos = debugger_list.begin(); pos != end; ++pos) for (pos = debugger_list.begin(); pos != end; ++pos)
@ -683,7 +684,7 @@ Debugger::FindTargetWithProcess (Process *process)
TargetSP target_sp; TargetSP target_sp;
if (lldb_initialized) if (lldb_initialized)
{ {
Mutex::Locker locker (GetDebuggerListMutex ()); std::lock_guard<std::recursive_mutex> guard(GetDebuggerListMutex());
DebuggerList &debugger_list = GetDebuggerList(); DebuggerList &debugger_list = GetDebuggerList();
DebuggerList::iterator pos, end = debugger_list.end(); DebuggerList::iterator pos, end = debugger_list.end();
for (pos = debugger_list.begin(); pos != end; ++pos) for (pos = debugger_list.begin(); pos != end; ++pos)
@ -922,33 +923,33 @@ Debugger::GetSelectedExecutionContext ()
} }
void void
Debugger::DispatchInputInterrupt () Debugger::DispatchInputInterrupt()
{ {
Mutex::Locker locker (m_input_reader_stack.GetMutex()); std::lock_guard<std::recursive_mutex> guard(m_input_reader_stack.GetMutex());
IOHandlerSP reader_sp (m_input_reader_stack.Top()); IOHandlerSP reader_sp(m_input_reader_stack.Top());
if (reader_sp) if (reader_sp)
reader_sp->Interrupt(); reader_sp->Interrupt();
} }
void void
Debugger::DispatchInputEndOfFile () Debugger::DispatchInputEndOfFile()
{ {
Mutex::Locker locker (m_input_reader_stack.GetMutex()); std::lock_guard<std::recursive_mutex> guard(m_input_reader_stack.GetMutex());
IOHandlerSP reader_sp (m_input_reader_stack.Top()); IOHandlerSP reader_sp(m_input_reader_stack.Top());
if (reader_sp) if (reader_sp)
reader_sp->GotEOF(); reader_sp->GotEOF();
} }
void void
Debugger::ClearIOHandlers () Debugger::ClearIOHandlers()
{ {
// The bottom input reader should be the main debugger input reader. We do not want to close that one here. // The bottom input reader should be the main debugger input reader. We do not want to close that one here.
Mutex::Locker locker (m_input_reader_stack.GetMutex()); std::lock_guard<std::recursive_mutex> guard(m_input_reader_stack.GetMutex());
while (m_input_reader_stack.GetSize() > 1) while (m_input_reader_stack.GetSize() > 1)
{ {
IOHandlerSP reader_sp (m_input_reader_stack.Top()); IOHandlerSP reader_sp(m_input_reader_stack.Top());
if (reader_sp) if (reader_sp)
PopIOHandler (reader_sp); PopIOHandler(reader_sp);
} }
} }
@ -1041,7 +1042,7 @@ Debugger::RunIOHandler (const IOHandlerSP& reader_sp)
} }
void void
Debugger::AdoptTopIOHandlerFilesIfInvalid (StreamFileSP &in, StreamFileSP &out, StreamFileSP &err) Debugger::AdoptTopIOHandlerFilesIfInvalid(StreamFileSP &in, StreamFileSP &out, StreamFileSP &err)
{ {
// Before an IOHandler runs, it must have in/out/err streams. // Before an IOHandler runs, it must have in/out/err streams.
// This function is called when one ore more of the streams // This function is called when one ore more of the streams
@ -1049,8 +1050,8 @@ Debugger::AdoptTopIOHandlerFilesIfInvalid (StreamFileSP &in, StreamFileSP &out,
// or fall back to the debugger file handles, or we fall back // or fall back to the debugger file handles, or we fall back
// onto stdin/stdout/stderr as a last resort. // onto stdin/stdout/stderr as a last resort.
Mutex::Locker locker (m_input_reader_stack.GetMutex()); std::lock_guard<std::recursive_mutex> guard(m_input_reader_stack.GetMutex());
IOHandlerSP top_reader_sp (m_input_reader_stack.Top()); IOHandlerSP top_reader_sp(m_input_reader_stack.Top());
// If no STDIN has been set, then set it appropriately // If no STDIN has been set, then set it appropriately
if (!in) if (!in)
{ {
@ -1086,27 +1087,26 @@ Debugger::AdoptTopIOHandlerFilesIfInvalid (StreamFileSP &in, StreamFileSP &out,
// If there is nothing, use stderr // If there is nothing, use stderr
if (!err) if (!err)
err = StreamFileSP(new StreamFile(stdout, false)); err = StreamFileSP(new StreamFile(stdout, false));
} }
} }
void void
Debugger::PushIOHandler (const IOHandlerSP& reader_sp) Debugger::PushIOHandler(const IOHandlerSP &reader_sp)
{ {
if (!reader_sp) if (!reader_sp)
return; return;
Mutex::Locker locker (m_input_reader_stack.GetMutex()); std::lock_guard<std::recursive_mutex> guard(m_input_reader_stack.GetMutex());
// Get the current top input reader... // Get the current top input reader...
IOHandlerSP top_reader_sp (m_input_reader_stack.Top()); IOHandlerSP top_reader_sp(m_input_reader_stack.Top());
// Don't push the same IO handler twice... // Don't push the same IO handler twice...
if (reader_sp == top_reader_sp) if (reader_sp == top_reader_sp)
return; return;
// Push our new input reader // Push our new input reader
m_input_reader_stack.Push (reader_sp); m_input_reader_stack.Push(reader_sp);
reader_sp->Activate(); reader_sp->Activate();
// Interrupt the top input reader to it will exit its Run() function // Interrupt the top input reader to it will exit its Run() function
@ -1119,12 +1119,12 @@ Debugger::PushIOHandler (const IOHandlerSP& reader_sp)
} }
bool bool
Debugger::PopIOHandler (const IOHandlerSP& pop_reader_sp) Debugger::PopIOHandler(const IOHandlerSP &pop_reader_sp)
{ {
if (! pop_reader_sp) if (!pop_reader_sp)
return false; return false;
Mutex::Locker locker (m_input_reader_stack.GetMutex()); std::lock_guard<std::recursive_mutex> guard(m_input_reader_stack.GetMutex());
// The reader on the stop of the stack is done, so let the next // The reader on the stop of the stack is done, so let the next
// read on the stack refresh its prompt and if there is one... // read on the stack refresh its prompt and if there is one...
@ -1138,7 +1138,7 @@ Debugger::PopIOHandler (const IOHandlerSP& pop_reader_sp)
reader_sp->Deactivate(); reader_sp->Deactivate();
reader_sp->Cancel(); reader_sp->Cancel();
m_input_reader_stack.Pop (); m_input_reader_stack.Pop();
reader_sp = m_input_reader_stack.Top(); reader_sp = m_input_reader_stack.Top();
if (reader_sp) if (reader_sp)
@ -1164,7 +1164,7 @@ Debugger::GetNumDebuggers()
{ {
if (lldb_initialized) if (lldb_initialized)
{ {
Mutex::Locker locker (GetDebuggerListMutex ()); std::lock_guard<std::recursive_mutex> guard(GetDebuggerListMutex());
return GetDebuggerList().size(); return GetDebuggerList().size();
} }
return 0; return 0;
@ -1177,7 +1177,7 @@ Debugger::GetDebuggerAtIndex (size_t index)
if (lldb_initialized) if (lldb_initialized)
{ {
Mutex::Locker locker (GetDebuggerListMutex ()); std::lock_guard<std::recursive_mutex> guard(GetDebuggerListMutex());
DebuggerList &debugger_list = GetDebuggerList(); DebuggerList &debugger_list = GetDebuggerList();
if (index < debugger_list.size()) if (index < debugger_list.size())
@ -1194,7 +1194,7 @@ Debugger::FindDebuggerWithID (lldb::user_id_t id)
if (lldb_initialized) if (lldb_initialized)
{ {
Mutex::Locker locker (GetDebuggerListMutex ()); std::lock_guard<std::recursive_mutex> guard(GetDebuggerListMutex());
DebuggerList &debugger_list = GetDebuggerList(); DebuggerList &debugger_list = GetDebuggerList();
DebuggerList::iterator pos, end = debugger_list.end(); DebuggerList::iterator pos, end = debugger_list.end();
for (pos = debugger_list.begin(); pos != end; ++pos) for (pos = debugger_list.begin(); pos != end; ++pos)

View File

@ -169,13 +169,13 @@ IOHandler::WaitForPop ()
} }
void void
IOHandlerStack::PrintAsync (Stream *stream, const char *s, size_t len) IOHandlerStack::PrintAsync(Stream *stream, const char *s, size_t len)
{ {
if (stream) if (stream)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_top) if (m_top)
m_top->PrintAsync (stream, s, len); m_top->PrintAsync(stream, s, len);
} }
} }

View File

@ -40,12 +40,8 @@ namespace
}; };
} // anonymous namespace } // anonymous namespace
Listener::Listener(const char *name) : Listener::Listener(const char *name)
m_name (name), : m_name(name), m_broadcasters(), m_broadcasters_mutex(), m_events(), m_events_mutex(Mutex::eMutexTypeNormal)
m_broadcasters(),
m_broadcasters_mutex (Mutex::eMutexTypeRecursive),
m_events (),
m_events_mutex (Mutex::eMutexTypeNormal)
{ {
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
if (log != nullptr) if (log != nullptr)
@ -67,7 +63,7 @@ void
Listener::Clear() Listener::Clear()
{ {
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
Mutex::Locker locker(m_broadcasters_mutex); std::lock_guard<std::recursive_mutex> guard(m_broadcasters_mutex);
broadcaster_collection::iterator pos, end = m_broadcasters.end(); broadcaster_collection::iterator pos, end = m_broadcasters.end();
for (pos = m_broadcasters.begin(); pos != end; ++pos) for (pos = m_broadcasters.begin(); pos != end; ++pos)
{ {
@ -100,7 +96,7 @@ Listener::StartListeningForEvents (Broadcaster* broadcaster, uint32_t event_mask
// Scope for "locker" // Scope for "locker"
// Tell the broadcaster to add this object as a listener // Tell the broadcaster to add this object as a listener
{ {
Mutex::Locker locker(m_broadcasters_mutex); std::lock_guard<std::recursive_mutex> guard(m_broadcasters_mutex);
Broadcaster::BroadcasterImplWP impl_wp(broadcaster->GetBroadcasterImpl()); Broadcaster::BroadcasterImplWP impl_wp(broadcaster->GetBroadcasterImpl());
m_broadcasters.insert(std::make_pair(impl_wp, BroadcasterInfo(event_mask))); m_broadcasters.insert(std::make_pair(impl_wp, BroadcasterInfo(event_mask)));
} }
@ -127,7 +123,7 @@ Listener::StartListeningForEvents (Broadcaster* broadcaster, uint32_t event_mask
// Scope for "locker" // Scope for "locker"
// Tell the broadcaster to add this object as a listener // Tell the broadcaster to add this object as a listener
{ {
Mutex::Locker locker(m_broadcasters_mutex); std::lock_guard<std::recursive_mutex> guard(m_broadcasters_mutex);
Broadcaster::BroadcasterImplWP impl_wp(broadcaster->GetBroadcasterImpl()); Broadcaster::BroadcasterImplWP impl_wp(broadcaster->GetBroadcasterImpl());
m_broadcasters.insert(std::make_pair(impl_wp, m_broadcasters.insert(std::make_pair(impl_wp,
BroadcasterInfo(event_mask, callback, callback_user_data))); BroadcasterInfo(event_mask, callback, callback_user_data)));
@ -158,7 +154,7 @@ Listener::StopListeningForEvents (Broadcaster* broadcaster, uint32_t event_mask)
{ {
// Scope for "locker" // Scope for "locker"
{ {
Mutex::Locker locker(m_broadcasters_mutex); std::lock_guard<std::recursive_mutex> guard(m_broadcasters_mutex);
m_broadcasters.erase (broadcaster->GetBroadcasterImpl()); m_broadcasters.erase (broadcaster->GetBroadcasterImpl());
} }
// Remove the broadcaster from our set of broadcasters // Remove the broadcaster from our set of broadcasters
@ -175,7 +171,7 @@ Listener::BroadcasterWillDestruct (Broadcaster *broadcaster)
{ {
// Scope for "broadcasters_locker" // Scope for "broadcasters_locker"
{ {
Mutex::Locker broadcasters_locker(m_broadcasters_mutex); std::lock_guard<std::recursive_mutex> guard(m_broadcasters_mutex);
m_broadcasters.erase (broadcaster->GetBroadcasterImpl()); m_broadcasters.erase (broadcaster->GetBroadcasterImpl());
} }
@ -474,7 +470,7 @@ size_t
Listener::HandleBroadcastEvent (EventSP &event_sp) Listener::HandleBroadcastEvent (EventSP &event_sp)
{ {
size_t num_handled = 0; size_t num_handled = 0;
Mutex::Locker locker(m_broadcasters_mutex); std::lock_guard<std::recursive_mutex> guard(m_broadcasters_mutex);
Broadcaster *broadcaster = event_sp->GetBroadcaster(); Broadcaster *broadcaster = event_sp->GetBroadcaster();
if (!broadcaster) if (!broadcaster)
return 0; return 0;
@ -507,8 +503,8 @@ Listener::StartListeningForEventSpec (BroadcasterManagerSP manager_sp,
// The BroadcasterManager mutex must be locked before m_broadcasters_mutex // The BroadcasterManager mutex must be locked before m_broadcasters_mutex
// to avoid violating the lock hierarchy (manager before broadcasters). // to avoid violating the lock hierarchy (manager before broadcasters).
Mutex::Locker manager_locker(manager_sp->m_manager_mutex); std::lock_guard<std::recursive_mutex> manager_guard(manager_sp->m_manager_mutex);
Mutex::Locker locker(m_broadcasters_mutex); std::lock_guard<std::recursive_mutex> guard(m_broadcasters_mutex);
uint32_t bits_acquired = manager_sp->RegisterListenerForEvents(this->shared_from_this(), event_spec); uint32_t bits_acquired = manager_sp->RegisterListenerForEvents(this->shared_from_this(), event_spec);
if (bits_acquired) if (bits_acquired)
@ -531,7 +527,7 @@ Listener::StopListeningForEventSpec (BroadcasterManagerSP manager_sp,
if (!manager_sp) if (!manager_sp)
return false; return false;
Mutex::Locker locker(m_broadcasters_mutex); std::lock_guard<std::recursive_mutex> guard(m_broadcasters_mutex);
return manager_sp->UnregisterListenerForEvents (this->shared_from_this(), event_spec); return manager_sp->UnregisterListenerForEvents (this->shared_from_this(), event_spec);
} }

View File

@ -9,10 +9,11 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <cstdio>
#include <cstdarg> #include <cstdarg>
#include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <map> #include <map>
#include <mutex>
#include <string> #include <string>
// Other libraries and framework includes // Other libraries and framework includes
@ -26,7 +27,6 @@
#include "lldb/Core/StreamFile.h" #include "lldb/Core/StreamFile.h"
#include "lldb/Core/StreamString.h" #include "lldb/Core/StreamString.h"
#include "lldb/Host/Host.h" #include "lldb/Host/Host.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/ThisThread.h" #include "lldb/Host/ThisThread.h"
#include "lldb/Host/TimeValue.h" #include "lldb/Host/TimeValue.h"
#include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/Args.h"
@ -147,8 +147,8 @@ Log::VAPrintf(const char *format, va_list args)
if (m_options.Test(LLDB_LOG_OPTION_THREADSAFE)) if (m_options.Test(LLDB_LOG_OPTION_THREADSAFE))
{ {
static Mutex g_LogThreadedMutex(Mutex::eMutexTypeRecursive); static std::recursive_mutex g_LogThreadedMutex;
Mutex::Locker locker(g_LogThreadedMutex); std::lock_guard<std::recursive_mutex> guard(g_LogThreadedMutex);
stream_sp->PutCString(header.GetString().c_str()); stream_sp->PutCString(header.GetString().c_str());
stream_sp->Flush(); stream_sp->Flush();
} }

View File

@ -72,7 +72,7 @@ GetModuleCollection()
return *g_module_collection; return *g_module_collection;
} }
Mutex * std::recursive_mutex &
Module::GetAllocationModuleCollectionMutex() Module::GetAllocationModuleCollectionMutex()
{ {
// NOTE: The mutex below must be leaked since the global module list in // NOTE: The mutex below must be leaked since the global module list in
@ -80,23 +80,23 @@ Module::GetAllocationModuleCollectionMutex()
// if it will tear itself down before the "g_module_collection_mutex" below // if it will tear itself down before the "g_module_collection_mutex" below
// will. So we leak a Mutex object below to safeguard against that // will. So we leak a Mutex object below to safeguard against that
static Mutex *g_module_collection_mutex = nullptr; static std::recursive_mutex *g_module_collection_mutex = nullptr;
if (g_module_collection_mutex == nullptr) if (g_module_collection_mutex == nullptr)
g_module_collection_mutex = new Mutex (Mutex::eMutexTypeRecursive); // NOTE: known leak g_module_collection_mutex = new std::recursive_mutex; // NOTE: known leak
return g_module_collection_mutex; return *g_module_collection_mutex;
} }
size_t size_t
Module::GetNumberAllocatedModules () Module::GetNumberAllocatedModules ()
{ {
Mutex::Locker locker (GetAllocationModuleCollectionMutex()); std::lock_guard<std::recursive_mutex> guard(GetAllocationModuleCollectionMutex());
return GetModuleCollection().size(); return GetModuleCollection().size();
} }
Module * Module *
Module::GetAllocatedModuleAtIndex (size_t idx) Module::GetAllocatedModuleAtIndex (size_t idx)
{ {
Mutex::Locker locker (GetAllocationModuleCollectionMutex()); std::lock_guard<std::recursive_mutex> guard(GetAllocationModuleCollectionMutex());
ModuleCollection &modules = GetModuleCollection(); ModuleCollection &modules = GetModuleCollection();
if (idx < modules.size()) if (idx < modules.size())
return modules[idx]; return modules[idx];
@ -140,44 +140,42 @@ namespace lldb {
#endif #endif
Module::Module (const ModuleSpec &module_spec) : Module::Module(const ModuleSpec &module_spec)
m_mutex (Mutex::eMutexTypeRecursive), : m_mutex(),
m_mod_time (), m_mod_time(),
m_arch (), m_arch(),
m_uuid (), m_uuid(),
m_file (), m_file(),
m_platform_file(), m_platform_file(),
m_remote_install_file(), m_remote_install_file(),
m_symfile_spec (), m_symfile_spec(),
m_object_name (), m_object_name(),
m_object_offset (), m_object_offset(),
m_object_mod_time (), m_object_mod_time(),
m_objfile_sp (), m_objfile_sp(),
m_symfile_ap (), m_symfile_ap(),
m_type_system_map(), m_type_system_map(),
m_source_mappings (), m_source_mappings(),
m_sections_ap(), m_sections_ap(),
m_did_load_objfile (false), m_did_load_objfile(false),
m_did_load_symbol_vendor (false), m_did_load_symbol_vendor(false),
m_did_parse_uuid (false), m_did_parse_uuid(false),
m_file_has_changed (false), m_file_has_changed(false),
m_first_file_changed_log (false) m_first_file_changed_log(false)
{ {
// Scope for locker below... // Scope for locker below...
{ {
Mutex::Locker locker (GetAllocationModuleCollectionMutex()); std::lock_guard<std::recursive_mutex> guard(GetAllocationModuleCollectionMutex());
GetModuleCollection().push_back(this); GetModuleCollection().push_back(this);
} }
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES)); Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_MODULES));
if (log != nullptr) if (log != nullptr)
log->Printf ("%p Module::Module((%s) '%s%s%s%s')", log->Printf("%p Module::Module((%s) '%s%s%s%s')", static_cast<void *>(this),
static_cast<void*>(this), module_spec.GetArchitecture().GetArchitectureName(), module_spec.GetFileSpec().GetPath().c_str(),
module_spec.GetArchitecture().GetArchitectureName(), module_spec.GetObjectName().IsEmpty() ? "" : "(",
module_spec.GetFileSpec().GetPath().c_str(), module_spec.GetObjectName().IsEmpty() ? "" : module_spec.GetObjectName().AsCString(""),
module_spec.GetObjectName().IsEmpty() ? "" : "(", module_spec.GetObjectName().IsEmpty() ? "" : ")");
module_spec.GetObjectName().IsEmpty() ? "" : module_spec.GetObjectName().AsCString(""),
module_spec.GetObjectName().IsEmpty() ? "" : ")");
// First extract all module specifications from the file using the local // First extract all module specifications from the file using the local
// file path. If there are no specifications, then don't fill anything in // file path. If there are no specifications, then don't fill anything in
@ -236,39 +234,35 @@ Module::Module (const ModuleSpec &module_spec) :
// module specification // module specification
m_object_offset = matching_module_spec.GetObjectOffset(); m_object_offset = matching_module_spec.GetObjectOffset();
m_object_mod_time = matching_module_spec.GetObjectModificationTime(); m_object_mod_time = matching_module_spec.GetObjectModificationTime();
} }
Module::Module(const FileSpec& file_spec, Module::Module(const FileSpec &file_spec, const ArchSpec &arch, const ConstString *object_name,
const ArchSpec& arch, lldb::offset_t object_offset, const TimeValue *object_mod_time_ptr)
const ConstString *object_name, : m_mutex(),
lldb::offset_t object_offset, m_mod_time(file_spec.GetModificationTime()),
const TimeValue *object_mod_time_ptr) : m_arch(arch),
m_mutex (Mutex::eMutexTypeRecursive), m_uuid(),
m_mod_time (file_spec.GetModificationTime()), m_file(file_spec),
m_arch (arch), m_platform_file(),
m_uuid (), m_remote_install_file(),
m_file (file_spec), m_symfile_spec(),
m_platform_file(), m_object_name(),
m_remote_install_file (), m_object_offset(object_offset),
m_symfile_spec (), m_object_mod_time(),
m_object_name (), m_objfile_sp(),
m_object_offset (object_offset), m_symfile_ap(),
m_object_mod_time (), m_type_system_map(),
m_objfile_sp (), m_source_mappings(),
m_symfile_ap (), m_sections_ap(),
m_type_system_map(), m_did_load_objfile(false),
m_source_mappings (), m_did_load_symbol_vendor(false),
m_sections_ap(), m_did_parse_uuid(false),
m_did_load_objfile (false), m_file_has_changed(false),
m_did_load_symbol_vendor (false), m_first_file_changed_log(false)
m_did_parse_uuid (false),
m_file_has_changed (false),
m_first_file_changed_log (false)
{ {
// Scope for locker below... // Scope for locker below...
{ {
Mutex::Locker locker (GetAllocationModuleCollectionMutex()); std::lock_guard<std::recursive_mutex> guard(GetAllocationModuleCollectionMutex());
GetModuleCollection().push_back(this); GetModuleCollection().push_back(this);
} }
@ -278,40 +272,37 @@ Module::Module(const FileSpec& file_spec,
if (object_mod_time_ptr) if (object_mod_time_ptr)
m_object_mod_time = *object_mod_time_ptr; m_object_mod_time = *object_mod_time_ptr;
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES)); Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_OBJECT | LIBLLDB_LOG_MODULES));
if (log != nullptr) if (log != nullptr)
log->Printf ("%p Module::Module((%s) '%s%s%s%s')", log->Printf("%p Module::Module((%s) '%s%s%s%s')", static_cast<void *>(this), m_arch.GetArchitectureName(),
static_cast<void*>(this), m_arch.GetArchitectureName(), m_file.GetPath().c_str(), m_object_name.IsEmpty() ? "" : "(",
m_file.GetPath().c_str(), m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""), m_object_name.IsEmpty() ? "" : ")");
m_object_name.IsEmpty() ? "" : "(",
m_object_name.IsEmpty() ? "" : m_object_name.AsCString(""),
m_object_name.IsEmpty() ? "" : ")");
} }
Module::Module () : Module::Module()
m_mutex (Mutex::eMutexTypeRecursive), : m_mutex(),
m_mod_time (), m_mod_time(),
m_arch (), m_arch(),
m_uuid (), m_uuid(),
m_file (), m_file(),
m_platform_file(), m_platform_file(),
m_remote_install_file (), m_remote_install_file(),
m_symfile_spec (), m_symfile_spec(),
m_object_name (), m_object_name(),
m_object_offset (0), m_object_offset(0),
m_object_mod_time (), m_object_mod_time(),
m_objfile_sp (), m_objfile_sp(),
m_symfile_ap (), m_symfile_ap(),
m_type_system_map(), m_type_system_map(),
m_source_mappings (), m_source_mappings(),
m_sections_ap(), m_sections_ap(),
m_did_load_objfile (false), m_did_load_objfile(false),
m_did_load_symbol_vendor (false), m_did_load_symbol_vendor(false),
m_did_parse_uuid (false), m_did_parse_uuid(false),
m_file_has_changed (false), m_file_has_changed(false),
m_first_file_changed_log (false) m_first_file_changed_log(false)
{ {
Mutex::Locker locker (GetAllocationModuleCollectionMutex()); std::lock_guard<std::recursive_mutex> guard(GetAllocationModuleCollectionMutex());
GetModuleCollection().push_back(this); GetModuleCollection().push_back(this);
} }
@ -319,10 +310,10 @@ Module::~Module()
{ {
// Lock our module down while we tear everything down to make sure // Lock our module down while we tear everything down to make sure
// we don't get any access to the module while it is being destroyed // we don't get any access to the module while it is being destroyed
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
// Scope for locker below... // Scope for locker below...
{ {
Mutex::Locker locker (GetAllocationModuleCollectionMutex()); std::lock_guard<std::recursive_mutex> guard(GetAllocationModuleCollectionMutex());
ModuleCollection &modules = GetModuleCollection(); ModuleCollection &modules = GetModuleCollection();
ModuleCollection::iterator end = modules.end(); ModuleCollection::iterator end = modules.end();
ModuleCollection::iterator pos = std::find(modules.begin(), end, this); ModuleCollection::iterator pos = std::find(modules.begin(), end, this);
@ -357,7 +348,7 @@ Module::GetMemoryObjectFile (const lldb::ProcessSP &process_sp, lldb::addr_t hea
} }
else else
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (process_sp) if (process_sp)
{ {
m_did_load_objfile = true; m_did_load_objfile = true;
@ -405,7 +396,7 @@ Module::GetUUID()
{ {
if (!m_did_parse_uuid.load()) if (!m_did_parse_uuid.load())
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_did_parse_uuid.load()) if (!m_did_parse_uuid.load())
{ {
ObjectFile * obj_file = GetObjectFile (); ObjectFile * obj_file = GetObjectFile ();
@ -429,7 +420,7 @@ Module::GetTypeSystemForLanguage (LanguageType language)
void void
Module::ParseAllDebugSymbols() Module::ParseAllDebugSymbols()
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
size_t num_comp_units = GetNumCompileUnits(); size_t num_comp_units = GetNumCompileUnits();
if (num_comp_units == 0) if (num_comp_units == 0)
return; return;
@ -484,7 +475,7 @@ Module::DumpSymbolContext(Stream *s)
size_t size_t
Module::GetNumCompileUnits() Module::GetNumCompileUnits()
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
Timer scoped_timer(__PRETTY_FUNCTION__, Timer scoped_timer(__PRETTY_FUNCTION__,
"Module::GetNumCompileUnits (module = %p)", "Module::GetNumCompileUnits (module = %p)",
static_cast<void*>(this)); static_cast<void*>(this));
@ -497,7 +488,7 @@ Module::GetNumCompileUnits()
CompUnitSP CompUnitSP
Module::GetCompileUnitAtIndex (size_t index) Module::GetCompileUnitAtIndex (size_t index)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
size_t num_comp_units = GetNumCompileUnits (); size_t num_comp_units = GetNumCompileUnits ();
CompUnitSP cu_sp; CompUnitSP cu_sp;
@ -513,7 +504,7 @@ Module::GetCompileUnitAtIndex (size_t index)
bool bool
Module::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr) Module::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
Timer scoped_timer(__PRETTY_FUNCTION__, "Module::ResolveFileAddress (vm_addr = 0x%" PRIx64 ")", vm_addr); Timer scoped_timer(__PRETTY_FUNCTION__, "Module::ResolveFileAddress (vm_addr = 0x%" PRIx64 ")", vm_addr);
SectionList *section_list = GetSectionList(); SectionList *section_list = GetSectionList();
if (section_list) if (section_list)
@ -525,7 +516,7 @@ uint32_t
Module::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc, Module::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc,
bool resolve_tail_call_address) bool resolve_tail_call_address)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
uint32_t resolved_flags = 0; uint32_t resolved_flags = 0;
// Clear the result symbol context in case we don't find anything, but don't clear the target // Clear the result symbol context in case we don't find anything, but don't clear the target
@ -675,7 +666,7 @@ Module::ResolveSymbolContextForFilePath
uint32_t uint32_t
Module::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) Module::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
Timer scoped_timer(__PRETTY_FUNCTION__, Timer scoped_timer(__PRETTY_FUNCTION__,
"Module::ResolveSymbolContextForFilePath (%s:%u, check_inlines = %s, resolve_scope = 0x%8.8x)", "Module::ResolveSymbolContextForFilePath (%s:%u, check_inlines = %s, resolve_scope = 0x%8.8x)",
file_spec.GetPath().c_str(), file_spec.GetPath().c_str(),
@ -1037,7 +1028,7 @@ Module::GetSymbolVendor (bool can_create, lldb_private::Stream *feedback_strm)
{ {
if (!m_did_load_symbol_vendor.load()) if (!m_did_load_symbol_vendor.load())
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_did_load_symbol_vendor.load() && can_create) if (!m_did_load_symbol_vendor.load() && can_create)
{ {
ObjectFile *obj_file = GetObjectFile (); ObjectFile *obj_file = GetObjectFile ();
@ -1084,7 +1075,7 @@ Module::GetSpecificationDescription () const
void void
Module::GetDescription (Stream *s, lldb::DescriptionLevel level) Module::GetDescription (Stream *s, lldb::DescriptionLevel level)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (level >= eDescriptionLevelFull) if (level >= eDescriptionLevelFull)
{ {
@ -1245,7 +1236,7 @@ Module::LogMessageVerboseBacktrace (Log *log, const char *format, ...)
void void
Module::Dump(Stream *s) Module::Dump(Stream *s)
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
//s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); //s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
s->Indent(); s->Indent();
s->Printf("Module %s%s%s%s\n", s->Printf("Module %s%s%s%s\n",
@ -1287,7 +1278,7 @@ Module::GetObjectFile()
{ {
if (!m_did_load_objfile.load()) if (!m_did_load_objfile.load())
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_did_load_objfile.load()) if (!m_did_load_objfile.load())
{ {
Timer scoped_timer(__PRETTY_FUNCTION__, Timer scoped_timer(__PRETTY_FUNCTION__,
@ -1710,14 +1701,14 @@ Module::MatchesModuleSpec (const ModuleSpec &module_ref)
bool bool
Module::FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const Module::FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_source_mappings.FindFile (orig_spec, new_spec); return m_source_mappings.FindFile (orig_spec, new_spec);
} }
bool bool
Module::RemapSourceFile (const char *path, std::string &new_path) const Module::RemapSourceFile (const char *path, std::string &new_path) const
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_source_mappings.RemapPath(path, new_path); return m_source_mappings.RemapPath(path, new_path);
} }

File diff suppressed because it is too large Load Diff

View File

@ -18,13 +18,8 @@
using namespace lldb; using namespace lldb;
using namespace lldb_private; using namespace lldb_private;
StreamCallback::StreamCallback(lldb::LogOutputCallback callback, void *baton)
StreamCallback::StreamCallback (lldb::LogOutputCallback callback, void *baton) : : Stream(0, 4, eByteOrderBig), m_callback(callback), m_baton(baton), m_accumulated_data(), m_collection_mutex()
Stream (0, 4, eByteOrderBig),
m_callback (callback),
m_baton (baton),
m_accumulated_data (),
m_collection_mutex ()
{ {
} }
@ -35,7 +30,7 @@ StreamCallback::~StreamCallback ()
StreamString & StreamString &
StreamCallback::FindStreamForThread(lldb::tid_t cur_tid) StreamCallback::FindStreamForThread(lldb::tid_t cur_tid)
{ {
Mutex::Locker locker(m_collection_mutex); std::lock_guard<std::mutex> guard(m_collection_mutex);
collection::iterator iter = m_accumulated_data.find (cur_tid); collection::iterator iter = m_accumulated_data.find (cur_tid);
if (iter == m_accumulated_data.end()) if (iter == m_accumulated_data.end())
{ {

View File

@ -8,12 +8,12 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "lldb/Core/Timer.h" #include "lldb/Core/Timer.h"
#include <map>
#include <vector>
#include <algorithm> #include <algorithm>
#include <map>
#include <mutex>
#include <vector>
#include "lldb/Core/Stream.h" #include "lldb/Core/Stream.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Host.h" #include "lldb/Host/Host.h"
#include <stdio.h> #include <stdio.h>
@ -52,11 +52,10 @@ GetFileMutex()
return *g_file_mutex_ptr; return *g_file_mutex_ptr;
} }
static std::mutex &
static Mutex &
GetCategoryMutex() GetCategoryMutex()
{ {
static Mutex g_category_mutex(Mutex::eMutexTypeNormal); static std::mutex g_category_mutex;
return g_category_mutex; return g_category_mutex;
} }
@ -169,7 +168,7 @@ Timer::~Timer()
} }
// Keep total results for each category so we can dump results. // Keep total results for each category so we can dump results.
Mutex::Locker locker (GetCategoryMutex()); std::lock_guard<std::mutex> guard(GetCategoryMutex());
TimerCategoryMap &category_map = GetCategoryMap(); TimerCategoryMap &category_map = GetCategoryMap();
category_map[m_category] += timer_nsec_uint; category_map[m_category] += timer_nsec_uint;
} }
@ -240,7 +239,7 @@ CategoryMapIteratorSortCriterion (const TimerCategoryMap::const_iterator& lhs, c
void void
Timer::ResetCategoryTimes () Timer::ResetCategoryTimes ()
{ {
Mutex::Locker locker (GetCategoryMutex()); std::lock_guard<std::mutex> guard(GetCategoryMutex());
TimerCategoryMap &category_map = GetCategoryMap(); TimerCategoryMap &category_map = GetCategoryMap();
category_map.clear(); category_map.clear();
} }
@ -248,7 +247,7 @@ Timer::ResetCategoryTimes ()
void void
Timer::DumpCategoryTimes (Stream *s) Timer::DumpCategoryTimes (Stream *s)
{ {
Mutex::Locker locker (GetCategoryMutex()); std::lock_guard<std::mutex> guard(GetCategoryMutex());
TimerCategoryMap &category_map = GetCategoryMap(); TimerCategoryMap &category_map = GetCategoryMap();
std::vector<TimerCategoryMap::const_iterator> sorted_iterators; std::vector<TimerCategoryMap::const_iterator> sorted_iterators;
TimerCategoryMap::const_iterator pos, end = category_map.end(); TimerCategoryMap::const_iterator pos, end = category_map.end();

View File

@ -158,11 +158,13 @@ FormatCache::Entry::SetValidator (lldb::TypeValidatorImplSP validator_sp)
m_validator_sp = validator_sp; m_validator_sp = validator_sp;
} }
FormatCache::FormatCache () : FormatCache::FormatCache()
m_map(), : m_map(),
m_mutex (Mutex::eMutexTypeRecursive) m_mutex()
#ifdef LLDB_CONFIGURATION_DEBUG #ifdef LLDB_CONFIGURATION_DEBUG
,m_cache_hits(0),m_cache_misses(0) ,
m_cache_hits(0),
m_cache_misses(0)
#endif #endif
{ {
} }
@ -181,7 +183,7 @@ FormatCache::GetEntry (const ConstString& type)
bool bool
FormatCache::GetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp) FormatCache::GetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp)
{ {
Mutex::Locker lock(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
auto entry = GetEntry(type); auto entry = GetEntry(type);
if (entry.IsFormatCached()) if (entry.IsFormatCached())
{ {
@ -201,7 +203,7 @@ FormatCache::GetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_s
bool bool
FormatCache::GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp) FormatCache::GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp)
{ {
Mutex::Locker lock(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
auto entry = GetEntry(type); auto entry = GetEntry(type);
if (entry.IsSummaryCached()) if (entry.IsSummaryCached())
{ {
@ -221,7 +223,7 @@ FormatCache::GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summar
bool bool
FormatCache::GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp) FormatCache::GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp)
{ {
Mutex::Locker lock(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
auto entry = GetEntry(type); auto entry = GetEntry(type);
if (entry.IsSyntheticCached()) if (entry.IsSyntheticCached())
{ {
@ -241,7 +243,7 @@ FormatCache::GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& sy
bool bool
FormatCache::GetValidator (const ConstString& type,lldb::TypeValidatorImplSP& validator_sp) FormatCache::GetValidator (const ConstString& type,lldb::TypeValidatorImplSP& validator_sp)
{ {
Mutex::Locker lock(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
auto entry = GetEntry(type); auto entry = GetEntry(type);
if (entry.IsValidatorCached()) if (entry.IsValidatorCached())
{ {
@ -261,35 +263,35 @@ FormatCache::GetValidator (const ConstString& type,lldb::TypeValidatorImplSP& va
void void
FormatCache::SetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp) FormatCache::SetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp)
{ {
Mutex::Locker lock(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
GetEntry(type).SetFormat(format_sp); GetEntry(type).SetFormat(format_sp);
} }
void void
FormatCache::SetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp) FormatCache::SetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp)
{ {
Mutex::Locker lock(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
GetEntry(type).SetSummary(summary_sp); GetEntry(type).SetSummary(summary_sp);
} }
void void
FormatCache::SetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp) FormatCache::SetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp)
{ {
Mutex::Locker lock(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
GetEntry(type).SetSynthetic(synthetic_sp); GetEntry(type).SetSynthetic(synthetic_sp);
} }
void void
FormatCache::SetValidator (const ConstString& type,lldb::TypeValidatorImplSP& validator_sp) FormatCache::SetValidator (const ConstString& type,lldb::TypeValidatorImplSP& validator_sp)
{ {
Mutex::Locker lock(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
GetEntry(type).SetValidator(validator_sp); GetEntry(type).SetValidator(validator_sp);
} }
void void
FormatCache::Clear () FormatCache::Clear ()
{ {
Mutex::Locker lock(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_map.clear(); m_map.clear();
} }

View File

@ -128,7 +128,7 @@ FormatManager::Changed ()
{ {
++m_last_revision; ++m_last_revision;
m_format_cache.Clear (); m_format_cache.Clear ();
Mutex::Locker lang_locker(m_language_categories_mutex); std::lock_guard<std::recursive_mutex> guard(m_language_categories_mutex);
for (auto& iter : m_language_categories_map) for (auto& iter : m_language_categories_map)
{ {
if (iter.second) if (iter.second)
@ -181,7 +181,7 @@ void
FormatManager::EnableAllCategories () FormatManager::EnableAllCategories ()
{ {
m_categories_map.EnableAllCategories (); m_categories_map.EnableAllCategories ();
Mutex::Locker lang_locker(m_language_categories_mutex); std::lock_guard<std::recursive_mutex> guard(m_language_categories_mutex);
for (auto& iter : m_language_categories_map) for (auto& iter : m_language_categories_map)
{ {
if (iter.second) if (iter.second)
@ -193,7 +193,7 @@ void
FormatManager::DisableAllCategories () FormatManager::DisableAllCategories ()
{ {
m_categories_map.DisableAllCategories (); m_categories_map.DisableAllCategories ();
Mutex::Locker lang_locker(m_language_categories_mutex); std::lock_guard<std::recursive_mutex> guard(m_language_categories_mutex);
for (auto& iter : m_language_categories_map) for (auto& iter : m_language_categories_map)
{ {
if (iter.second) if (iter.second)
@ -502,7 +502,7 @@ void
FormatManager::ForEachCategory(TypeCategoryMap::ForEachCallback callback) FormatManager::ForEachCategory(TypeCategoryMap::ForEachCallback callback)
{ {
m_categories_map.ForEach(callback); m_categories_map.ForEach(callback);
Mutex::Locker locker(m_language_categories_mutex); std::lock_guard<std::recursive_mutex> guard(m_language_categories_mutex);
for (const auto& entry : m_language_categories_map) for (const auto& entry : m_language_categories_map)
{ {
if (auto category_sp = entry.second->GetCategory()) if (auto category_sp = entry.second->GetCategory())
@ -712,7 +712,7 @@ FormatManager::GetCandidateLanguages (lldb::LanguageType lang_type)
LanguageCategory* LanguageCategory*
FormatManager::GetCategoryForLanguage (lldb::LanguageType lang_type) FormatManager::GetCategoryForLanguage (lldb::LanguageType lang_type)
{ {
Mutex::Locker locker(m_language_categories_mutex); std::lock_guard<std::recursive_mutex> guard(m_language_categories_mutex);
auto iter = m_language_categories_map.find(lang_type), end = m_language_categories_map.end(); auto iter = m_language_categories_map.find(lang_type), end = m_language_categories_map.end();
if (iter != end) if (iter != end)
return iter->second.get(); return iter->second.get();
@ -1055,22 +1055,22 @@ FormatManager::GetHardcodedValidator (FormattersMatchData& match_data)
return retval_sp; return retval_sp;
} }
FormatManager::FormatManager() : FormatManager::FormatManager()
m_last_revision(0), : m_last_revision(0),
m_format_cache(), m_format_cache(),
m_language_categories_mutex(Mutex::eMutexTypeRecursive), m_language_categories_mutex(),
m_language_categories_map(), m_language_categories_map(),
m_named_summaries_map(this), m_named_summaries_map(this),
m_categories_map(this), m_categories_map(this),
m_default_category_name(ConstString("default")), m_default_category_name(ConstString("default")),
m_system_category_name(ConstString("system")), m_system_category_name(ConstString("system")),
m_vectortypes_category_name(ConstString("VectorTypes")) m_vectortypes_category_name(ConstString("VectorTypes"))
{ {
LoadSystemFormatters(); LoadSystemFormatters();
LoadVectorFormatters(); LoadVectorFormatters();
EnableCategory(m_vectortypes_category_name,TypeCategoryMap::Last, lldb::eLanguageTypeObjC_plus_plus); EnableCategory(m_vectortypes_category_name, TypeCategoryMap::Last, lldb::eLanguageTypeObjC_plus_plus);
EnableCategory(m_system_category_name,TypeCategoryMap::Last, lldb::eLanguageTypeObjC_plus_plus); EnableCategory(m_system_category_name, TypeCategoryMap::Last, lldb::eLanguageTypeObjC_plus_plus);
} }
void void

View File

@ -18,21 +18,20 @@
using namespace lldb; using namespace lldb;
using namespace lldb_private; using namespace lldb_private;
TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener* clist, TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener *clist, ConstString name,
ConstString name, std::initializer_list<lldb::LanguageType> langs)
std::initializer_list<lldb::LanguageType> langs) : : m_format_cont("format", "regex-format", clist),
m_format_cont("format","regex-format",clist), m_summary_cont("summary", "regex-summary", clist),
m_summary_cont("summary","regex-summary",clist), m_filter_cont("filter", "regex-filter", clist),
m_filter_cont("filter","regex-filter",clist),
#ifndef LLDB_DISABLE_PYTHON #ifndef LLDB_DISABLE_PYTHON
m_synth_cont("synth","regex-synth",clist), m_synth_cont("synth", "regex-synth", clist),
#endif #endif
m_validator_cont("validator","regex-validator",clist), m_validator_cont("validator", "regex-validator", clist),
m_enabled(false), m_enabled(false),
m_change_listener(clist), m_change_listener(clist),
m_mutex(Mutex::eMutexTypeRecursive), m_mutex(),
m_name(name), m_name(name),
m_languages() m_languages()
{ {
for (const lldb::LanguageType lang : langs) for (const lldb::LanguageType lang : langs)
AddLanguage(lang); AddLanguage(lang);
@ -673,7 +672,7 @@ TypeCategoryImpl::GetTypeNameSpecifierForValidatorAtIndex (size_t index)
void void
TypeCategoryImpl::Enable (bool value, uint32_t position) TypeCategoryImpl::Enable (bool value, uint32_t position)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if ( (m_enabled = value) ) if ( (m_enabled = value) )
m_enabled_position = position; m_enabled_position = position;
if (m_change_listener) if (m_change_listener)

View File

@ -20,22 +20,19 @@
using namespace lldb; using namespace lldb;
using namespace lldb_private; using namespace lldb_private;
TypeCategoryMap::TypeCategoryMap (IFormatChangeListener* lst) : TypeCategoryMap::TypeCategoryMap(IFormatChangeListener *lst)
m_map_mutex(Mutex::eMutexTypeRecursive), : m_map_mutex(), listener(lst), m_map(), m_active_categories()
listener(lst),
m_map(),
m_active_categories()
{ {
ConstString default_cs("default"); ConstString default_cs("default");
lldb::TypeCategoryImplSP default_sp = lldb::TypeCategoryImplSP(new TypeCategoryImpl(listener, default_cs)); lldb::TypeCategoryImplSP default_sp = lldb::TypeCategoryImplSP(new TypeCategoryImpl(listener, default_cs));
Add(default_cs,default_sp); Add(default_cs, default_sp);
Enable(default_cs,First); Enable(default_cs, First);
} }
void void
TypeCategoryMap::Add (KeyType name, const ValueSP& entry) TypeCategoryMap::Add (KeyType name, const ValueSP& entry)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
m_map[name] = entry; m_map[name] = entry;
if (listener) if (listener)
listener->Changed(); listener->Changed();
@ -44,7 +41,7 @@ TypeCategoryMap::Add (KeyType name, const ValueSP& entry)
bool bool
TypeCategoryMap::Delete (KeyType name) TypeCategoryMap::Delete (KeyType name)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
MapIterator iter = m_map.find(name); MapIterator iter = m_map.find(name);
if (iter == m_map.end()) if (iter == m_map.end())
return false; return false;
@ -58,7 +55,7 @@ TypeCategoryMap::Delete (KeyType name)
bool bool
TypeCategoryMap::Enable (KeyType category_name, Position pos) TypeCategoryMap::Enable (KeyType category_name, Position pos)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
ValueSP category; ValueSP category;
if (!Get(category_name,category)) if (!Get(category_name,category))
return false; return false;
@ -68,7 +65,7 @@ TypeCategoryMap::Enable (KeyType category_name, Position pos)
bool bool
TypeCategoryMap::Disable (KeyType category_name) TypeCategoryMap::Disable (KeyType category_name)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
ValueSP category; ValueSP category;
if (!Get(category_name,category)) if (!Get(category_name,category))
return false; return false;
@ -78,7 +75,7 @@ TypeCategoryMap::Disable (KeyType category_name)
bool bool
TypeCategoryMap::Enable (ValueSP category, Position pos) TypeCategoryMap::Enable (ValueSP category, Position pos)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
if (category.get()) if (category.get())
{ {
Position pos_w = pos; Position pos_w = pos;
@ -107,7 +104,7 @@ TypeCategoryMap::Enable (ValueSP category, Position pos)
bool bool
TypeCategoryMap::Disable (ValueSP category) TypeCategoryMap::Disable (ValueSP category)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
if (category.get()) if (category.get())
{ {
m_active_categories.remove_if(delete_matching_categories(category)); m_active_categories.remove_if(delete_matching_categories(category));
@ -120,7 +117,7 @@ TypeCategoryMap::Disable (ValueSP category)
void void
TypeCategoryMap::EnableAllCategories () TypeCategoryMap::EnableAllCategories ()
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
std::vector<ValueSP> sorted_categories(m_map.size(), ValueSP()); std::vector<ValueSP> sorted_categories(m_map.size(), ValueSP());
MapType::iterator iter = m_map.begin(), end = m_map.end(); MapType::iterator iter = m_map.begin(), end = m_map.end();
for (; iter != end; ++iter) for (; iter != end; ++iter)
@ -148,7 +145,7 @@ TypeCategoryMap::EnableAllCategories ()
void void
TypeCategoryMap::DisableAllCategories () TypeCategoryMap::DisableAllCategories ()
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
Position p = First; Position p = First;
for (; false == m_active_categories.empty(); p++) for (; false == m_active_categories.empty(); p++)
{ {
@ -160,7 +157,7 @@ TypeCategoryMap::DisableAllCategories ()
void void
TypeCategoryMap::Clear () TypeCategoryMap::Clear ()
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
m_map.clear(); m_map.clear();
m_active_categories.clear(); m_active_categories.clear();
if (listener) if (listener)
@ -170,7 +167,7 @@ TypeCategoryMap::Clear ()
bool bool
TypeCategoryMap::Get (KeyType name, ValueSP& entry) TypeCategoryMap::Get (KeyType name, ValueSP& entry)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
MapIterator iter = m_map.find(name); MapIterator iter = m_map.find(name);
if (iter == m_map.end()) if (iter == m_map.end())
return false; return false;
@ -181,7 +178,7 @@ TypeCategoryMap::Get (KeyType name, ValueSP& entry)
bool bool
TypeCategoryMap::Get (uint32_t pos, ValueSP& entry) TypeCategoryMap::Get (uint32_t pos, ValueSP& entry)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
MapIterator iter = m_map.begin(); MapIterator iter = m_map.begin();
MapIterator end = m_map.end(); MapIterator end = m_map.end();
while (pos > 0) while (pos > 0)
@ -202,7 +199,7 @@ TypeCategoryMap::AnyMatches (ConstString type_name,
const char** matching_category, const char** matching_category,
TypeCategoryImpl::FormatCategoryItems* matching_type) TypeCategoryImpl::FormatCategoryItems* matching_type)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
MapIterator pos, end = m_map.end(); MapIterator pos, end = m_map.end();
for (pos = m_map.begin(); pos != end; pos++) for (pos = m_map.begin(); pos != end; pos++)
@ -220,7 +217,7 @@ TypeCategoryMap::AnyMatches (ConstString type_name,
lldb::TypeFormatImplSP lldb::TypeFormatImplSP
TypeCategoryMap::GetFormat (FormattersMatchData& match_data) TypeCategoryMap::GetFormat (FormattersMatchData& match_data)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
uint32_t reason_why; uint32_t reason_why;
ActiveCategoriesIterator begin, end = m_active_categories.end(); ActiveCategoriesIterator begin, end = m_active_categories.end();
@ -258,7 +255,7 @@ TypeCategoryMap::GetFormat (FormattersMatchData& match_data)
lldb::TypeSummaryImplSP lldb::TypeSummaryImplSP
TypeCategoryMap::GetSummaryFormat (FormattersMatchData& match_data) TypeCategoryMap::GetSummaryFormat (FormattersMatchData& match_data)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
uint32_t reason_why; uint32_t reason_why;
ActiveCategoriesIterator begin, end = m_active_categories.end(); ActiveCategoriesIterator begin, end = m_active_categories.end();
@ -297,7 +294,7 @@ TypeCategoryMap::GetSummaryFormat (FormattersMatchData& match_data)
lldb::SyntheticChildrenSP lldb::SyntheticChildrenSP
TypeCategoryMap::GetSyntheticChildren (FormattersMatchData& match_data) TypeCategoryMap::GetSyntheticChildren (FormattersMatchData& match_data)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
uint32_t reason_why; uint32_t reason_why;
@ -337,7 +334,7 @@ TypeCategoryMap::GetSyntheticChildren (FormattersMatchData& match_data)
lldb::TypeValidatorImplSP lldb::TypeValidatorImplSP
TypeCategoryMap::GetValidator (FormattersMatchData& match_data) TypeCategoryMap::GetValidator (FormattersMatchData& match_data)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
uint32_t reason_why; uint32_t reason_why;
ActiveCategoriesIterator begin, end = m_active_categories.end(); ActiveCategoriesIterator begin, end = m_active_categories.end();
@ -377,7 +374,7 @@ TypeCategoryMap::ForEach(ForEachCallback callback)
{ {
if (callback) if (callback)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
// loop through enabled categories in respective order // loop through enabled categories in respective order
{ {
@ -408,7 +405,7 @@ TypeCategoryMap::ForEach(ForEachCallback callback)
TypeCategoryImplSP TypeCategoryImplSP
TypeCategoryMap::GetAtIndex (uint32_t index) TypeCategoryMap::GetAtIndex (uint32_t index)
{ {
Mutex::Locker locker(m_map_mutex); std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
if (index < m_map.size()) if (index < m_map.size())
{ {

View File

@ -247,7 +247,7 @@ IRExecutionUnit::GetRunnableInfo(Error &error,
{ {
lldb::ProcessSP process_sp(GetProcessWP().lock()); lldb::ProcessSP process_sp(GetProcessWP().lock());
static Mutex s_runnable_info_mutex(Mutex::Type::eMutexTypeRecursive); static std::recursive_mutex s_runnable_info_mutex;
func_addr = LLDB_INVALID_ADDRESS; func_addr = LLDB_INVALID_ADDRESS;
func_end = LLDB_INVALID_ADDRESS; func_end = LLDB_INVALID_ADDRESS;
@ -267,7 +267,7 @@ IRExecutionUnit::GetRunnableInfo(Error &error,
return; return;
}; };
Mutex::Locker runnable_info_mutex_locker(s_runnable_info_mutex); std::lock_guard<std::recursive_mutex> guard(s_runnable_info_mutex);
m_did_jit = true; m_did_jit = true;

View File

@ -19,7 +19,6 @@
#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSpec.h"
#include "lldb/Host/FileSystem.h" #include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h" #include "lldb/Host/Host.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/LLDBAssert.h"
using namespace lldb_private; using namespace lldb_private;
@ -227,9 +226,9 @@ namespace lldb_private
GetHistory (const std::string &prefix) GetHistory (const std::string &prefix)
{ {
typedef std::map<std::string, EditlineHistoryWP> WeakHistoryMap; typedef std::map<std::string, EditlineHistoryWP> WeakHistoryMap;
static Mutex g_mutex (Mutex::eMutexTypeRecursive); static std::recursive_mutex g_mutex;
static WeakHistoryMap g_weak_map; static WeakHistoryMap g_weak_map;
Mutex::Locker locker (g_mutex); std::lock_guard<std::recursive_mutex> guard(g_mutex);
WeakHistoryMap::const_iterator pos = g_weak_map.find (prefix); WeakHistoryMap::const_iterator pos = g_weak_map.find (prefix);
EditlineHistorySP history_sp; EditlineHistorySP history_sp;
if (pos != g_weak_map.end()) if (pos != g_weak_map.end())
@ -587,9 +586,9 @@ Editline::GetCharacter (EditLineCharType * c)
// (blocking operation), so we do not hold the mutex indefinitely. This gives a chance // (blocking operation), so we do not hold the mutex indefinitely. This gives a chance
// for someone to interrupt us. After Read returns, immediately lock the mutex again and // for someone to interrupt us. After Read returns, immediately lock the mutex again and
// check if we were interrupted. // check if we were interrupted.
m_output_mutex.Unlock(); m_output_mutex.unlock();
int read_count = m_input_connection.Read(&ch, 1, UINT32_MAX, status, NULL); int read_count = m_input_connection.Read(&ch, 1, UINT32_MAX, status, NULL);
m_output_mutex.Lock(); m_output_mutex.lock();
if (m_editor_status == EditorStatus::Interrupted) if (m_editor_status == EditorStatus::Interrupted)
{ {
while (read_count > 0 && status == lldb::eConnectionStatusSuccess) while (read_count > 0 && status == lldb::eConnectionStatusSuccess)
@ -1284,7 +1283,7 @@ bool
Editline::Interrupt() Editline::Interrupt()
{ {
bool result = true; bool result = true;
Mutex::Locker locker(m_output_mutex); std::lock_guard<std::mutex> guard(m_output_mutex);
if (m_editor_status == EditorStatus::Editing) { if (m_editor_status == EditorStatus::Editing) {
fprintf(m_output_file, "^C\n"); fprintf(m_output_file, "^C\n");
result = m_input_connection.InterruptRead(); result = m_input_connection.InterruptRead();
@ -1297,7 +1296,7 @@ bool
Editline::Cancel() Editline::Cancel()
{ {
bool result = true; bool result = true;
Mutex::Locker locker(m_output_mutex); std::lock_guard<std::mutex> guard(m_output_mutex);
if (m_editor_status == EditorStatus::Editing) { if (m_editor_status == EditorStatus::Editing) {
MoveCursor(CursorLocation::EditingCursor, CursorLocation::BlockStart); MoveCursor(CursorLocation::EditingCursor, CursorLocation::BlockStart);
fprintf(m_output_file, ANSI_CLEAR_BELOW); fprintf(m_output_file, ANSI_CLEAR_BELOW);
@ -1339,7 +1338,7 @@ Editline::GetLine (std::string &line, bool &interrupted)
m_input_lines = std::vector<EditLineStringType>(); m_input_lines = std::vector<EditLineStringType>();
m_input_lines.insert (m_input_lines.begin(), EditLineConstString("")); m_input_lines.insert (m_input_lines.begin(), EditLineConstString(""));
Mutex::Locker locker(m_output_mutex); std::lock_guard<std::mutex> guard(m_output_mutex);
lldbassert(m_editor_status != EditorStatus::Editing); lldbassert(m_editor_status != EditorStatus::Editing);
if (m_editor_status == EditorStatus::Interrupted) if (m_editor_status == EditorStatus::Interrupted)
@ -1393,7 +1392,7 @@ Editline::GetLines (int first_line_number, StringList &lines, bool &interrupted)
m_input_lines = std::vector<EditLineStringType>(); m_input_lines = std::vector<EditLineStringType>();
m_input_lines.insert (m_input_lines.begin(), EditLineConstString("")); m_input_lines.insert (m_input_lines.begin(), EditLineConstString(""));
Mutex::Locker locker(m_output_mutex); std::lock_guard<std::mutex> guard(m_output_mutex);
// Begin the line editing loop // Begin the line editing loop
DisplayInput(); DisplayInput();
SetCurrentLine (0); SetCurrentLine (0);
@ -1427,7 +1426,7 @@ Editline::GetLines (int first_line_number, StringList &lines, bool &interrupted)
void void
Editline::PrintAsync (Stream *stream, const char *s, size_t len) Editline::PrintAsync (Stream *stream, const char *s, size_t len)
{ {
Mutex::Locker locker(m_output_mutex); std::lock_guard<std::mutex> guard(m_output_mutex);
if (m_editor_status == EditorStatus::Editing) if (m_editor_status == EditorStatus::Editing)
{ {
MoveCursor(CursorLocation::EditingCursor, CursorLocation::BlockStart); MoveCursor(CursorLocation::EditingCursor, CursorLocation::BlockStart);

View File

@ -17,8 +17,7 @@
using namespace lldb; using namespace lldb;
using namespace lldb_private; using namespace lldb_private;
NativeBreakpointList::NativeBreakpointList () : NativeBreakpointList::NativeBreakpointList() : m_mutex()
m_mutex (Mutex::eMutexTypeRecursive)
{ {
} }
@ -29,7 +28,7 @@ NativeBreakpointList::AddRef (lldb::addr_t addr, size_t size_hint, bool hardware
if (log) if (log)
log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64 ", size_hint = %lu, hardware = %s", __FUNCTION__, addr, size_hint, hardware ? "true" : "false"); log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64 ", size_hint = %lu, hardware = %s", __FUNCTION__, addr, size_hint, hardware ? "true" : "false");
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
// Check if the breakpoint is already set. // Check if the breakpoint is already set.
auto iter = m_breakpoints.find (addr); auto iter = m_breakpoints.find (addr);
@ -72,7 +71,7 @@ NativeBreakpointList::DecRef (lldb::addr_t addr)
if (log) if (log)
log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr); log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
// Check if the breakpoint is already set. // Check if the breakpoint is already set.
auto iter = m_breakpoints.find (addr); auto iter = m_breakpoints.find (addr);
@ -136,7 +135,7 @@ NativeBreakpointList::EnableBreakpoint (lldb::addr_t addr)
if (log) if (log)
log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr); log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
// Ensure we have said breakpoint. // Ensure we have said breakpoint.
auto iter = m_breakpoints.find (addr); auto iter = m_breakpoints.find (addr);
@ -159,7 +158,7 @@ NativeBreakpointList::DisableBreakpoint (lldb::addr_t addr)
if (log) if (log)
log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr); log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
// Ensure we have said breakpoint. // Ensure we have said breakpoint.
auto iter = m_breakpoints.find (addr); auto iter = m_breakpoints.find (addr);
@ -182,7 +181,7 @@ NativeBreakpointList::GetBreakpoint (lldb::addr_t addr, NativeBreakpointSP &brea
if (log) if (log)
log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr); log->Printf ("NativeBreakpointList::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
Mutex::Locker locker (m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
// Ensure we have said breakpoint. // Ensure we have said breakpoint.
auto iter = m_breakpoints.find (addr); auto iter = m_breakpoints.find (addr);

View File

@ -26,22 +26,22 @@ using namespace lldb_private;
// NativeProcessProtocol Members // NativeProcessProtocol Members
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
NativeProcessProtocol::NativeProcessProtocol (lldb::pid_t pid) : NativeProcessProtocol::NativeProcessProtocol(lldb::pid_t pid)
m_pid (pid), : m_pid(pid),
m_threads (), m_threads(),
m_current_thread_id (LLDB_INVALID_THREAD_ID), m_current_thread_id(LLDB_INVALID_THREAD_ID),
m_threads_mutex (Mutex::eMutexTypeRecursive), m_threads_mutex(),
m_state (lldb::eStateInvalid), m_state(lldb::eStateInvalid),
m_state_mutex (Mutex::eMutexTypeRecursive), m_state_mutex(),
m_exit_type (eExitTypeInvalid), m_exit_type(eExitTypeInvalid),
m_exit_status (0), m_exit_status(0),
m_exit_description (), m_exit_description(),
m_delegates_mutex (Mutex::eMutexTypeRecursive), m_delegates_mutex(),
m_delegates (), m_delegates(),
m_breakpoint_list (), m_breakpoint_list(),
m_watchpoint_list (), m_watchpoint_list(),
m_terminal_fd (-1), m_terminal_fd(-1),
m_stop_id (0) m_stop_id(0)
{ {
} }
@ -117,7 +117,7 @@ NativeProcessProtocol::SetExitStatus (ExitType exit_type, int status, const char
NativeThreadProtocolSP NativeThreadProtocolSP
NativeProcessProtocol::GetThreadAtIndex (uint32_t idx) NativeProcessProtocol::GetThreadAtIndex (uint32_t idx)
{ {
Mutex::Locker locker (m_threads_mutex); std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
if (idx < m_threads.size ()) if (idx < m_threads.size ())
return m_threads[idx]; return m_threads[idx];
return NativeThreadProtocolSP (); return NativeThreadProtocolSP ();
@ -137,7 +137,7 @@ NativeProcessProtocol::GetThreadByIDUnlocked (lldb::tid_t tid)
NativeThreadProtocolSP NativeThreadProtocolSP
NativeProcessProtocol::GetThreadByID (lldb::tid_t tid) NativeProcessProtocol::GetThreadByID (lldb::tid_t tid)
{ {
Mutex::Locker locker (m_threads_mutex); std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
return GetThreadByIDUnlocked (tid); return GetThreadByIDUnlocked (tid);
} }
@ -221,7 +221,7 @@ NativeProcessProtocol::SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t w
// conceivable that if there are more threads than hardware // conceivable that if there are more threads than hardware
// watchpoints available, some of the threads will fail to set // watchpoints available, some of the threads will fail to set
// hardware watchpoints while software ones may be available. // hardware watchpoints while software ones may be available.
Mutex::Locker locker (m_threads_mutex); std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
for (auto thread_sp : m_threads) for (auto thread_sp : m_threads)
{ {
assert (thread_sp && "thread list should not have a NULL thread!"); assert (thread_sp && "thread list should not have a NULL thread!");
@ -276,7 +276,7 @@ NativeProcessProtocol::RemoveWatchpoint (lldb::addr_t addr)
Error overall_error; Error overall_error;
Mutex::Locker locker (m_threads_mutex); std::lock_guard<std::recursive_mutex> guard(m_threads_mutex);
for (auto thread_sp : m_threads) for (auto thread_sp : m_threads)
{ {
assert (thread_sp && "thread list should not have a NULL thread!"); assert (thread_sp && "thread list should not have a NULL thread!");
@ -300,7 +300,7 @@ NativeProcessProtocol::RemoveWatchpoint (lldb::addr_t addr)
bool bool
NativeProcessProtocol::RegisterNativeDelegate (NativeDelegate &native_delegate) NativeProcessProtocol::RegisterNativeDelegate (NativeDelegate &native_delegate)
{ {
Mutex::Locker locker (m_delegates_mutex); std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
if (std::find (m_delegates.begin (), m_delegates.end (), &native_delegate) != m_delegates.end ()) if (std::find (m_delegates.begin (), m_delegates.end (), &native_delegate) != m_delegates.end ())
return false; return false;
@ -312,7 +312,7 @@ NativeProcessProtocol::RegisterNativeDelegate (NativeDelegate &native_delegate)
bool bool
NativeProcessProtocol::UnregisterNativeDelegate (NativeDelegate &native_delegate) NativeProcessProtocol::UnregisterNativeDelegate (NativeDelegate &native_delegate)
{ {
Mutex::Locker locker (m_delegates_mutex); std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
const auto initial_size = m_delegates.size (); const auto initial_size = m_delegates.size ();
m_delegates.erase (remove (m_delegates.begin (), m_delegates.end (), &native_delegate), m_delegates.end ()); m_delegates.erase (remove (m_delegates.begin (), m_delegates.end (), &native_delegate), m_delegates.end ());
@ -327,7 +327,7 @@ NativeProcessProtocol::SynchronouslyNotifyProcessStateChanged (lldb::StateType s
{ {
Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
Mutex::Locker locker (m_delegates_mutex); std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
for (auto native_delegate: m_delegates) for (auto native_delegate: m_delegates)
native_delegate->ProcessStateChanged (this, state); native_delegate->ProcessStateChanged (this, state);
@ -354,7 +354,7 @@ NativeProcessProtocol::NotifyDidExec ()
log->Printf ("NativeProcessProtocol::%s - preparing to call delegates", __FUNCTION__); log->Printf ("NativeProcessProtocol::%s - preparing to call delegates", __FUNCTION__);
{ {
Mutex::Locker locker (m_delegates_mutex); std::lock_guard<std::recursive_mutex> guard(m_delegates_mutex);
for (auto native_delegate: m_delegates) for (auto native_delegate: m_delegates)
native_delegate->DidExec (this); native_delegate->DidExec (this);
} }
@ -394,14 +394,14 @@ NativeProcessProtocol::DisableBreakpoint (lldb::addr_t addr)
lldb::StateType lldb::StateType
NativeProcessProtocol::GetState () const NativeProcessProtocol::GetState () const
{ {
Mutex::Locker locker (m_state_mutex); std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
return m_state; return m_state;
} }
void void
NativeProcessProtocol::SetState (lldb::StateType state, bool notify_delegates) NativeProcessProtocol::SetState (lldb::StateType state, bool notify_delegates)
{ {
Mutex::Locker locker (m_state_mutex); std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
if (state == m_state) if (state == m_state)
return; return;
@ -426,8 +426,8 @@ NativeProcessProtocol::SetState (lldb::StateType state, bool notify_delegates)
uint32_t NativeProcessProtocol::GetStopID () const uint32_t NativeProcessProtocol::GetStopID () const
{ {
Mutex::Locker locker (m_state_mutex); std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
return m_stop_id; return m_stop_id;
} }
void void

View File

@ -12,7 +12,6 @@
#include "lldb/Core/Error.h" #include "lldb/Core/Error.h"
#include "lldb/Core/Log.h" #include "lldb/Core/Log.h"
#include "lldb/Host/Debug.h" #include "lldb/Host/Debug.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Host/common/NativeProcessProtocol.h"

View File

@ -556,10 +556,10 @@ LaunchInNewTerminalWithAppleScript (const char *exe_path, ProcessLaunchInfo &lau
// On MacOSX CrashReporter will display a string for each shared library if // On MacOSX CrashReporter will display a string for each shared library if
// the shared library has an exported symbol named "__crashreporter_info__". // the shared library has an exported symbol named "__crashreporter_info__".
static Mutex& static std::mutex &
GetCrashReporterMutex () GetCrashReporterMutex()
{ {
static Mutex g_mutex; static std::mutex g_mutex;
return g_mutex; return g_mutex;
} }
@ -573,7 +573,7 @@ void
Host::SetCrashDescriptionWithFormat (const char *format, ...) Host::SetCrashDescriptionWithFormat (const char *format, ...)
{ {
static StreamString g_crash_description; static StreamString g_crash_description;
Mutex::Locker locker (GetCrashReporterMutex ()); std::lock_guard<std::mutex> guard(GetCrashReporterMutex());
if (format) if (format)
{ {
@ -593,7 +593,7 @@ Host::SetCrashDescriptionWithFormat (const char *format, ...)
void void
Host::SetCrashDescription (const char *cstr) Host::SetCrashDescription (const char *cstr)
{ {
Mutex::Locker locker (GetCrashReporterMutex ()); std::lock_guard<std::mutex> guard(GetCrashReporterMutex());
static std::string g_crash_description; static std::string g_crash_description;
if (cstr) if (cstr)
{ {

View File

@ -79,12 +79,12 @@ GetURLAddress(const char *url, const char *scheme)
} }
ConnectionFileDescriptor::ConnectionFileDescriptor(bool child_processes_inherit) ConnectionFileDescriptor::ConnectionFileDescriptor(bool child_processes_inherit)
: Connection() : Connection(),
, m_pipe() m_pipe(),
, m_mutex(Mutex::eMutexTypeRecursive) m_mutex(),
, m_shutting_down(false) m_shutting_down(false),
, m_waiting_for_accept(false) m_waiting_for_accept(false),
, m_child_processes_inherit(child_processes_inherit) m_child_processes_inherit(child_processes_inherit)
{ {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT)); Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
if (log) if (log)
@ -92,30 +92,30 @@ ConnectionFileDescriptor::ConnectionFileDescriptor(bool child_processes_inherit)
} }
ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, bool owns_fd) ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, bool owns_fd)
: Connection() : Connection(),
, m_pipe() m_pipe(),
, m_mutex(Mutex::eMutexTypeRecursive) m_mutex(),
, m_shutting_down(false) m_shutting_down(false),
, m_waiting_for_accept(false) m_waiting_for_accept(false),
, m_child_processes_inherit(false) m_child_processes_inherit(false)
{ {
m_write_sp.reset(new File(fd, owns_fd)); m_write_sp.reset(new File(fd, owns_fd));
m_read_sp.reset(new File(fd, false)); m_read_sp.reset(new File(fd, false));
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT)); Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
if (log) if (log)
log->Printf("%p ConnectionFileDescriptor::ConnectionFileDescriptor (fd = %i, owns_fd = %i)", static_cast<void *>(this), fd, log->Printf("%p ConnectionFileDescriptor::ConnectionFileDescriptor (fd = %i, owns_fd = %i)",
owns_fd); static_cast<void *>(this), fd, owns_fd);
OpenCommandPipe(); OpenCommandPipe();
} }
ConnectionFileDescriptor::ConnectionFileDescriptor(Socket* socket) ConnectionFileDescriptor::ConnectionFileDescriptor(Socket *socket)
: Connection() : Connection(),
, m_pipe() m_pipe(),
, m_mutex(Mutex::eMutexTypeRecursive) m_mutex(),
, m_shutting_down(false) m_shutting_down(false),
, m_waiting_for_accept(false) m_waiting_for_accept(false),
, m_child_processes_inherit(false) m_child_processes_inherit(false)
{ {
InitializeSocket(socket); InitializeSocket(socket);
} }
@ -170,7 +170,7 @@ ConnectionFileDescriptor::IsConnected() const
ConnectionStatus ConnectionStatus
ConnectionFileDescriptor::Connect(const char *s, Error *error_ptr) ConnectionFileDescriptor::Connect(const char *s, Error *error_ptr)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
if (log) if (log)
log->Printf("%p ConnectionFileDescriptor::Connect (url = '%s')", static_cast<void *>(this), s); log->Printf("%p ConnectionFileDescriptor::Connect (url = '%s')", static_cast<void *>(this), s);
@ -374,10 +374,8 @@ ConnectionFileDescriptor::Disconnect(Error *error_ptr)
m_shutting_down = true; m_shutting_down = true;
Mutex::Locker locker; std::unique_lock<std::recursive_mutex> locker(m_mutex, std::defer_lock);
bool got_lock = locker.TryLock(m_mutex); if (!locker.try_lock())
if (!got_lock)
{ {
if (m_pipe.CanWrite()) if (m_pipe.CanWrite())
{ {
@ -392,7 +390,7 @@ ConnectionFileDescriptor::Disconnect(Error *error_ptr)
log->Printf("%p ConnectionFileDescriptor::Disconnect(): Couldn't get the lock, but no command pipe is available.", log->Printf("%p ConnectionFileDescriptor::Disconnect(): Couldn't get the lock, but no command pipe is available.",
static_cast<void *>(this)); static_cast<void *>(this));
} }
locker.Lock(m_mutex); locker.lock();
} }
Error error = m_read_sp->Close(); Error error = m_read_sp->Close();
@ -415,9 +413,8 @@ ConnectionFileDescriptor::Read(void *dst, size_t dst_len, uint32_t timeout_usec,
{ {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION)); Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
Mutex::Locker locker; std::unique_lock<std::recursive_mutex> locker(m_mutex, std::defer_lock);
bool got_lock = locker.TryLock(m_mutex); if (!locker.try_lock())
if (!got_lock)
{ {
if (log) if (log)
log->Printf("%p ConnectionFileDescriptor::Read () failed to get the connection lock.", static_cast<void *>(this)); log->Printf("%p ConnectionFileDescriptor::Read () failed to get the connection lock.", static_cast<void *>(this));

View File

@ -10,16 +10,13 @@
#include "lldb/Initialization/SystemLifetimeManager.h" #include "lldb/Initialization/SystemLifetimeManager.h"
#include "lldb/Core/Debugger.h" #include "lldb/Core/Debugger.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Initialization/SystemInitializer.h" #include "lldb/Initialization/SystemInitializer.h"
#include <utility> #include <utility>
using namespace lldb_private; using namespace lldb_private;
SystemLifetimeManager::SystemLifetimeManager() SystemLifetimeManager::SystemLifetimeManager() : m_mutex(), m_initialized(false)
: m_mutex(Mutex::eMutexTypeRecursive)
, m_initialized(false)
{ {
} }
@ -32,7 +29,7 @@ void
SystemLifetimeManager::Initialize(std::unique_ptr<SystemInitializer> initializer, SystemLifetimeManager::Initialize(std::unique_ptr<SystemInitializer> initializer,
LoadPluginCallbackType plugin_callback) LoadPluginCallbackType plugin_callback)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_initialized) if (!m_initialized)
{ {
assert(!m_initializer && assert(!m_initializer &&
@ -48,7 +45,7 @@ SystemLifetimeManager::Initialize(std::unique_ptr<SystemInitializer> initializer
void void
SystemLifetimeManager::Terminate() SystemLifetimeManager::Terminate()
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_initialized) if (m_initialized)
{ {

View File

@ -15,10 +15,7 @@
using namespace lldb; using namespace lldb;
using namespace lldb_private; using namespace lldb_private;
CommandHistory::CommandHistory() : m_mutex(), m_history()
CommandHistory::CommandHistory () :
m_mutex(Mutex::eMutexTypeRecursive),
m_history()
{} {}
CommandHistory::~CommandHistory () CommandHistory::~CommandHistory ()
@ -27,21 +24,21 @@ CommandHistory::~CommandHistory ()
size_t size_t
CommandHistory::GetSize () const CommandHistory::GetSize () const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_history.size(); return m_history.size();
} }
bool bool
CommandHistory::IsEmpty () const CommandHistory::IsEmpty () const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_history.empty(); return m_history.empty();
} }
const char* const char*
CommandHistory::FindString (const char* input_str) const CommandHistory::FindString (const char* input_str) const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!input_str) if (!input_str)
return nullptr; return nullptr;
if (input_str[0] != g_repeat_char) if (input_str[0] != g_repeat_char)
@ -80,7 +77,7 @@ CommandHistory::FindString (const char* input_str) const
const char* const char*
CommandHistory::GetStringAtIndex (size_t idx) const CommandHistory::GetStringAtIndex (size_t idx) const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (idx < m_history.size()) if (idx < m_history.size())
return m_history[idx].c_str(); return m_history[idx].c_str();
return nullptr; return nullptr;
@ -95,7 +92,7 @@ CommandHistory::operator [] (size_t idx) const
const char* const char*
CommandHistory::GetRecentmostString () const CommandHistory::GetRecentmostString () const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_history.empty()) if (m_history.empty())
return nullptr; return nullptr;
return m_history.back().c_str(); return m_history.back().c_str();
@ -105,7 +102,7 @@ void
CommandHistory::AppendString (const std::string& str, CommandHistory::AppendString (const std::string& str,
bool reject_if_dupe) bool reject_if_dupe)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (reject_if_dupe) if (reject_if_dupe)
{ {
if (!m_history.empty()) if (!m_history.empty())
@ -120,7 +117,7 @@ CommandHistory::AppendString (const std::string& str,
void void
CommandHistory::Clear () CommandHistory::Clear ()
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_history.clear(); m_history.clear();
} }
@ -129,7 +126,7 @@ CommandHistory::Dump (Stream& stream,
size_t start_idx, size_t start_idx,
size_t stop_idx) const size_t stop_idx) const
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
stop_idx = std::min(stop_idx + 1, m_history.size()); stop_idx = std::min(stop_idx + 1, m_history.size());
for (size_t counter = start_idx; for (size_t counter = start_idx;
counter < stop_idx; counter < stop_idx;

View File

@ -13,6 +13,7 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <memory> #include <memory>
#include <mutex>
#include <string> #include <string>
// Other libraries and framework includes // Other libraries and framework includes
@ -22,7 +23,6 @@
#include "lldb/Core/Address.h" #include "lldb/Core/Address.h"
#include "lldb/Core/Disassembler.h" #include "lldb/Core/Disassembler.h"
#include "lldb/Core/PluginManager.h" #include "lldb/Core/PluginManager.h"
#include "lldb/Host/Mutex.h"
// Opaque references to C++ Objects in LLVM's MC. // Opaque references to C++ Objects in LLVM's MC.
namespace llvm namespace llvm
@ -147,7 +147,7 @@ protected:
void Lock(InstructionLLVMC *inst, void Lock(InstructionLLVMC *inst,
const lldb_private::ExecutionContext *exe_ctx) const lldb_private::ExecutionContext *exe_ctx)
{ {
m_mutex.Lock(); m_mutex.lock();
m_inst = inst; m_inst = inst;
m_exe_ctx = exe_ctx; m_exe_ctx = exe_ctx;
} }
@ -156,12 +156,12 @@ protected:
{ {
m_inst = NULL; m_inst = NULL;
m_exe_ctx = NULL; m_exe_ctx = NULL;
m_mutex.Unlock(); m_mutex.unlock();
} }
const lldb_private::ExecutionContext *m_exe_ctx; const lldb_private::ExecutionContext *m_exe_ctx;
InstructionLLVMC *m_inst; InstructionLLVMC *m_inst;
lldb_private::Mutex m_mutex; std::mutex m_mutex;
bool m_data_from_file; bool m_data_from_file;
std::unique_ptr<LLVMCDisassembler> m_disasm_ap; std::unique_ptr<LLVMCDisassembler> m_disasm_ap;

View File

@ -452,16 +452,16 @@ DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress (lldb::addr_t addr, Proc
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Constructor // Constructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel (Process* process, lldb::addr_t kernel_addr) : DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel(Process *process, lldb::addr_t kernel_addr)
DynamicLoader(process), : DynamicLoader(process),
m_kernel_load_address (kernel_addr), m_kernel_load_address(kernel_addr),
m_kernel(), m_kernel(),
m_kext_summary_header_ptr_addr (), m_kext_summary_header_ptr_addr(),
m_kext_summary_header_addr (), m_kext_summary_header_addr(),
m_kext_summary_header (), m_kext_summary_header(),
m_known_kexts (), m_known_kexts(),
m_mutex(Mutex::eMutexTypeRecursive), m_mutex(),
m_break_id (LLDB_INVALID_BREAK_ID) m_break_id(LLDB_INVALID_BREAK_ID)
{ {
Error error; Error error;
PlatformSP platform_sp(Platform::Create(PlatformDarwinKernel::GetPluginNameStatic(), error)); PlatformSP platform_sp(Platform::Create(PlatformDarwinKernel::GetPluginNameStatic(), error));
@ -470,7 +470,7 @@ DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel (Process* process, lldb::ad
// shouldn't be done if kext loading is explicitly disabled. // shouldn't be done if kext loading is explicitly disabled.
if (platform_sp.get() && GetGlobalProperties()->GetLoadKexts()) if (platform_sp.get() && GetGlobalProperties()->GetLoadKexts())
{ {
process->GetTarget().SetPlatform (platform_sp); process->GetTarget().SetPlatform(platform_sp);
} }
} }
@ -521,7 +521,7 @@ DynamicLoaderDarwinKernel::DidLaunch ()
void void
DynamicLoaderDarwinKernel::Clear (bool clear_process) DynamicLoaderDarwinKernel::Clear (bool clear_process)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_process->IsAlive() && LLDB_BREAK_ID_IS_VALID(m_break_id)) if (m_process->IsAlive() && LLDB_BREAK_ID_IS_VALID(m_break_id))
m_process->ClearBreakpointSiteByID(m_break_id); m_process->ClearBreakpointSiteByID(m_break_id);
@ -1131,7 +1131,7 @@ DynamicLoaderDarwinKernel::BreakpointHit (StoppointCallbackContext *context,
bool bool
DynamicLoaderDarwinKernel::ReadKextSummaryHeader () DynamicLoaderDarwinKernel::ReadKextSummaryHeader ()
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
// the all image infos is already valid for this process stop ID // the all image infos is already valid for this process stop ID
@ -1217,7 +1217,7 @@ DynamicLoaderDarwinKernel::ParseKextSummaries (const Address &kext_summary_addr,
if (log) if (log)
log->Printf ("Kexts-changed breakpoint hit, there are %d kexts currently.\n", count); log->Printf ("Kexts-changed breakpoint hit, there are %d kexts currently.\n", count);
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!ReadKextSummaries (kext_summary_addr, count, kext_summaries)) if (!ReadKextSummaries (kext_summary_addr, count, kext_summaries))
return false; return false;
@ -1438,7 +1438,7 @@ DynamicLoaderDarwinKernel::ReadKextSummaries (const Address &kext_summary_addr,
bool bool
DynamicLoaderDarwinKernel::ReadAllKextSummaries () DynamicLoaderDarwinKernel::ReadAllKextSummaries ()
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (ReadKextSummaryHeader ()) if (ReadKextSummaryHeader ())
{ {
@ -1508,7 +1508,7 @@ DynamicLoaderDarwinKernel::PutToLog(Log *log) const
if (log == NULL) if (log == NULL)
return; return;
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
log->Printf("gLoadedKextSummaries = 0x%16.16" PRIx64 " { version=%u, entry_size=%u, entry_count=%u }", log->Printf("gLoadedKextSummaries = 0x%16.16" PRIx64 " { version=%u, entry_size=%u, entry_count=%u }",
m_kext_summary_header_addr.GetFileAddress(), m_kext_summary_header_addr.GetFileAddress(),
m_kext_summary_header.version, m_kext_summary_header.version,

View File

@ -12,8 +12,9 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <vector> #include <mutex>
#include <string> #include <string>
#include <vector>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
@ -21,7 +22,6 @@
#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSpec.h"
#include "lldb/Host/TimeValue.h" #include "lldb/Host/TimeValue.h"
#include "lldb/Core/UUID.h" #include "lldb/Core/UUID.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Target/Process.h" #include "lldb/Target/Process.h"
class DynamicLoaderDarwinKernel : public lldb_private::DynamicLoader class DynamicLoaderDarwinKernel : public lldb_private::DynamicLoader
@ -361,7 +361,7 @@ protected:
lldb_private::Address m_kext_summary_header_addr; lldb_private::Address m_kext_summary_header_addr;
OSKextLoadedKextSummaryHeader m_kext_summary_header; OSKextLoadedKextSummaryHeader m_kext_summary_header;
KextImageInfo::collection m_known_kexts; KextImageInfo::collection m_known_kexts;
mutable lldb_private::Mutex m_mutex; mutable std::recursive_mutex m_mutex;
lldb::user_id_t m_break_id; lldb::user_id_t m_break_id;
private: private:

View File

@ -138,18 +138,18 @@ DynamicLoaderMacOSXDYLD::CreateInstance (Process* process, bool force)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Constructor // Constructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
DynamicLoaderMacOSXDYLD::DynamicLoaderMacOSXDYLD (Process* process) : DynamicLoaderMacOSXDYLD::DynamicLoaderMacOSXDYLD(Process *process)
DynamicLoader(process), : DynamicLoader(process),
m_dyld(), m_dyld(),
m_dyld_module_wp(), m_dyld_module_wp(),
m_dyld_all_image_infos_addr(LLDB_INVALID_ADDRESS), m_dyld_all_image_infos_addr(LLDB_INVALID_ADDRESS),
m_dyld_all_image_infos(), m_dyld_all_image_infos(),
m_dyld_all_image_infos_stop_id (UINT32_MAX), m_dyld_all_image_infos_stop_id(UINT32_MAX),
m_break_id(LLDB_INVALID_BREAK_ID), m_break_id(LLDB_INVALID_BREAK_ID),
m_dyld_image_infos(), m_dyld_image_infos(),
m_dyld_image_infos_stop_id (UINT32_MAX), m_dyld_image_infos_stop_id(UINT32_MAX),
m_mutex(Mutex::eMutexTypeRecursive), m_mutex(),
m_process_image_addr_is_all_images_infos (false) m_process_image_addr_is_all_images_infos(false)
{ {
} }
@ -244,7 +244,7 @@ DynamicLoaderMacOSXDYLD::ProcessDidExec ()
void void
DynamicLoaderMacOSXDYLD::Clear (bool clear_process) DynamicLoaderMacOSXDYLD::Clear (bool clear_process)
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (LLDB_BREAK_ID_IS_VALID(m_break_id)) if (LLDB_BREAK_ID_IS_VALID(m_break_id))
m_process->GetTarget().RemoveBreakpointByID (m_break_id); m_process->GetTarget().RemoveBreakpointByID (m_break_id);
@ -683,7 +683,7 @@ DynamicLoaderMacOSXDYLD::NotifyBreakpointHit (void *baton,
bool bool
DynamicLoaderMacOSXDYLD::ReadAllImageInfosStructure () DynamicLoaderMacOSXDYLD::ReadAllImageInfosStructure ()
{ {
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
// the all image infos is already valid for this process stop ID // the all image infos is already valid for this process stop ID
if (m_process->GetStopID() == m_dyld_all_image_infos_stop_id) if (m_process->GetStopID() == m_dyld_all_image_infos_stop_id)
@ -975,7 +975,7 @@ DynamicLoaderMacOSXDYLD::AddModulesUsingImageInfosAddress (lldb::addr_t image_in
if (log) if (log)
log->Printf ("Adding %d modules.\n", image_infos_count); log->Printf ("Adding %d modules.\n", image_infos_count);
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_process->GetStopID() == m_dyld_image_infos_stop_id) if (m_process->GetStopID() == m_dyld_image_infos_stop_id)
return true; return true;
@ -1098,7 +1098,7 @@ DynamicLoaderMacOSXDYLD::RemoveModulesUsingImageInfosAddress (lldb::addr_t image
DYLDImageInfo::collection image_infos; DYLDImageInfo::collection image_infos;
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER)); Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER));
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_process->GetStopID() == m_dyld_image_infos_stop_id) if (m_process->GetStopID() == m_dyld_image_infos_stop_id)
return true; return true;
@ -1240,7 +1240,7 @@ DynamicLoaderMacOSXDYLD::InitializeFromAllImageInfos ()
{ {
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER)); Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER));
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_process->GetStopID() == m_dyld_image_infos_stop_id if (m_process->GetStopID() == m_dyld_image_infos_stop_id
|| m_dyld_image_infos.size() != 0) || m_dyld_image_infos.size() != 0)
return false; return false;
@ -1678,7 +1678,7 @@ DynamicLoaderMacOSXDYLD::PutToLog(Log *log) const
if (log == NULL) if (log == NULL)
return; return;
Mutex::Locker locker(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
log->Printf("dyld_all_image_infos = { version=%d, count=%d, addr=0x%8.8" PRIx64 ", notify=0x%8.8" PRIx64 " }", log->Printf("dyld_all_image_infos = { version=%d, count=%d, addr=0x%8.8" PRIx64 ", notify=0x%8.8" PRIx64 " }",
m_dyld_all_image_infos.version, m_dyld_all_image_infos.version,
m_dyld_all_image_infos.dylib_info_count, m_dyld_all_image_infos.dylib_info_count,

View File

@ -12,6 +12,7 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <mutex>
#include <vector> #include <vector>
// Other libraries and framework includes // Other libraries and framework includes
@ -20,7 +21,6 @@
#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSpec.h"
#include "lldb/Core/StructuredData.h" #include "lldb/Core/StructuredData.h"
#include "lldb/Core/UUID.h" #include "lldb/Core/UUID.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Target/Process.h" #include "lldb/Target/Process.h"
#include "lldb/Utility/SafeMachO.h" #include "lldb/Utility/SafeMachO.h"
@ -374,7 +374,7 @@ protected:
lldb::user_id_t m_break_id; lldb::user_id_t m_break_id;
DYLDImageInfo::collection m_dyld_image_infos; // Current shared libraries information DYLDImageInfo::collection m_dyld_image_infos; // Current shared libraries information
uint32_t m_dyld_image_infos_stop_id; // The process stop ID that "m_dyld_image_infos" is valid for uint32_t m_dyld_image_infos_stop_id; // The process stop ID that "m_dyld_image_infos" is valid for
mutable lldb_private::Mutex m_mutex; mutable std::recursive_mutex m_mutex;
lldb_private::Process::Notifications m_notification_callbacks; lldb_private::Process::Notifications m_notification_callbacks;
bool m_process_image_addr_is_all_images_infos; bool m_process_image_addr_is_all_images_infos;

View File

@ -17,7 +17,6 @@
#include "lldb/Target/DynamicLoader.h" #include "lldb/Target/DynamicLoader.h"
#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSpec.h"
#include "lldb/Core/UUID.h" #include "lldb/Core/UUID.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Target/Process.h" #include "lldb/Target/Process.h"
class DynamicLoaderStatic : public lldb_private::DynamicLoader class DynamicLoaderStatic : public lldb_private::DynamicLoader

View File

@ -499,11 +499,9 @@ ClassDescriptorV2::GetInstanceSize ()
return 0; return 0;
} }
ClassDescriptorV2::iVarsStorage::iVarsStorage (): ClassDescriptorV2::iVarsStorage::iVarsStorage() : m_filled(false), m_ivars(), m_mutex()
m_filled(false), {
m_ivars(), }
m_mutex(Mutex::eMutexTypeRecursive)
{}
size_t size_t
ClassDescriptorV2::iVarsStorage::size () ClassDescriptorV2::iVarsStorage::size ()
@ -522,7 +520,7 @@ ClassDescriptorV2::iVarsStorage::fill (AppleObjCRuntimeV2& runtime, ClassDescrip
{ {
if (m_filled) if (m_filled)
return; return;
Mutex::Locker lock(m_mutex); std::lock_guard<std::recursive_mutex> guard(m_mutex);
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_VERBOSE)); Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_VERBOSE));
if (log) if (log)
log->Printf("[ClassDescriptorV2::iVarsStorage::fill] class_name = %s", descriptor.GetClassName().AsCString("<unknown")); log->Printf("[ClassDescriptorV2::iVarsStorage::fill] class_name = %s", descriptor.GetClassName().AsCString("<unknown"));

View File

@ -12,10 +12,11 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <mutex>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/lldb-private.h" #include "lldb/lldb-private.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/ObjCLanguageRuntime.h"
#include "AppleObjCRuntimeV2.h" #include "AppleObjCRuntimeV2.h"
@ -247,7 +248,7 @@ private:
private: private:
bool m_filled; bool m_filled;
std::vector<iVarDescriptor> m_ivars; std::vector<iVarDescriptor> m_ivars;
Mutex m_mutex; std::recursive_mutex m_mutex;
}; };
// The constructor should only be invoked by the runtime as it builds its caches // The constructor should only be invoked by the runtime as it builds its caches

View File

@ -379,27 +379,27 @@ ExtractRuntimeGlobalSymbol (Process* process,
} }
} }
AppleObjCRuntimeV2::AppleObjCRuntimeV2 (Process *process, AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process, const ModuleSP &objc_module_sp)
const ModuleSP &objc_module_sp) : : AppleObjCRuntime(process),
AppleObjCRuntime (process), m_get_class_info_code(),
m_get_class_info_code(), m_get_class_info_args(LLDB_INVALID_ADDRESS),
m_get_class_info_args (LLDB_INVALID_ADDRESS), m_get_class_info_args_mutex(),
m_get_class_info_args_mutex (Mutex::eMutexTypeNormal), m_get_shared_cache_class_info_code(),
m_get_shared_cache_class_info_code(), m_get_shared_cache_class_info_args(LLDB_INVALID_ADDRESS),
m_get_shared_cache_class_info_args (LLDB_INVALID_ADDRESS), m_get_shared_cache_class_info_args_mutex(),
m_get_shared_cache_class_info_args_mutex (Mutex::eMutexTypeNormal), m_decl_vendor_ap(),
m_decl_vendor_ap (), m_isa_hash_table_ptr(LLDB_INVALID_ADDRESS),
m_isa_hash_table_ptr (LLDB_INVALID_ADDRESS), m_hash_signature(),
m_hash_signature (), m_has_object_getClass(false),
m_has_object_getClass (false), m_loaded_objc_opt(false),
m_loaded_objc_opt (false), m_non_pointer_isa_cache_ap(NonPointerISACache::CreateInstance(*this, objc_module_sp)),
m_non_pointer_isa_cache_ap(NonPointerISACache::CreateInstance(*this,objc_module_sp)), m_tagged_pointer_vendor_ap(TaggedPointerVendorV2::CreateInstance(*this, objc_module_sp)),
m_tagged_pointer_vendor_ap(TaggedPointerVendorV2::CreateInstance(*this,objc_module_sp)), m_encoding_to_type_sp(),
m_encoding_to_type_sp(), m_noclasses_warning_emitted(false)
m_noclasses_warning_emitted(false)
{ {
static const ConstString g_gdb_object_getClass("gdb_object_getClass"); static const ConstString g_gdb_object_getClass("gdb_object_getClass");
m_has_object_getClass = (objc_module_sp->FindFirstSymbolWithNameAndType(g_gdb_object_getClass, eSymbolTypeCode) != NULL); m_has_object_getClass =
(objc_module_sp->FindFirstSymbolWithNameAndType(g_gdb_object_getClass, eSymbolTypeCode) != NULL);
} }
bool bool
@ -1484,7 +1484,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(RemoteNXMapTable &hash_table
if (class_infos_addr == LLDB_INVALID_ADDRESS) if (class_infos_addr == LLDB_INVALID_ADDRESS)
return false; return false;
Mutex::Locker locker(m_get_class_info_args_mutex); std::lock_guard<std::mutex> guard(m_get_class_info_args_mutex);
// Fill in our function argument values // Fill in our function argument values
arguments.GetValueAtIndex(0)->GetScalar() = hash_table.GetTableLoadAddress(); arguments.GetValueAtIndex(0)->GetScalar() = hash_table.GetTableLoadAddress();
@ -1736,7 +1736,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache()
if (class_infos_addr == LLDB_INVALID_ADDRESS) if (class_infos_addr == LLDB_INVALID_ADDRESS)
return DescriptorMapUpdateResult::Fail(); return DescriptorMapUpdateResult::Fail();
Mutex::Locker locker(m_get_shared_cache_class_info_args_mutex); std::lock_guard<std::mutex> guard(m_get_shared_cache_class_info_args_mutex);
// Fill in our function argument values // Fill in our function argument values
arguments.GetValueAtIndex(0)->GetScalar() = objc_opt_ptr; arguments.GetValueAtIndex(0)->GetScalar() = objc_opt_ptr;

View File

@ -14,6 +14,7 @@
// C++ Includes // C++ Includes
#include <map> #include <map>
#include <memory> #include <memory>
#include <mutex>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
@ -353,11 +354,11 @@ private:
std::unique_ptr<UtilityFunction> m_get_class_info_code; std::unique_ptr<UtilityFunction> m_get_class_info_code;
lldb::addr_t m_get_class_info_args; lldb::addr_t m_get_class_info_args;
Mutex m_get_class_info_args_mutex; std::mutex m_get_class_info_args_mutex;
std::unique_ptr<UtilityFunction> m_get_shared_cache_class_info_code; std::unique_ptr<UtilityFunction> m_get_shared_cache_class_info_code;
lldb::addr_t m_get_shared_cache_class_info_args; lldb::addr_t m_get_shared_cache_class_info_args;
Mutex m_get_shared_cache_class_info_args_mutex; std::mutex m_get_shared_cache_class_info_args_mutex;
std::unique_ptr<DeclVendor> m_decl_vendor_ap; std::unique_ptr<DeclVendor> m_decl_vendor_ap;
lldb::addr_t m_isa_hash_table_ptr; lldb::addr_t m_isa_hash_table_ptr;

View File

@ -751,7 +751,7 @@ AppleObjCTrampolineHandler::SetupDispatchFunction(Thread &thread, ValueList &dis
// Scope for mutex locker: // Scope for mutex locker:
{ {
Mutex::Locker locker(m_impl_function_mutex); std::lock_guard<std::mutex> guard(m_impl_function_mutex);
// First stage is to make the ClangUtility to hold our injected function: // First stage is to make the ClangUtility to hold our injected function:

View File

@ -13,12 +13,12 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <map> #include <map>
#include <mutex>
#include <vector> #include <vector>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/lldb-public.h" #include "lldb/lldb-public.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Expression/UtilityFunction.h" #include "lldb/Expression/UtilityFunction.h"
namespace lldb_private namespace lldb_private
@ -196,7 +196,7 @@ private:
lldb::ProcessWP m_process_wp; lldb::ProcessWP m_process_wp;
lldb::ModuleSP m_objc_module_sp; lldb::ModuleSP m_objc_module_sp;
std::unique_ptr<UtilityFunction> m_impl_code; std::unique_ptr<UtilityFunction> m_impl_code;
Mutex m_impl_function_mutex; std::mutex m_impl_function_mutex;
lldb::addr_t m_impl_fn_addr; lldb::addr_t m_impl_fn_addr;
lldb::addr_t m_impl_stret_fn_addr; lldb::addr_t m_impl_stret_fn_addr;
lldb::addr_t m_msg_forward_addr; lldb::addr_t m_msg_forward_addr;

View File

@ -35,7 +35,6 @@ typedef struct ar_hdr
#include "lldb/Core/PluginManager.h" #include "lldb/Core/PluginManager.h"
#include "lldb/Core/Stream.h" #include "lldb/Core/Stream.h"
#include "lldb/Core/Timer.h" #include "lldb/Core/Timer.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/ObjectFile.h"
using namespace lldb; using namespace lldb;
@ -226,7 +225,7 @@ ObjectContainerBSDArchive::Archive::FindObject (const ConstString &object_name,
ObjectContainerBSDArchive::Archive::shared_ptr ObjectContainerBSDArchive::Archive::shared_ptr
ObjectContainerBSDArchive::Archive::FindCachedArchive (const FileSpec &file, const ArchSpec &arch, const TimeValue &time, lldb::offset_t file_offset) ObjectContainerBSDArchive::Archive::FindCachedArchive (const FileSpec &file, const ArchSpec &arch, const TimeValue &time, lldb::offset_t file_offset)
{ {
Mutex::Locker locker(Archive::GetArchiveCacheMutex ()); std::lock_guard<std::recursive_mutex> guard(Archive::GetArchiveCacheMutex());
shared_ptr archive_sp; shared_ptr archive_sp;
Archive::Map &archive_map = Archive::GetArchiveCache (); Archive::Map &archive_map = Archive::GetArchiveCache ();
Archive::Map::iterator pos = archive_map.find (file); Archive::Map::iterator pos = archive_map.find (file);
@ -281,7 +280,7 @@ ObjectContainerBSDArchive::Archive::ParseAndCacheArchiveForFile
const size_t num_objects = archive_sp->ParseObjects (); const size_t num_objects = archive_sp->ParseObjects ();
if (num_objects > 0) if (num_objects > 0)
{ {
Mutex::Locker locker(Archive::GetArchiveCacheMutex ()); std::lock_guard<std::recursive_mutex> guard(Archive::GetArchiveCacheMutex());
Archive::GetArchiveCache().insert(std::make_pair(file, archive_sp)); Archive::GetArchiveCache().insert(std::make_pair(file, archive_sp));
} }
else else
@ -299,14 +298,13 @@ ObjectContainerBSDArchive::Archive::GetArchiveCache ()
return g_archive_map; return g_archive_map;
} }
Mutex & std::recursive_mutex &
ObjectContainerBSDArchive::Archive::GetArchiveCacheMutex () ObjectContainerBSDArchive::Archive::GetArchiveCacheMutex()
{ {
static Mutex g_archive_map_mutex (Mutex::eMutexTypeRecursive); static std::recursive_mutex g_archive_map_mutex;
return g_archive_map_mutex; return g_archive_map_mutex;
} }
void void
ObjectContainerBSDArchive::Initialize() ObjectContainerBSDArchive::Initialize()
{ {

View File

@ -12,6 +12,8 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <mutex>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/Symbol/ObjectContainer.h" #include "lldb/Symbol/ObjectContainer.h"
@ -138,8 +140,8 @@ protected:
static Map & static Map &
GetArchiveCache (); GetArchiveCache ();
static lldb_private::Mutex & static std::recursive_mutex &
GetArchiveCacheMutex (); GetArchiveCacheMutex();
static Archive::shared_ptr static Archive::shared_ptr
FindCachedArchive (const lldb_private::FileSpec &file, FindCachedArchive (const lldb_private::FileSpec &file,

View File

@ -2938,7 +2938,7 @@ ObjectFileELF::GetSymtab()
return NULL; return NULL;
uint64_t symbol_id = 0; uint64_t symbol_id = 0;
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
// Sharable objects and dynamic executables usually have 2 distinct symbol // Sharable objects and dynamic executables usually have 2 distinct symbol
// tables, one named ".symtab", and the other ".dynsym". The dynsym is a smaller // tables, one named ".symtab", and the other ".dynsym". The dynsym is a smaller
@ -3102,7 +3102,7 @@ ObjectFileELF::Dump(Stream *s)
return; return;
} }
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
s->Printf("%p: ", static_cast<void *>(this)); s->Printf("%p: ", static_cast<void *>(this));
s->Indent(); s->Indent();
s->PutCString("ObjectFileELF"); s->PutCString("ObjectFileELF");

View File

@ -158,7 +158,7 @@ ObjectFileJIT::GetSymtab()
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
if (m_symtab_ap.get() == NULL) if (m_symtab_ap.get() == NULL)
{ {
m_symtab_ap.reset(new Symtab(this)); m_symtab_ap.reset(new Symtab(this));
@ -200,7 +200,7 @@ ObjectFileJIT::Dump (Stream *s)
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
s->Printf("%p: ", static_cast<void*>(this)); s->Printf("%p: ", static_cast<void*>(this));
s->Indent(); s->Indent();
s->PutCString("ObjectFileJIT"); s->PutCString("ObjectFileJIT");

View File

@ -1217,7 +1217,7 @@ ObjectFileMachO::ParseHeader ()
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
bool can_parse = false; bool can_parse = false;
lldb::offset_t offset = 0; lldb::offset_t offset = 0;
m_data.SetByteOrder (endian::InlHostByteOrder()); m_data.SetByteOrder (endian::InlHostByteOrder());
@ -1457,7 +1457,7 @@ ObjectFileMachO::GetSymtab()
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
if (m_symtab_ap.get() == NULL) if (m_symtab_ap.get() == NULL)
{ {
m_symtab_ap.reset(new Symtab(this)); m_symtab_ap.reset(new Symtab(this));
@ -4755,7 +4755,7 @@ ObjectFileMachO::Dump (Stream *s)
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
s->Printf("%p: ", static_cast<void*>(this)); s->Printf("%p: ", static_cast<void*>(this));
s->Indent(); s->Indent();
if (m_header.magic == MH_MAGIC_64 || m_header.magic == MH_CIGAM_64) if (m_header.magic == MH_MAGIC_64 || m_header.magic == MH_CIGAM_64)
@ -4911,7 +4911,7 @@ ObjectFileMachO::GetUUID (lldb_private::UUID* uuid)
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic); lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
return GetUUID (m_header, m_data, offset, *uuid); return GetUUID (m_header, m_data, offset, *uuid);
} }
@ -4925,7 +4925,7 @@ ObjectFileMachO::GetDependentModules (FileSpecList& files)
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
struct load_command load_cmd; struct load_command load_cmd;
lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic); lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
std::vector<std::string> rpath_paths; std::vector<std::string> rpath_paths;
@ -5053,7 +5053,7 @@ ObjectFileMachO::GetEntryPointAddress ()
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
struct load_command load_cmd; struct load_command load_cmd;
lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic); lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
uint32_t i; uint32_t i;
@ -5203,7 +5203,7 @@ ObjectFileMachO::GetNumThreadContexts ()
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
if (!m_thread_context_offsets_valid) if (!m_thread_context_offsets_valid)
{ {
m_thread_context_offsets_valid = true; m_thread_context_offsets_valid = true;
@ -5237,7 +5237,7 @@ ObjectFileMachO::GetThreadContextAtIndex (uint32_t idx, lldb_private::Thread &th
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
if (!m_thread_context_offsets_valid) if (!m_thread_context_offsets_valid)
GetNumThreadContexts (); GetNumThreadContexts ();
@ -5373,7 +5373,7 @@ ObjectFileMachO::GetVersion (uint32_t *versions, uint32_t num_versions)
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
struct dylib_command load_cmd; struct dylib_command load_cmd;
lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic); lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
uint32_t version_cmd = 0; uint32_t version_cmd = 0;
@ -5428,7 +5428,7 @@ ObjectFileMachO::GetArchitecture (ArchSpec &arch)
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
return GetArchitecture (m_header, m_data, MachHeaderSizeFromMagic(m_header.magic), arch); return GetArchitecture (m_header, m_data, MachHeaderSizeFromMagic(m_header.magic), arch);
} }
return false; return false;

View File

@ -19,7 +19,6 @@
#include "lldb/Core/FileSpecList.h" #include "lldb/Core/FileSpecList.h"
#include "lldb/Core/RangeMap.h" #include "lldb/Core/RangeMap.h"
#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSpec.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/ObjectFile.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -212,7 +212,7 @@ ObjectFilePECOFF::ParseHeader ()
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
m_sect_headers.clear(); m_sect_headers.clear();
m_data.SetByteOrder (eByteOrderLittle); m_data.SetByteOrder (eByteOrderLittle);
lldb::offset_t offset = 0; lldb::offset_t offset = 0;
@ -534,7 +534,7 @@ ObjectFilePECOFF::GetSymtab()
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
if (m_symtab_ap.get() == NULL) if (m_symtab_ap.get() == NULL)
{ {
SectionList *sect_list = GetSectionList(); SectionList *sect_list = GetSectionList();
@ -689,7 +689,7 @@ ObjectFilePECOFF::CreateSections (SectionList &unified_section_list)
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
const uint32_t nsects = m_sect_headers.size(); const uint32_t nsects = m_sect_headers.size();
ModuleSP module_sp (GetModule()); ModuleSP module_sp (GetModule());
for (uint32_t idx = 0; idx<nsects; ++idx) for (uint32_t idx = 0; idx<nsects; ++idx)
@ -847,7 +847,7 @@ ObjectFilePECOFF::Dump(Stream *s)
ModuleSP module_sp(GetModule()); ModuleSP module_sp(GetModule());
if (module_sp) if (module_sp)
{ {
lldb_private::Mutex::Locker locker(module_sp->GetMutex()); std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
s->Printf("%p: ", static_cast<void*>(this)); s->Printf("%p: ", static_cast<void*>(this));
s->Indent(); s->Indent();
s->PutCString("ObjectFilePECOFF"); s->PutCString("ObjectFilePECOFF");

View File

@ -252,7 +252,7 @@ FileSpec
PlatformAppleSimulator::GetCoreSimulatorPath() PlatformAppleSimulator::GetCoreSimulatorPath()
{ {
#if defined(__APPLE__) #if defined(__APPLE__)
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
if (!m_core_simulator_framework_path.hasValue()) if (!m_core_simulator_framework_path.hasValue())
{ {
const char *developer_dir = GetDeveloperDirectory(); const char *developer_dir = GetDeveloperDirectory();

View File

@ -304,7 +304,7 @@ EnumerateDirectoryCallback (void *baton, FileSpec::FileType file_type, const Fil
const char * const char *
PlatformAppleTVSimulator::GetSDKDirectoryAsCString() PlatformAppleTVSimulator::GetSDKDirectoryAsCString()
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
if (m_sdk_directory.empty()) if (m_sdk_directory.empty())
{ {
const char *developer_dir = GetDeveloperDirectory(); const char *developer_dir = GetDeveloperDirectory();

View File

@ -304,7 +304,7 @@ EnumerateDirectoryCallback (void *baton, FileSpec::FileType file_type, const Fil
const char * const char *
PlatformAppleWatchSimulator::GetSDKDirectoryAsCString() PlatformAppleWatchSimulator::GetSDKDirectoryAsCString()
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
if (m_sdk_directory.empty()) if (m_sdk_directory.empty())
{ {
const char *developer_dir = GetDeveloperDirectory(); const char *developer_dir = GetDeveloperDirectory();

View File

@ -1015,7 +1015,7 @@ PlatformDarwin::ARMGetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch
const char * const char *
PlatformDarwin::GetDeveloperDirectory() PlatformDarwin::GetDeveloperDirectory()
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
if (m_developer_directory.empty()) if (m_developer_directory.empty())
{ {
bool developer_dir_path_valid = false; bool developer_dir_path_valid = false;
@ -1572,7 +1572,7 @@ PlatformDarwin::AddClangModuleCompilationOptionsForSDKType (Target *target, std:
FileSpec sysroot_spec; FileSpec sysroot_spec;
// Scope for mutex locker below // Scope for mutex locker below
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
sysroot_spec = GetSDKDirectoryForModules(sdk_type); sysroot_spec = GetSDKDirectoryForModules(sdk_type);
} }

View File

@ -308,7 +308,7 @@ EnumerateDirectoryCallback (void *baton, FileSpec::FileType file_type, const Fil
const char * const char *
PlatformiOSSimulator::GetSDKDirectoryAsCString() PlatformiOSSimulator::GetSDKDirectoryAsCString()
{ {
Mutex::Locker locker (m_mutex); std::lock_guard<std::mutex> guard(m_mutex);
if (m_sdk_directory.empty()) if (m_sdk_directory.empty())
{ {
const char *developer_dir = GetDeveloperDirectory(); const char *developer_dir = GetDeveloperDirectory();

View File

@ -229,7 +229,7 @@ ProcessFreeBSD::WillResume()
void void
ProcessFreeBSD::SendMessage(const ProcessMessage &message) ProcessFreeBSD::SendMessage(const ProcessMessage &message)
{ {
Mutex::Locker lock(m_message_mutex); std::lock_guard<std::recursive_mutex> guard(m_message_mutex);
switch (message.GetKind()) switch (message.GetKind())
{ {
@ -274,7 +274,7 @@ ProcessFreeBSD::ProcessFreeBSD(lldb::TargetSP target_sp, lldb::ListenerSP listen
m_byte_order(endian::InlHostByteOrder()), m_byte_order(endian::InlHostByteOrder()),
m_monitor(NULL), m_monitor(NULL),
m_module(NULL), m_module(NULL),
m_message_mutex (Mutex::eMutexTypeRecursive), m_message_mutex(),
m_exit_now(false), m_exit_now(false),
m_seen_initial_stop(), m_seen_initial_stop(),
m_resume_signo(0) m_resume_signo(0)
@ -603,7 +603,7 @@ ProcessFreeBSD::RefreshStateAfterStop()
if (log && log->GetMask().Test(POSIX_LOG_VERBOSE)) if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
log->Printf ("ProcessFreeBSD::%s(), message_queue size = %d", __FUNCTION__, (int)m_message_queue.size()); log->Printf ("ProcessFreeBSD::%s(), message_queue size = %d", __FUNCTION__, (int)m_message_queue.size());
Mutex::Locker lock(m_message_mutex); std::lock_guard<std::recursive_mutex> guard(m_message_mutex);
// This method used to only handle one message. Changing it to loop allows // This method used to only handle one message. Changing it to loop allows
// it to handle the case where we hit a breakpoint while handling a different // it to handle the case where we hit a breakpoint while handling a different

View File

@ -13,8 +13,9 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <set> #include <mutex>
#include <queue> #include <queue>
#include <set>
// Other libraries and framework includes // Other libraries and framework includes
#include "lldb/Target/Process.h" #include "lldb/Target/Process.h"
@ -212,7 +213,7 @@ protected:
lldb_private::Module *m_module; lldb_private::Module *m_module;
/// Message queue notifying this instance of inferior process state changes. /// Message queue notifying this instance of inferior process state changes.
lldb_private::Mutex m_message_mutex; std::recursive_mutex m_message_mutex;
std::queue<ProcessMessage> m_message_queue; std::queue<ProcessMessage> m_message_queue;
/// Drive any exit events to completion. /// Drive any exit events to completion.

View File

@ -1348,7 +1348,7 @@ ProcessMonitor::ServeOperation(OperationArgs *args)
void void
ProcessMonitor::DoOperation(Operation *op) ProcessMonitor::DoOperation(Operation *op)
{ {
Mutex::Locker lock(m_operation_mutex); std::lock_guard<std::mutex> guard(m_operation_mutex);
m_operation = op; m_operation = op;

View File

@ -15,11 +15,12 @@
#include <signal.h> #include <signal.h>
// C++ Includes // C++ Includes
#include <mutex>
// Other libraries and framework includes // Other libraries and framework includes
#include "lldb/lldb-types.h" #include "lldb/lldb-types.h"
#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostThread.h" #include "lldb/Host/HostThread.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private namespace lldb_private
{ {
@ -223,7 +224,7 @@ private:
// current operation which must be executed on the privileged thread // current operation which must be executed on the privileged thread
Operation *m_operation; Operation *m_operation;
lldb_private::Mutex m_operation_mutex; std::mutex m_operation_mutex;
// semaphores notified when Operation is ready to be processed and when // semaphores notified when Operation is ready to be processed and when
// the operation is complete. // the operation is complete.

View File

@ -284,7 +284,7 @@ bool
CommunicationKDP::CheckForPacket (const uint8_t *src, size_t src_len, DataExtractor &packet) CommunicationKDP::CheckForPacket (const uint8_t *src, size_t src_len, DataExtractor &packet)
{ {
// Put the packet data into the buffer in a thread safe fashion // Put the packet data into the buffer in a thread safe fashion
Mutex::Locker locker(m_bytes_mutex); std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex);
Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS)); Log *log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS));

View File

@ -22,28 +22,24 @@ using namespace lldb_private;
// Constructor // Constructor
HistoryThread::HistoryThread (lldb_private::Process &process, HistoryThread::HistoryThread(lldb_private::Process &process, lldb::tid_t tid, std::vector<lldb::addr_t> pcs,
lldb::tid_t tid, uint32_t stop_id, bool stop_id_is_valid)
std::vector<lldb::addr_t> pcs, : Thread(process, tid, true),
uint32_t stop_id, m_framelist_mutex(),
bool stop_id_is_valid) : m_framelist(),
Thread (process, tid, true), m_pcs(pcs),
m_framelist_mutex(), m_stop_id(stop_id),
m_framelist(), m_stop_id_is_valid(stop_id_is_valid),
m_pcs (pcs), m_extended_unwind_token(LLDB_INVALID_ADDRESS),
m_stop_id (stop_id), m_queue_name(),
m_stop_id_is_valid (stop_id_is_valid), m_thread_name(),
m_extended_unwind_token (LLDB_INVALID_ADDRESS), m_originating_unique_thread_id(tid),
m_queue_name (), m_queue_id(LLDB_INVALID_QUEUE_ID)
m_thread_name (),
m_originating_unique_thread_id (tid),
m_queue_id (LLDB_INVALID_QUEUE_ID)
{ {
m_unwinder_ap.reset (new HistoryUnwind (*this, pcs, stop_id_is_valid)); m_unwinder_ap.reset(new HistoryUnwind(*this, pcs, stop_id_is_valid));
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
if (log) if (log)
log->Printf ("%p HistoryThread::HistoryThread", log->Printf("%p HistoryThread::HistoryThread", static_cast<void *>(this));
static_cast<void*>(this));
} }
// Destructor // Destructor
@ -78,7 +74,9 @@ HistoryThread::CreateRegisterContextForFrame (StackFrame *frame)
lldb::StackFrameListSP lldb::StackFrameListSP
HistoryThread::GetStackFrameList () HistoryThread::GetStackFrameList ()
{ {
Mutex::Locker (m_framelist_mutex); // FIXME do not throw away the lock after we acquire it.. // FIXME do not throw away the lock after we acquire it..
std::unique_lock<std::mutex> lock(m_framelist_mutex);
lock.release();
if (m_framelist.get() == NULL) if (m_framelist.get() == NULL)
{ {
m_framelist.reset (new StackFrameList (*this, StackFrameListSP(), true)); m_framelist.reset (new StackFrameList (*this, StackFrameListSP(), true));

View File

@ -12,10 +12,11 @@
// C Includes // C Includes
// C++ Includes // C++ Includes
#include <mutex>
// Other libraries and framework includes // Other libraries and framework includes
// Project includes // Project includes
#include "lldb/lldb-private.h" #include "lldb/lldb-private.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Event.h" #include "lldb/Core/Event.h"
#include "lldb/Core/UserID.h" #include "lldb/Core/UserID.h"
@ -125,7 +126,7 @@ protected:
virtual lldb::StackFrameListSP virtual lldb::StackFrameListSP
GetStackFrameList (); GetStackFrameList ();
mutable Mutex m_framelist_mutex; mutable std::mutex m_framelist_mutex;
lldb::StackFrameListSP m_framelist; lldb::StackFrameListSP m_framelist;
std::vector<lldb::addr_t> m_pcs; std::vector<lldb::addr_t> m_pcs;
uint32_t m_stop_id; uint32_t m_stop_id;

Some files were not shown because too many files have changed in this diff Show More