second pass over removal of Mutex and Condition

llvm-svn: 270024
This commit is contained in:
Saleem Abdulrasool 2016-05-19 05:13:57 +00:00
parent fe12d0e3e5
commit bb19a13c0b
84 changed files with 995 additions and 1046 deletions

View File

@ -13,10 +13,11 @@
// C Includes
// C++ Includes
#include <list>
#include <mutex>
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private {
@ -116,7 +117,7 @@ public:
size_t
GetSize() const
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_breakpoints.size();
}
@ -193,7 +194,7 @@ public:
/// The locker object that is set.
//------------------------------------------------------------------
void
GetListMutex (lldb_private::Mutex::Locker &locker);
GetListMutex(std::unique_lock<std::recursive_mutex> &lock);
protected:
typedef std::list<lldb::BreakpointSP> bp_collection;
@ -204,19 +205,20 @@ protected:
bp_collection::const_iterator
GetBreakpointIDConstIterator(lldb::break_id_t breakID) const;
Mutex &
GetMutex () const
std::recursive_mutex &
GetMutex() const
{
return m_mutex;
}
mutable Mutex m_mutex;
mutable std::recursive_mutex m_mutex;
bp_collection m_breakpoints; // The breakpoint list, currently a list.
lldb::break_id_t m_next_break_id;
bool m_is_internal;
public:
typedef LockingAdaptedIterable<bp_collection, lldb::BreakpointSP, list_adapter> BreakpointIterable;
typedef LockingAdaptedIterable<bp_collection, lldb::BreakpointSP, list_adapter, std::recursive_mutex>
BreakpointIterable;
BreakpointIterable
Breakpoints()
{

View File

@ -13,6 +13,7 @@
// C Includes
// C++ Includes
#include <memory>
#include <mutex>
// Other libraries and framework includes
// Project includes
@ -20,7 +21,6 @@
#include "lldb/Breakpoint/StoppointLocation.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/UserID.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private {
@ -460,7 +460,8 @@ private:
std::unique_ptr<BreakpointOptions> m_options_ap; ///< Breakpoint options pointer, nullptr if we're using our breakpoint's options.
lldb::BreakpointSiteSP m_bp_site_sp; ///< Our breakpoint site (it may be shared by more than one location.)
lldb::UserExpressionSP m_user_expression_sp; ///< The compiled expression to use in testing our condition.
Mutex m_condition_mutex; ///< Guards parsing and evaluation of the condition, which could be evaluated by multiple processes.
std::mutex m_condition_mutex; ///< Guards parsing and evaluation of the condition, which could be evaluated by
/// multiple processes.
size_t m_condition_hash; ///< For testing whether the condition source code changed.
void

View File

@ -13,12 +13,13 @@
// C Includes
// C++ Includes
#include <list>
#include <mutex>
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/Address.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private {
@ -217,7 +218,7 @@ public:
size_t
GetSize() const
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_watchpoints.size();
}
@ -250,7 +251,7 @@ public:
/// The locker object that is set.
//------------------------------------------------------------------
void
GetListMutex (lldb_private::Mutex::Locker &locker);
GetListMutex(std::unique_lock<std::recursive_mutex> &lock);
protected:
typedef std::list<lldb::WatchpointSP> wp_collection;
@ -266,7 +267,7 @@ protected:
GetIDConstIterator(lldb::watch_id_t watchID) const;
wp_collection m_watchpoints;
mutable Mutex m_mutex;
mutable std::recursive_mutex m_mutex;
lldb::watch_id_t m_next_wp_id;
};

View File

@ -29,7 +29,6 @@
#include "lldb/Core/Stream.h"
#include "lldb/Core/StringList.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Predicate.h"
namespace curses

View File

@ -14,12 +14,12 @@
// C++ Includes
#include <functional>
#include <list>
#include <mutex>
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Utility/Iterable.h"
#include "llvm/ADT/DenseSet.h"
@ -164,13 +164,13 @@ public:
void
LogUUIDAndPaths (Log *log, const char *prefix_cstr);
Mutex &
GetMutex () const
std::recursive_mutex &
GetMutex() const
{
return m_modules_mutex;
}
size_t
GetIndexForModule (const Module *module) const;
@ -593,12 +593,12 @@ protected:
// Member variables.
//------------------------------------------------------------------
collection m_modules; ///< The collection of modules.
mutable Mutex m_modules_mutex;
mutable std::recursive_mutex m_modules_mutex;
Notifier* m_notifier;
public:
typedef LockingAdaptedIterable<collection, lldb::ModuleSP, vector_adapter> ModuleIterable;
typedef LockingAdaptedIterable<collection, lldb::ModuleSP, vector_adapter, std::recursive_mutex> ModuleIterable;
ModuleIterable
Modules()
{

View File

@ -10,8 +10,8 @@
#ifndef liblldb_OptionParser_h_
#define liblldb_OptionParser_h_
#include <mutex>
#include <string>
#include "lldb/Host/Mutex.h"
struct option;
@ -39,7 +39,8 @@ public:
eOptionalArgument
};
static void Prepare(Mutex::Locker &locker);
static void
Prepare(std::unique_lock<std::mutex> &lock);
static void EnableError(bool error);

View File

@ -23,7 +23,6 @@
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Core/StringList.h"
#include "lldb/Core/Flags.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Target/ExecutionContext.h"
namespace lldb_private {
@ -517,7 +516,7 @@ protected:
CommandInterpreter &m_interpreter;
ExecutionContext m_exe_ctx;
Mutex::Locker m_api_locker;
std::unique_lock<std::recursive_mutex> m_api_locker;
std::string m_cmd_name;
std::string m_cmd_help_short;
std::string m_cmd_help_long;

View File

@ -10,11 +10,11 @@
#ifndef liblldb_CompactUnwindInfo_h_
#define liblldb_CompactUnwindInfo_h_
#include <mutex>
#include <vector>
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/lldb-private.h"
@ -137,7 +137,7 @@ private:
lldb::SectionSP m_section_sp;
lldb::DataBufferSP m_section_contents_if_encrypted; // if the binary is encrypted, read the sect contents
// out of live memory and cache them here
Mutex m_mutex;
std::mutex m_mutex;
std::vector<UnwindIndex> m_indexes;
LazyBool m_indexes_computed; // eLazyBoolYes once we've tried to parse the unwind info

View File

@ -11,6 +11,7 @@
#define liblldb_DWARFCallFrameInfo_h_
#include <map>
#include <mutex>
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/DataExtractor.h"
@ -18,7 +19,6 @@
#include "lldb/Core/RangeMap.h"
#include "lldb/Core/VMRange.h"
#include "lldb/Core/dwarf.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/lldb-private.h"
@ -155,7 +155,7 @@ private:
FDEEntryMap m_fde_index;
bool m_fde_index_initialized; // only scan the section for FDEs once
Mutex m_fde_index_mutex; // and isolate the thread that does it
std::mutex m_fde_index_mutex; // and isolate the thread that does it
bool m_is_eh_frame;

View File

@ -11,12 +11,12 @@
#ifndef liblldb_Symtab_h_
#define liblldb_Symtab_h_
#include <mutex>
#include <vector>
#include "lldb/lldb-private.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/Symbol.h"
namespace lldb_private {
@ -50,10 +50,11 @@ public:
void Dump(Stream *s, Target *target, SortOrder sort_type);
void Dump(Stream *s, Target *target, std::vector<uint32_t>& indexes) const;
uint32_t GetIndexForSymbol (const Symbol *symbol) const;
Mutex & GetMutex ()
{
return m_mutex;
}
std::recursive_mutex &
GetMutex()
{
return m_mutex;
}
Symbol * FindSymbolByID (lldb::user_id_t uid) const;
Symbol * SymbolAtIndex (size_t idx);
const Symbol * SymbolAtIndex (size_t idx) const;
@ -124,7 +125,7 @@ protected:
UniqueCStringMap<uint32_t> m_basename_to_index;
UniqueCStringMap<uint32_t> m_method_to_index;
UniqueCStringMap<uint32_t> m_selector_to_index;
mutable Mutex m_mutex; // Provide thread safety for this symbol table
mutable std::recursive_mutex m_mutex; // Provide thread safety for this symbol table
bool m_file_addr_to_index_computed:1,
m_name_indexes_computed:1;
private:

View File

@ -14,6 +14,7 @@
// C++ Includes
#include <functional>
#include <map>
#include <mutex>
#include <string>
// Other libraries and framework includes
@ -24,7 +25,6 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Expression/Expression.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/CompilerDeclContext.h"
@ -617,7 +617,7 @@ protected:
AddToMap (lldb::LanguageType language, lldb::TypeSystemSP const &type_system_sp);
typedef std::map<lldb::LanguageType, lldb::TypeSystemSP> collection;
mutable Mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments.
mutable std::mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments.
collection m_map;
bool m_clear_in_progress;
};

View File

@ -12,9 +12,9 @@
#define liblldb_UnwindTable_h
#include <map>
#include <mutex>
#include "lldb/lldb-private.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private {
@ -69,7 +69,7 @@ private:
collection m_unwinds;
bool m_initialized; // delay some initialization until ObjectFile is set up
Mutex m_mutex;
std::mutex m_mutex;
std::unique_ptr<DWARFCallFrameInfo> m_eh_frame_up;
std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up;

View File

@ -12,11 +12,12 @@
// C Includes
// C++ Includes
#include <mutex>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Target/StackID.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private {
@ -412,8 +413,8 @@ public:
// These two variants take in a locker, and grab the target, lock the API mutex into locker, then
// fill in the rest of the shared pointers.
ExecutionContext (const ExecutionContextRef &exe_ctx_ref, Mutex::Locker &locker);
ExecutionContext (const ExecutionContextRef *exe_ctx_ref, Mutex::Locker &locker);
ExecutionContext(const ExecutionContextRef &exe_ctx_ref, std::unique_lock<std::recursive_mutex> &locker);
ExecutionContext(const ExecutionContextRef *exe_ctx_ref, std::unique_lock<std::recursive_mutex> &locker);
//------------------------------------------------------------------
// Create execution contexts from execution context scopes
//------------------------------------------------------------------

View File

@ -13,6 +13,7 @@
// C Includes
// C++ Includes
#include <map>
#include <mutex>
#include <vector>
// Other libraries and framework includes
@ -20,7 +21,6 @@
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Host/Mutex.h"
namespace lldb_private {
//----------------------------------------------------------------------
@ -75,7 +75,7 @@ namespace lldb_private {
//------------------------------------------------------------------
// Classes that inherit from MemoryCache can see and modify these
//------------------------------------------------------------------
Mutex m_mutex;
std::recursive_mutex m_mutex;
BlockMap m_L1_cache; // A first level memory cache whose chunk sizes vary that will be used only if the memory read fits entirely in a chunk
BlockMap m_L2_cache; // A memory cache of fixed size chinks (m_L2_cache_line_byte_size bytes in size each)
InvalidRanges m_invalid_ranges;
@ -192,7 +192,7 @@ namespace lldb_private {
// Classes that inherit from MemoryCache can see and modify these
//------------------------------------------------------------------
Process &m_process;
Mutex m_mutex;
std::recursive_mutex m_mutex;
typedef std::multimap<uint32_t, AllocatedBlockSP> PermissionsToBlockMap;
PermissionsToBlockMap m_memory_map;

View File

@ -3351,8 +3351,9 @@ protected:
std::map<uint64_t, uint32_t> m_thread_id_to_index_id_map;
int m_exit_status; ///< The exit status of the process, or -1 if not set.
std::string m_exit_string; ///< A textual description of why a process exited.
Mutex m_exit_status_mutex; ///< Mutex so m_exit_status m_exit_string can be safely accessed from multiple threads
Mutex m_thread_mutex;
std::mutex
m_exit_status_mutex; ///< Mutex so m_exit_status m_exit_string can be safely accessed from multiple threads
std::recursive_mutex m_thread_mutex;
ThreadList m_thread_list_real; ///< The threads for this process as are known to the protocol we are debugging with
ThreadList m_thread_list; ///< The threads for this process as the user will see them. This is usually the same as
///< m_thread_list_real, but might be different if there is an OS plug-in creating memory threads
@ -3373,11 +3374,11 @@ protected:
lldb::ABISP m_abi_sp;
lldb::IOHandlerSP m_process_input_reader;
Communication m_stdio_communication;
Mutex m_stdio_communication_mutex;
std::recursive_mutex m_stdio_communication_mutex;
bool m_stdin_forward; /// Remember if stdin must be forwarded to remote debug server
std::string m_stdout_data;
std::string m_stderr_data;
Mutex m_profile_data_comm_mutex;
std::recursive_mutex m_profile_data_comm_mutex;
std::vector<std::string> m_profile_data;
Predicate<uint32_t> m_iohandler_sync;
MemoryCache m_memory_cache;

View File

@ -10,6 +10,7 @@
#ifndef liblldb_QueueList_h_
#define liblldb_QueueList_h_
#include <mutex>
#include <vector>
#include "lldb/lldb-private.h"
@ -60,7 +61,7 @@ public:
GetQueueAtIndex (uint32_t idx);
typedef std::vector<lldb::QueueSP> collection;
typedef LockingAdaptedIterable<collection, lldb::QueueSP, vector_adapter> QueueIterable;
typedef LockingAdaptedIterable<collection, lldb::QueueSP, vector_adapter, std::mutex> QueueIterable;
//------------------------------------------------------------------
/// Iterate over the list of queues
@ -119,8 +120,8 @@ public:
lldb::QueueSP
FindQueueByIndexID (uint32_t index_id);
lldb_private::Mutex &
GetMutex ();
std::mutex &
GetMutex();
protected:
@ -130,7 +131,7 @@ protected:
Process *m_process; ///< The process that manages this queue list.
uint32_t m_stop_id; ///< The process stop ID that this queue list is valid for.
collection m_queues; ///< The queues for this process.
Mutex m_mutex;
std::mutex m_mutex;
private:
QueueList ();

View File

@ -13,6 +13,7 @@
// C Includes
// C++ Includes
#include <memory>
#include <mutex>
// Other libraries and framework includes
// Project includes
@ -537,7 +538,7 @@ private:
lldb::VariableListSP m_variable_list_sp;
ValueObjectList m_variable_list_value_objects; // Value objects for each variable in m_variable_list_sp
StreamString m_disassembly;
Mutex m_mutex;
std::recursive_mutex m_mutex;
DISALLOW_COPY_AND_ASSIGN (StackFrame);
};

View File

@ -13,11 +13,11 @@
// C Includes
// C++ Includes
#include <memory>
#include <mutex>
#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/Host/Mutex.h"
#include "lldb/Target/StackFrame.h"
namespace lldb_private {
@ -135,7 +135,7 @@ protected:
Thread &m_thread;
lldb::StackFrameListSP m_prev_frames_sp;
mutable Mutex m_mutex;
mutable std::recursive_mutex m_mutex;
collection m_frames;
uint32_t m_selected_frame_idx;
uint32_t m_concrete_frames_fetched;

View File

@ -713,8 +713,8 @@ public:
static const lldb::TargetPropertiesSP &
GetGlobalProperties();
Mutex &
GetAPIMutex ()
std::recursive_mutex &
GetAPIMutex()
{
return m_mutex;
}
@ -1594,7 +1594,8 @@ protected:
//------------------------------------------------------------------
Debugger & m_debugger;
lldb::PlatformSP m_platform_sp; ///< The platform for this target.
Mutex m_mutex; ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe
std::recursive_mutex
m_mutex; ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe
ArchSpec m_arch;
ModuleList m_images; ///< The list of images for this process (shared libraries and anything dynamically loaded).
SectionLoadHistory m_section_load_history;

View File

@ -10,10 +10,10 @@
#ifndef liblldb_ThreadCollection_h_
#define liblldb_ThreadCollection_h_
#include <mutex>
#include <vector>
#include "lldb/lldb-private.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Utility/Iterable.h"
namespace lldb_private {
@ -22,8 +22,8 @@ class ThreadCollection
{
public:
typedef std::vector<lldb::ThreadSP> collection;
typedef LockingAdaptedIterable<collection, lldb::ThreadSP, vector_adapter> ThreadIterable;
typedef LockingAdaptedIterable<collection, lldb::ThreadSP, vector_adapter, std::recursive_mutex> ThreadIterable;
ThreadCollection();
ThreadCollection(collection threads);
@ -53,16 +53,16 @@ public:
{
return ThreadIterable(m_threads, GetMutex());
}
virtual Mutex &
virtual std::recursive_mutex &
GetMutex()
{
return m_mutex;
}
protected:
collection m_threads;
Mutex m_mutex;
std::recursive_mutex m_mutex;
};
} // namespace lldb_private

View File

@ -10,6 +10,7 @@
#ifndef liblldb_ThreadList_h_
#define liblldb_ThreadList_h_
#include <mutex>
#include <vector>
#include "lldb/lldb-private.h"
@ -164,9 +165,9 @@ public:
void
SetStopID (uint32_t stop_id);
Mutex &
std::recursive_mutex &
GetMutex() override;
void
Update (ThreadList &rhs);

View File

@ -16,7 +16,6 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Host/Mutex.h"
namespace lldb_private
{
@ -207,36 +206,33 @@ public:
return AdaptedConstIterator<C, E, A>(m_container.end());
}
};
template <typename C, typename E, E (*A)(typename C::const_iterator &)> class LockingAdaptedIterable : public AdaptedIterable<C, E, A>
template <typename C, typename E, E (*A)(typename C::const_iterator &), typename MutexType>
class LockingAdaptedIterable : public AdaptedIterable<C, E, A>
{
public:
LockingAdaptedIterable (C &container, Mutex &mutex) :
AdaptedIterable<C,E,A>(container),
m_mutex(&mutex)
LockingAdaptedIterable(C &container, MutexType &mutex) : AdaptedIterable<C, E, A>(container), m_mutex(&mutex)
{
m_mutex->Lock();
m_mutex->lock();
}
LockingAdaptedIterable (LockingAdaptedIterable &&rhs) :
AdaptedIterable<C,E,A>(rhs),
m_mutex(rhs.m_mutex)
LockingAdaptedIterable(LockingAdaptedIterable &&rhs) : AdaptedIterable<C, E, A>(rhs), m_mutex(rhs.m_mutex)
{
rhs.m_mutex = nullptr;
}
~LockingAdaptedIterable ()
~LockingAdaptedIterable()
{
if (m_mutex)
m_mutex->Unlock();
m_mutex->unlock();
}
private:
Mutex *m_mutex = nullptr;
MutexType *m_mutex = nullptr;
DISALLOW_COPY_AND_ASSIGN(LockingAdaptedIterable);
};
} // namespace lldb_private
#endif // liblldb_Iterable_h_

View File

@ -15,7 +15,6 @@
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Target/Target.h"
@ -125,7 +124,7 @@ SBAddress::GetLoadAddress (const SBTarget &target) const
{
if (m_opaque_ap->IsValid())
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
addr = m_opaque_ap->GetLoadAddress (target_sp.get());
}
}

View File

@ -149,7 +149,7 @@ SBBreakpoint::ClearAllBreakpointSites ()
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->ClearAllBreakpointSites ();
}
}
@ -163,7 +163,7 @@ SBBreakpoint::FindLocationByAddress (addr_t vm_addr)
{
if (vm_addr != LLDB_INVALID_ADDRESS)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Address address;
Target &target = m_opaque_sp->GetTarget();
if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address))
@ -183,7 +183,7 @@ SBBreakpoint::FindLocationIDByAddress (addr_t vm_addr)
if (m_opaque_sp && vm_addr != LLDB_INVALID_ADDRESS)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Address address;
Target &target = m_opaque_sp->GetTarget();
if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address))
@ -203,7 +203,7 @@ SBBreakpoint::FindLocationByID (break_id_t bp_loc_id)
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
sb_bp_location.SetLocation (m_opaque_sp->FindLocationByID (bp_loc_id));
}
@ -217,7 +217,7 @@ SBBreakpoint::GetLocationAtIndex (uint32_t index)
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
sb_bp_location.SetLocation (m_opaque_sp->GetLocationAtIndex (index));
}
@ -235,7 +235,7 @@ SBBreakpoint::SetEnabled (bool enable)
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetEnabled (enable);
}
}
@ -245,7 +245,7 @@ SBBreakpoint::IsEnabled ()
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->IsEnabled();
}
else
@ -263,7 +263,7 @@ SBBreakpoint::SetOneShot (bool one_shot)
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetOneShot (one_shot);
}
}
@ -273,7 +273,7 @@ SBBreakpoint::IsOneShot () const
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->IsOneShot();
}
else
@ -285,7 +285,7 @@ SBBreakpoint::IsInternal ()
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->IsInternal();
}
else
@ -303,7 +303,7 @@ SBBreakpoint::SetIgnoreCount (uint32_t count)
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetIgnoreCount (count);
}
}
@ -313,7 +313,7 @@ SBBreakpoint::SetCondition (const char *condition)
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetCondition (condition);
}
}
@ -323,7 +323,7 @@ SBBreakpoint::GetCondition ()
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->GetConditionText ();
}
return nullptr;
@ -335,7 +335,7 @@ SBBreakpoint::GetHitCount () const
uint32_t count = 0;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
count = m_opaque_sp->GetHitCount();
}
@ -353,7 +353,7 @@ SBBreakpoint::GetIgnoreCount () const
uint32_t count = 0;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
count = m_opaque_sp->GetIgnoreCount();
}
@ -370,7 +370,7 @@ SBBreakpoint::SetThreadID (tid_t tid)
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetThreadID (tid);
}
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@ -385,7 +385,7 @@ SBBreakpoint::GetThreadID ()
tid_t tid = LLDB_INVALID_THREAD_ID;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
tid = m_opaque_sp->GetThreadID();
}
@ -405,7 +405,7 @@ SBBreakpoint::SetThreadIndex (uint32_t index)
static_cast<void*>(m_opaque_sp.get()), index);
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex (index);
}
}
@ -416,7 +416,7 @@ SBBreakpoint::GetThreadIndex() const
uint32_t thread_idx = UINT32_MAX;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
if (thread_spec != nullptr)
thread_idx = thread_spec->GetIndex();
@ -439,7 +439,7 @@ SBBreakpoint::SetThreadName (const char *thread_name)
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->GetOptions()->GetThreadSpec()->SetName (thread_name);
}
}
@ -450,7 +450,7 @@ SBBreakpoint::GetThreadName () const
const char *name = nullptr;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
if (thread_spec != nullptr)
name = thread_spec->GetName();
@ -472,7 +472,7 @@ SBBreakpoint::SetQueueName (const char *queue_name)
static_cast<void*>(m_opaque_sp.get()), queue_name);
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName (queue_name);
}
}
@ -483,7 +483,7 @@ SBBreakpoint::GetQueueName () const
const char *name = nullptr;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
if (thread_spec)
name = thread_spec->GetQueueName();
@ -502,7 +502,7 @@ SBBreakpoint::GetNumResolvedLocations() const
size_t num_resolved = 0;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
num_resolved = m_opaque_sp->GetNumResolvedLocations();
}
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@ -519,7 +519,7 @@ SBBreakpoint::GetNumLocations() const
size_t num_locs = 0;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
num_locs = m_opaque_sp->GetNumLocations();
}
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@ -535,7 +535,7 @@ SBBreakpoint::GetDescription (SBStream &s)
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID());
m_opaque_sp->GetResolverDescription (s.get());
m_opaque_sp->GetFilterDescription (s.get());
@ -598,7 +598,7 @@ SBBreakpoint::SetCallback (BreakpointHitCallback callback, void *baton)
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
BatonSP baton_sp(new SBBreakpointCallbackBaton (callback, baton));
m_opaque_sp->SetCallback (SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, false);
}
@ -616,7 +616,7 @@ SBBreakpoint::SetScriptCallbackFunction (const char *callback_function_name)
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
BreakpointOptions *bp_options = m_opaque_sp->GetOptions();
m_opaque_sp->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallbackFunction (bp_options,
callback_function_name);
@ -635,7 +635,7 @@ SBBreakpoint::SetScriptCallbackBody (const char *callback_body_text)
SBError sb_error;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
BreakpointOptions *bp_options = m_opaque_sp->GetOptions();
Error error = m_opaque_sp->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options,
callback_body_text);
@ -659,7 +659,7 @@ SBBreakpoint::AddName (const char *new_name)
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Error error; // Think I'm just going to swallow the error here, it's probably more annoying to have to provide it.
return m_opaque_sp->AddName(new_name, error);
}
@ -679,7 +679,7 @@ SBBreakpoint::RemoveName (const char *name_to_remove)
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->RemoveName(name_to_remove);
}
}
@ -696,7 +696,7 @@ SBBreakpoint::MatchesName (const char *name)
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->MatchesName(name);
}
@ -714,7 +714,7 @@ SBBreakpoint::GetNames (SBStringList &names)
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
std::vector<std::string> names_vec;
m_opaque_sp->GetNames(names_vec);
for (std::string name : names_vec)

