Skip to content

Commit 68b8c34

Browse files
committed
[lldb] Replace stop_others_thread_sp with thread_to_run
We don't need `stop_others_thread_sp` to be a separate variable anymore, we can just use `thread_to_run` from the start.
1 parent 123c346 commit 68b8c34

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

lldb/source/Target/ThreadList.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,7 @@ bool ThreadList::WillResume() {
531531
// There are two special kinds of thread that have priority for "StopOthers":
532532
// a "ShouldRunBeforePublicStop thread, or the currently selected thread. If
533533
// we find one satisfying that critereon, put it here.
534-
ThreadSP stop_others_thread_sp;
535-
534+
ThreadSP thread_to_run;
536535
for (pos = m_threads.begin(); pos != end; ++pos) {
537536
ThreadSP thread_sp(*pos);
538537
if (thread_sp->GetResumeState() != eStateSuspended &&
@@ -546,21 +545,18 @@ bool ThreadList::WillResume() {
546545
run_me_only_list.AddThread(thread_sp);
547546

548547
if (thread_sp == GetSelectedThread())
549-
stop_others_thread_sp = thread_sp;
548+
thread_to_run = thread_sp;
550549

551550
if (thread_sp->ShouldRunBeforePublicStop()) {
552551
// This takes precedence, so if we find one of these, service it:
553-
stop_others_thread_sp = thread_sp;
552+
thread_to_run = thread_sp;
554553
break;
555554
}
556555
}
557556
}
558557

559-
ThreadSP thread_to_run;
560-
if (run_me_only_list.GetSize(false) > 0) {
561-
if (stop_others_thread_sp) {
562-
thread_to_run = stop_others_thread_sp;
563-
} else if (run_me_only_list.GetSize(false) == 1) {
558+
if (run_me_only_list.GetSize(false) > 0 && !thread_to_run) {
559+
if (run_me_only_list.GetSize(false) == 1) {
564560
thread_to_run = run_me_only_list.GetThreadAtIndex(0);
565561
} else {
566562
int random_thread =
@@ -593,15 +589,12 @@ bool ThreadList::WillResume() {
593589
assert(thread_sp->GetCurrentPlan()->RunState() != eStateSuspended);
594590
run_me_only_list.AddThread(thread_sp);
595591

596-
if (!(stop_others_thread_sp && stop_others_thread_sp->ShouldRunBeforePublicStop())) {
597-
if (thread_sp == GetSelectedThread()) {
598-
stop_others_thread_sp = thread_sp;
592+
if (!(thread_to_run && thread_to_run->ShouldRunBeforePublicStop())) {
593+
if (thread_sp == GetSelectedThread())
599594
thread_to_run = thread_sp;
600-
}
601595

602596
if (thread_sp->ShouldRunBeforePublicStop()) {
603597
// This takes precedence, so if we find one of these, service it:
604-
stop_others_thread_sp = thread_sp;
605598
thread_to_run = thread_sp;
606599
break;
607600
}

0 commit comments

Comments
 (0)