@@ -609,15 +609,10 @@ std::string Thread::GetStopDescriptionRaw() {
609609}
610610
611611void Thread::WillStop () {
612- ThreadPlan *current_plan = GetCurrentPlan ();
613-
614612 // FIXME: I may decide to disallow threads with no plans. In which
615613 // case this should go to an assert.
616-
617- if (!current_plan)
618- return ;
619-
620- current_plan->WillStop ();
614+ if (ThreadPlanSP current_plan = GetCurrentPlan ())
615+ current_plan->WillStop ();
621616}
622617
623618bool Thread::SetupToStepOverBreakpointIfNeeded (RunDirection direction) {
@@ -652,12 +647,12 @@ bool Thread::SetupToStepOverBreakpointIfNeeded(RunDirection direction) {
652647 // Note, don't assume there's a ThreadPlanStepOverBreakpoint, the
653648 // target may not require anything special to step over a breakpoint.
654649
655- ThreadPlan *cur_plan = GetCurrentPlan ();
650+ ThreadPlanSP cur_plan_sp = GetCurrentPlan ();
656651
657652 bool push_step_over_bp_plan = false ;
658- if (cur_plan ->GetKind () == ThreadPlan::eKindStepOverBreakpoint) {
653+ if (cur_plan_sp ->GetKind () == ThreadPlan::eKindStepOverBreakpoint) {
659654 ThreadPlanStepOverBreakpoint *bp_plan =
660- (ThreadPlanStepOverBreakpoint *)cur_plan ;
655+ (ThreadPlanStepOverBreakpoint *)cur_plan_sp. get () ;
661656 if (bp_plan->GetBreakpointLoadAddress () != thread_pc)
662657 push_step_over_bp_plan = true ;
663658 } else
@@ -720,12 +715,12 @@ bool Thread::ShouldResume(StateType resume_state) {
720715 // runs.
721716
722717 bool need_to_resume = false ;
723- ThreadPlan *plan_ptr = GetCurrentPlan ();
724- if (plan_ptr ) {
725- need_to_resume = plan_ptr ->WillResume (resume_state, true );
718+ ThreadPlanSP plan_sp = GetCurrentPlan ();
719+ if (plan_sp ) {
720+ need_to_resume = plan_sp ->WillResume (resume_state, true );
726721
727- while ((plan_ptr = GetPreviousPlan (plan_ptr)) != nullptr ) {
728- plan_ptr ->WillResume (resume_state, false );
722+ while ((plan_sp = GetPreviousPlan (plan_sp. get ())) ) {
723+ plan_sp ->WillResume (resume_state, false );
729724 }
730725
731726 // If the WillResume for the plan says we are faking a resume, then it will
@@ -755,7 +750,7 @@ void Thread::DidResume() {
755750void Thread::DidStop () { SetState (eStateStopped); }
756751
757752bool Thread::ShouldStop (Event *event_ptr) {
758- ThreadPlan * current_plan = GetCurrentPlan ();
753+ ThreadPlanSP current_plan = GetCurrentPlan ();
759754
760755 bool should_stop = true ;
761756
@@ -854,34 +849,34 @@ bool Thread::ShouldStop(Event *event_ptr) {
854849
855850 // If the current plan doesn't explain the stop, then find one that does
856851 // and let it handle the situation.
857- ThreadPlan *plan_ptr = current_plan;
858- while ((plan_ptr = GetPreviousPlan (plan_ptr )) != nullptr ) {
859- if (plan_ptr ->PlanExplainsStop (event_ptr)) {
860- LLDB_LOGF (log, " Plan %s explains stop." , plan_ptr ->GetName ());
852+ ThreadPlanSP plan_sp = current_plan;
853+ while ((plan_sp = GetPreviousPlan (plan_sp. get () )) != nullptr ) {
854+ if (plan_sp ->PlanExplainsStop (event_ptr)) {
855+ LLDB_LOGF (log, " Plan %s explains stop." , plan_sp ->GetName ());
861856
862- should_stop = plan_ptr ->ShouldStop (event_ptr);
857+ should_stop = plan_sp ->ShouldStop (event_ptr);
863858
864859 // plan_ptr explains the stop, next check whether plan_ptr is done,
865860 // if so, then we should take it and all the plans below it off the
866861 // stack.
867862
868- if (plan_ptr ->MischiefManaged ()) {
863+ if (plan_sp ->MischiefManaged ()) {
869864 // We're going to pop the plans up to and including the plan that
870865 // explains the stop.
871- ThreadPlan *prev_plan_ptr = GetPreviousPlan (plan_ptr );
866+ ThreadPlanSP prev_plan_sp = GetPreviousPlan (plan_sp. get () );
872867
873868 do {
874869 if (should_stop)
875870 current_plan->WillStop ();
876871 PopPlan ();
877- } while ((current_plan = GetCurrentPlan ()) != prev_plan_ptr );
872+ } while ((current_plan = GetCurrentPlan ()) != prev_plan_sp );
878873 // Now, if the responsible plan was not "Okay to discard" then
879874 // we're done, otherwise we forward this to the next plan in the
880875 // stack below.
881876 done_processing_current_plan =
882- (plan_ptr ->IsControllingPlan () && !plan_ptr ->OkayToDiscard ());
877+ (plan_sp ->IsControllingPlan () && !plan_sp ->OkayToDiscard ());
883878 } else {
884- bool should_force_run = plan_ptr ->ShouldRunBeforePublicStop ();
879+ bool should_force_run = plan_sp ->ShouldRunBeforePublicStop ();
885880 if (should_force_run) {
886881 SetShouldRunBeforePublicStop (true );
887882 should_stop = false ;
@@ -952,14 +947,14 @@ bool Thread::ShouldStop(Event *event_ptr) {
952947 // original plan on the stack, This code clears stale plans off the stack.
953948
954949 if (should_stop) {
955- ThreadPlan *plan_ptr = GetCurrentPlan ();
950+ ThreadPlanSP plan_sp = GetCurrentPlan ();
956951
957952 // Discard the stale plans and all plans below them in the stack, plus move
958953 // the completed plans to the completed plan stack
959- while (!plan_ptr ->IsBasePlan ()) {
960- bool stale = plan_ptr ->IsPlanStale ();
961- ThreadPlan * examined_plan = plan_ptr ;
962- plan_ptr = GetPreviousPlan (examined_plan);
954+ while (!plan_sp ->IsBasePlan ()) {
955+ bool stale = plan_sp ->IsPlanStale ();
956+ ThreadPlanSP examined_plan = plan_sp ;
957+ plan_sp = GetPreviousPlan (examined_plan. get () );
963958
964959 if (stale) {
965960 LLDB_LOGF (
@@ -1034,16 +1029,16 @@ Vote Thread::ShouldReportStop(Event *event_ptr) {
10341029 return GetPlans ().GetCompletedPlan (false )->ShouldReportStop (event_ptr);
10351030 } else {
10361031 Vote thread_vote = eVoteNoOpinion;
1037- ThreadPlan *plan_ptr = GetCurrentPlan ();
1032+ ThreadPlanSP plan_sp = GetCurrentPlan ();
10381033 while (true ) {
1039- if (plan_ptr ->PlanExplainsStop (event_ptr)) {
1040- thread_vote = plan_ptr ->ShouldReportStop (event_ptr);
1034+ if (plan_sp ->PlanExplainsStop (event_ptr)) {
1035+ thread_vote = plan_sp ->ShouldReportStop (event_ptr);
10411036 break ;
10421037 }
1043- if (plan_ptr ->IsBasePlan ())
1038+ if (plan_sp ->IsBasePlan ())
10441039 break ;
10451040 else
1046- plan_ptr = GetPreviousPlan (plan_ptr );
1041+ plan_sp = GetPreviousPlan (plan_sp. get () );
10471042 }
10481043 LLDB_LOGF (log,
10491044 " Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
@@ -1154,8 +1149,8 @@ void Thread::AutoCompleteThreadPlans(CompletionRequest &request) const {
11541149 }
11551150}
11561151
1157- ThreadPlan * Thread::GetCurrentPlan () const {
1158- return GetPlans ().GetCurrentPlan (). get () ;
1152+ ThreadPlanSP Thread::GetCurrentPlan () const {
1153+ return GetPlans ().GetCurrentPlan ();
11591154}
11601155
11611156ThreadPlanSP Thread::GetCompletedPlan () const {
@@ -1182,7 +1177,7 @@ bool Thread::CompletedPlanOverridesBreakpoint() const {
11821177 return GetPlans ().AnyCompletedPlans ();
11831178}
11841179
1185- ThreadPlan * Thread::GetPreviousPlan (ThreadPlan *current_plan) const {
1180+ lldb::ThreadPlanSP Thread::GetPreviousPlan (ThreadPlan *current_plan) const {
11861181 return GetPlans ().GetPreviousPlan (current_plan);
11871182}
11881183
0 commit comments