Skip to content

Commit 481bb62

Browse files
committed
[lldb] Assert immediately prior to calling PopPlan
This is part of ongoing attempts to catch the test from 2684281 failing on Arm and AArch64. I did get logs for the failure but only on Arm, where the backtrace is truncated. So, let's do the assert that PopPlan was going to do, before we call it. Then I should know exactly which PopPlan is asserting. Technically I should take a mutex here, but technically I shouldn't be debugging via buildbot, so I'm going to take the risk temporarily.
1 parent 3d422a9 commit 481bb62

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lldb/source/Target/Thread.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,16 @@ void Thread::DidResume() {
717717

718718
void Thread::DidStop() { SetState(eStateStopped); }
719719

720+
#define CHECK_BEFORE_POP_PLAN \
721+
{ \
722+
uint32_t i = 0; \
723+
ThreadPlanSP p; \
724+
while ((p = GetPlans().GetPlanByIndex(i, false))) \
725+
i++; \
726+
(void)i;
727+
assert(i != 1 && "Cannot pop plan when there is only one plan (the base plan)");
728+
}
729+
720730
bool Thread::ShouldStop(Event *event_ptr) {
721731
ThreadPlan *current_plan = GetCurrentPlan();
722732

@@ -831,7 +841,7 @@ bool Thread::ShouldStop(Event *event_ptr) {
831841
do {
832842
if (should_stop)
833843
current_plan->WillStop();
834-
assert(!current_plan->IsBasePlan() && "Cannot pop base plan!");
844+
CHECK_BEFORE_POP_PLAN;
835845
PopPlan();
836846
} while ((current_plan = GetCurrentPlan()) != prev_plan_ptr);
837847
// Now, if the responsible plan was not "Okay to discard" then
@@ -884,6 +894,7 @@ bool Thread::ShouldStop(Event *event_ptr) {
884894
// If a Controlling Plan wants to stop, we let it. Otherwise, see if
885895
// the plan's parent wants to stop.
886896

897+
CHECK_BEFORE_POP_PLAN;
887898
PopPlan();
888899
if (should_stop && current_plan->IsControllingPlan() &&
889900
!current_plan->OkayToDiscard()) {
@@ -932,6 +943,7 @@ bool Thread::ShouldStop(Event *event_ptr) {
932943
// plan is complete but does not explain the stop (example: step to a
933944
// line with breakpoint), let us move the plan to
934945
// completed_plan_stack anyway
946+
CHECK_BEFORE_POP_PLAN;
935947
PopPlan();
936948
} else
937949
DiscardPlan();

0 commit comments

Comments
 (0)