[lldb] Refine ThreadPlan::ShouldAutoContinue
authorDave Lee <davelee.com@gmail.com>
Fri, 19 Feb 2021 19:26:28 +0000 (11:26 -0800)
committerDave Lee <davelee.com@gmail.com>
Sun, 21 Feb 2021 01:25:31 +0000 (17:25 -0800)
commitb0186c25c62e79869d37b81ad819c67a3e97b0cd
tree344772099aa416676a03b6a95b81781236ae3af2
parentfa211f3ce9a9c83b72a524799e4e060e79e92da4
[lldb] Refine ThreadPlan::ShouldAutoContinue

Adjust `ShouldAutoContinue` to be available to any thread plan previous to the plan that
explains a stop, not limited to the parent to the plan that explains the stop.

Before this change, `Thread::ShouldStop` did the following:

1. find the plan that explains the stop
2. if it's not a master plan, continue processing previous (aka parent) plans
3. first, call `ShouldAutoContinue` on the immediate parent of the explaining plan
4. then loop over previous plans, calling `ShouldStop` and `MischiefManaged`

Of note, the iteration in step 4 does not call `ShouldAutoContinue`, so again only the
plan just prior to the explaining plan is given the opportunity to override whether to
continue or stop.

This commit changes the loop call `ShouldAutoContinue`, giving each plan the opportunity
to override `ShouldStop` of previous plans.

Why? This allows a plan to do the following:

1. mark itself done and be popped off the stack
2. allow parent plans to finish their work, and to also be popped off the stack
3. and finally, have the thread continue, not stop

This is useful for stepping into async functions. A plan will would step far enough
enough to set a breakpoint on the async target, and then use `ShouldAutoContinue` to
unwind the necessary stepping, and then have the calling thread continue.

Differential Revision: https://reviews.llvm.org/D97076
lldb/include/lldb/Target/ThreadPlan.h
lldb/source/Target/Thread.cpp