[Lldb-commits] [lldb] 606c3be - [lldb] Minor cleanups to ThreadPlan.h (NFC)

Dave Lee via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 10 13:36:46 PST 2021


Author: Dave Lee
Date: 2021-02-10T13:36:38-08:00
New Revision: 606c3be85d9252c0b9964bf4c799a947e3d16a8f

URL: https://github.com/llvm/llvm-project/commit/606c3be85d9252c0b9964bf4c799a947e3d16a8f
DIFF: https://github.com/llvm/llvm-project/commit/606c3be85d9252c0b9964bf4c799a947e3d16a8f.diff

LOG: [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

Added: 
    

Modified: 
    lldb/include/lldb/Target/ThreadPlan.h
    lldb/source/Target/ThreadPlan.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Target/ThreadPlan.h b/lldb/include/lldb/Target/ThreadPlan.h
index 242a4d3c2d6c..17bbfc988f56 100644
--- a/lldb/include/lldb/Target/ThreadPlan.h
+++ b/lldb/include/lldb/Target/ThreadPlan.h
@@ -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 @@ class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>,
     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 @@ class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>,
 
   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 @@ class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>,
 
   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 @@ class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>,
 
   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 @@ class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>,
     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 @@ class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>,
 
   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 @@ class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>,
     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 @@ class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>,
   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();
 

diff  --git a/lldb/source/Target/ThreadPlan.cpp b/lldb/source/Target/ThreadPlan.cpp
index c7a00e2450c8..df59da157319 100644
--- a/lldb/source/Target/ThreadPlan.cpp
+++ b/lldb/source/Target/ThreadPlan.cpp
@@ -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;


        


More information about the lldb-commits mailing list