[lldb] Minor cleanups to ThreadPlan.h (NFC)

While learning about ThreadPlan, I did a bit of cleanup:

* Remove unused code
* Move functions to protected where applicable
* Remove virtual for functions that are not overridden

Differential Revision: https://reviews.llvm.org/D96277
This commit is contained in:
Dave Lee 2021-02-07 20:16:48 -08:00
parent db0d7d0ba9
commit 606c3be85d
2 changed files with 21 additions and 36 deletions

View File

@ -281,8 +281,6 @@ namespace lldb_private {
class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>,
public UserID {
public:
enum ThreadScope { eAllThreads, eSomeThreads, eThisThread };
// We use these enums so that we can cast a base thread plan to it's real
// type without having to resort to dynamic casting.
enum ThreadPlanKind {
@ -298,15 +296,9 @@ public:
eKindStepInRange,
eKindRunToAddress,
eKindStepThrough,
eKindStepUntil,
eKindTestCondition
eKindStepUntil
};
// Constructors and Destructors
ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread,
Vote stop_vote, Vote run_vote);
virtual ~ThreadPlan();
/// Returns the name of this thread plan.
@ -375,7 +367,7 @@ public:
virtual Vote ShouldReportStop(Event *event_ptr);
virtual Vote ShouldReportRun(Event *event_ptr);
Vote ShouldReportRun(Event *event_ptr);
virtual void SetStopOthers(bool new_value);
@ -416,15 +408,6 @@ public:
virtual void WillPop();
// This pushes a plan onto the plan stack of the current plan's thread.
// Also sets the plans to private and not master plans. A plan pushed by
// another thread plan is never either of the above.
void PushPlan(lldb::ThreadPlanSP &thread_plan_sp) {
GetThread().PushPlan(thread_plan_sp);
thread_plan_sp->SetPrivate(false);
thread_plan_sp->SetIsMasterPlan(false);
}
ThreadPlanKind GetKind() const { return m_kind; }
bool IsPlanComplete();
@ -488,7 +471,7 @@ public:
virtual bool IsVirtualStep() { return false; }
virtual bool SetIterationCount(size_t count) {
bool SetIterationCount(size_t count) {
if (m_takes_iteration_count) {
// Don't tell me to do something 0 times...
if (count == 0)
@ -498,14 +481,11 @@ public:
return m_takes_iteration_count;
}
virtual size_t GetIterationCount() {
if (!m_takes_iteration_count)
return 0;
else
return m_iteration_count;
}
protected:
// Constructors and Destructors
ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread,
Vote stop_vote, Vote run_vote);
// Classes that inherit from ThreadPlan can see and modify these
virtual bool DoWillResume(lldb::StateType resume_state, bool current_plan) {
@ -514,6 +494,15 @@ protected:
virtual bool DoPlanExplainsStop(Event *event_ptr) = 0;
// This pushes a plan onto the plan stack of the current plan's thread.
// Also sets the plans to private and not master plans. A plan pushed by
// another thread plan is never either of the above.
void PushPlan(lldb::ThreadPlanSP &thread_plan_sp) {
GetThread().PushPlan(thread_plan_sp);
thread_plan_sp->SetPrivate(false);
thread_plan_sp->SetIsMasterPlan(false);
}
// This gets the previous plan to the current plan (for forwarding requests).
// This is mostly a formal requirement, it allows us to make the Thread's
// GetPreviousPlan protected, but only friend ThreadPlan to thread.
@ -531,14 +520,6 @@ protected:
GetThread().SetStopInfo(stop_reason_sp);
}
void CachePlanExplainsStop(bool does_explain) {
m_cached_plan_explains_stop = does_explain ? eLazyBoolYes : eLazyBoolNo;
}
LazyBool GetCachedPlanExplainsStop() const {
return m_cached_plan_explains_stop;
}
virtual lldb::StateType GetPlanRunState() = 0;
bool IsUsuallyUnexplainedStopReason(lldb::StopReason);
@ -553,6 +534,10 @@ protected:
int32_t m_iteration_count = 1;
private:
void CachePlanExplainsStop(bool does_explain) {
m_cached_plan_explains_stop = does_explain ? eLazyBoolYes : eLazyBoolNo;
}
// For ThreadPlan only
static lldb::user_id_t GetNextID();

View File

@ -50,7 +50,7 @@ Thread &ThreadPlan::GetThread() {
bool ThreadPlan::PlanExplainsStop(Event *event_ptr) {
if (m_cached_plan_explains_stop == eLazyBoolCalculate) {
bool actual_value = DoPlanExplainsStop(event_ptr);
m_cached_plan_explains_stop = actual_value ? eLazyBoolYes : eLazyBoolNo;
CachePlanExplainsStop(actual_value);
return actual_value;
} else {
return m_cached_plan_explains_stop == eLazyBoolYes;