View File

@ -92,7 +92,7 @@ SBBreakpointLocation::GetLoadAddress ()
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
ret_addr = m_opaque_sp->GetLoadAddress();
}
@ -104,7 +104,7 @@ SBBreakpointLocation::SetEnabled (bool enabled)
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetEnabled (enabled);
}
}
@ -114,7 +114,7 @@ SBBreakpointLocation::IsEnabled ()
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->IsEnabled();
}
else
@ -126,7 +126,7 @@ SBBreakpointLocation::GetIgnoreCount ()
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->GetIgnoreCount();
}
else
@ -138,7 +138,7 @@ SBBreakpointLocation::SetIgnoreCount (uint32_t n)
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetIgnoreCount (n);
}
}
@ -148,7 +148,7 @@ SBBreakpointLocation::SetCondition (const char *condition)
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetCondition (condition);
}
}
@ -158,7 +158,7 @@ SBBreakpointLocation::GetCondition ()
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->GetConditionText ();
}
return NULL;
@ -176,7 +176,7 @@ SBBreakpointLocation::SetScriptCallbackFunction (const char *callback_function_n
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
BreakpointOptions *bp_options = m_opaque_sp->GetLocationOptions();
m_opaque_sp->GetBreakpoint().GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallbackFunction (bp_options,
callback_function_name);
@ -195,7 +195,7 @@ SBBreakpointLocation::SetScriptCallbackBody (const char *callback_body_text)
SBError sb_error;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
BreakpointOptions *bp_options = m_opaque_sp->GetLocationOptions();
Error error = m_opaque_sp->GetBreakpoint().GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options,
callback_body_text);
@ -212,7 +212,7 @@ SBBreakpointLocation::SetThreadID (tid_t thread_id)
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetThreadID (thread_id);
}
}
@ -223,7 +223,7 @@ SBBreakpointLocation::GetThreadID ()
tid_t tid = LLDB_INVALID_THREAD_ID;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->GetThreadID();
}
return tid;
@ -234,7 +234,7 @@ SBBreakpointLocation::SetThreadIndex (uint32_t index)
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetThreadIndex (index);
}
}
@ -245,7 +245,7 @@ SBBreakpointLocation::GetThreadIndex() const
uint32_t thread_idx = UINT32_MAX;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->GetThreadIndex();
}
return thread_idx;
@ -257,7 +257,7 @@ SBBreakpointLocation::SetThreadName (const char *thread_name)
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetThreadName (thread_name);
}
}
@ -267,7 +267,7 @@ SBBreakpointLocation::GetThreadName () const
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->GetThreadName();
}
return NULL;
@ -278,7 +278,7 @@ SBBreakpointLocation::SetQueueName (const char *queue_name)
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->SetQueueName (queue_name);
}
}
@ -288,7 +288,7 @@ SBBreakpointLocation::GetQueueName () const
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->GetQueueName ();
}
return NULL;
@ -299,7 +299,7 @@ SBBreakpointLocation::IsResolved ()
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->IsResolved();
}
return false;
@ -319,7 +319,7 @@ SBBreakpointLocation::GetDescription (SBStream &description, DescriptionLevel le
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
m_opaque_sp->GetDescription (&strm, level);
strm.EOL();
}
@ -334,7 +334,7 @@ SBBreakpointLocation::GetID ()
{
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
return m_opaque_sp->GetID ();
}
else
@ -352,7 +352,7 @@ SBBreakpointLocation::GetBreakpoint ()
SBBreakpoint sb_bp;
if (m_opaque_sp)
{
Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
*sb_bp = m_opaque_sp->GetBreakpoint ().shared_from_this();
}

View File

