SBThread also had some places where it got the ExecutionContext w/o

taking the API lock.

llvm-svn: 272407
This commit is contained in:
Jim Ingham 2016-06-10 17:22:26 +00:00
parent 9a0542a792
commit b2e7d28ed6
1 changed files with 27 additions and 9 deletions

View File

@ -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);