Skip to content

Commit 070a256

Browse files
committed
[lldb] Move SetupForResume() calls to happen after the first pass populating run_me_only_list
Eventually we will need to determine the execution direction after populating `run_me_only_list` and before calling `SetupForResume()`.
1 parent 0fe7e98 commit 070a256

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

lldb/source/Target/ThreadList.cpp

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -541,22 +541,6 @@ bool ThreadList::WillResume() {
541541
}
542542
}
543543

544-
// Give all the threads that are likely to run a last chance to set up their
545-
// state before we negotiate who is actually going to get a chance to run...
546-
// Don't set to resume suspended threads, and if any thread wanted to stop
547-
// others, only call setup on the threads that request StopOthers...
548-
549-
for (pos = m_threads.begin(); pos != end; ++pos) {
550-
ThreadSP thread_sp(*pos);
551-
if (thread_sp->GetResumeState() != eStateSuspended &&
552-
(!wants_solo_run || (*pos)->GetCurrentPlan()->StopOthers())) {
553-
if (thread_sp->IsOperatingSystemPluginThread() &&
554-
!thread_sp->GetBackingThread())
555-
continue;
556-
thread_sp->SetupForResume();
557-
}
558-
}
559-
560544
// Now go through the threads and see if any thread wants to run just itself.
561545
// if so then pick one and run it.
562546

@@ -595,6 +579,36 @@ bool ThreadList::WillResume() {
595579
}
596580
}
597581

582+
// Give all the threads that are likely to run a last chance to set up their
583+
// state before we negotiate who is actually going to get a chance to run...
584+
// Don't set to resume suspended threads, and if any thread wanted to stop
585+
// others, only call setup on the threads that request StopOthers...
586+
for (pos = m_threads.begin(); pos != end; ++pos) {
587+
ThreadSP thread_sp(*pos);
588+
if (thread_sp->GetResumeState() != eStateSuspended &&
589+
(!wants_solo_run || (*pos)->GetCurrentPlan()->StopOthers())) {
590+
if (thread_sp->IsOperatingSystemPluginThread() &&
591+
!thread_sp->GetBackingThread())
592+
continue;
593+
if (thread_sp->SetupForResume()) {
594+
// You can't say "stop others" and also want yourself to be suspended.
595+
assert(thread_sp->GetCurrentPlan()->RunState() != eStateSuspended);
596+
run_me_only_list.AddThread(thread_sp);
597+
598+
if (!(stop_others_thread_sp && stop_others_thread_sp->ShouldRunBeforePublicStop())) {
599+
if (thread_sp == GetSelectedThread())
600+
stop_others_thread_sp = thread_sp;
601+
602+
if (thread_sp->ShouldRunBeforePublicStop()) {
603+
// This takes precedence, so if we find one of these, service it:
604+
stop_others_thread_sp = thread_sp;
605+
break;
606+
}
607+
}
608+
}
609+
}
610+
}
611+
598612
if (run_me_only_list.GetSize(false) == 0) {
599613
Log *log = GetLog(LLDBLog::Step);
600614
if (log && log->GetVerbose())

0 commit comments

Comments
 (0)