@@ -494,6 +494,49 @@ void ThreadList::DiscardThreadPlans() {
494494 (*pos)->DiscardThreadPlans (true );
495495}
496496
497+ void ThreadList::SetUpStepOverBreakpointBeforeResumeIfNeeded (
498+ ThreadSP thread_to_run, RunDirection &direction) {
499+ // If the process doesn't need the client to disable breakpoints before
500+ // issuing a resume operation, we can skip the step-over breakpoint plan
501+ // setup.
502+ if (!m_process.SupportsResumeWithoutDisablingBreakpoints ())
503+ return ;
504+
505+ // Give all the threads that are likely to run a chance to set up their
506+ // step over breakpoint behavior.
507+ if (thread_to_run != nullptr ) {
508+ if (thread_to_run->SetupToStepOverBreakpointIfNeeded (direction)) {
509+ // We only need to step over breakpoints when running forward, and the
510+ // step-over-breakpoint plan itself wants to run forward, so this
511+ // keeps our desired direction.
512+ assert (thread_to_run->GetCurrentPlan ()->GetDirection () == direction);
513+ }
514+ } else {
515+ collection::iterator end = m_threads.end ();
516+ for (auto pos = m_threads.begin (); pos != end; ++pos) {
517+ ThreadSP thread_sp (*pos);
518+ if (thread_sp->GetResumeState () != eStateSuspended) {
519+ if (thread_sp->IsOperatingSystemPluginThread () &&
520+ !thread_sp->GetBackingThread ())
521+ continue ;
522+ if (thread_sp->SetupToStepOverBreakpointIfNeeded (direction)) {
523+ // We only need to step over breakpoints when running forward, and the
524+ // step-over-breakpoint plan itself wants to run forward, so this
525+ // keeps our desired direction.
526+ assert (thread_sp->GetCurrentPlan ()->GetDirection () == direction);
527+ // You can't say "stop others" and also want yourself to be suspended.
528+ assert (thread_sp->GetCurrentPlan ()->RunState () != eStateSuspended);
529+ thread_to_run = thread_sp;
530+ if (thread_sp->ShouldRunBeforePublicStop ()) {
531+ // This takes precedence, so if we find one of these, service it:
532+ break ;
533+ }
534+ }
535+ }
536+ }
537+ }
538+ }
539+
497540bool ThreadList::WillResume (RunDirection &direction) {
498541 // Run through the threads and perform their momentary actions. But we only
499542 // do this for threads that are running, user suspended threads stay where
@@ -558,46 +601,7 @@ bool ThreadList::WillResume(RunDirection &direction) {
558601 direction = m_process.GetBaseDirection ();
559602 }
560603
561- // Give all the threads that are likely to run a last chance to set up their
562- // state before we negotiate who is actually going to get a chance to run...
563- // Don't set to resume suspended threads, and if any thread wanted to stop
564- // others, only call setup on the threads that request StopOthers...
565- if (thread_to_run != nullptr ) {
566- // See if any thread wants to run stopping others. If it does, then we
567- // won't setup the other threads for resume, since they aren't going to get
568- // a chance to run. This is necessary because the SetupForResume might add
569- // "StopOthers" plans which would then get to be part of the who-gets-to-run
570- // negotiation, but they're coming in after the fact, and the threads that
571- // are already set up should take priority.
572- if (thread_to_run->SetupToStepOverBreakpointIfNeeded (direction)) {
573- // We only need to step over breakpoints when running forward, and the
574- // step-over-breakpoint plan itself wants to run forward, so this
575- // keeps our desired direction.
576- assert (thread_to_run->GetCurrentPlan ()->GetDirection () == direction);
577- }
578- } else {
579- for (pos = m_threads.begin (); pos != end; ++pos) {
580- ThreadSP thread_sp (*pos);
581- if (thread_sp->GetResumeState () != eStateSuspended) {
582- if (thread_sp->IsOperatingSystemPluginThread () &&
583- !thread_sp->GetBackingThread ())
584- continue ;
585- if (thread_sp->SetupToStepOverBreakpointIfNeeded (direction)) {
586- // We only need to step over breakpoints when running forward, and the
587- // step-over-breakpoint plan itself wants to run forward, so this
588- // keeps our desired direction.
589- assert (thread_sp->GetCurrentPlan ()->GetDirection () == direction);
590- // You can't say "stop others" and also want yourself to be suspended.
591- assert (thread_sp->GetCurrentPlan ()->RunState () != eStateSuspended);
592- thread_to_run = thread_sp;
593- if (thread_sp->ShouldRunBeforePublicStop ()) {
594- // This takes precedence, so if we find one of these, service it:
595- break ;
596- }
597- }
598- }
599- }
600- }
604+ SetUpStepOverBreakpointBeforeResumeIfNeeded (thread_to_run, direction);
601605
602606 if (thread_to_run != nullptr ) {
603607 Log *log = GetLog (LLDBLog::Step);
0 commit comments