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