@ -398,7 +398,7 @@ SBCommandInterpreter::GetProcess ()
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
if (target_sp)
{
Mutex::Locker api_locker(target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
process_sp = target_sp->GetProcessSP();
sb_process.SetSP(process_sp);
}
@ -483,9 +483,9 @@ SBCommandInterpreter::SourceInitFileInHomeDirectory (SBCommandReturnObject &resu
if (IsValid())
{
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
Mutex::Locker api_locker;
std::unique_lock<std::recursive_mutex> lock;
if (target_sp)
api_locker.Lock(target_sp->GetAPIMutex());
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
m_opaque_ptr->SourceInitFile (false, result.ref());
}
else
@ -508,9 +508,9 @@ SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory (SBCommandReturnOb
if (IsValid())
{
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
Mutex::Locker api_locker;
std::unique_lock<std::recursive_mutex> lock;
if (target_sp)
api_locker.Lock(target_sp->GetAPIMutex());
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
m_opaque_ptr->SourceInitFile (true, result.ref());
}
else

View File

@ -411,9 +411,9 @@ SBDebugger::HandleCommand (const char *command)
if (m_opaque_sp)
{
TargetSP target_sp (m_opaque_sp->GetSelectedTarget());
Mutex::Locker api_locker;
std::unique_lock<std::recursive_mutex> lock;
if (target_sp)
api_locker.Lock(target_sp->GetAPIMutex());
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
SBCommandInterpreter sb_interpreter(GetCommandInterpreter ());
SBCommandReturnObject result;
@ -474,8 +474,8 @@ SBDebugger::HandleProcessEvent (const SBProcess &process, const SBEvent &event,
char stdio_buffer[1024];
size_t len;
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
if (event_type & (Process::eBroadcastBitSTDOUT | Process::eBroadcastBitStateChanged))
{
// Drain stdout when we stop just in case we have any bytes

View File

@ -105,8 +105,8 @@ SBFrame::SetFrameSP (const StackFrameSP &lldb_object_sp)
bool
SBFrame::IsValid() const
{
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
@ -126,8 +126,8 @@ SBFrame::GetSymbolContext (uint32_t resolve_scope) const
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBSymbolContext sb_sym_ctx;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -169,8 +169,8 @@ SBFrame::GetModule () const
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBModule sb_module;
ModuleSP module_sp;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -212,8 +212,8 @@ SBFrame::GetCompileUnit () const
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBCompileUnit sb_comp_unit;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -253,8 +253,8 @@ SBFrame::GetFunction () const
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBFunction sb_function;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -294,8 +294,8 @@ SBFrame::GetSymbol () const
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBSymbol sb_symbol;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -334,8 +334,8 @@ SBFrame::GetBlock () const
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBBlock sb_block;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -374,8 +374,8 @@ SBBlock
SBFrame::GetFrameBlock () const
{
SBBlock sb_block;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -415,8 +415,8 @@ SBFrame::GetLineEntry () const
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBLineEntry sb_line_entry;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -482,8 +482,8 @@ SBFrame::GetPC () const
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
addr_t addr = LLDB_INVALID_ADDRESS;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -523,8 +523,8 @@ SBFrame::SetPC (addr_t new_pc)
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
bool ret_val = false;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -564,8 +564,8 @@ SBFrame::GetSP () const
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
addr_t addr = LLDB_INVALID_ADDRESS;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -604,8 +604,8 @@ SBFrame::GetFP () const
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
addr_t addr = LLDB_INVALID_ADDRESS;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -644,8 +644,8 @@ SBFrame::GetPCAddress () const
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBAddress sb_addr;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = exe_ctx.GetFramePtr();
Target *target = exe_ctx.GetTargetPtr();
@ -704,7 +704,6 @@ lldb::SBValue
SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dynamic)
{
SBValue sb_value;
Mutex::Locker api_locker;
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (var_path == nullptr || var_path[0] == '\0')
{
@ -712,8 +711,9 @@ SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dyn
log->Printf ("SBFrame::GetValueForVariablePath called with empty variable path.");
return sb_value;
}
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -780,8 +780,8 @@ SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic)
}
ValueObjectSP value_sp;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -869,8 +869,8 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy
}
ValueObjectSP value_sp;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -1048,8 +1048,8 @@ SBFrame::Disassemble () const
{
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
const char *disassembly = nullptr;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -1138,8 +1138,8 @@ SBFrame::GetVariables (const lldb::SBVariablesOptions& options)
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBValueList value_list;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -1253,8 +1253,8 @@ SBFrame::GetRegisters ()
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBValueList value_list;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -1305,8 +1305,8 @@ SBFrame::FindRegister (const char *name)
SBValue result;
ValueObjectSP value_sp;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@ -1364,8 +1364,8 @@ SBFrame::GetDescription (SBStream &description)
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Stream &strm = description.ref();
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame;
Target *target = exe_ctx.GetTargetPtr();
@ -1477,8 +1477,8 @@ SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &option
ValueObjectSP expr_value_sp;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (log)
log->Printf ("SBFrame()::EvaluateExpression (expr=\"%s\")...", expr);

View File

@ -156,12 +156,12 @@ SBFunction::GetInstructions (SBTarget target, const char *flavor)
SBInstructionList sb_instructions;
if (m_opaque_ptr)
{
Mutex::Locker api_locker;
ExecutionContext exe_ctx;
TargetSP target_sp (target.GetSP());
std::unique_lock<std::recursive_mutex> lock;
if (target_sp)
{
api_locker.Lock (target_sp->GetAPIMutex());
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
target_sp->CalculateExecutionContext (exe_ctx);
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
}

View File

@ -75,12 +75,13 @@ SBInstruction::GetMnemonic(SBTarget target)
{
if (m_opaque_sp)
{
Mutex::Locker api_locker;
ExecutionContext exe_ctx;
TargetSP target_sp (target.GetSP());
std::unique_lock<std::recursive_mutex> lock;
if (target_sp)
{
api_locker.Lock (target_sp->GetAPIMutex());
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
target_sp->CalculateExecutionContext (exe_ctx);
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
}
@ -94,12 +95,13 @@ SBInstruction::GetOperands(SBTarget target)
{
if (m_opaque_sp)
{
Mutex::Locker api_locker;
ExecutionContext exe_ctx;
TargetSP target_sp (target.GetSP());
std::unique_lock<std::recursive_mutex> lock;
if (target_sp)
{
api_locker.Lock (target_sp->GetAPIMutex());
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
target_sp->CalculateExecutionContext (exe_ctx);
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
}
@ -113,12 +115,13 @@ SBInstruction::GetComment(SBTarget target)
{
if (m_opaque_sp)
{
Mutex::Locker api_locker;
ExecutionContext exe_ctx;
TargetSP target_sp (target.GetSP());
std::unique_lock<std::recursive_mutex> lock;
if (target_sp)
{
api_locker.Lock (target_sp->GetAPIMutex());
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
target_sp->CalculateExecutionContext (exe_ctx);
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
}

View File

@ -163,7 +163,7 @@ SBProcess::RemoteLaunch (char const **argv,
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
if (process_sp->GetState() == eStateConnected)
{
if (stop_at_entry)
@ -209,7 +209,7 @@ SBProcess::RemoteAttachToProcessWithID (lldb::pid_t pid, lldb::SBError& error)
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
if (process_sp->GetState() == eStateConnected)
{
ProcessAttachInfo attach_info;
@ -251,7 +251,7 @@ SBProcess::GetNumThreads ()
Process::StopLocker stop_locker;
const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
num_threads = process_sp->GetThreadList().GetSize(can_update);
}
@ -272,7 +272,7 @@ SBProcess::GetSelectedThread () const
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
thread_sp = process_sp->GetThreadList().GetSelectedThread();
sb_thread.SetThread (thread_sp);
}
@ -295,7 +295,7 @@ SBProcess::CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context)
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
thread_sp = process_sp->CreateOSPluginThread(tid, context);
sb_thread.SetThread (thread_sp);
}
@ -465,7 +465,7 @@ SBProcess::SetSelectedThread (const SBThread &thread)
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
return process_sp->GetThreadList().SetSelectedThreadByID (thread.GetThreadID());
}
return false;
@ -480,7 +480,7 @@ SBProcess::SetSelectedThreadByID (lldb::tid_t tid)
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
ret_val = process_sp->GetThreadList().SetSelectedThreadByID (tid);
}
@ -501,7 +501,7 @@ SBProcess::SetSelectedThreadByIndexID (uint32_t index_id)
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
ret_val = process_sp->GetThreadList().SetSelectedThreadByIndexID (index_id);
}
@ -525,7 +525,7 @@ SBProcess::GetThreadAtIndex (size_t index)
{
Process::StopLocker stop_locker;
const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, can_update);
sb_thread.SetThread (thread_sp);
}
@ -550,7 +550,7 @@ SBProcess::GetNumQueues ()
{
Process::StopLocker stop_locker;
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
num_queues = process_sp->GetQueueList().GetSize();
}
@ -572,7 +572,7 @@ SBProcess::GetQueueAtIndex (size_t index)
if (process_sp)
{
Process::StopLocker stop_locker;
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
queue_sp = process_sp->GetQueueList().GetQueueAtIndex(index);
sb_queue.SetQueue (queue_sp);
}
@ -593,7 +593,7 @@ SBProcess::GetStopID(bool include_expression_stops)
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
if (include_expression_stops)
return process_sp->GetStopID();
else
@ -612,7 +612,7 @@ SBProcess::GetStopEventForStopID(uint32_t stop_id)
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
event_sp = process_sp->GetStopEventForStopID(stop_id);
sb_event.reset(event_sp);
}
@ -634,7 +634,7 @@ SBProcess::GetState ()
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
ret_val = process_sp->GetState();
}
@ -655,7 +655,7 @@ SBProcess::GetExitStatus ()
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
exit_status = process_sp->GetExitStatus ();
}
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@ -674,7 +674,7 @@ SBProcess::GetExitDescription ()
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
exit_desc = process_sp->GetExitDescription ();
}
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@ -760,7 +760,7 @@ SBProcess::Continue ()
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
if (process_sp->GetTarget().GetDebugger().GetAsyncExecution ())
sb_error.ref() = process_sp->Resume ();
@ -790,7 +790,7 @@ SBProcess::Destroy ()
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
sb_error.SetError(process_sp->Destroy(false));
}
else
@ -817,7 +817,7 @@ SBProcess::Stop ()
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
sb_error.SetError (process_sp->Halt());
}
else
@ -843,7 +843,7 @@ SBProcess::Kill ()
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
sb_error.SetError (process_sp->Destroy(true));
}
else
@ -877,7 +877,7 @@ SBProcess::Detach (bool keep_stopped)
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
sb_error.SetError (process_sp->Detach(keep_stopped));
}
else
@ -893,7 +893,7 @@ SBProcess::Signal (int signo)
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
sb_error.SetError (process_sp->Signal (signo));
}
else
@ -939,7 +939,7 @@ SBProcess::GetThreadByID (tid_t tid)
{
Process::StopLocker stop_locker;
const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
thread_sp = process_sp->GetThreadList().FindThreadByID (tid, can_update);
sb_thread.SetThread (thread_sp);
}
@ -963,7 +963,7 @@ SBProcess::GetThreadByIndexID (uint32_t index_id)
{
Process::StopLocker stop_locker;
const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
thread_sp = process_sp->GetThreadList().FindThreadByIndexID (index_id, can_update);
sb_thread.SetThread (thread_sp);
}
@ -1080,7 +1080,7 @@ SBProcess::ReadMemory (addr_t addr, void *dst, size_t dst_len, SBError &sb_error
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock()))
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
bytes_read = process_sp->ReadMemory (addr, dst, dst_len, sb_error.ref());
}
else
@ -1120,7 +1120,7 @@ SBProcess::ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBE
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock()))
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
bytes_read = process_sp->ReadCStringFromMemory (addr, (char *)buf, size, sb_error.ref());
}
else
@ -1149,7 +1149,7 @@ SBProcess::ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBErro
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock()))
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
value = process_sp->ReadUnsignedIntegerFromMemory (addr, byte_size, 0, sb_error.ref());
}
else
@ -1178,7 +1178,7 @@ SBProcess::ReadPointerFromMemory (addr_t addr, lldb::SBError &sb_error)
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock()))
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
ptr = process_sp->ReadPointerFromMemory (addr, sb_error.ref());
}
else
@ -1218,7 +1218,7 @@ SBProcess::WriteMemory (addr_t addr, const void *src, size_t src_len, SBError &s
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock()))
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
bytes_written = process_sp->WriteMemory (addr, src, src_len, sb_error.ref());
}
else
@ -1282,7 +1282,7 @@ SBProcess::GetNumSupportedHardwareWatchpoints (lldb::SBError &sb_error) const
ProcessSP process_sp(GetSP());
if (process_sp)
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
sb_error.SetError(process_sp->GetWatchpointSupportInfo (num));
if (log)
log->Printf ("SBProcess(%p)::GetNumSupportedHardwareWatchpoints () => %u",
@ -1312,7 +1312,7 @@ SBProcess::LoadImage (const lldb::SBFileSpec &sb_local_image_spec,
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock()))
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
return platform_sp->LoadImage (process_sp.get(),
*sb_local_image_spec,
@ -1341,7 +1341,7 @@ SBProcess::UnloadImage (uint32_t image_token)
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock()))
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
sb_error.SetError (platform_sp->UnloadImage (process_sp.get(), image_token));
}
@ -1369,7 +1369,7 @@ SBProcess::SendEventData (const char *event_data)
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock()))
{
Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
sb_error.SetError (process_sp->SendEventData (event_data));
}
else
@ -1459,7 +1459,7 @@ SBProcess::SaveCore(const char *file_name)
return error;
}
Mutex::Locker api_locker(process_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(process_sp->GetTarget().GetAPIMutex());
if (process_sp->GetState() != eStateStopped)
{

View File

@ -141,12 +141,13 @@ SBSymbol::GetInstructions (SBTarget target, const char *flavor_string)
SBInstructionList sb_instructions;
if (m_opaque_ptr)
{
Mutex::Locker api_locker;
ExecutionContext exe_ctx;
TargetSP target_sp (target.GetSP());
std::unique_lock<std::recursive_mutex> lock;
if (target_sp)
{
api_locker.Lock (target_sp->GetAPIMutex());
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
target_sp->CalculateExecutionContext (exe_ctx);
}
if (m_opaque_ptr->ValueIsAddress())

View File

@ -77,7 +77,7 @@ namespace {
Error
AttachToProcess (ProcessAttachInfo &attach_info, Target &target)
{
Mutex::Locker api_locker (target.GetAPIMutex ());
std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex());
auto process_sp = target.GetProcessSP ();
if (process_sp)
@ -267,7 +267,7 @@ SBTarget::Install()
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
sb_error.ref() = target_sp->Install(NULL);
}
return sb_error;
@ -307,7 +307,7 @@ SBTarget::Launch
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
if (stop_at_entry)
launch_flags |= eLaunchFlagStopAtEntry;
@ -394,7 +394,7 @@ SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error)
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
StateType state = eStateInvalid;
{
ProcessSP process_sp = target_sp->GetProcessSP();
@ -622,7 +622,7 @@ SBTarget::ConnectRemote
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
if (listener.IsValid())
process_sp = target_sp->CreateProcess (listener.m_opaque_sp, plugin_name, NULL);
else
@ -706,7 +706,7 @@ SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr)
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
if (target_sp->ResolveLoadAddress (vm_addr, addr))
return sb_addr;
}
@ -725,7 +725,7 @@ SBTarget::ResolveFileAddress (lldb::addr_t file_addr)
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
if (target_sp->ResolveFileAddress (file_addr, addr))
return sb_addr;
}
@ -742,7 +742,7 @@ SBTarget::ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr)
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
if (target_sp->ResolveLoadAddress (vm_addr, addr))
return sb_addr;
}
@ -778,7 +778,7 @@ SBTarget::ReadMemory (const SBAddress addr,
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
bytes_read = target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref());
}
else
@ -814,7 +814,7 @@ SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec,
TargetSP target_sp(GetSP());
if (target_sp && line != 0)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
const LazyBool check_inlines = eLazyBoolCalculate;
const LazyBool skip_prologue = eLazyBoolCalculate;
@ -856,7 +856,7 @@ SBTarget::BreakpointCreateByName (const char *symbol_name,
TargetSP target_sp(GetSP());
if (target_sp.get())
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
const bool internal = false;
const bool hardware = false;
@ -916,7 +916,7 @@ SBTarget::BreakpointCreateByName (const char *symbol_name,
const bool internal = false;
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
*sb_bp = target_sp->CreateBreakpoint (module_list.get(),
comp_unit_list.get(),
symbol_name,
@ -972,7 +972,7 @@ SBTarget::BreakpointCreateByNames (const char *symbol_names[],
TargetSP target_sp(GetSP());
if (target_sp && num_names > 0)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
const bool internal = false;
const bool hardware = false;
const LazyBool skip_prologue = eLazyBoolCalculate;
@ -1045,7 +1045,7 @@ SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
TargetSP target_sp(GetSP());
if (target_sp && symbol_name_regex && symbol_name_regex[0])
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
RegularExpression regexp(symbol_name_regex);
const bool internal = false;
const bool hardware = false;
@ -1071,7 +1071,7 @@ SBTarget::BreakpointCreateByAddress (addr_t address)
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
const bool hardware = false;
*sb_bp = target_sp->CreateBreakpoint (address, false, hardware);
}
@ -1102,7 +1102,7 @@ SBTarget::BreakpointCreateBySBAddress (SBAddress &sb_address)
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
const bool hardware = false;
*sb_bp = target_sp->CreateBreakpoint (sb_address.ref(), false, hardware);
}
@ -1162,7 +1162,7 @@ SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
TargetSP target_sp(GetSP());
if (target_sp && source_regex && source_regex[0])
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
const bool hardware = false;
const LazyBool move_to_nearest_code = eLazyBoolCalculate;
RegularExpression regexp(source_regex);
@ -1200,7 +1200,7 @@ SBTarget::BreakpointCreateForException (lldb::LanguageType language,
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
const bool hardware = false;
*sb_bp = target_sp->CreateExceptionBreakpoint (language, catch_bp, throw_bp, hardware);
}
@ -1249,7 +1249,7 @@ SBTarget::BreakpointDelete (break_id_t bp_id)
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
result = target_sp->RemoveBreakpointByID (bp_id);
}
@ -1270,7 +1270,7 @@ SBTarget::FindBreakpointByID (break_id_t bp_id)
TargetSP target_sp(GetSP());
if (target_sp && bp_id != LLDB_INVALID_BREAK_ID)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
*sb_breakpoint = target_sp->GetBreakpointByID (bp_id);
}
@ -1289,7 +1289,7 @@ SBTarget::EnableAllBreakpoints ()
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
target_sp->EnableAllBreakpoints ();
return true;
}
@ -1302,7 +1302,7 @@ SBTarget::DisableAllBreakpoints ()
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
target_sp->DisableAllBreakpoints ();
return true;
}
@ -1315,7 +1315,7 @@ SBTarget::DeleteAllBreakpoints ()
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
target_sp->RemoveAllBreakpoints ();
return true;
}
@ -1356,9 +1356,9 @@ SBTarget::DeleteWatchpoint (watch_id_t wp_id)
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
Mutex::Locker locker;
target_sp->GetWatchpointList().GetListMutex(locker);
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
std::unique_lock<std::recursive_mutex> lock;
target_sp->GetWatchpointList().GetListMutex(lock);
result = target_sp->RemoveWatchpointByID (wp_id);
}
@ -1380,9 +1380,9 @@ SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id)
TargetSP target_sp(GetSP());
if (target_sp && wp_id != LLDB_INVALID_WATCH_ID)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
Mutex::Locker locker;
target_sp->GetWatchpointList().GetListMutex(locker);
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
std::unique_lock<std::recursive_mutex> lock;
target_sp->GetWatchpointList().GetListMutex(lock);
watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id);
sb_watchpoint.SetSP (watchpoint_sp);
}
@ -1406,7 +1406,7 @@ SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write, S
TargetSP target_sp(GetSP());
if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS && size > 0)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
uint32_t watch_type = 0;
if (read)
watch_type |= LLDB_WATCH_TYPE_READ;
@ -1442,9 +1442,9 @@ SBTarget::EnableAllWatchpoints ()
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
Mutex::Locker locker;
target_sp->GetWatchpointList().GetListMutex(locker);
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
std::unique_lock<std::recursive_mutex> lock;
target_sp->GetWatchpointList().GetListMutex(lock);
target_sp->EnableAllWatchpoints ();
return true;
}
@ -1457,9 +1457,9 @@ SBTarget::DisableAllWatchpoints ()
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
Mutex::Locker locker;
target_sp->GetWatchpointList().GetListMutex(locker);
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
std::unique_lock<std::recursive_mutex> lock;
target_sp->GetWatchpointList().GetListMutex(lock);
target_sp->DisableAllWatchpoints ();
return true;
}
@ -1551,9 +1551,9 @@ SBTarget::DeleteAllWatchpoints ()
TargetSP target_sp(GetSP());
if (target_sp)
{
Mutex::Locker api_locker (target_sp->GetAPIMutex());
Mutex::Locker locker;
target_sp->GetWatchpointList().GetListMutex(locker);
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
std::unique_lock<std::recursive_mutex> lock;
target_sp->GetWatchpointList().GetListMutex(lock);
target_sp->RemoveAllWatchpoints ();
return true;
}
@ -2431,7 +2431,7 @@ SBTarget::EvaluateExpression (const char *expr, const SBExpressionOptions &optio
return expr_result;
}
Mutex::Locker api_locker (target_sp->GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
ExecutionContext exe_ctx (m_opaque_sp.get());
if (log)

View File

@ -96,8 +96,8 @@ SBThread::GetQueue () const
{
SBQueue sb_queue;
QueueSP queue_sp;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (exe_ctx.HasThreadScope())
@ -130,8 +130,8 @@ SBThread::GetQueue () const
bool
SBThread::IsValid() const
{
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
@ -158,8 +158,8 @@ SBThread::GetStopReason()
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
StopReason reason = eStopReasonInvalid;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (exe_ctx.HasThreadScope())
{
@ -187,8 +187,8 @@ SBThread::GetStopReason()
size_t
SBThread::GetStopReasonDataCount ()
{
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (exe_ctx.HasThreadScope())
{
@ -247,8 +247,8 @@ SBThread::GetStopReasonDataCount ()
uint64_t
SBThread::GetStopReasonDataAtIndex (uint32_t idx)
{
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (exe_ctx.HasThreadScope())
{
@ -369,8 +369,8 @@ SBThread::GetStopDescription (char *dst, size_t dst_len)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (exe_ctx.HasThreadScope())
{
@ -501,8 +501,8 @@ SBThread::GetStopReturnValue ()
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
ValueObjectSP return_valobj_sp;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (exe_ctx.HasThreadScope())
{
@ -562,8 +562,8 @@ SBThread::GetName () const
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
const char *name = NULL;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (exe_ctx.HasThreadScope())
{
@ -592,8 +592,8 @@ const char *
SBThread::GetQueueName () const
{
const char *name = NULL;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (exe_ctx.HasThreadScope())
@ -623,8 +623,8 @@ lldb::queue_id_t
SBThread::GetQueueID () const
{
queue_id_t id = LLDB_INVALID_QUEUE_ID;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (exe_ctx.HasThreadScope())
@ -654,8 +654,8 @@ SBThread::GetInfoItemByPathAsString (const char *path, SBStream &strm)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
bool success = false;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (exe_ctx.HasThreadScope())
{
@ -760,9 +760,8 @@ SBThread::StepOver (lldb::RunMode stop_other_threads)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (log)
log->Printf ("SBThread(%p)::StepOver (stop_other_threads='%s')",
@ -819,8 +818,8 @@ SBThread::StepInto (const char *target_name, uint32_t end_line, SBError &error,
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (log)
log->Printf ("SBThread(%p)::StepInto (target_name='%s', stop_other_threads='%s')",
@ -874,8 +873,8 @@ SBThread::StepOut ()
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (log)
log->Printf ("SBThread(%p)::StepOut ()",
@ -908,8 +907,8 @@ SBThread::StepOutOfFrame (lldb::SBFrame &sb_frame)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (!sb_frame.IsValid())
{
@ -961,10 +960,8 @@ SBThread::StepInstruction (bool step_over)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (log)
log->Printf ("SBThread(%p)::StepInstruction (step_over=%i)",
@ -985,9 +982,8 @@ SBThread::RunToAddress (lldb::addr_t addr)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (log)
log->Printf ("SBThread(%p)::RunToAddress (addr=0x%" PRIx64 ")",
@ -1020,8 +1016,8 @@ SBThread::StepOverUntil (lldb::SBFrame &sb_frame,
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
char path[PATH_MAX];
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrameSP frame_sp (sb_frame.GetFrameSP());
@ -1164,8 +1160,8 @@ SBThread::StepUsingScriptedThreadPlan (const char *script_class_name)
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBError sb_error;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (log)
{
@ -1204,8 +1200,8 @@ SBThread::JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line)
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
SBError sb_error;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (log)
log->Printf ("SBThread(%p)::JumpToLine (file+line = %s:%u)",
@ -1232,9 +1228,8 @@ SBThread::ReturnFromFrame (SBFrame &frame, SBValue &return_value)
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (log)
log->Printf ("SBThread(%p)::ReturnFromFrame (frame=%d)",
@ -1355,8 +1350,8 @@ SBThread::GetNumFrames ()
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
uint32_t num_frames = 0;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (exe_ctx.HasThreadScope())
{
@ -1387,8 +1382,8 @@ SBThread::GetFrameAtIndex (uint32_t idx)
SBFrame sb_frame;
StackFrameSP frame_sp;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (exe_ctx.HasThreadScope())
{
@ -1426,8 +1421,8 @@ SBThread::GetSelectedFrame ()
SBFrame sb_frame;
StackFrameSP frame_sp;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (exe_ctx.HasThreadScope())
{
@ -1465,8 +1460,8 @@ SBThread::SetSelectedFrame (uint32_t idx)
SBFrame sb_frame;
StackFrameSP frame_sp;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (exe_ctx.HasThreadScope())
{
@ -1569,8 +1564,8 @@ SBThread
SBThread::GetExtendedBacktraceThread (const char *type)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
SBThread sb_origin_thread;
if (exe_ctx.HasThreadScope())

View File

@ -127,7 +127,7 @@ public:
}
lldb::ValueObjectSP
GetSP (Process::StopLocker &stop_locker, Mutex::Locker &api_locker, Error &error)
GetSP(Process::StopLocker &stop_locker, std::unique_lock<std::recursive_mutex> &lock, Error &error)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (!m_valobj_sp)
@ -139,11 +139,11 @@ public:
lldb::ValueObjectSP value_sp = m_valobj_sp;
Target *target = value_sp->GetTargetSP().get();
if (target)
api_locker.Lock(target->GetAPIMutex());
else
if (!target)
return ValueObjectSP();
lock = std::unique_lock<std::recursive_mutex>(target->GetAPIMutex());
ProcessSP process_sp(value_sp->GetProcessSP());
if (process_sp && !stop_locker.TryLock (&process_sp->GetRunLock()))
{
@ -255,13 +255,13 @@ public:
ValueLocker ()
{
}
ValueObjectSP
GetLockedSP(ValueImpl &in_value)
{
return in_value.GetSP(m_stop_locker, m_api_locker, m_lock_error);
return in_value.GetSP(m_stop_locker, m_lock, m_lock_error);
}
Error &
GetError()
{
@ -270,9 +270,8 @@ public:
private:
Process::StopLocker m_stop_locker;
Mutex::Locker m_api_locker;
std::unique_lock<std::recursive_mutex> m_lock;
Error m_lock_error;
};
SBValue::SBValue () :

View File

@ -115,7 +115,7 @@ SBWatchpoint::GetHardwareIndex ()
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp)
{
Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
hw_index = watchpoint_sp->GetHardwareIndex();
}
@ -130,7 +130,7 @@ SBWatchpoint::GetWatchAddress ()
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp)
{
Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
ret_addr = watchpoint_sp->GetLoadAddress();
}
@ -145,7 +145,7 @@ SBWatchpoint::GetWatchSize ()
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp)
{
Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
watch_size = watchpoint_sp->GetByteSize();
}
@ -158,7 +158,7 @@ SBWatchpoint::SetEnabled (bool enabled)
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp)
{
Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
watchpoint_sp->GetTarget().DisableWatchpointByID(watchpoint_sp->GetID());
}
}
@ -169,7 +169,7 @@ SBWatchpoint::IsEnabled ()
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp)
{
Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
return watchpoint_sp->IsEnabled();
}
else
@ -183,7 +183,7 @@ SBWatchpoint::GetHitCount ()
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp)
{
Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
count = watchpoint_sp->GetHitCount();
}
@ -201,7 +201,7 @@ SBWatchpoint::GetIgnoreCount ()
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp)
{
Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
return watchpoint_sp->GetIgnoreCount();
}
else
@ -214,7 +214,7 @@ SBWatchpoint::SetIgnoreCount (uint32_t n)
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp)
{
Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
watchpoint_sp->SetIgnoreCount (n);
}
}
@ -225,7 +225,7 @@ SBWatchpoint::GetCondition ()
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp)
{
Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
return watchpoint_sp->GetConditionText ();
}
return NULL;
@ -237,7 +237,7 @@ SBWatchpoint::SetCondition (const char *condition)
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp)
{
Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
watchpoint_sp->SetCondition (condition);
}
}
@ -250,7 +250,7 @@ SBWatchpoint::GetDescription (SBStream &description, DescriptionLevel level)
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp)
{
Mutex::Locker api_locker (watchpoint_sp->GetTarget().GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(watchpoint_sp->GetTarget().GetAPIMutex());
watchpoint_sp->GetDescription (&strm, level);
strm.EOL();
}

View File

@ -410,8 +410,8 @@ Breakpoint::ModulesChanged (ModuleList &module_list, bool load, bool delete_loca
if (log)
log->Printf ("Breakpoint::ModulesChanged: num_modules: %zu load: %i delete_locations: %i\n",
module_list.GetSize(), load, delete_locations);
Mutex::Locker modules_mutex(module_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
if (load)
{
// The logic for handling new modules is:

View File

@ -18,11 +18,8 @@
using namespace lldb;
using namespace lldb_private;
BreakpointList::BreakpointList (bool is_internal) :
m_mutex (Mutex::eMutexTypeRecursive),
m_breakpoints(),
m_next_break_id (0),
m_is_internal (is_internal)
BreakpointList::BreakpointList(bool is_internal)
: m_mutex(), m_breakpoints(), m_next_break_id(0), m_is_internal(is_internal)
{
}
@ -34,7 +31,7 @@ BreakpointList::~BreakpointList()
break_id_t
BreakpointList::Add (BreakpointSP &bp_sp, bool notify)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
// Internal breakpoint IDs are negative, normal ones are positive
bp_sp->SetID (m_is_internal ? --m_next_break_id : ++m_next_break_id);
@ -51,7 +48,7 @@ BreakpointList::Add (BreakpointSP &bp_sp, bool notify)
bool
BreakpointList::Remove (break_id_t break_id, bool notify)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
bp_collection::iterator pos = GetBreakpointIDIterator(break_id); // Predicate
if (pos != m_breakpoints.end())
{
@ -71,7 +68,7 @@ BreakpointList::Remove (break_id_t break_id, bool notify)
void
BreakpointList::RemoveInvalidLocations (const ArchSpec &arch)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
for (const auto &bp_sp : m_breakpoints)
bp_sp->RemoveInvalidLocations(arch);
}
@ -80,7 +77,7 @@ BreakpointList::RemoveInvalidLocations (const ArchSpec &arch)
void
BreakpointList::SetEnabledAll (bool enabled)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
for (const auto &bp_sp : m_breakpoints)
bp_sp->SetEnabled (enabled);
}
@ -89,7 +86,7 @@ BreakpointList::SetEnabledAll (bool enabled)
void
BreakpointList::RemoveAll (bool notify)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
ClearAllBreakpointSites ();
if (notify)
@ -142,7 +139,7 @@ BreakpointList::GetBreakpointIDConstIterator (break_id_t break_id) const
BreakpointSP
BreakpointList::FindBreakpointByID (break_id_t break_id)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
BreakpointSP stop_sp;
bp_collection::iterator pos = GetBreakpointIDIterator(break_id);
if (pos != m_breakpoints.end())
@ -154,7 +151,7 @@ BreakpointList::FindBreakpointByID (break_id_t break_id)
const BreakpointSP
BreakpointList::FindBreakpointByID (break_id_t break_id) const
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
BreakpointSP stop_sp;
bp_collection::const_iterator pos = GetBreakpointIDConstIterator(break_id);
if (pos != m_breakpoints.end())
@ -166,7 +163,7 @@ BreakpointList::FindBreakpointByID (break_id_t break_id) const
void
BreakpointList::Dump (Stream *s) const
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
s->Printf("%p: ", static_cast<const void*>(this));
s->Indent();
s->Printf("BreakpointList with %u Breakpoints:\n", (uint32_t)m_breakpoints.size());
@ -180,7 +177,7 @@ BreakpointList::Dump (Stream *s) const
BreakpointSP
BreakpointList::GetBreakpointAtIndex (size_t i)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
BreakpointSP stop_sp;
bp_collection::iterator end = m_breakpoints.end();
bp_collection::iterator pos;
@ -196,7 +193,7 @@ BreakpointList::GetBreakpointAtIndex (size_t i)
const BreakpointSP
BreakpointList::GetBreakpointAtIndex (size_t i) const
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
BreakpointSP stop_sp;
bp_collection::const_iterator end = m_breakpoints.end();
bp_collection::const_iterator pos;
@ -212,7 +209,7 @@ BreakpointList::GetBreakpointAtIndex (size_t i) const
void
BreakpointList::UpdateBreakpoints (ModuleList& module_list, bool added, bool delete_locations)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
for (const auto &bp_sp : m_breakpoints)
bp_sp->ModulesChanged (module_list, added, delete_locations);
@ -221,7 +218,7 @@ BreakpointList::UpdateBreakpoints (ModuleList& module_list, bool added, bool del
void
BreakpointList::UpdateBreakpointsWhenModuleIsReplaced (ModuleSP old_module_sp, ModuleSP new_module_sp)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
for (const auto &bp_sp : m_breakpoints)
bp_sp->ModuleReplaced (old_module_sp, new_module_sp);
@ -230,14 +227,14 @@ BreakpointList::UpdateBreakpointsWhenModuleIsReplaced (ModuleSP old_module_sp, M
void
BreakpointList::ClearAllBreakpointSites ()
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
for (const auto &bp_sp : m_breakpoints)
bp_sp->ClearAllBreakpointSites ();
}
void
BreakpointList::GetListMutex (Mutex::Locker &locker)
BreakpointList::GetListMutex(std::unique_lock<std::recursive_mutex> &lock)
{
return locker.Lock (m_mutex);
lock = std::unique_lock<std::recursive_mutex>(m_mutex);
}

View File

@ -33,36 +33,29 @@
using namespace lldb;
using namespace lldb_private;
BreakpointLocation::BreakpointLocation
(
break_id_t loc_id,
Breakpoint &owner,
const Address &addr,
lldb::tid_t tid,
bool hardware,
bool check_for_resolver
) :
StoppointLocation (loc_id, addr.GetOpcodeLoadAddress(&owner.GetTarget()), hardware),
m_being_created(true),
m_should_resolve_indirect_functions (false),
m_is_reexported (false),
m_is_indirect (false),
m_address (addr),
m_owner (owner),
m_options_ap (),
m_bp_site_sp (),
m_condition_mutex ()
BreakpointLocation::BreakpointLocation(break_id_t loc_id, Breakpoint &owner, const Address &addr, lldb::tid_t tid,
bool hardware, bool check_for_resolver)
: StoppointLocation(loc_id, addr.GetOpcodeLoadAddress(&owner.GetTarget()), hardware),
m_being_created(true),
m_should_resolve_indirect_functions(false),
m_is_reexported(false),
m_is_indirect(false),
m_address(addr),
m_owner(owner),
m_options_ap(),
m_bp_site_sp(),
m_condition_mutex()
{
if (check_for_resolver)
{
Symbol *symbol = m_address.CalculateSymbolContextSymbol();
if (symbol && symbol->IsIndirect())
{
SetShouldResolveIndirectFunctions (true);
SetShouldResolveIndirectFunctions(true);
}
}
SetThreadID (tid);
SetThreadID(tid);
m_being_created = false;
}
@ -267,9 +260,9 @@ bool
BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error)
{
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
Mutex::Locker evaluation_locker(m_condition_mutex);
std::lock_guard<std::mutex> guard(m_condition_mutex);
size_t condition_hash;
const char *condition_text = GetConditionText(&condition_hash);

View File

@ -18,10 +18,7 @@
using namespace lldb;
using namespace lldb_private;
WatchpointList::WatchpointList() :
m_watchpoints (),
m_mutex (Mutex::eMutexTypeRecursive),
m_next_wp_id (0)
WatchpointList::WatchpointList() : m_watchpoints(), m_mutex(), m_next_wp_id(0)
{
}
@ -33,7 +30,7 @@ WatchpointList::~WatchpointList()
lldb::watch_id_t
WatchpointList::Add (const WatchpointSP &wp_sp, bool notify)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
wp_sp->SetID(++m_next_wp_id);
m_watchpoints.push_back(wp_sp);
if (notify)
@ -54,7 +51,7 @@ WatchpointList::Dump (Stream *s) const
void
WatchpointList::DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
s->Printf("%p: ", static_cast<const void*>(this));
//s->Indent();
s->Printf("WatchpointList with %" PRIu64 " Watchpoints:\n",
@ -70,7 +67,7 @@ const WatchpointSP
WatchpointList::FindByAddress (lldb::addr_t addr) const
{
WatchpointSP wp_sp;
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_watchpoints.empty())
{
wp_collection::const_iterator pos, end = m_watchpoints.end();
@ -93,7 +90,7 @@ const WatchpointSP
WatchpointList::FindBySpec (std::string spec) const
{
WatchpointSP wp_sp;
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_watchpoints.empty())
{
wp_collection::const_iterator pos, end = m_watchpoints.end();
@ -142,7 +139,7 @@ WatchpointSP
WatchpointList::FindByID (lldb::watch_id_t watch_id) const
{
WatchpointSP wp_sp;
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
wp_collection::const_iterator pos = GetIDConstIterator(watch_id);
if (pos != m_watchpoints.end())
wp_sp = *pos;
@ -175,7 +172,7 @@ WatchpointList::FindIDBySpec (std::string spec)
WatchpointSP
WatchpointList::GetByIndex (uint32_t i)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
WatchpointSP wp_sp;
if (i < m_watchpoints.size())
{
@ -189,7 +186,7 @@ WatchpointList::GetByIndex (uint32_t i)
const WatchpointSP
WatchpointList::GetByIndex (uint32_t i) const
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
WatchpointSP wp_sp;
if (i < m_watchpoints.size())
{
@ -213,7 +210,7 @@ WatchpointList::GetWatchpointIDs() const
bool
WatchpointList::Remove (lldb::watch_id_t watch_id, bool notify)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
wp_collection::iterator pos = GetIDIterator(watch_id);
if (pos != m_watchpoints.end())
{
@ -234,7 +231,7 @@ uint32_t
WatchpointList::GetHitCount () const
{
uint32_t hit_count = 0;
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
wp_collection::const_iterator pos, end = m_watchpoints.end();
for (pos = m_watchpoints.begin(); pos != end; ++pos)
hit_count += (*pos)->GetHitCount();
@ -261,7 +258,7 @@ WatchpointList::ShouldStop (StoppointCallbackContext *context, lldb::watch_id_t
void
WatchpointList::GetDescription (Stream *s, lldb::DescriptionLevel level)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
wp_collection::iterator pos, end = m_watchpoints.end();
for (pos = m_watchpoints.begin(); pos != end; ++pos)
@ -274,7 +271,7 @@ WatchpointList::GetDescription (Stream *s, lldb::DescriptionLevel level)
void
WatchpointList::SetEnabledAll (bool enabled)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
wp_collection::iterator pos, end = m_watchpoints.end();
for (pos = m_watchpoints.begin(); pos != end; ++pos)
@ -284,7 +281,7 @@ WatchpointList::SetEnabledAll (bool enabled)
void
WatchpointList::RemoveAll (bool notify)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (notify)
{
@ -305,7 +302,7 @@ WatchpointList::RemoveAll (bool notify)
}
void
WatchpointList::GetListMutex (Mutex::Locker &locker)
WatchpointList::GetListMutex(std::unique_lock<std::recursive_mutex> &lock)
{
return locker.Lock (m_mutex);
lock = std::unique_lock<std::recursive_mutex>(m_mutex);
}

View File

@ -1092,9 +1092,9 @@ protected:
return false;
}
Mutex::Locker locker;
target->GetBreakpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetBreakpointList().GetListMutex(lock);
BreakpointIDList valid_bp_ids;
CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (command, target, result, &valid_bp_ids);
@ -1222,8 +1222,8 @@ protected:
return false;
}
Mutex::Locker locker;
target->GetBreakpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetBreakpointList().GetListMutex(lock);
const BreakpointList &breakpoints = target->GetBreakpointList();
@ -1339,8 +1339,8 @@ protected:
return false;
}
Mutex::Locker locker;
target->GetBreakpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetBreakpointList().GetListMutex(lock);
const BreakpointList &breakpoints = target->GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
@ -1523,8 +1523,8 @@ protected:
}
const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal);
Mutex::Locker locker;
target->GetBreakpointList(m_options.m_internal).GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetBreakpointList(m_options.m_internal).GetListMutex(lock);
size_t num_breakpoints = breakpoints.GetSize();
@ -1713,8 +1713,8 @@ protected:
if (m_options.m_line_num != 0)
break_type = eClearTypeFileAndLine;
Mutex::Locker locker;
target->GetBreakpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetBreakpointList().GetListMutex(lock);
BreakpointList &breakpoints = target->GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
@ -1901,9 +1901,9 @@ protected:
return false;
}
Mutex::Locker locker;
target->GetBreakpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetBreakpointList().GetListMutex(lock);
const BreakpointList &breakpoints = target->GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
@ -2118,9 +2118,9 @@ protected:
return false;
}
Mutex::Locker locker;
target->GetBreakpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetBreakpointList().GetListMutex(lock);
const BreakpointList &breakpoints = target->GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
@ -2211,9 +2211,9 @@ protected:
return false;
}
Mutex::Locker locker;
target->GetBreakpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetBreakpointList().GetListMutex(lock);
const BreakpointList &breakpoints = target->GetBreakpointList();
size_t num_breakpoints = breakpoints.GetSize();
@ -2292,9 +2292,9 @@ protected:
if (m_name_options.m_name.OptionWasSet())
{
const char *name = m_name_options.m_name.GetCurrentValue();
Mutex::Locker locker;
target->GetBreakpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetBreakpointList().GetListMutex(lock);
BreakpointList &breakpoints = target->GetBreakpointList();
for (BreakpointSP bp_sp : breakpoints.Breakpoints())
{

View File

@ -733,7 +733,7 @@ protected:
}
{ // Scope for thread list mutex:
Mutex::Locker locker (process->GetThreadList().GetMutex());
std::lock_guard<std::recursive_mutex> guard(process->GetThreadList().GetMutex());
const uint32_t num_threads = process->GetThreadList().GetSize();
// Set the actions that the threads should each take when resuming

View File

@ -1548,7 +1548,7 @@ static size_t
DumpModuleObjfileHeaders(Stream &strm, ModuleList &module_list)
{
size_t num_dumped = 0;
Mutex::Locker modules_locker(module_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
const size_t num_modules = module_list.GetSize();
if (num_modules > 0)
{
@ -2302,7 +2302,7 @@ protected:
if (command.GetArgumentCount() == 0)
{
// Dump all sections for all modules images
Mutex::Locker modules_locker(target->GetImages().GetMutex());
std::lock_guard<std::recursive_mutex> guard(target->GetImages().GetMutex());
const size_t num_modules = target->GetImages().GetSize();
if (num_modules > 0)
{
@ -2532,7 +2532,7 @@ protected:
{
// Dump all sections for all modules images
const ModuleList &target_modules = target->GetImages();
Mutex::Locker modules_locker (target_modules.GetMutex());
std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
const size_t num_modules = target_modules.GetSize();
if (num_modules > 0)
{
@ -2633,7 +2633,7 @@ protected:
FileSpec file_spec(arg_cstr, false);
const ModuleList &target_modules = target->GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
const size_t num_modules = target_modules.GetSize();
if (num_modules > 0)
{
@ -3296,7 +3296,6 @@ protected:
// 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 size_t argc = command.GetArgumentCount();
@ -3333,10 +3332,11 @@ protected:
module_list_ptr = &module_list;
}
std::unique_lock<std::recursive_mutex> lock;
if (module_list_ptr != nullptr)
{
assert(use_global_module_list == false && "locking violation");
locker.Lock(module_list_ptr->GetMutex());
lock = std::unique_lock<std::recursive_mutex>(module_list_ptr->GetMutex());
num_modules = module_list_ptr->GetSize();
}
@ -4239,7 +4239,7 @@ protected:
// Dump all sections for all other modules
const ModuleList &target_modules = target->GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
const size_t num_modules = target_modules.GetSize();
if (num_modules > 0)
{

View File

@ -87,7 +87,7 @@ public:
const size_t num_args = command.GetArgumentCount();
Process *process = m_exe_ctx.GetProcessPtr();
Mutex::Locker locker (process->GetThreadList().GetMutex());
std::lock_guard<std::recursive_mutex> guard(process->GetThreadList().GetMutex());
for (size_t i = 0; i < num_args; i++)
{
@ -859,7 +859,7 @@ public:
// These two lines appear at the beginning of both blocks in
// this if..else, but that is because we need to release the
// lock before calling process->Resume below.
Mutex::Locker locker (process->GetThreadList().GetMutex());
std::lock_guard<std::recursive_mutex> guard(process->GetThreadList().GetMutex());
const uint32_t num_threads = process->GetThreadList().GetSize();
std::vector<Thread *> resume_threads;
for (uint32_t i = 0; i < argc; ++i)
@ -932,7 +932,7 @@ public:
// These two lines appear at the beginning of both blocks in
// this if..else, but that is because we need to release the
// lock before calling process->Resume below.
Mutex::Locker locker (process->GetThreadList().GetMutex());
std::lock_guard<std::recursive_mutex> guard(process->GetThreadList().GetMutex());
const uint32_t num_threads = process->GetThreadList().GetSize();
Thread *current_thread = GetDefaultThread();
if (current_thread == nullptr)

View File

@ -265,8 +265,9 @@ protected:
}
const WatchpointList &watchpoints = target->GetWatchpointList();
Mutex::Locker locker;
target->GetWatchpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetWatchpointList().GetListMutex(lock);
size_t num_watchpoints = watchpoints.GetSize();
@ -369,8 +370,8 @@ protected:
if (!CheckTargetForWatchpointOperations(target, result))
return false;
Mutex::Locker locker;
target->GetWatchpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetWatchpointList().GetListMutex(lock);
const WatchpointList &watchpoints = target->GetWatchpointList();
@ -444,8 +445,8 @@ protected:
if (!CheckTargetForWatchpointOperations(target, result))
return false;
Mutex::Locker locker;
target->GetWatchpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetWatchpointList().GetListMutex(lock);
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
@ -525,9 +526,9 @@ protected:
if (!CheckTargetForWatchpointOperations(target, result))
return false;
Mutex::Locker locker;
target->GetWatchpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetWatchpointList().GetListMutex(lock);
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
@ -666,9 +667,9 @@ protected:
if (!CheckTargetForWatchpointOperations(target, result))
return false;
Mutex::Locker locker;
target->GetWatchpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetWatchpointList().GetListMutex(lock);
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
@ -819,9 +820,9 @@ protected:
if (!CheckTargetForWatchpointOperations(target, result))
return false;
Mutex::Locker locker;
target->GetWatchpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
target->GetWatchpointList().GetListMutex(lock);
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();

View File

@ -3330,7 +3330,7 @@ public:
if (thread_sp)
{
ThreadList &thread_list = thread_sp->GetProcess()->GetThreadList();
Mutex::Locker locker (thread_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(thread_list.GetMutex());
ThreadSP selected_thread_sp = thread_list.GetSelectedThread();
if (selected_thread_sp->GetID() != thread_sp->GetID())
{
@ -3412,7 +3412,7 @@ public:
TreeItem t (&item, *m_thread_delegate_sp, false);
ThreadList &threads = process_sp->GetThreadList();
Mutex::Locker locker (threads.GetMutex());
std::lock_guard<std::recursive_mutex> guard(threads.GetMutex());
size_t num_threads = threads.GetSize();
item.Resize (num_threads, t);
for (size_t i = 0; i < num_threads; ++i)
@ -4431,7 +4431,7 @@ public:
submenus.erase (submenus.begin() + 8, submenus.end());
ThreadList &threads = process->GetThreadList();
Mutex::Locker locker (threads.GetMutex());
std::lock_guard<std::recursive_mutex> guard(threads.GetMutex());
size_t num_threads = threads.GetSize();
for (size_t i = 0; i < num_threads; ++i)
{

View File

@ -28,27 +28,18 @@
using namespace lldb;
using namespace lldb_private;
ModuleList::ModuleList() :
m_modules(),
m_modules_mutex (Mutex::eMutexTypeRecursive),
m_notifier(nullptr)
ModuleList::ModuleList() : m_modules(), m_modules_mutex(), m_notifier(nullptr)
{
}
ModuleList::ModuleList(const ModuleList& rhs) :
m_modules(),
m_modules_mutex (Mutex::eMutexTypeRecursive),
m_notifier(nullptr)
ModuleList::ModuleList(const ModuleList &rhs) : m_modules(), m_modules_mutex(), m_notifier(nullptr)
{
Mutex::Locker lhs_locker(m_modules_mutex);
Mutex::Locker rhs_locker(rhs.m_modules_mutex);
std::lock_guard<std::recursive_mutex> lhs_guard(m_modules_mutex);
std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_modules_mutex);
m_modules = rhs.m_modules;
}
ModuleList::ModuleList (ModuleList::Notifier* notifier) :
m_modules(),
m_modules_mutex (Mutex::eMutexTypeRecursive),
m_notifier(notifier)
ModuleList::ModuleList(ModuleList::Notifier *notifier) : m_modules(), m_modules_mutex(), m_notifier(notifier)
{
}
@ -69,14 +60,14 @@ ModuleList::operator= (const ModuleList& rhs)
// avoids priority inversion.
if (uintptr_t(this) > uintptr_t(&rhs))
{
Mutex::Locker lhs_locker(m_modules_mutex);
Mutex::Locker rhs_locker(rhs.m_modules_mutex);
std::lock_guard<std::recursive_mutex> lhs_guard(m_modules_mutex);
std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_modules_mutex);
m_modules = rhs.m_modules;
}
else
{
Mutex::Locker rhs_locker(rhs.m_modules_mutex);
Mutex::Locker lhs_locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> lhs_guard(m_modules_mutex);
std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_modules_mutex);
m_modules = rhs.m_modules;
}
}
@ -90,7 +81,7 @@ ModuleList::AppendImpl (const ModuleSP &module_sp, bool use_notifier)
{
if (module_sp)
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
m_modules.push_back(module_sp);
if (use_notifier && m_notifier)
m_notifier->ModuleAdded(*this, module_sp);
@ -108,7 +99,7 @@ ModuleList::ReplaceEquivalent (const ModuleSP &module_sp)
{
if (module_sp)
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
// First remove any equivalent modules. Equivalent modules are modules
// whose path, platform path and architecture match.
@ -134,7 +125,7 @@ ModuleList::AppendIfNeeded (const ModuleSP &module_sp)
{
if (module_sp)
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -172,7 +163,7 @@ ModuleList::RemoveImpl (const ModuleSP &module_sp, bool use_notifier)
{
if (module_sp)
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -220,7 +211,7 @@ ModuleList::RemoveIfOrphaned (const Module *module_ptr)
{
if (module_ptr)
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -242,16 +233,16 @@ ModuleList::RemoveIfOrphaned (const Module *module_ptr)
size_t
ModuleList::RemoveOrphans (bool mandatory)
{
Mutex::Locker locker;
std::unique_lock<std::recursive_mutex> lock(m_modules_mutex, std::defer_lock);
if (mandatory)
{
locker.Lock (m_modules_mutex);
lock.lock();
}
else
{
// Not mandatory, remove orphans if we can get the mutex
if (!locker.TryLock(m_modules_mutex))
if (!lock.try_lock())
return 0;
}
collection::iterator pos = m_modules.begin();
@ -274,7 +265,7 @@ ModuleList::RemoveOrphans (bool mandatory)
size_t
ModuleList::Remove (ModuleList &module_list)
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
size_t num_removed = 0;
collection::iterator pos, end = module_list.m_modules.end();
for (pos = module_list.m_modules.begin(); pos != end; ++pos)
@ -301,7 +292,7 @@ ModuleList::Destroy()
void
ModuleList::ClearImpl (bool use_notifier)
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
if (use_notifier && m_notifier)
m_notifier->WillClearList(*this);
m_modules.clear();
@ -310,7 +301,7 @@ ModuleList::ClearImpl (bool use_notifier)
Module*
ModuleList::GetModulePointerAtIndex (size_t idx) const
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
return GetModulePointerAtIndexUnlocked(idx);
}
@ -325,7 +316,7 @@ ModuleList::GetModulePointerAtIndexUnlocked (size_t idx) const
ModuleSP
ModuleList::GetModuleAtIndex(size_t idx) const
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
return GetModuleAtIndexUnlocked(idx);
}
@ -361,8 +352,8 @@ ModuleList::FindFunctions (const ConstString &name,
lookup_name,
lookup_name_type_mask,
match_name_after_lookup);
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -398,7 +389,7 @@ ModuleList::FindFunctions (const ConstString &name,
}
else
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -425,8 +416,8 @@ ModuleList::FindFunctionSymbols (const ConstString &name,
lookup_name,
lookup_name_type_mask,
match_name_after_lookup);
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -458,7 +449,7 @@ ModuleList::FindFunctionSymbols (const ConstString &name,
}
else
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -478,7 +469,7 @@ ModuleList::FindFunctions(const RegularExpression &name,
{
const size_t old_size = sc_list.GetSize();
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -495,8 +486,8 @@ ModuleList::FindCompileUnits (const FileSpec &path,
{
if (!append)
sc_list.Clear();
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -513,7 +504,7 @@ ModuleList::FindGlobalVariables (const ConstString &name,
VariableList& variable_list) const
{
size_t initial_size = variable_list.GetSize();
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -529,7 +520,7 @@ ModuleList::FindGlobalVariables (const RegularExpression& regex,
VariableList& variable_list) const
{
size_t initial_size = variable_list.GetSize();
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -544,7 +535,7 @@ ModuleList::FindSymbolsWithNameAndType (const ConstString &name,
SymbolContextList &sc_list,
bool append) const
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
if (!append)
sc_list.Clear();
size_t initial_size = sc_list.GetSize();
@ -561,7 +552,7 @@ ModuleList::FindSymbolsMatchingRegExAndType (const RegularExpression &regex,
SymbolContextList &sc_list,
bool append) const
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
if (!append)
sc_list.Clear();
size_t initial_size = sc_list.GetSize();
@ -577,7 +568,7 @@ ModuleList::FindModules (const ModuleSpec &module_spec, ModuleList& matching_mod
{
size_t existing_matches = matching_module_list.GetSize();
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -595,7 +586,7 @@ ModuleList::FindModule (const Module *module_ptr) const
// Scope for "locker"
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
@ -617,7 +608,7 @@ ModuleList::FindModule (const UUID &uuid) const
if (uuid.IsValid())
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
@ -635,7 +626,7 @@ ModuleList::FindModule (const UUID &uuid) const
size_t
ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool name_is_fully_qualified, size_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeList& types) const
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
size_t total_matches = 0;
collection::const_iterator pos, end = m_modules.end();
@ -677,7 +668,7 @@ ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool na
bool
ModuleList::FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -693,7 +684,7 @@ ModuleList::FindAddressesForLine (const lldb::TargetSP target_sp,
Function *function,
std::vector<Address> &output_local, std::vector<Address> &output_extern)
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -705,7 +696,7 @@ ModuleSP
ModuleList::FindFirstModule (const ModuleSpec &module_spec) const
{
ModuleSP module_sp;
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -722,7 +713,7 @@ ModuleList::GetSize() const
{
size_t size = 0;
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
size = m_modules.size();
}
return size;
@ -731,11 +722,11 @@ ModuleList::GetSize() const
void
ModuleList::Dump(Stream *s) const
{
// s.Printf("%.*p: ", (int)sizeof(void*) * 2, this);
// s.Indent();
// s << "ModuleList\n";
// s.Printf("%.*p: ", (int)sizeof(void*) * 2, this);
// s.Indent();
// s << "ModuleList\n";
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -747,8 +738,8 @@ void
ModuleList::LogUUIDAndPaths (Log *log, const char *prefix_cstr)
{
if (log != nullptr)
{
Mutex::Locker locker(m_modules_mutex);
{
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, begin = m_modules.begin(), end = m_modules.end();
for (pos = begin; pos != end; ++pos)
{
@ -767,7 +758,7 @@ ModuleList::LogUUIDAndPaths (Log *log, const char *prefix_cstr)
bool
ModuleList::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr) const
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -792,7 +783,7 @@ ModuleList::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t res
}
else
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -821,7 +812,7 @@ ModuleList::ResolveSymbolContextForFilePath(const char *file_path,
uint32_t
ModuleList::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) const
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
@ -836,7 +827,7 @@ ModuleList::GetIndexForModule (const Module *module) const
{
if (module)
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos;
collection::const_iterator begin = m_modules.begin();
collection::const_iterator end = m_modules.end();
@ -896,7 +887,7 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec,
bool always_create)
{
ModuleList &shared_module_list = GetSharedModuleList ();
Mutex::Locker locker(shared_module_list.m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(shared_module_list.m_modules_mutex);
char path[PATH_MAX];
Error error;
@ -1175,7 +1166,7 @@ ModuleList::LoadScriptingResourcesInTarget (Target *target,
{
if (!target)
return false;
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
for (auto module : m_modules)
{
Error error;
@ -1202,7 +1193,7 @@ ModuleList::LoadScriptingResourcesInTarget (Target *target,
void
ModuleList::ForEach (std::function <bool (const ModuleSP &module_sp)> const &callback) const
{
Mutex::Locker locker(m_modules_mutex);
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
for (const auto &module : m_modules)
{
// If the callback returns false, then stop iterating and break out

View File

@ -130,7 +130,7 @@ SearchFilter::SearchInModuleList (Searcher &searcher, ModuleList &modules)
searcher.SearchCallback(*this, empty_sc, nullptr, false);
else
{
Mutex::Locker modules_locker(modules.GetMutex());
std::lock_guard<std::recursive_mutex> guard(modules.GetMutex());
const size_t numModules = modules.GetSize();
for (size_t i = 0; i < numModules; i++)
@ -172,8 +172,8 @@ SearchFilter::DoModuleIteration (const SymbolContext &context, Searcher &searche
else
{
const ModuleList &target_images = m_target_sp->GetImages();
Mutex::Locker modules_locker(target_images.GetMutex());
std::lock_guard<std::recursive_mutex> guard(target_images.GetMutex());
size_t n_modules = target_images.GetSize();
for (size_t i = 0; i < n_modules; i++)
{
@ -363,8 +363,8 @@ SearchFilterByModule::Search (Searcher &searcher)
// find the ones that match the file name.
const ModuleList &target_modules = m_target_sp->GetImages();
Mutex::Locker modules_locker (target_modules.GetMutex());
std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
const size_t num_modules = target_modules.GetSize ();
for (size_t i = 0; i < num_modules; i++)
{
@ -502,8 +502,8 @@ SearchFilterByModuleList::Search (Searcher &searcher)
// find the ones that match the file name.
const ModuleList &target_modules = m_target_sp->GetImages();
Mutex::Locker modules_locker (target_modules.GetMutex());
std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
const size_t num_modules = target_modules.GetSize ();
for (size_t i = 0; i < num_modules; i++)
{
@ -656,8 +656,8 @@ SearchFilterByModuleListAndCU::Search (Searcher &searcher)
ModuleList matching_modules;
const ModuleList &target_images = m_target_sp->GetImages();
Mutex::Locker modules_locker(target_images.GetMutex());
std::lock_guard<std::recursive_mutex> guard(target_images.GetMutex());
const size_t num_modules = target_images.GetSize ();
bool no_modules_in_filter = m_module_spec_list.GetSize() == 0;
for (size_t i = 0; i < num_modules; i++)

View File

@ -16,10 +16,10 @@
using namespace lldb_private;
void
OptionParser::Prepare(Mutex::Locker &locker)
OptionParser::Prepare(std::unique_lock<std::mutex> &lock)
{
static Mutex g_mutex(Mutex::eMutexTypeNormal);
locker.Lock(g_mutex);
static std::mutex g_mutex;
lock = std::unique_lock<std::mutex>(g_mutex);
#ifdef __GLIBC__
optind = 0;
#else

View File

@ -575,8 +575,8 @@ Args::ParseOptions (Options &options)
}
}
}
Mutex::Locker options_locker(NULL);
OptionParser::Prepare(options_locker);
std::unique_lock<std::mutex> lock;
OptionParser::Prepare(lock);
int val;
while (1)
{
@ -1218,8 +1218,8 @@ Args::ParseAliasOptions (Options &options,
}
}
Mutex::Locker options_locker(NULL);
OptionParser::Prepare(options_locker);
std::unique_lock<std::mutex> lock;
OptionParser::Prepare(lock);
int val;
while (1)
{
@ -1396,8 +1396,8 @@ Args::ParseArgsForCompletion
}
}
Mutex::Locker options_locker(NULL);
OptionParser::Prepare(options_locker);
std::unique_lock<std::mutex> lock;
OptionParser::Prepare(lock);
OptionParser::EnableError(false);
int val;

View File

@ -276,7 +276,7 @@ CommandObject::CheckRequirements (CommandReturnObject &result)
{
Target *target = m_exe_ctx.GetTargetPtr();
if (target)
m_api_locker.Lock (target->GetAPIMutex());
m_api_locker = std::unique_lock<std::recursive_mutex>(target->GetAPIMutex());
}
}
@ -336,7 +336,8 @@ void
CommandObject::Cleanup ()
{
m_exe_ctx.Clear();
m_api_locker.Unlock();
if (m_api_locker.owns_lock())
m_api_locker.unlock();
}
int

View File

@ -1275,8 +1275,8 @@ DynamicLoaderMacOSXDYLD::InitializeFromAllImageInfos ()
Target &target = m_process->GetTarget();
const ModuleList &target_modules = target.GetImages();
ModuleList not_loaded_modules;
Mutex::Locker modules_locker(target_modules.GetMutex());
std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
size_t num_modules = target_modules.GetSize();
for (size_t i = 0; i < num_modules; i++)
{

View File

@ -102,8 +102,8 @@ DynamicLoaderStatic::LoadAllImagesAtFileAddresses ()
// Disable JIT for static dynamic loader targets
m_process->SetCanJIT(false);
Mutex::Locker mutex_locker(module_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
const size_t num_modules = module_list.GetSize();
for (uint32_t idx = 0; idx < num_modules; ++idx)
{

View File

@ -708,7 +708,7 @@ ClangASTSource::FindExternalVisibleDecls (NameSearchContext &context,
else
{
const ModuleList &target_images = m_target->GetImages();
Mutex::Locker modules_locker (target_images.GetMutex());
std::lock_guard<std::recursive_mutex> guard(target_images.GetMutex());
for (size_t i = 0, e = target_images.GetSize(); i < e; ++i)
{
@ -1826,7 +1826,7 @@ ClangASTSource::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespac
else
{
const ModuleList &target_images = m_target->GetImages();
Mutex::Locker modules_locker(target_images.GetMutex());
std::lock_guard<std::recursive_mutex> guard(target_images.GetMutex());
CompilerDeclContext null_namespace_decl;

View File

@ -98,8 +98,8 @@ AddressSanitizerRuntime::ModulesDidLoad(lldb_private::ModuleList &module_list)
Activate();
return;
}
Mutex::Locker modules_locker(module_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
const size_t num_modules = module_list.GetSize();
for (size_t i = 0; i < num_modules; ++i)
{

View File

@ -394,8 +394,8 @@ AppleObjCRuntime::GetObjCVersion (Process *process, ModuleSP &objc_module_sp)
return ObjCRuntimeVersions::eObjC_VersionUnknown;
const ModuleList &target_modules = target.GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
std::lock_guard<std::recursive_mutex> gaurd(target_modules.GetMutex());
size_t num_images = target_modules.GetSize();
for (size_t i = 0; i < num_images; i++)
{
@ -524,7 +524,7 @@ AppleObjCRuntime::ReadObjCLibraryIfNeeded (const ModuleList &module_list)
{
if (!HasReadObjCLibrary ())
{
Mutex::Locker locker (module_list.GetMutex ());
std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
size_t num_modules = module_list.GetSize();
for (size_t i = 0; i < num_modules; i++)

View File

@ -462,7 +462,7 @@ AppleObjCTrampolineHandler::AppleObjCVTables::InitializeVTableSymbols ()
Target &target = process_sp->GetTarget();
const ModuleList &target_modules = target.GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
size_t num_modules = target_modules.GetSize();
if (!m_objc_module_sp)
{

View File

@ -871,7 +871,7 @@ RenderScriptRuntime::IsRenderScriptModule(const lldb::ModuleSP &module_sp)
void
RenderScriptRuntime::ModulesDidLoad(const ModuleList &module_list)
{
Mutex::Locker locker(module_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
size_t num_modules = module_list.GetSize();
for (size_t i = 0; i < num_modules; i++)

View File

@ -38,7 +38,7 @@ MemoryHistoryASan::CreateInstance (const ProcessSP &process_sp)
Target & target = process_sp->GetTarget();
const ModuleList &target_modules = target.GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
const size_t num_modules = target_modules.GetSize();
for (size_t i = 0; i < num_modules; ++i)
{

View File

@ -162,7 +162,7 @@ ObjectFileJIT::GetSymtab()
if (m_symtab_ap.get() == NULL)
{
m_symtab_ap.reset(new Symtab(this));
Mutex::Locker symtab_locker (m_symtab_ap->GetMutex());
std::lock_guard<std::recursive_mutex> symtab_guard(m_symtab_ap->GetMutex());
ObjectFileJITDelegateSP delegate_sp (m_delegate_wp.lock());
if (delegate_sp)
delegate_sp->PopulateSymtab(this, *m_symtab_ap);

View File

@ -1461,7 +1461,7 @@ ObjectFileMachO::GetSymtab()
if (m_symtab_ap.get() == NULL)
{
m_symtab_ap.reset(new Symtab(this));
Mutex::Locker symtab_locker (m_symtab_ap->GetMutex());
std::lock_guard<std::recursive_mutex> symtab_guard(m_symtab_ap->GetMutex());
ParseSymtab ();
m_symtab_ap->Finalize ();
}

View File

@ -539,8 +539,8 @@ ObjectFilePECOFF::GetSymtab()
{
SectionList *sect_list = GetSectionList();
m_symtab_ap.reset(new Symtab(this));
Mutex::Locker symtab_locker (m_symtab_ap->GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_symtab_ap->GetMutex());
const uint32_t num_syms = m_coff_header.nsyms;
if (num_syms > 0 && m_coff_header.symoff > 0)

View File

@ -197,7 +197,7 @@ OperatingSystemGo::CreateInstance(Process *process, bool force)
if (!target_sp)
return nullptr;
ModuleList &module_list = target_sp->GetImages();
Mutex::Locker modules_locker(module_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
const size_t num_modules = module_list.GetSize();
bool found_go_runtime = false;
for (size_t i = 0; i < num_modules; ++i)

View File

@ -183,16 +183,16 @@ OperatingSystemPython::UpdateThreadList (ThreadList &old_thread_list,
// This is a recursive lock so we can grant it to any Python code called on
// the stack below us.
Target &target = m_process->GetTarget();
Mutex::Locker api_locker;
api_locker.TryLock(target.GetAPIMutex());
std::unique_lock<std::recursive_mutex> lock(target.GetAPIMutex(), std::defer_lock);
lock.try_lock();
if (log)
log->Printf ("OperatingSystemPython::UpdateThreadList() fetching thread data from python for pid %" PRIu64, m_process->GetID());
// The threads that are in "new_thread_list" upon entry are the threads from the
// lldb_private::Process subclass, no memory threads will be in this list.
auto lock = m_interpreter->AcquireInterpreterLock(); // to make sure threads_list stays alive
auto interpreter_lock = m_interpreter->AcquireInterpreterLock(); // to make sure threads_list stays alive
StructuredData::ArraySP threads_list = m_interpreter->OSPlugin_ThreadsInfo(m_python_object_sp);
const uint32_t num_cores = core_thread_list.GetSize(false);
@ -324,7 +324,7 @@ OperatingSystemPython::CreateRegisterContextForThread (Thread *thread, addr_t re
// content of the process, and we're going to use python, which requires the API lock to do it.
// So get & hold that. This is a recursive lock so we can grant it to any Python code called on the stack below us.
Target &target = m_process->GetTarget();
Mutex::Locker api_locker (target.GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex());
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
@ -399,8 +399,8 @@ OperatingSystemPython::CreateThread (lldb::tid_t tid, addr_t context)
// content of the process, and we're going to use python, which requires the API lock to do it.
// So get & hold that. This is a recursive lock so we can grant it to any Python code called on the stack below us.
Target &target = m_process->GetTarget();
Mutex::Locker api_locker (target.GetAPIMutex());
std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex());
auto lock = m_interpreter->AcquireInterpreterLock(); // to make sure thread_info_dict stays alive
StructuredData::DictionarySP thread_info_dict = m_interpreter->OSPlugin_CreateThread(m_python_object_sp, tid, context);
std::vector<bool> core_used_map;

View File

@ -143,7 +143,7 @@ ProcessFreeBSD::DoResume()
SetPrivateState(eStateRunning);
Mutex::Locker lock(m_thread_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
bool do_step = false;
for (tid_collection::const_iterator t_pos = m_run_tids.begin(), t_end = m_run_tids.end(); t_pos != t_end; ++t_pos)
@ -630,7 +630,7 @@ ProcessFreeBSD::RefreshStateAfterStop()
if (log)
log->Printf ("ProcessFreeBSD::%s() removing thread, tid = %" PRIi64, __FUNCTION__, tid);
Mutex::Locker lock(m_thread_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
ThreadSP thread_sp = m_thread_list.RemoveThreadByID(tid, false);
thread_sp.reset();
@ -801,7 +801,7 @@ ProcessFreeBSD::EnableWatchpoint(Watchpoint *wp, bool notify)
// Try to find a vacant watchpoint slot in the inferiors' main thread
uint32_t wp_hw_index = LLDB_INVALID_INDEX32;
Mutex::Locker lock(m_thread_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
FreeBSDThread *thread = static_cast<FreeBSDThread*>(
m_thread_list.GetThreadAtIndex(0, false).get());
@ -871,7 +871,7 @@ ProcessFreeBSD::DisableWatchpoint(Watchpoint *wp, bool notify)
if (wp->IsHardware())
{
bool wp_disabled = true;
Mutex::Locker lock(m_thread_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
uint32_t thread_count = m_thread_list.GetSize(false);
for (uint32_t i = 0; i < thread_count; ++i)
{
@ -901,7 +901,7 @@ Error
ProcessFreeBSD::GetWatchpointSupportInfo(uint32_t &num)
{
Error error;
Mutex::Locker lock(m_thread_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
FreeBSDThread *thread = static_cast<FreeBSDThread*>(
m_thread_list.GetThreadAtIndex(0, false).get());
if (thread)
@ -924,7 +924,7 @@ ProcessFreeBSD::GetWatchpointSupportInfo(uint32_t &num, bool &after)
uint32_t
ProcessFreeBSD::UpdateThreadListIfNeeded()
{
Mutex::Locker lock(m_thread_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
// Do not allow recursive updates.
return m_thread_list.GetSize(false);
}
@ -1015,7 +1015,7 @@ bool
ProcessFreeBSD::IsAThreadRunning()
{
bool is_running = false;
Mutex::Locker lock(m_thread_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
uint32_t thread_count = m_thread_list.GetSize(false);
for (uint32_t i = 0; i < thread_count; ++i)
{

View File

@ -37,21 +37,21 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// CommunicationKDP constructor
//----------------------------------------------------------------------
CommunicationKDP::CommunicationKDP (const char *comm_name) :
Communication(comm_name),
m_addr_byte_size (4),
m_byte_order (eByteOrderLittle),
m_packet_timeout (5),
m_sequence_mutex (Mutex::eMutexTypeRecursive),
m_is_running (false),
m_session_key (0u),
m_request_sequence_id (0u),
m_exception_sequence_id (0u),
m_kdp_version_version (0u),
m_kdp_version_feature (0u),
m_kdp_hostinfo_cpu_mask (0u),
m_kdp_hostinfo_cpu_type (0u),
m_kdp_hostinfo_cpu_subtype (0u)
CommunicationKDP::CommunicationKDP(const char *comm_name)
: Communication(comm_name),
m_addr_byte_size(4),
m_byte_order(eByteOrderLittle),
m_packet_timeout(5),
m_sequence_mutex(),
m_is_running(false),
m_session_key(0u),
m_request_sequence_id(0u),
m_exception_sequence_id(0u),
m_kdp_version_version(0u),
m_kdp_version_feature(0u),
m_kdp_hostinfo_cpu_mask(0u),
m_kdp_hostinfo_cpu_type(0u),
m_kdp_hostinfo_cpu_subtype(0u)
{
}
@ -69,7 +69,7 @@ CommunicationKDP::~CommunicationKDP()
bool
CommunicationKDP::SendRequestPacket (const PacketStreamType &request_packet)
{
Mutex::Locker locker(m_sequence_mutex);
std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
return SendRequestPacketNoLock (request_packet);
}
@ -111,7 +111,7 @@ CommunicationKDP::SendRequestAndGetReply (const CommandType command,
return false;
}
Mutex::Locker locker(m_sequence_mutex);
std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
#ifdef LLDB_CONFIGURATION_DEBUG
// NOTE: this only works for packets that are in native endian byte order
assert (request_packet.GetSize() == *((uint16_t *)(request_packet.GetData() + 2)));
@ -205,9 +205,9 @@ CommunicationKDP::SendRequestPacketNoLock (const PacketStreamType &request_packe
}
bool
CommunicationKDP::GetSequenceMutex (Mutex::Locker& locker)
CommunicationKDP::GetSequenceMutex(std::unique_lock<std::recursive_mutex> &lock)
{
return locker.TryLock (m_sequence_mutex);
return (lock = std::unique_lock<std::recursive_mutex>(m_sequence_mutex, std::try_to_lock)).owns_lock();
}
@ -220,7 +220,7 @@ CommunicationKDP::WaitForNotRunningPrivate (const TimeValue *timeout_ptr)
size_t
CommunicationKDP::WaitForPacketWithTimeoutMicroSeconds (DataExtractor &packet, uint32_t timeout_usec)
{
Mutex::Locker locker(m_sequence_mutex);
std::lock_guard<std::recursive_mutex> guard(m_sequence_mutex);
return WaitForPacketWithTimeoutMicroSecondsNoLock (packet, timeout_usec);
}

View File

@ -13,6 +13,7 @@
// C Includes
// C++ Includes
#include <list>
#include <mutex>
#include <string>
// Other libraries and framework includes
@ -21,7 +22,6 @@
#include "lldb/Core/Communication.h"
#include "lldb/Core/Listener.h"
#include "lldb/Core/StreamBuffer.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Host/TimeValue.h"
@ -109,7 +109,7 @@ public:
uint32_t usec);
bool
GetSequenceMutex(lldb_private::Mutex::Locker& locker);
GetSequenceMutex(std::unique_lock<std::recursive_mutex> &lock);
bool
CheckForPacket (const uint8_t *src,
@ -324,7 +324,7 @@ protected:
uint32_t m_addr_byte_size;
lldb::ByteOrder m_byte_order;
uint32_t m_packet_timeout;
lldb_private::Mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time
std::recursive_mutex m_sequence_mutex; // Restrict access to sending/receiving packets to a single thread at a time
lldb_private::Predicate<bool> m_is_running;
uint32_t m_session_key;
uint8_t m_request_sequence_id;

View File

@ -1646,7 +1646,7 @@ ProcessGDBRemote::HandleStopReplySequence ()
void
ProcessGDBRemote::ClearThreadIDList ()
{
Mutex::Locker locker(m_thread_list_real.GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_thread_list_real.GetMutex());
m_thread_ids.clear();
m_thread_pcs.clear();
}
@ -1696,7 +1696,7 @@ ProcessGDBRemote::UpdateThreadPCsFromStopReplyThreadsValue (std::string &value)
bool
ProcessGDBRemote::UpdateThreadIDList ()
{
Mutex::Locker locker(m_thread_list_real.GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_thread_list_real.GetMutex());
if (m_jthreadsinfo_sp)
{
@ -1944,7 +1944,7 @@ ProcessGDBRemote::SetThreadStopInfo (lldb::tid_t tid,
// m_thread_list_real does have its own mutex, but we need to
// hold onto the mutex between the call to m_thread_list_real.FindThreadByID(...)
// and the m_thread_list_real.AddThread(...) so it doesn't change on us
Mutex::Locker locker (m_thread_list_real.GetMutex ());
std::lock_guard<std::recursive_mutex> guard(m_thread_list_real.GetMutex());
thread_sp = m_thread_list_real.FindThreadByProtocolID(tid, false);
if (!thread_sp)
@ -2440,7 +2440,8 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
}
else if (key.compare("threads") == 0)
{
Mutex::Locker locker(m_thread_list_real.GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_thread_list_real.GetMutex());
m_thread_ids.clear();
// A comma separated list of all threads in the current
// process that includes the thread for this stop reply
@ -2663,7 +2664,8 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
void
ProcessGDBRemote::RefreshStateAfterStop ()
{
Mutex::Locker locker(m_thread_list_real.GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_thread_list_real.GetMutex());
m_thread_ids.clear();
m_thread_pcs.clear();
// Set the thread stop info. It might have a "threads" key whose value is
@ -2818,7 +2820,7 @@ ProcessGDBRemote::DoDestroy ()
ThreadList &threads = GetThreadList();
{
Mutex::Locker locker(threads.GetMutex());
std::lock_guard<std::recursive_mutex> guard(threads.GetMutex());
size_t num_threads = threads.GetSize();
for (size_t i = 0; i < num_threads; i++)
@ -2853,7 +2855,7 @@ ProcessGDBRemote::DoDestroy ()
// have to run the risk of letting those threads proceed a bit.
{
Mutex::Locker locker(threads.GetMutex());
std::lock_guard<std::recursive_mutex> guard(threads.GetMutex());
size_t num_threads = threads.GetSize();
for (size_t i = 0; i < num_threads; i++)

View File

@ -9,7 +9,6 @@
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
#include "lldb/Core/Stream.h"
#include "lldb/Host/Mutex.h"
using namespace lldb_private;

View File

@ -130,19 +130,17 @@ namespace lldb_private {
// constructor
//----------------------
CompactUnwindInfo::CompactUnwindInfo(ObjectFile& objfile, SectionSP& section_sp) :
m_objfile (objfile),
m_section_sp (section_sp),
m_section_contents_if_encrypted (),
m_mutex (),
m_indexes (),
m_indexes_computed (eLazyBoolCalculate),
m_unwindinfo_data (),
m_unwindinfo_data_computed (false),
m_unwind_header ()
CompactUnwindInfo::CompactUnwindInfo(ObjectFile &objfile, SectionSP &section_sp)
: m_objfile(objfile),
m_section_sp(section_sp),
m_section_contents_if_encrypted(),
m_mutex(),
m_indexes(),
m_indexes_computed(eLazyBoolCalculate),
m_unwindinfo_data(),
m_unwindinfo_data_computed(false),
m_unwind_header()
{
}
//----------------------
@ -223,7 +221,7 @@ CompactUnwindInfo::IsValid (const ProcessSP &process_sp)
void
CompactUnwindInfo::ScanIndex (const ProcessSP &process_sp)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::mutex> guard(m_mutex);
if (m_indexes_computed == eLazyBoolYes && m_unwindinfo_data_computed)
return;

View File

@ -308,9 +308,9 @@ DWARFCallFrameInfo::GetFDEIndex ()
if (m_fde_index_initialized)
return;
Mutex::Locker locker(m_fde_index_mutex);
std::lock_guard<std::mutex> guard(m_fde_index_mutex);
if (m_fde_index_initialized) // if two threads hit the locker
return;

View File

@ -25,16 +25,14 @@
using namespace lldb;
using namespace lldb_private;
Symtab::Symtab(ObjectFile *objfile) :
m_objfile (objfile),
m_symbols (),
m_file_addr_to_index (),
m_name_to_index (),
m_mutex (Mutex::eMutexTypeRecursive),
m_file_addr_to_index_computed (false),
m_name_indexes_computed (false)
Symtab::Symtab(ObjectFile *objfile)
: m_objfile(objfile),
m_symbols(),
m_file_addr_to_index(),
m_name_to_index(),
m_mutex(),
m_file_addr_to_index_computed(false),
m_name_indexes_computed(false)
{
}
@ -76,7 +74,7 @@ Symtab::AddSymbol(const Symbol& symbol)
size_t
Symtab::GetNumSymbols() const
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_symbols.size();
}
@ -90,9 +88,9 @@ Symtab::SectionFileAddressesChanged ()
void
Symtab::Dump (Stream *s, Target *target, SortOrder sort_order)
{
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();
const FileSpec &file_spec = m_objfile->GetFileSpec();
const char * object_name = nullptr;
@ -171,7 +169,7 @@ Symtab::Dump (Stream *s, Target *target, SortOrder sort_order)
void
Symtab::Dump(Stream *s, Target *target, std::vector<uint32_t>& indexes) const
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
const size_t num_symbols = GetNumSymbols();
//s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
@ -224,7 +222,7 @@ CompareSymbolID (const void *key, const void *p)
Symbol *
Symtab::FindSymbolByID (lldb::user_id_t symbol_uid) const
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
Symbol *symbol = (Symbol*)::bsearch (&symbol_uid,
&m_symbols[0],
@ -474,7 +472,7 @@ Symtab::AppendSymbolNamesToMap (const IndexCollection &indexes,
if (add_demangled || add_mangled)
{
Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__);
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
// Create the name index vector to be able to quickly search by name
NameToIndexMap::Entry entry;
@ -506,7 +504,7 @@ Symtab::AppendSymbolNamesToMap (const IndexCollection &indexes,
uint32_t
Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, std::vector<uint32_t>& indexes, uint32_t start_idx, uint32_t end_index) const
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
uint32_t prev_size = indexes.size();
@ -524,7 +522,7 @@ Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, std::vector<uint32_
uint32_t
Symtab::AppendSymbolIndexesWithTypeAndFlagsValue (SymbolType symbol_type, uint32_t flags_value, std::vector<uint32_t>& indexes, uint32_t start_idx, uint32_t end_index) const
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
uint32_t prev_size = indexes.size();
@ -542,7 +540,7 @@ Symtab::AppendSymbolIndexesWithTypeAndFlagsValue (SymbolType symbol_type, uint32
uint32_t
Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& indexes, uint32_t start_idx, uint32_t end_index) const
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
uint32_t prev_size = indexes.size();
@ -632,7 +630,7 @@ namespace {
void
Symtab::SortSymbolIndexesByValue (std::vector<uint32_t>& indexes, bool remove_duplicates) const
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
Timer scoped_timer (__PRETTY_FUNCTION__,__PRETTY_FUNCTION__);
// No need to sort if we have zero or one items...
@ -657,7 +655,7 @@ Symtab::SortSymbolIndexesByValue (std::vector<uint32_t>& indexes, bool remove_du
uint32_t
Symtab::AppendSymbolIndexesWithName (const ConstString& symbol_name, std::vector<uint32_t>& indexes)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__);
if (symbol_name)
@ -674,7 +672,7 @@ Symtab::AppendSymbolIndexesWithName (const ConstString& symbol_name, std::vector
uint32_t
Symtab::AppendSymbolIndexesWithName (const ConstString& symbol_name, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& indexes)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__);
if (symbol_name)
@ -700,7 +698,7 @@ Symtab::AppendSymbolIndexesWithName (const ConstString& symbol_name, Debug symbo
uint32_t
Symtab::AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, SymbolType symbol_type, std::vector<uint32_t>& indexes)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (AppendSymbolIndexesWithName(symbol_name, indexes) > 0)
{
@ -719,7 +717,7 @@ Symtab::AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, Symb
uint32_t
Symtab::AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& indexes)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (AppendSymbolIndexesWithName(symbol_name, symbol_debug_type, symbol_visibility, indexes) > 0)
{
@ -739,7 +737,7 @@ Symtab::AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, Symb
uint32_t
Symtab::AppendSymbolIndexesMatchingRegExAndType (const RegularExpression &regexp, SymbolType symbol_type, std::vector<uint32_t>& indexes)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
uint32_t prev_size = indexes.size();
uint32_t sym_end = m_symbols.size();
@ -763,7 +761,7 @@ Symtab::AppendSymbolIndexesMatchingRegExAndType (const RegularExpression &regexp
uint32_t
Symtab::AppendSymbolIndexesMatchingRegExAndType (const RegularExpression &regexp, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& indexes)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
uint32_t prev_size = indexes.size();
uint32_t sym_end = m_symbols.size();
@ -790,7 +788,7 @@ Symtab::AppendSymbolIndexesMatchingRegExAndType (const RegularExpression &regexp
Symbol *
Symtab::FindSymbolWithType (SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t& start_idx)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
const size_t count = m_symbols.size();
for (size_t idx = start_idx; idx < count; ++idx)
@ -810,7 +808,7 @@ Symtab::FindSymbolWithType (SymbolType symbol_type, Debug symbol_debug_type, Vis
size_t
Symtab::FindAllSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, std::vector<uint32_t>& symbol_indexes)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__);
// Initialize all of the lookup by name indexes before converting NAME
@ -830,7 +828,7 @@ Symtab::FindAllSymbolsWithNameAndType (const ConstString &name, SymbolType symbo
size_t
Symtab::FindAllSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& symbol_indexes)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__);
// Initialize all of the lookup by name indexes before converting NAME
@ -850,7 +848,7 @@ Symtab::FindAllSymbolsWithNameAndType (const ConstString &name, SymbolType symbo
size_t
Symtab::FindAllSymbolsMatchingRexExAndType (const RegularExpression &regex, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& symbol_indexes)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
AppendSymbolIndexesMatchingRegExAndType(regex, symbol_type, symbol_debug_type, symbol_visibility, symbol_indexes);
return symbol_indexes.size();
@ -859,7 +857,7 @@ Symtab::FindAllSymbolsMatchingRexExAndType (const RegularExpression &regex, Symb
Symbol *
Symtab::FindFirstSymbolWithNameAndType (const ConstString &name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__);
if (!m_name_indexes_computed)
@ -1026,7 +1024,7 @@ Symtab::InitAddressIndexes()
void
Symtab::CalculateSymbolSizes ()
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_symbols.empty())
{
@ -1060,7 +1058,7 @@ Symtab::CalculateSymbolSizes ()
Symbol *
Symtab::FindSymbolAtFileAddress (addr_t file_addr)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_file_addr_to_index_computed)
InitAddressIndexes();
@ -1077,7 +1075,7 @@ Symtab::FindSymbolAtFileAddress (addr_t file_addr)
Symbol *
Symtab::FindSymbolContainingFileAddress (addr_t file_addr)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_file_addr_to_index_computed)
InitAddressIndexes();
@ -1095,7 +1093,7 @@ Symtab::FindSymbolContainingFileAddress (addr_t file_addr)
void
Symtab::ForEachSymbolContainingFileAddress(addr_t file_addr, std::function<bool(Symbol *)> const &callback)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_file_addr_to_index_computed)
InitAddressIndexes();
@ -1159,7 +1157,7 @@ Symtab::FindFunctionSymbols (const ConstString &name,
unsigned temp_symbol_indexes_size = temp_symbol_indexes.size();
if (temp_symbol_indexes_size > 0)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
for (unsigned i = 0; i < temp_symbol_indexes_size; i++)
{
SymbolContext sym_ctx;

View File

@ -163,10 +163,7 @@ TypeSystem::DeclContextFindDeclByName (void *opaque_decl_ctx,
#pragma mark TypeSystemMap
TypeSystemMap::TypeSystemMap() :
m_mutex (),
m_map (),
m_clear_in_progress(false)
TypeSystemMap::TypeSystemMap() : m_mutex(), m_map(), m_clear_in_progress(false)
{
}
@ -179,7 +176,7 @@ TypeSystemMap::Clear ()
{
collection map;
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::mutex> guard(m_mutex);
map = m_map;
m_clear_in_progress = true;
}
@ -195,7 +192,7 @@ TypeSystemMap::Clear ()
}
map.clear();
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::mutex> guard(m_mutex);
m_map.clear();
m_clear_in_progress = false;
}
@ -205,7 +202,7 @@ TypeSystemMap::Clear ()
void
TypeSystemMap::ForEach (std::function <bool(TypeSystem *)> const &callback)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::mutex> guard(m_mutex);
// Use a std::set so we only call the callback once for each unique
// TypeSystem instance
std::set<TypeSystem *> visited;
@ -224,7 +221,7 @@ TypeSystemMap::ForEach (std::function <bool(TypeSystem *)> const &callback)
TypeSystem *
TypeSystemMap::GetTypeSystemForLanguage (lldb::LanguageType language, Module *module, bool can_create)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::mutex> guard(m_mutex);
collection::iterator pos = m_map.find(language);
if (pos != m_map.end())
return pos->second.get();
@ -252,7 +249,7 @@ TypeSystemMap::GetTypeSystemForLanguage (lldb::LanguageType language, Module *mo
TypeSystem *
TypeSystemMap::GetTypeSystemForLanguage (lldb::LanguageType language, Target *target, bool can_create)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::mutex> guard(m_mutex);
collection::iterator pos = m_map.find(language);
if (pos != m_map.end())
return pos->second.get();

View File

@ -27,14 +27,14 @@
using namespace lldb;
using namespace lldb_private;
UnwindTable::UnwindTable (ObjectFile& objfile) :
m_object_file (objfile),
m_unwinds (),
m_initialized (false),
m_mutex (),
m_eh_frame_up (),
m_compact_unwind_up (),
m_arm_unwind_up ()
UnwindTable::UnwindTable(ObjectFile &objfile)
: m_object_file(objfile),
m_unwinds(),
m_initialized(false),
m_mutex(),
m_eh_frame_up(),
m_compact_unwind_up(),
m_arm_unwind_up()
{
}
@ -47,7 +47,7 @@ UnwindTable::Initialize ()
if (m_initialized)
return;
Mutex::Locker locker(m_mutex);
std::lock_guard<std::mutex> guard(m_mutex);
if (m_initialized) // check again once we've acquired the lock
return;
@ -90,7 +90,7 @@ UnwindTable::GetFuncUnwindersContainingAddress (const Address& addr, SymbolConte
Initialize();
Mutex::Locker locker(m_mutex);
std::lock_guard<std::mutex> guard(m_mutex);
// There is an UnwindTable per object file, so we can safely use file handles
addr_t file_addr = addr.GetFileAddress();
@ -152,7 +152,7 @@ UnwindTable::GetUncachedFuncUnwindersContainingAddress (const Address& addr, Sym
void
UnwindTable::Dump (Stream &s)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::mutex> guard(m_mutex);
s.Printf("UnwindTable for '%s':\n", m_object_file.GetFileSpec().GetPath().c_str());
const_iterator begin = m_unwinds.begin();
const_iterator end = m_unwinds.end();

View File

@ -186,18 +186,17 @@ ExecutionContext::ExecutionContext (const ExecutionContextRef *exe_ctx_ref_ptr,
}
}
ExecutionContext::ExecutionContext (const ExecutionContextRef *exe_ctx_ref_ptr, Mutex::Locker &locker) :
m_target_sp (),
m_process_sp (),
m_thread_sp (),
m_frame_sp ()
ExecutionContext::ExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr,
std::unique_lock<std::recursive_mutex> &lock)
: m_target_sp(), m_process_sp(), m_thread_sp(), m_frame_sp()
{
if (exe_ctx_ref_ptr)
{
m_target_sp = exe_ctx_ref_ptr->GetTargetSP();
m_target_sp = exe_ctx_ref_ptr->GetTargetSP();
if (m_target_sp)
{
locker.Lock(m_target_sp->GetAPIMutex());
lock = std::unique_lock<std::recursive_mutex>(m_target_sp->GetAPIMutex());
m_process_sp = exe_ctx_ref_ptr->GetProcessSP();
m_thread_sp = exe_ctx_ref_ptr->GetThreadSP();
m_frame_sp = exe_ctx_ref_ptr->GetFrameSP();
@ -205,18 +204,16 @@ ExecutionContext::ExecutionContext (const ExecutionContextRef *exe_ctx_ref_ptr,
}
}
ExecutionContext::ExecutionContext (const ExecutionContextRef &exe_ctx_ref, Mutex::Locker &locker) :
m_target_sp (exe_ctx_ref.GetTargetSP()),
m_process_sp (),
m_thread_sp (),
m_frame_sp ()
ExecutionContext::ExecutionContext(const ExecutionContextRef &exe_ctx_ref, std::unique_lock<std::recursive_mutex> &lock)
: m_target_sp(exe_ctx_ref.GetTargetSP()), m_process_sp(), m_thread_sp(), m_frame_sp()
{
if (m_target_sp)
{
locker.Lock(m_target_sp->GetAPIMutex());
lock = std::unique_lock<std::recursive_mutex>(m_target_sp->GetAPIMutex());
m_process_sp = exe_ctx_ref.GetProcessSP();
m_thread_sp = exe_ctx_ref.GetThreadSP();
m_frame_sp = exe_ctx_ref.GetFrameSP();
m_thread_sp = exe_ctx_ref.GetThreadSP();
m_frame_sp = exe_ctx_ref.GetFrameSP();
}
}

View File

@ -13,7 +13,6 @@
#include "lldb/Target/Language.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Stream.h"

View File

@ -25,13 +25,13 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// MemoryCache constructor
//----------------------------------------------------------------------
MemoryCache::MemoryCache(Process &process) :
m_mutex (Mutex::eMutexTypeRecursive),
m_L1_cache (),
m_L2_cache (),
m_invalid_ranges (),
m_process (process),
m_L2_cache_line_byte_size (process.GetMemoryCacheLineSize())
MemoryCache::MemoryCache(Process &process)
: m_mutex(),
m_L1_cache(),
m_L2_cache(),
m_invalid_ranges(),
m_process(process),
m_L2_cache_line_byte_size(process.GetMemoryCacheLineSize())
{
}
@ -45,7 +45,7 @@ MemoryCache::~MemoryCache()
void
MemoryCache::Clear(bool clear_invalid_ranges)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_L1_cache.clear();
m_L2_cache.clear();
if (clear_invalid_ranges)
@ -62,7 +62,7 @@ MemoryCache::AddL1CacheData(lldb::addr_t addr, const void *src, size_t src_len)
void
MemoryCache::AddL1CacheData(lldb::addr_t addr, const DataBufferSP &data_buffer_sp)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_L1_cache[addr] = data_buffer_sp;
}
@ -72,7 +72,7 @@ MemoryCache::Flush (addr_t addr, size_t size)
if (size == 0)
return;
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
// Erase any blocks from the L1 cache that intersect with the flush range
if (!m_L1_cache.empty())
@ -123,7 +123,7 @@ MemoryCache::AddInvalidRange (lldb::addr_t base_addr, lldb::addr_t byte_size)
{
if (byte_size > 0)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
InvalidRanges::Entry range (base_addr, byte_size);
m_invalid_ranges.Append(range);
m_invalid_ranges.Sort();
@ -135,7 +135,7 @@ MemoryCache::RemoveInvalidRange (lldb::addr_t base_addr, lldb::addr_t byte_size)
{
if (byte_size > 0)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
const uint32_t idx = m_invalid_ranges.FindEntryIndexThatContains(base_addr);
if (idx != UINT32_MAX)
{
@ -164,7 +164,7 @@ MemoryCache::Read (addr_t addr,
// m_L2_cache_line_byte_size bytes in size, so we don't try anything
// tricky when reading from them (no partial reads from the L1 cache).
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_L1_cache.empty())
{
AddrRange read_range(addr, dst_len);
@ -436,11 +436,7 @@ AllocatedBlock::FreeBlock (addr_t addr)
return success;
}
AllocatedMemoryCache::AllocatedMemoryCache (Process &process) :
m_process (process),
m_mutex (Mutex::eMutexTypeRecursive),
m_memory_map()
AllocatedMemoryCache::AllocatedMemoryCache(Process &process) : m_process(process), m_mutex(), m_memory_map()
{
}
@ -452,7 +448,7 @@ AllocatedMemoryCache::~AllocatedMemoryCache ()
void
AllocatedMemoryCache::Clear()
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_process.IsAlive())
{
PermissionsToBlockMap::iterator pos, end = m_memory_map.end();
@ -498,8 +494,8 @@ AllocatedMemoryCache::AllocateMemory (size_t byte_size,
uint32_t permissions,
Error &error)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
addr_t addr = LLDB_INVALID_ADDRESS;
std::pair<PermissionsToBlockMap::iterator, PermissionsToBlockMap::iterator> range = m_memory_map.equal_range (permissions);
@ -526,7 +522,7 @@ AllocatedMemoryCache::AllocateMemory (size_t byte_size,
bool
AllocatedMemoryCache::DeallocateMemory (lldb::addr_t addr)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
PermissionsToBlockMap::iterator pos, end = m_memory_map.end();
bool success = false;

View File

@ -716,105 +716,99 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp) :
// defaulting to using the Host's UnixSignals.
}
Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp, const UnixSignalsSP &unix_signals_sp) :
ProcessProperties (this),
UserID (LLDB_INVALID_PROCESS_ID),
Broadcaster ((target_sp->GetDebugger().GetBroadcasterManager()), Process::GetStaticBroadcasterClass().AsCString()),
m_target_sp (target_sp),
m_public_state (eStateUnloaded),
m_private_state (eStateUnloaded),
m_private_state_broadcaster(nullptr, "lldb.process.internal_state_broadcaster"),
m_private_state_control_broadcaster(nullptr, "lldb.process.internal_state_control_broadcaster"),
m_private_state_listener_sp (Listener::MakeListener("lldb.process.internal_state_listener")),
m_mod_id (),
m_process_unique_id(0),
m_thread_index_id (0),
m_thread_id_to_index_id_map (),
m_exit_status (-1),
m_exit_string (),
m_exit_status_mutex(),
m_thread_mutex (Mutex::eMutexTypeRecursive),
m_thread_list_real (this),
m_thread_list (this),
m_extended_thread_list (this),
m_extended_thread_stop_id (0),
m_queue_list (this),
m_queue_list_stop_id (0),
m_notifications (),
m_image_tokens (),
m_listener_sp (listener_sp),
m_breakpoint_site_list (),
m_dynamic_checkers_ap (),
m_unix_signals_sp (unix_signals_sp),
m_abi_sp (),
m_process_input_reader (),
m_stdio_communication ("process.stdio"),
m_stdio_communication_mutex (Mutex::eMutexTypeRecursive),
m_stdin_forward (false),
m_stdout_data (),
m_stderr_data (),
m_profile_data_comm_mutex (Mutex::eMutexTypeRecursive),
m_profile_data (),
m_iohandler_sync (0),
m_memory_cache (*this),
m_allocated_memory_cache (*this),
m_should_detach (false),
m_next_event_action_ap(),
m_public_run_lock (),
m_private_run_lock (),
m_stop_info_override_callback(nullptr),
m_finalizing (false),
m_finalize_called (false),
m_clear_thread_plans_on_stop (false),
m_force_next_event_delivery (false),
m_last_broadcast_state (eStateInvalid),
m_destroy_in_process (false),
m_can_interpret_function_calls(false),
m_warnings_issued (),
m_can_jit(eCanJITDontKnow)
Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp, const UnixSignalsSP &unix_signals_sp)
: ProcessProperties(this),
UserID(LLDB_INVALID_PROCESS_ID),
Broadcaster((target_sp->GetDebugger().GetBroadcasterManager()), Process::GetStaticBroadcasterClass().AsCString()),
m_target_sp(target_sp),
m_public_state(eStateUnloaded),
m_private_state(eStateUnloaded),
m_private_state_broadcaster(nullptr, "lldb.process.internal_state_broadcaster"),
m_private_state_control_broadcaster(nullptr, "lldb.process.internal_state_control_broadcaster"),
m_private_state_listener_sp(Listener::MakeListener("lldb.process.internal_state_listener")),
m_mod_id(),
m_process_unique_id(0),
m_thread_index_id(0),
m_thread_id_to_index_id_map(),
m_exit_status(-1),
m_exit_string(),
m_exit_status_mutex(),
m_thread_mutex(),
m_thread_list_real(this),
m_thread_list(this),
m_extended_thread_list(this),
m_extended_thread_stop_id(0),
m_queue_list(this),
m_queue_list_stop_id(0),
m_notifications(),
m_image_tokens(),
m_listener_sp(listener_sp),
m_breakpoint_site_list(),
m_dynamic_checkers_ap(),
m_unix_signals_sp(unix_signals_sp),
m_abi_sp(),
m_process_input_reader(),
m_stdio_communication("process.stdio"),
m_stdio_communication_mutex(),
m_stdin_forward(false),
m_stdout_data(),
m_stderr_data(),
m_profile_data_comm_mutex(),
m_profile_data(),
m_iohandler_sync(0),
m_memory_cache(*this),
m_allocated_memory_cache(*this),
m_should_detach(false),
m_next_event_action_ap(),
m_public_run_lock(),
m_private_run_lock(),
m_stop_info_override_callback(nullptr),
m_finalizing(false),
m_finalize_called(false),
m_clear_thread_plans_on_stop(false),
m_force_next_event_delivery(false),
m_last_broadcast_state(eStateInvalid),
m_destroy_in_process(false),
m_can_interpret_function_calls(false),
m_warnings_issued(),
m_can_jit(eCanJITDontKnow)
{
CheckInWithManager ();
CheckInWithManager();
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
if (log)
log->Printf ("%p Process::Process()", static_cast<void*>(this));
log->Printf("%p Process::Process()", static_cast<void *>(this));
if (!m_unix_signals_sp)
m_unix_signals_sp = std::make_shared<UnixSignals>();
SetEventName (eBroadcastBitStateChanged, "state-changed");
SetEventName (eBroadcastBitInterrupt, "interrupt");
SetEventName (eBroadcastBitSTDOUT, "stdout-available");
SetEventName (eBroadcastBitSTDERR, "stderr-available");
SetEventName (eBroadcastBitProfileData, "profile-data-available");
SetEventName(eBroadcastBitStateChanged, "state-changed");
SetEventName(eBroadcastBitInterrupt, "interrupt");
SetEventName(eBroadcastBitSTDOUT, "stdout-available");
SetEventName(eBroadcastBitSTDERR, "stderr-available");
SetEventName(eBroadcastBitProfileData, "profile-data-available");
m_private_state_control_broadcaster.SetEventName (eBroadcastInternalStateControlStop , "control-stop" );
m_private_state_control_broadcaster.SetEventName (eBroadcastInternalStateControlPause , "control-pause" );
m_private_state_control_broadcaster.SetEventName (eBroadcastInternalStateControlResume, "control-resume");
m_private_state_control_broadcaster.SetEventName(eBroadcastInternalStateControlStop, "control-stop");
m_private_state_control_broadcaster.SetEventName(eBroadcastInternalStateControlPause, "control-pause");
m_private_state_control_broadcaster.SetEventName(eBroadcastInternalStateControlResume, "control-resume");
m_listener_sp->StartListeningForEvents (this,
eBroadcastBitStateChanged |
eBroadcastBitInterrupt |
eBroadcastBitSTDOUT |
eBroadcastBitSTDERR |
eBroadcastBitProfileData);
m_listener_sp->StartListeningForEvents(this, eBroadcastBitStateChanged | eBroadcastBitInterrupt |
eBroadcastBitSTDOUT | eBroadcastBitSTDERR |
eBroadcastBitProfileData);
m_private_state_listener_sp->StartListeningForEvents(&m_private_state_broadcaster,
eBroadcastBitStateChanged |
eBroadcastBitInterrupt);
eBroadcastBitStateChanged | eBroadcastBitInterrupt);
m_private_state_listener_sp->StartListeningForEvents(&m_private_state_control_broadcaster,
eBroadcastInternalStateControlStop |
eBroadcastInternalStateControlPause |
eBroadcastInternalStateControlResume);
m_private_state_listener_sp->StartListeningForEvents(
&m_private_state_control_broadcaster, eBroadcastInternalStateControlStop | eBroadcastInternalStateControlPause |
eBroadcastInternalStateControlResume);
// We need something valid here, even if just the default UnixSignalsSP.
assert (m_unix_signals_sp && "null m_unix_signals_sp after initialization");
assert(m_unix_signals_sp && "null m_unix_signals_sp after initialization");
// Allow the platform to override the default cache line size
OptionValueSP value_sp =
m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertyMemCacheLineSize)->GetValue();
OptionValueSP value_sp = m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertyMemCacheLineSize)->GetValue();
uint32_t platform_cache_line_size = target_sp->GetPlatform()->GetDefaultMemoryCacheLineSize();
if (! value_sp->OptionWasSet() && platform_cache_line_size != 0)
if (!value_sp->OptionWasSet() && platform_cache_line_size != 0)
value_sp->SetUInt64Value(platform_cache_line_size);
}
@ -1153,7 +1147,7 @@ Process::HandleProcessStateChangedEvent (const EventSP &event_sp,
// Lock the thread list so it doesn't change on us, this is the scope for the locker:
{
ThreadList &thread_list = process_sp->GetThreadList();
Mutex::Locker locker (thread_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(thread_list.GetMutex());
ThreadSP curr_thread (thread_list.GetSelectedThread());
ThreadSP thread;
@ -1422,7 +1416,7 @@ Process::IsRunning () const
int
Process::GetExitStatus ()
{
Mutex::Locker locker (m_exit_status_mutex);
std::lock_guard<std::mutex> guard(m_exit_status_mutex);
if (m_public_state.GetValue() == eStateExited)
return m_exit_status;
@ -1432,7 +1426,7 @@ Process::GetExitStatus ()
const char *
Process::GetExitDescription ()
{
Mutex::Locker locker (m_exit_status_mutex);
std::lock_guard<std::mutex> guard(m_exit_status_mutex);
if (m_public_state.GetValue() == eStateExited && !m_exit_string.empty())
return m_exit_string.c_str();
@ -1443,7 +1437,7 @@ bool
Process::SetExitStatus (int status, const char *cstr)
{
// Use a mutex to protect setting the exit status.
Mutex::Locker locker (m_exit_status_mutex);
std::lock_guard<std::mutex> guard(m_exit_status_mutex);
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STATE | LIBLLDB_LOG_PROCESS));
if (log)
@ -1550,7 +1544,7 @@ Process::UpdateThreadListIfNeeded ()
const StateType state = GetPrivateState();
if (StateIsStoppedState (state, true))
{
Mutex::Locker locker (m_thread_list.GetMutex ());
std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
// m_thread_list does have its own mutex, but we need to
// hold onto the mutex between the call to UpdateThreadList(...)
// and the os->UpdateThreadList(...) so it doesn't change on us
@ -1794,7 +1788,7 @@ Process::SetPrivateState (StateType new_state)
if (log)
log->Printf("Process::SetPrivateState (%s)", StateAsCString(new_state));
Mutex::Locker thread_locker(m_thread_list.GetMutex());
std::lock_guard<std::recursive_mutex> thread_guard(m_thread_list.GetMutex());
std::lock_guard<std::recursive_mutex> guard(m_private_state.GetMutex());
const StateType old_state = m_private_state.GetValueNoLock ();
@ -3461,7 +3455,7 @@ Process::CompleteAttach ()
m_os_ap.reset(OperatingSystem::FindPlugin(this, nullptr));
// Figure out which one is the executable, and set that in our target:
const ModuleList &target_modules = GetTarget().GetImages();
Mutex::Locker modules_locker(target_modules.GetMutex());
std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
size_t num_modules = target_modules.GetSize();
ModuleSP new_executable_module_sp;
@ -4783,7 +4777,7 @@ Process::CalculateExecutionContext (ExecutionContext &exe_ctx)
void
Process::AppendSTDOUT (const char * s, size_t len)
{
Mutex::Locker locker (m_stdio_communication_mutex);
std::lock_guard<std::recursive_mutex> guard(m_stdio_communication_mutex);
m_stdout_data.append (s, len);
BroadcastEventIfUnique (eBroadcastBitSTDOUT, new ProcessEventData (shared_from_this(), GetState()));
}
@ -4791,7 +4785,7 @@ Process::AppendSTDOUT (const char * s, size_t len)
void
Process::AppendSTDERR (const char * s, size_t len)
{
Mutex::Locker locker (m_stdio_communication_mutex);
std::lock_guard<std::recursive_mutex> guard(m_stdio_communication_mutex);
m_stderr_data.append (s, len);
BroadcastEventIfUnique (eBroadcastBitSTDERR, new ProcessEventData (shared_from_this(), GetState()));
}
@ -4799,7 +4793,7 @@ Process::AppendSTDERR (const char * s, size_t len)
void
Process::BroadcastAsyncProfileData(const std::string &one_profile_data)
{
Mutex::Locker locker (m_profile_data_comm_mutex);
std::lock_guard<std::recursive_mutex> guard(m_profile_data_comm_mutex);
m_profile_data.push_back(one_profile_data);
BroadcastEventIfUnique (eBroadcastBitProfileData, new ProcessEventData (shared_from_this(), GetState()));
}
@ -4807,7 +4801,7 @@ Process::BroadcastAsyncProfileData(const std::string &one_profile_data)
size_t
Process::GetAsyncProfileData (char *buf, size_t buf_size, Error &error)
{
Mutex::Locker locker(m_profile_data_comm_mutex);
std::lock_guard<std::recursive_mutex> guard(m_profile_data_comm_mutex);
if (m_profile_data.empty())
return 0;
@ -4842,7 +4836,7 @@ Process::GetAsyncProfileData (char *buf, size_t buf_size, Error &error)
size_t
Process::GetSTDOUT (char *buf, size_t buf_size, Error &error)
{
Mutex::Locker locker(m_stdio_communication_mutex);
std::lock_guard<std::recursive_mutex> guard(m_stdio_communication_mutex);
size_t bytes_available = m_stdout_data.size();
if (bytes_available > 0)
{
@ -4869,7 +4863,7 @@ Process::GetSTDOUT (char *buf, size_t buf_size, Error &error)
size_t
Process::GetSTDERR (char *buf, size_t buf_size, Error &error)
{
Mutex::Locker locker(m_stdio_communication_mutex);
std::lock_guard<std::recursive_mutex> gaurd(m_stdio_communication_mutex);
size_t bytes_available = m_stderr_data.size();
if (bytes_available > 0)
{
@ -6105,7 +6099,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx, lldb::ThreadPlanSP &thread_pla
if (GetThreadList().SetSelectedThreadByIndexID (selected_tid) && selected_stack_id.IsValid())
{
// We were able to restore the selected thread, now restore the frame:
Mutex::Locker lock(GetThreadList().GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetThreadList().GetMutex());
StackFrameSP old_frame_sp = GetThreadList().GetSelectedThread()->GetFrameWithStackID(selected_stack_id);
if (old_frame_sp)
GetThreadList().GetSelectedThread()->SetSelectedFrame(old_frame_sp.get());
@ -6210,7 +6204,7 @@ Process::GetThreadStatus (Stream &strm,
std::vector<lldb::tid_t> thread_id_array;
//Scope for thread list locker;
{
Mutex::Locker locker (GetThreadList().GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetThreadList().GetMutex());
ThreadList &curr_thread_list = GetThreadList();
num_threads = curr_thread_list.GetSize();
uint32_t idx;

View File

@ -14,11 +14,7 @@
using namespace lldb;
using namespace lldb_private;
QueueList::QueueList (Process *process) :
m_process (process),
m_stop_id (0),
m_queues (),
m_mutex ()
QueueList::QueueList(Process *process) : m_process(process), m_stop_id(0), m_queues(), m_mutex()
{
}
@ -30,14 +26,14 @@ QueueList::~QueueList ()
uint32_t
QueueList::GetSize ()
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::mutex> guard(m_mutex);
return m_queues.size();
}
lldb::QueueSP
QueueList::GetQueueAtIndex (uint32_t idx)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::mutex> guard(m_mutex);
if (idx < m_queues.size())
{
return m_queues[idx];
@ -51,14 +47,14 @@ QueueList::GetQueueAtIndex (uint32_t idx)
void
QueueList::Clear ()
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::mutex> guard(m_mutex);
m_queues.clear();
}
void
QueueList::AddQueue (QueueSP queue_sp)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::mutex> guard(m_mutex);
if (queue_sp.get ())
{
m_queues.push_back (queue_sp);
@ -95,8 +91,8 @@ QueueList::FindQueueByIndexID (uint32_t index_id)
return ret;
}
lldb_private::Mutex &
QueueList::GetMutex ()
std::mutex &
QueueList::GetMutex()
{
return m_mutex;
}

View File

@ -44,135 +44,119 @@ using namespace lldb_private;
#define RESOLVED_VARIABLES (GOT_FRAME_BASE << 1)
#define RESOLVED_GLOBAL_VARIABLES (RESOLVED_VARIABLES << 1)
StackFrame::StackFrame (const ThreadSP &thread_sp,
user_id_t frame_idx,
user_id_t unwind_frame_index,
addr_t cfa,
bool cfa_is_valid,
addr_t pc,
uint32_t stop_id,
bool stop_id_is_valid,
bool is_history_frame,
const SymbolContext *sc_ptr) :
m_thread_wp (thread_sp),
m_frame_index (frame_idx),
m_concrete_frame_index (unwind_frame_index),
m_reg_context_sp (),
m_id(pc, cfa, nullptr),
m_frame_code_addr (pc),
m_sc (),
m_flags (),
m_frame_base (),
m_frame_base_error (),
m_cfa_is_valid (cfa_is_valid),
m_stop_id (stop_id),
m_stop_id_is_valid (stop_id_is_valid),
m_is_history_frame (is_history_frame),
m_variable_list_sp (),
m_variable_list_value_objects (),
m_disassembly (),
m_mutex (Mutex::eMutexTypeRecursive)
StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx, user_id_t unwind_frame_index, addr_t cfa,
bool cfa_is_valid, addr_t pc, uint32_t stop_id, bool stop_id_is_valid, bool is_history_frame,
const SymbolContext *sc_ptr)
: m_thread_wp(thread_sp),
m_frame_index(frame_idx),
m_concrete_frame_index(unwind_frame_index),
m_reg_context_sp(),
m_id(pc, cfa, nullptr),
m_frame_code_addr(pc),
m_sc(),
m_flags(),
m_frame_base(),
m_frame_base_error(),
m_cfa_is_valid(cfa_is_valid),
m_stop_id(stop_id),
m_stop_id_is_valid(stop_id_is_valid),
m_is_history_frame(is_history_frame),
m_variable_list_sp(),
m_variable_list_value_objects(),
m_disassembly(),
m_mutex()
{
// If we don't have a CFA value, use the frame index for our StackID so that recursive
// functions properly aren't confused with one another on a history stack.
if (m_is_history_frame && !m_cfa_is_valid)
{
m_id.SetCFA (m_frame_index);
m_id.SetCFA(m_frame_index);
}
if (sc_ptr != nullptr)
{
m_sc = *sc_ptr;
m_flags.Set(m_sc.GetResolvedMask ());
m_flags.Set(m_sc.GetResolvedMask());
}
}
StackFrame::StackFrame (const ThreadSP &thread_sp,
user_id_t frame_idx,
user_id_t unwind_frame_index,
const RegisterContextSP &reg_context_sp,
addr_t cfa,
addr_t pc,
const SymbolContext *sc_ptr) :
m_thread_wp (thread_sp),
m_frame_index (frame_idx),
m_concrete_frame_index (unwind_frame_index),
m_reg_context_sp (reg_context_sp),
m_id(pc, cfa, nullptr),
m_frame_code_addr (pc),
m_sc (),
m_flags (),
m_frame_base (),
m_frame_base_error (),
m_cfa_is_valid (true),
m_stop_id (0),
m_stop_id_is_valid (false),
m_is_history_frame (false),
m_variable_list_sp (),
m_variable_list_value_objects (),
m_disassembly (),
m_mutex (Mutex::eMutexTypeRecursive)
StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx, user_id_t unwind_frame_index,
const RegisterContextSP &reg_context_sp, addr_t cfa, addr_t pc, const SymbolContext *sc_ptr)
: m_thread_wp(thread_sp),
m_frame_index(frame_idx),
m_concrete_frame_index(unwind_frame_index),
m_reg_context_sp(reg_context_sp),
m_id(pc, cfa, nullptr),
m_frame_code_addr(pc),
m_sc(),
m_flags(),
m_frame_base(),
m_frame_base_error(),
m_cfa_is_valid(true),
m_stop_id(0),
m_stop_id_is_valid(false),
m_is_history_frame(false),
m_variable_list_sp(),
m_variable_list_value_objects(),
m_disassembly(),
m_mutex()
{
if (sc_ptr != nullptr)
{
m_sc = *sc_ptr;
m_flags.Set(m_sc.GetResolvedMask ());
m_flags.Set(m_sc.GetResolvedMask());
}
if (reg_context_sp && !m_sc.target_sp)
{
m_sc.target_sp = reg_context_sp->CalculateTarget();
if (m_sc.target_sp)
m_flags.Set (eSymbolContextTarget);
m_flags.Set(eSymbolContextTarget);
}
}
StackFrame::StackFrame (const ThreadSP &thread_sp,
user_id_t frame_idx,
user_id_t unwind_frame_index,
const RegisterContextSP &reg_context_sp,
addr_t cfa,
const Address& pc_addr,
const SymbolContext *sc_ptr) :
m_thread_wp (thread_sp),
m_frame_index (frame_idx),
m_concrete_frame_index (unwind_frame_index),
m_reg_context_sp (reg_context_sp),
m_id(pc_addr.GetLoadAddress(thread_sp->CalculateTarget().get()), cfa, nullptr),
m_frame_code_addr (pc_addr),
m_sc (),
m_flags (),
m_frame_base (),
m_frame_base_error (),
m_cfa_is_valid (true),
m_stop_id (0),
m_stop_id_is_valid (false),
m_is_history_frame (false),
m_variable_list_sp (),
m_variable_list_value_objects (),
m_disassembly (),
m_mutex (Mutex::eMutexTypeRecursive)
StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx, user_id_t unwind_frame_index,
const RegisterContextSP &reg_context_sp, addr_t cfa, const Address &pc_addr,
const SymbolContext *sc_ptr)
: m_thread_wp(thread_sp),
m_frame_index(frame_idx),
m_concrete_frame_index(unwind_frame_index),
m_reg_context_sp(reg_context_sp),
m_id(pc_addr.GetLoadAddress(thread_sp->CalculateTarget().get()), cfa, nullptr),
m_frame_code_addr(pc_addr),
m_sc(),
m_flags(),
m_frame_base(),
m_frame_base_error(),
m_cfa_is_valid(true),
m_stop_id(0),
m_stop_id_is_valid(false),
m_is_history_frame(false),
m_variable_list_sp(),
m_variable_list_value_objects(),
m_disassembly(),
m_mutex()
{
if (sc_ptr != nullptr)
{
m_sc = *sc_ptr;
m_flags.Set(m_sc.GetResolvedMask ());
m_flags.Set(m_sc.GetResolvedMask());
}
if (!m_sc.target_sp && reg_context_sp)
{
m_sc.target_sp = reg_context_sp->CalculateTarget();
if (m_sc.target_sp)
m_flags.Set (eSymbolContextTarget);
m_flags.Set(eSymbolContextTarget);
}
ModuleSP pc_module_sp (pc_addr.GetModule());
ModuleSP pc_module_sp(pc_addr.GetModule());
if (!m_sc.module_sp || m_sc.module_sp != pc_module_sp)
{
if (pc_module_sp)
{
m_sc.module_sp = pc_module_sp;
m_flags.Set (eSymbolContextModule);
m_flags.Set(eSymbolContextModule);
}
else
{
@ -186,7 +170,7 @@ StackFrame::~StackFrame() = default;
StackID&
StackFrame::GetStackID()
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
// Make sure we have resolved the StackID object's symbol context scope if
// we already haven't looked it up.
@ -233,7 +217,7 @@ StackFrame::GetFrameIndex () const
void
StackFrame::SetSymbolContextScope (SymbolContextScope *symbol_scope)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE);
m_id.SetSymbolContextScope (symbol_scope);
}
@ -241,7 +225,7 @@ StackFrame::SetSymbolContextScope (SymbolContextScope *symbol_scope)
const Address&
StackFrame::GetFrameCodeAddress()
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_flags.IsClear(RESOLVED_FRAME_CODE_ADDR) && !m_frame_code_addr.IsSectionOffset())
{
m_flags.Set (RESOLVED_FRAME_CODE_ADDR);
@ -272,7 +256,7 @@ StackFrame::GetFrameCodeAddress()
bool
StackFrame::ChangePC (addr_t pc)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
// We can't change the pc value of a history stack frame - it is immutable.
if (m_is_history_frame)
return false;
@ -288,7 +272,7 @@ StackFrame::ChangePC (addr_t pc)
const char *
StackFrame::Disassemble ()
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_disassembly.GetSize() == 0)
{
ExecutionContext exe_ctx (shared_from_this());
@ -348,7 +332,7 @@ StackFrame::GetFrameBlock ()
const SymbolContext&
StackFrame::GetSymbolContext (uint32_t resolve_scope)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
// Copy our internal symbol context into "sc".
if ((m_flags.Get() & resolve_scope) != resolve_scope)
{
@ -521,7 +505,7 @@ StackFrame::GetSymbolContext (uint32_t resolve_scope)
VariableList *
StackFrame::GetVariableList (bool get_file_globals)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_flags.IsClear(RESOLVED_VARIABLES))
{
m_flags.Set(RESOLVED_VARIABLES);
@ -566,7 +550,7 @@ StackFrame::GetVariableList (bool get_file_globals)
VariableListSP
StackFrame::GetInScopeVariableList (bool get_file_globals, bool must_have_valid_location)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
// We can't fetch variable information for a history stack frame.
if (m_is_history_frame)
return VariableListSP();
@ -1197,7 +1181,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
bool
StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_cfa_is_valid)
{
m_frame_base_error.SetErrorString("No frame base available for this historical stack frame.");
@ -1255,7 +1239,7 @@ StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr)
RegisterContextSP
StackFrame::GetRegisterContext ()
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_reg_context_sp)
{
ThreadSP thread_sp (GetThread());
@ -1275,7 +1259,7 @@ StackFrame::HasDebugInformation ()
ValueObjectSP
StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
ValueObjectSP valobj_sp;
if (m_is_history_frame)
{
@ -1311,7 +1295,7 @@ StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp, Dynam
ValueObjectSP
StackFrame::TrackGlobalVariable (const VariableSP &variable_sp, DynamicValueType use_dynamic)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_is_history_frame)
return ValueObjectSP();
@ -1471,7 +1455,7 @@ StackFrame::Dump (Stream *strm, bool show_frame_index, bool show_fullpaths)
void
StackFrame::UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
assert (GetStackID() == prev_frame.GetStackID()); // TODO: remove this after some testing
m_variable_list_sp = prev_frame.m_variable_list_sp;
m_variable_list_value_objects.Swap (prev_frame.m_variable_list_value_objects);
@ -1482,7 +1466,7 @@ StackFrame::UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame)
void
StackFrame::UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame)
{
Mutex::Locker locker(m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
assert (GetStackID() == curr_frame.GetStackID()); // TODO: remove this after some testing
m_id.SetPC (curr_frame.m_id.GetPC()); // Update the Stack ID PC value
assert (GetThread() == curr_frame.GetThread());

View File

@ -36,26 +36,21 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// StackFrameList constructor
//----------------------------------------------------------------------
StackFrameList::StackFrameList
(
Thread &thread,
const lldb::StackFrameListSP &prev_frames_sp,
bool show_inline_frames
) :
m_thread (thread),
m_prev_frames_sp (prev_frames_sp),
m_mutex (Mutex::eMutexTypeRecursive),
m_frames (),
m_selected_frame_idx (0),
m_concrete_frames_fetched (0),
m_current_inlined_depth (UINT32_MAX),
m_current_inlined_pc (LLDB_INVALID_ADDRESS),
m_show_inlined_frames (show_inline_frames)
StackFrameList::StackFrameList(Thread &thread, const lldb::StackFrameListSP &prev_frames_sp, bool show_inline_frames)
: m_thread(thread),
m_prev_frames_sp(prev_frames_sp),
m_mutex(),
m_frames(),
m_selected_frame_idx(0),
m_concrete_frames_fetched(0),
m_current_inlined_depth(UINT32_MAX),
m_current_inlined_pc(LLDB_INVALID_ADDRESS),
m_show_inlined_frames(show_inline_frames)
{
if (prev_frames_sp)
{
m_current_inlined_depth = prev_frames_sp->m_current_inlined_depth;
m_current_inlined_pc = prev_frames_sp->m_current_inlined_pc;
m_current_inlined_pc = prev_frames_sp->m_current_inlined_pc;
}
}
@ -101,7 +96,7 @@ StackFrameList::GetCurrentInlinedDepth ()
void
StackFrameList::ResetCurrentInlinedDepth ()
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_show_inlined_frames)
{
@ -485,7 +480,7 @@ StackFrameList::GetFramesUpTo(uint32_t end_idx)
uint32_t
StackFrameList::GetNumFrames (bool can_create)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (can_create)
GetFramesUpTo (UINT32_MAX);
@ -502,7 +497,8 @@ StackFrameList::Dump (Stream *s)
{
if (s == nullptr)
return;
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
const_iterator pos, begin = m_frames.begin(), end = m_frames.end();
for (pos = begin; pos != end; ++pos)
@ -525,7 +521,7 @@ StackFrameSP
StackFrameList::GetFrameAtIndex (uint32_t idx)
{
StackFrameSP frame_sp;
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
uint32_t original_idx = idx;
uint32_t inlined_depth = GetCurrentInlinedDepth();
@ -634,7 +630,7 @@ StackFrameList::GetFrameWithStackID (const StackID &stack_id)
if (stack_id.IsValid())
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
uint32_t frame_idx = 0;
// Do a binary search in case the stack frame is already in our cache
collection::const_iterator begin = m_frames.begin();
@ -680,14 +676,14 @@ StackFrameList::SetFrameAtIndex (uint32_t idx, StackFrameSP &frame_sp)
uint32_t
StackFrameList::GetSelectedFrameIndex () const
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_selected_frame_idx;
}
uint32_t
StackFrameList::SetSelectedFrame (lldb_private::StackFrame *frame)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
const_iterator pos;
const_iterator begin = m_frames.begin();
const_iterator end = m_frames.end();
@ -711,7 +707,7 @@ StackFrameList::SetSelectedFrame (lldb_private::StackFrame *frame)
bool
StackFrameList::SetSelectedFrameByIndex (uint32_t idx)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
StackFrameSP frame_sp (GetFrameAtIndex (idx));
if (frame_sp)
{
@ -743,7 +739,7 @@ StackFrameList::SetDefaultFileAndLineToSelectedFrame()
void
StackFrameList::Clear ()
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_frames.clear();
m_concrete_frames_fetched = 0;
}
@ -751,7 +747,7 @@ StackFrameList::Clear ()
void
StackFrameList::InvalidateFrames (uint32_t start_idx)
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_show_inlined_frames)
{
Clear();
@ -770,8 +766,11 @@ StackFrameList::InvalidateFrames (uint32_t start_idx)
void
StackFrameList::Merge (std::unique_ptr<StackFrameList>& curr_ap, lldb::StackFrameListSP& prev_sp)
{
Mutex::Locker curr_locker(curr_ap ? &curr_ap->m_mutex : nullptr);
Mutex::Locker prev_locker(prev_sp ? &prev_sp->m_mutex : nullptr);
std::unique_lock<std::recursive_mutex> current_lock, previous_lock;
if (curr_ap)
current_lock = std::unique_lock<std::recursive_mutex>(curr_ap->m_mutex);
if (prev_sp)
previous_lock = std::unique_lock<std::recursive_mutex>(prev_sp->m_mutex);
#if defined (DEBUG_STACK_FRAMES)
StreamFile s(stdout, false);

View File

@ -68,45 +68,47 @@ Target::GetStaticBroadcasterClass ()
return class_name;
}
Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp, bool is_dummy_target) :
TargetProperties (this),
Broadcaster (debugger.GetBroadcasterManager(), Target::GetStaticBroadcasterClass().AsCString()),
ExecutionContextScope (),
m_debugger (debugger),
m_platform_sp (platform_sp),
m_mutex (Mutex::eMutexTypeRecursive),
m_arch (target_arch),
m_images (this),
m_section_load_history (),
m_breakpoint_list (false),
m_internal_breakpoint_list (true),
m_watchpoint_list (),
m_process_sp (),
m_search_filter_sp (),
m_image_search_paths (ImageSearchPathsChanged, this),
m_ast_importer_sp (),
m_source_manager_ap(),
m_stop_hooks (),
m_stop_hook_next_id (0),
m_valid (true),
m_suppress_stop_hooks (false),
m_is_dummy_target(is_dummy_target)
Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp,
bool is_dummy_target)
: TargetProperties(this),
Broadcaster(debugger.GetBroadcasterManager(), Target::GetStaticBroadcasterClass().AsCString()),
ExecutionContextScope(),
m_debugger(debugger),
m_platform_sp(platform_sp),
m_mutex(),
m_arch(target_arch),
m_images(this),
m_section_load_history(),
m_breakpoint_list(false),
m_internal_breakpoint_list(true),
m_watchpoint_list(),
m_process_sp(),
m_search_filter_sp(),
m_image_search_paths(ImageSearchPathsChanged, this),
m_ast_importer_sp(),
m_source_manager_ap(),
m_stop_hooks(),
m_stop_hook_next_id(0),
m_valid(true),
m_suppress_stop_hooks(false),
m_is_dummy_target(is_dummy_target)
{
SetEventName (eBroadcastBitBreakpointChanged, "breakpoint-changed");
SetEventName (eBroadcastBitModulesLoaded, "modules-loaded");
SetEventName (eBroadcastBitModulesUnloaded, "modules-unloaded");
SetEventName (eBroadcastBitWatchpointChanged, "watchpoint-changed");
SetEventName (eBroadcastBitSymbolsLoaded, "symbols-loaded");
SetEventName(eBroadcastBitBreakpointChanged, "breakpoint-changed");
SetEventName(eBroadcastBitModulesLoaded, "modules-loaded");
SetEventName(eBroadcastBitModulesUnloaded, "modules-unloaded");
SetEventName(eBroadcastBitWatchpointChanged, "watchpoint-changed");
SetEventName(eBroadcastBitSymbolsLoaded, "symbols-loaded");
CheckInWithManager();
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
if (log)
log->Printf ("%p Target::Target()", static_cast<void*>(this));
log->Printf("%p Target::Target()", static_cast<void *>(this));
if (m_arch.IsValid())
{
LogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET, "Target::Target created with architecture %s (%s)", m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str());
LogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET, "Target::Target created with architecture %s (%s)",
m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str());
}
}
@ -169,8 +171,8 @@ Target::CleanupProcess ()
m_breakpoint_list.ClearAllBreakpointSites();
m_internal_breakpoint_list.ClearAllBreakpointSites();
// Disable watchpoints just on the debugger side.
Mutex::Locker locker;
this->GetWatchpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
this->GetWatchpointList().GetListMutex(lock);
DisableAllWatchpoints(false);
ClearAllWatchpointHitCounts();
ClearAllWatchpointHistoricValues();
@ -273,7 +275,7 @@ Target::SetREPL (lldb::LanguageType language, lldb::REPLSP repl_sp)
void
Target::Destroy()
{
Mutex::Locker locker (m_mutex);
std::lock_guard<std::recursive_mutex> guard(m_mutex);
m_valid = false;
DeleteCurrentProcess ();
m_platform_sp.reset();
@ -753,8 +755,8 @@ Target::CreateWatchpoint(lldb::addr_t addr, size_t size, const CompilerType *typ
// Grab the list mutex while doing operations.
const bool notify = false; // Don't notify about all the state changes we do on creating the watchpoint.
Mutex::Locker locker;
this->GetWatchpointList().GetListMutex(locker);
std::unique_lock<std::recursive_mutex> lock;
this->GetWatchpointList().GetListMutex(lock);
WatchpointSP matched_sp = m_watchpoint_list.FindByAddress(addr);
if (matched_sp)
{

View File

@ -30,14 +30,14 @@ ThreadCollection::ThreadCollection(collection threads) :
void
ThreadCollection::AddThread (const ThreadSP &thread_sp)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
m_threads.push_back (thread_sp);
}
void
ThreadCollection::InsertThread (const lldb::ThreadSP &thread_sp, uint32_t idx)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
if (idx < m_threads.size())
m_threads.insert(m_threads.begin() + idx, thread_sp);
else
@ -47,14 +47,14 @@ ThreadCollection::InsertThread (const lldb::ThreadSP &thread_sp, uint32_t idx)
uint32_t
ThreadCollection::GetSize ()
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
return m_threads.size();
}
ThreadSP
ThreadCollection::GetThreadAtIndex (uint32_t idx)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
ThreadSP thread_sp;
if (idx < m_threads.size())
thread_sp = m_threads[idx];

View File

@ -53,7 +53,8 @@ ThreadList::operator = (const ThreadList& rhs)
{
// Lock both mutexes to make sure neither side changes anyone on us
// while the assignment occurs
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
m_process = rhs.m_process;
m_stop_id = rhs.m_stop_id;
m_threads = rhs.m_threads;
@ -111,7 +112,8 @@ ThreadList::SetStopID (uint32_t stop_id)
uint32_t
ThreadList::GetSize (bool can_update)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
if (can_update)
m_process->UpdateThreadListIfNeeded();
return m_threads.size();
@ -120,7 +122,8 @@ ThreadList::GetSize (bool can_update)
ThreadSP
ThreadList::GetThreadAtIndex (uint32_t idx, bool can_update)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
if (can_update)
m_process->UpdateThreadListIfNeeded();
@ -133,7 +136,7 @@ ThreadList::GetThreadAtIndex (uint32_t idx, bool can_update)
ThreadSP
ThreadList::FindThreadByID (lldb::tid_t tid, bool can_update)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
if (can_update)
m_process->UpdateThreadListIfNeeded();
@ -155,8 +158,8 @@ ThreadList::FindThreadByID (lldb::tid_t tid, bool can_update)
ThreadSP
ThreadList::FindThreadByProtocolID (lldb::tid_t tid, bool can_update)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
if (can_update)
m_process->UpdateThreadListIfNeeded();
@ -178,8 +181,8 @@ ThreadList::FindThreadByProtocolID (lldb::tid_t tid, bool can_update)
ThreadSP
ThreadList::RemoveThreadByID (lldb::tid_t tid, bool can_update)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
if (can_update)
m_process->UpdateThreadListIfNeeded();
@ -201,8 +204,8 @@ ThreadList::RemoveThreadByID (lldb::tid_t tid, bool can_update)
ThreadSP
ThreadList::RemoveThreadByProtocolID (lldb::tid_t tid, bool can_update)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
if (can_update)
m_process->UpdateThreadListIfNeeded();
@ -227,7 +230,7 @@ ThreadList::GetThreadSPForThreadPtr (Thread *thread_ptr)
ThreadSP thread_sp;
if (thread_ptr)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
uint32_t idx = 0;
const uint32_t num_threads = m_threads.size();
@ -248,7 +251,7 @@ ThreadList::GetThreadSPForThreadPtr (Thread *thread_ptr)
ThreadSP
ThreadList::FindThreadByIndexID (uint32_t index_id, bool can_update)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
if (can_update)
m_process->UpdateThreadListIfNeeded();
@ -284,7 +287,7 @@ ThreadList::ShouldStop (Event *event_ptr)
collection threads_copy;
{
// Scope for locker
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
m_process->UpdateThreadListIfNeeded();
for (lldb::ThreadSP thread_sp : m_threads)
@ -395,7 +398,7 @@ ThreadList::ShouldStop (Event *event_ptr)
Vote
ThreadList::ShouldReportStop (Event *event_ptr)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
Vote result = eVoteNoOpinion;
m_process->UpdateThreadListIfNeeded();
@ -446,7 +449,8 @@ ThreadList::ShouldReportStop (Event *event_ptr)
void
ThreadList::SetShouldReportStop (Vote vote)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
m_process->UpdateThreadListIfNeeded();
collection::iterator pos, end = m_threads.end();
for (pos = m_threads.begin(); pos != end; ++pos)
@ -460,7 +464,7 @@ Vote
ThreadList::ShouldReportRun (Event *event_ptr)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
Vote result = eVoteNoOpinion;
m_process->UpdateThreadListIfNeeded();
@ -499,7 +503,7 @@ ThreadList::ShouldReportRun (Event *event_ptr)
void
ThreadList::Clear()
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
m_stop_id = 0;
m_threads.clear();
m_selected_tid = LLDB_INVALID_THREAD_ID;
@ -508,7 +512,7 @@ ThreadList::Clear()
void
ThreadList::Destroy()
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
const uint32_t num_threads = m_threads.size();
for (uint32_t idx = 0; idx < num_threads; ++idx)
{
@ -519,7 +523,7 @@ ThreadList::Destroy()
void
ThreadList::RefreshStateAfterStop ()
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
m_process->UpdateThreadListIfNeeded();
@ -537,7 +541,7 @@ ThreadList::DiscardThreadPlans ()
{
// You don't need to update the thread list here, because only threads
// that you currently know about have any thread plans.
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
collection::iterator pos, end = m_threads.end();
for (pos = m_threads.begin(); pos != end; ++pos)
@ -552,7 +556,7 @@ ThreadList::WillResume ()
// But we only do this for threads that are running, user suspended
// threads stay where they are.
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
m_process->UpdateThreadListIfNeeded();
collection::iterator pos, end = m_threads.end();
@ -700,7 +704,7 @@ ThreadList::WillResume ()
void
ThreadList::DidResume ()
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
collection::iterator pos, end = m_threads.end();
for (pos = m_threads.begin(); pos != end; ++pos)
{
@ -715,7 +719,7 @@ ThreadList::DidResume ()
void
ThreadList::DidStop ()
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
collection::iterator pos, end = m_threads.end();
for (pos = m_threads.begin(); pos != end; ++pos)
{
@ -736,7 +740,7 @@ ThreadList::DidStop ()
ThreadSP
ThreadList::GetSelectedThread ()
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
ThreadSP thread_sp = FindThreadByID(m_selected_tid);
if (!thread_sp.get())
{
@ -751,7 +755,7 @@ ThreadList::GetSelectedThread ()
bool
ThreadList::SetSelectedThreadByID (lldb::tid_t tid, bool notify)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
ThreadSP selected_thread_sp(FindThreadByID(tid));
if (selected_thread_sp)
{
@ -770,7 +774,7 @@ ThreadList::SetSelectedThreadByID (lldb::tid_t tid, bool notify)
bool
ThreadList::SetSelectedThreadByIndexID (uint32_t index_id, bool notify)
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
ThreadSP selected_thread_sp (FindThreadByIndexID(index_id));
if (selected_thread_sp.get())
{
@ -802,7 +806,8 @@ ThreadList::Update (ThreadList &rhs)
{
// Lock both mutexes to make sure neither side changes anyone on us
// while the assignment occurs
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
m_process = rhs.m_process;
m_stop_id = rhs.m_stop_id;
m_threads.swap(rhs.m_threads);
@ -840,14 +845,14 @@ ThreadList::Update (ThreadList &rhs)
void
ThreadList::Flush ()
{
Mutex::Locker locker(GetMutex());
std::lock_guard<std::recursive_mutex> guard(GetMutex());
collection::iterator pos, end = m_threads.end();
for (pos = m_threads.begin(); pos != end; ++pos)
(*pos)->Flush ();
}
Mutex &
ThreadList::GetMutex ()
std::recursive_mutex &
ThreadList::GetMutex()
{
return m_process->m_thread_mutex;
}