mirror of
https://github.com/intel/llvm.git
synced 2026-01-23 07:58:23 +08:00
This change introduces a "ExpressionExecutionThread" to the ThreadList.
Turns out that most of the code that runs expressions (e.g. the ObjC runtime grubber) on behalf of the expression parser was using the currently selected thread. But sometimes, e.g. when we are evaluating breakpoint conditions/commands, we don't select the thread we're running on, we instead set the context for the interpreter, and explicitly pass that to other callers. That wasn't getting communicated to these utility expressions, so they would run on some other thread instead, and that could cause a variety of subtle and hard to reproduce problems. I also went through the commands and cleaned up the use of GetSelectedThread. All those uses should have been trying the thread in the m_exe_ctx belonging to the command object first. It would actually have been pretty hard to get misbehavior in these cases, but for correctness sake it is good to make this usage consistent. <rdar://problem/24978569> llvm-svn: 263326
This commit is contained in:
@@ -71,6 +71,30 @@ ThreadList::~ThreadList()
|
||||
Clear();
|
||||
}
|
||||
|
||||
lldb::ThreadSP
|
||||
ThreadList::GetExpressionExecutionThread()
|
||||
{
|
||||
if (m_expression_tid_stack.empty())
|
||||
return GetSelectedThread();
|
||||
ThreadSP expr_thread_sp = FindThreadByID(m_expression_tid_stack.back());
|
||||
if (expr_thread_sp)
|
||||
return expr_thread_sp;
|
||||
else
|
||||
return GetSelectedThread();
|
||||
}
|
||||
|
||||
void
|
||||
ThreadList::PushExpressionExecutionThread(lldb::tid_t tid)
|
||||
{
|
||||
m_expression_tid_stack.push_back(tid);
|
||||
}
|
||||
|
||||
void
|
||||
ThreadList::PopExpressionExecutionThread(lldb::tid_t tid)
|
||||
{
|
||||
assert(m_expression_tid_stack.back() == tid);
|
||||
m_expression_tid_stack.pop_back();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
ThreadList::GetStopID () const
|
||||
@@ -828,3 +852,16 @@ ThreadList::GetMutex ()
|
||||
return m_process->m_thread_mutex;
|
||||
}
|
||||
|
||||
ThreadList::ExpressionExecutionThreadPusher::ExpressionExecutionThreadPusher (lldb::ThreadSP thread_sp) :
|
||||
m_thread_list(nullptr),
|
||||
m_tid(LLDB_INVALID_THREAD_ID)
|
||||
{
|
||||
if (thread_sp)
|
||||
{
|
||||
m_tid = thread_sp->GetID();
|
||||
m_thread_list = &thread_sp->GetProcess()->GetThreadList();
|
||||
m_thread_list->PushExpressionExecutionThread(m_tid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user