Skip to content

Commit 11c95a4

Browse files
committed
[lldb] Call ClearThreadCache after changing ThreadPlan TID (#4997)
`ThreadPlan`s have a TID field, but also have a `Thread` field where the thread for the TID is "cached". When assigning or clearing the TID, the `m_thread` field needs to be cleared. This can cause issues in particular with async code, where thread plans move from one thread to another. (cherry-picked from commit 50cf9ae)
1 parent 55dc811 commit 11c95a4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lldb/include/lldb/Target/ThreadPlan.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,19 @@ class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>,
485485

486486
bool IsTID(lldb::tid_t tid) { return tid == m_tid; }
487487
bool HasTID() { return m_tid != LLDB_INVALID_THREAD_ID; }
488-
void ClearTID() { m_tid = LLDB_INVALID_THREAD_ID; }
489488
lldb::tid_t GetTID() { return m_tid; }
490-
void SetTID(lldb::tid_t tid) { m_tid = tid; }
489+
490+
void SetTID(lldb::tid_t tid) {
491+
if (m_tid != tid) {
492+
m_tid = tid;
493+
ClearThreadCache();
494+
}
495+
}
496+
497+
void ClearTID() {
498+
m_tid = LLDB_INVALID_THREAD_ID;
499+
ClearThreadCache();
500+
}
491501

492502
friend lldb::ThreadPlanSP
493503
Process::DoesStackExplainStopNoLock(ThreadPlanStack &stack, Thread &thread,

0 commit comments

Comments
 (0)