summaryrefslogtreecommitdiffstats
path: root/lldb/source/API/SBThread.cpp
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2016-06-10 17:22:26 +0000
committerJim Ingham <jingham@apple.com>2016-06-10 17:22:26 +0000
commitb2e7d28ed6f1ba234a0fdd0db93a52009053b93f (patch)
treecf80c475d9f4e8fec49954ab6461a1ac51468ac2 /lldb/source/API/SBThread.cpp
parent9a0542a792930c11a26bc9fa7e0eaa70dfd32d16 (diff)
downloadbcm5719-llvm-b2e7d28ed6f1ba234a0fdd0db93a52009053b93f.tar.gz
bcm5719-llvm-b2e7d28ed6f1ba234a0fdd0db93a52009053b93f.zip
SBThread also had some places where it got the ExecutionContext w/o
taking the API lock. llvm-svn: 272407
Diffstat (limited to 'lldb/source/API/SBThread.cpp')
-rw-r--r--lldb/source/API/SBThread.cpp36
1 files changed, 27 insertions, 9 deletions
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index 0685c17a5a2..2b36e4dfae9 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -325,7 +325,9 @@ SBThread::GetStopReasonExtendedInfoAsJSON (lldb::SBStream &stream)
{
Stream &strm = stream.ref();
- ExecutionContext exe_ctx (m_opaque_sp.get());
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
if (! exe_ctx.HasThreadScope())
return false;
@@ -350,7 +352,9 @@ SBThread::GetStopReasonExtendedBacktraces (InstrumentationRuntimeType type)
if (type != eInstrumentationRuntimeTypeThreadSanitizer)
return threads;
- ExecutionContext exe_ctx (m_opaque_sp.get());
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
if (! exe_ctx.HasThreadScope())
return threads;
@@ -1250,7 +1254,9 @@ bool
SBThread::Suspend()
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- ExecutionContext exe_ctx (m_opaque_sp.get());
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
bool result = false;
if (exe_ctx.HasThreadScope())
{
@@ -1277,7 +1283,9 @@ bool
SBThread::Resume ()
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
- ExecutionContext exe_ctx (m_opaque_sp.get());
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
bool result = false;
if (exe_ctx.HasThreadScope())
{
@@ -1304,7 +1312,9 @@ SBThread::Resume ()
bool
SBThread::IsSuspended()
{
- ExecutionContext exe_ctx (m_opaque_sp.get());
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
if (exe_ctx.HasThreadScope())
return exe_ctx.GetThreadPtr()->GetResumeState () == eStateSuspended;
return false;
@@ -1313,7 +1323,9 @@ SBThread::IsSuspended()
bool
SBThread::IsStopped()
{
- ExecutionContext exe_ctx (m_opaque_sp.get());
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
if (exe_ctx.HasThreadScope())
return StateIsStoppedState(exe_ctx.GetThreadPtr()->GetState(), true);
return false;
@@ -1323,7 +1335,9 @@ SBProcess
SBThread::GetProcess ()
{
SBProcess sb_process;
- ExecutionContext exe_ctx (m_opaque_sp.get());
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
if (exe_ctx.HasThreadScope())
{
// Have to go up to the target so we can get a shared pointer to our process...
@@ -1532,7 +1546,9 @@ SBThread::GetStatus (SBStream &status) const
{
Stream &strm = status.ref();
- ExecutionContext exe_ctx (m_opaque_sp.get());
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
if (exe_ctx.HasThreadScope())
{
exe_ctx.GetThreadPtr()->GetStatus(strm, 0, 1, 1);
@@ -1548,7 +1564,9 @@ SBThread::GetDescription (SBStream &description) const
{
Stream &strm = description.ref();
- ExecutionContext exe_ctx (m_opaque_sp.get());
+ std::unique_lock<std::recursive_mutex> lock;
+ ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
if (exe_ctx.HasThreadScope())
{
exe_ctx.GetThreadPtr()->DumpUsingSettingsFormat(strm, LLDB_INVALID_THREAD_ID);
OpenPOWER on IntegriCloud