[Lldb-commits] [lldb] 2309392 - [lldb] Inline invariant params to AppleThreadPlanStepThrough (NFC)

Dave Lee via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 9 08:04:24 PST 2021


Author: Dave Lee
Date: 2021-02-09T08:03:51-08:00
New Revision: 2309392449376295a70354273500730be0f28510

URL: https://github.com/llvm/llvm-project/commit/2309392449376295a70354273500730be0f28510
DIFF: https://github.com/llvm/llvm-project/commit/2309392449376295a70354273500730be0f28510.diff

LOG: [lldb] Inline invariant params to AppleThreadPlanStepThrough (NFC)

These two `AppleThreadPlanStepThrough` thread plans have parameterized behavior
that is unutilized. To make their interface and implementation simpler, this
change inlines those outside parameters.

Differential Revision: https://reviews.llvm.org/D96276

Added: 
    

Modified: 
    lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
    lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
    lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
index bcc1f6fd339f..f1d18f11b267 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -1157,13 +1157,8 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
         flag_value.GetScalar() = 0; // FIXME - Set to 0 when debugging is done.
       dispatch_values.PushValue(flag_value);
 
-      // The step through code might have to fill in the cache, so it
-      // is not safe to run only one thread.  So we override the
-      // stop_others value passed in to us here:
-      const bool trampoline_stop_others = false;
       ret_plan_sp = std::make_shared<AppleThreadPlanStepThroughObjCTrampoline>(
-          thread, *this, dispatch_values, isa_addr, sel_addr,
-          trampoline_stop_others);
+          thread, *this, dispatch_values, isa_addr, sel_addr);
       if (log) {
         StreamString s;
         ret_plan_sp->GetDescription(&s, eDescriptionLevelFull);
@@ -1182,13 +1177,9 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
     MsgsendMap::iterator pos;
     pos = m_opt_dispatch_map.find(curr_pc);
     if (pos != m_opt_dispatch_map.end()) {
-
       const char *opt_name = g_opt_dispatch_names[(*pos).second];
-
-      bool trampoline_stop_others = false;
-      LazyBool step_in_should_stop = eLazyBoolCalculate;
-      ret_plan_sp = std::make_shared<AppleThreadPlanStepThroughDirectDispatch> (
-          thread, *this, opt_name, trampoline_stop_others, step_in_should_stop);
+      ret_plan_sp = std::make_shared<AppleThreadPlanStepThroughDirectDispatch>(
+          thread, *this, opt_name);
     }
   }
 

diff  --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
index 653e007c7b5f..fe31cfc28c6e 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
@@ -30,15 +30,13 @@ using namespace lldb_private;
 AppleThreadPlanStepThroughObjCTrampoline::
     AppleThreadPlanStepThroughObjCTrampoline(
         Thread &thread, AppleObjCTrampolineHandler &trampoline_handler,
-        ValueList &input_values, lldb::addr_t isa_addr, lldb::addr_t sel_addr,
-        bool stop_others)
+        ValueList &input_values, lldb::addr_t isa_addr, lldb::addr_t sel_addr)
     : ThreadPlan(ThreadPlan::eKindGeneric,
                  "MacOSX Step through ObjC Trampoline", thread, eVoteNoOpinion,
                  eVoteNoOpinion),
       m_trampoline_handler(trampoline_handler),
       m_args_addr(LLDB_INVALID_ADDRESS), m_input_values(input_values),
-      m_isa_addr(isa_addr), m_sel_addr(sel_addr), m_impl_function(nullptr),
-      m_stop_others(stop_others) {}
+      m_isa_addr(isa_addr), m_sel_addr(sel_addr), m_impl_function(nullptr) {}
 
 // Destructor
 AppleThreadPlanStepThroughObjCTrampoline::
@@ -66,7 +64,7 @@ bool AppleThreadPlanStepThroughObjCTrampoline::InitializeFunctionCaller() {
     EvaluateExpressionOptions options;
     options.SetUnwindOnError(true);
     options.SetIgnoreBreakpoints(true);
-    options.SetStopOthers(m_stop_others);
+    options.SetStopOthers(false);
     GetThread().CalculateExecutionContext(exc_ctx);
     m_func_sp = m_impl_function->GetThreadPlanToCallFunction(
         exc_ctx, m_args_addr, options, diagnostics);
@@ -157,7 +155,7 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) {
       const bool first_insn = true;
       const uint32_t frame_idx = 0;
       m_run_to_sp = GetThread().QueueThreadPlanForStepOutNoShouldStop(
-          abort_other_plans, &sc, first_insn, m_stop_others, eVoteNoOpinion,
+          abort_other_plans, &sc, first_insn, false, eVoteNoOpinion,
           eVoteNoOpinion, frame_idx, status);
       if (m_run_to_sp && status.Success())
         m_run_to_sp->SetPrivate(true);
@@ -179,7 +177,7 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) {
     // Extract the target address from the value:
 
     m_run_to_sp = std::make_shared<ThreadPlanRunToAddress>(
-        GetThread(), target_so_addr, m_stop_others);
+        GetThread(), target_so_addr, false);
     PushPlan(m_run_to_sp);
     return false;
   } else if (GetThread().IsThreadPlanDone(m_run_to_sp.get())) {
@@ -222,10 +220,9 @@ bool AppleThreadPlanStepThroughObjCTrampoline::WillStop() { return true; }
 AppleThreadPlanStepThroughDirectDispatch ::
     AppleThreadPlanStepThroughDirectDispatch(
         Thread &thread, AppleObjCTrampolineHandler &handler,
-        llvm::StringRef dispatch_func_name, bool stop_others,
-        LazyBool step_in_avoids_code_without_debug_info)
-    : ThreadPlanStepOut(thread, nullptr, true /* first instruction */,
-                        stop_others, eVoteNoOpinion, eVoteNoOpinion,
+        llvm::StringRef dispatch_func_name)
+    : ThreadPlanStepOut(thread, nullptr, true /* first instruction */, false,
+                        eVoteNoOpinion, eVoteNoOpinion,
                         0 /* Step out of zeroth frame */,
                         eLazyBoolNo /* Our parent plan will decide this
                                when we are done */
@@ -234,7 +231,7 @@ AppleThreadPlanStepThroughDirectDispatch ::
                         false /* Don't gather the return value */),
       m_trampoline_handler(handler),
       m_dispatch_func_name(std::string(dispatch_func_name)),
-      m_at_msg_send(false), m_stop_others(stop_others) {
+      m_at_msg_send(false) {
   // Set breakpoints on the dispatch functions:
   auto bkpt_callback = [&] (lldb::addr_t addr, 
                             const AppleObjCTrampolineHandler
@@ -249,20 +246,7 @@ AppleThreadPlanStepThroughDirectDispatch ::
   // We'll set the step-out plan in the DidPush so it gets queued in the right
   // order.
 
-  bool avoid_nodebug = true;
-
-  switch (step_in_avoids_code_without_debug_info) {
-  case eLazyBoolYes:
-    avoid_nodebug = true;
-    break;
-  case eLazyBoolNo:
-    avoid_nodebug = false;
-    break;
-  case eLazyBoolCalculate:
-    avoid_nodebug = GetThread().GetStepInAvoidsNoDebug();
-    break;
-  }
-  if (avoid_nodebug)
+  if (GetThread().GetStepInAvoidsNoDebug())
     GetFlags().Set(ThreadPlanShouldStopHere::eStepInAvoidNoDebug);
   else
     GetFlags().Clear(ThreadPlanShouldStopHere::eStepInAvoidNoDebug);
@@ -398,8 +382,8 @@ bool AppleThreadPlanStepThroughDirectDispatch::ShouldStop(Event *event_ptr) {
     // There's no way we could have gotten here without an ObjC language 
     // runtime.
     assert(objc_runtime);
-    m_objc_step_through_sp 
-      = objc_runtime->GetStepThroughTrampolinePlan(GetThread(), m_stop_others);
+    m_objc_step_through_sp =
+        objc_runtime->GetStepThroughTrampolinePlan(GetThread(), false);
     // If we failed to find the target for this dispatch, just keep going and
     // let the step out complete.
     if (!m_objc_step_through_sp) {

diff  --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
index 89aed89f1ab1..b5b45079094c 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
@@ -24,8 +24,7 @@ class AppleThreadPlanStepThroughObjCTrampoline : public ThreadPlan {
 public:
   AppleThreadPlanStepThroughObjCTrampoline(
       Thread &thread, AppleObjCTrampolineHandler &trampoline_handler,
-      ValueList &values, lldb::addr_t isa_addr, lldb::addr_t sel_addr,
-      bool stop_others);
+      ValueList &values, lldb::addr_t isa_addr, lldb::addr_t sel_addr);
 
   ~AppleThreadPlanStepThroughObjCTrampoline() override;
 
@@ -39,7 +38,9 @@ class AppleThreadPlanStepThroughObjCTrampoline : public ThreadPlan {
 
   bool ShouldStop(Event *event_ptr) override;
 
-  bool StopOthers() override { return m_stop_others; }
+  // The step through code might have to fill in the cache, so it is not safe
+  // to run only one thread.
+  bool StopOthers() override { return false; }
 
   // The base class MischiefManaged does some cleanup - so you have to call it
   // in your MischiefManaged derived class.
@@ -69,15 +70,13 @@ class AppleThreadPlanStepThroughObjCTrampoline : public ThreadPlan {
   FunctionCaller *m_impl_function; /// This is a pointer to a impl function that
                                    /// is owned by the client that pushes this
                                    /// plan.
-  bool m_stop_others;  /// Whether we should stop other threads.
 };
 
 class AppleThreadPlanStepThroughDirectDispatch: public ThreadPlanStepOut {
 public:
-  AppleThreadPlanStepThroughDirectDispatch(
-      Thread &thread, AppleObjCTrampolineHandler &handler,
-      llvm::StringRef dispatch_func_name, bool stop_others,
-      LazyBool step_in_avoids_code_without_debug_info);
+  AppleThreadPlanStepThroughDirectDispatch(Thread &thread,
+                                           AppleObjCTrampolineHandler &handler,
+                                           llvm::StringRef dispatch_func_name);
 
   ~AppleThreadPlanStepThroughDirectDispatch() override;
 
@@ -85,7 +84,7 @@ class AppleThreadPlanStepThroughDirectDispatch: public ThreadPlanStepOut {
 
   bool ShouldStop(Event *event_ptr) override;
 
-  bool StopOthers() override { return m_stop_others; }
+  bool StopOthers() override { return false; }
 
   bool MischiefManaged() override;
 
@@ -107,7 +106,6 @@ class AppleThreadPlanStepThroughDirectDispatch: public ThreadPlanStepOut {
   std::vector<lldb::BreakpointSP> m_msgSend_bkpts; /// Breakpoints on the objc
                                                    /// dispatch functions.
   bool m_at_msg_send;  /// Are we currently handling an msg_send
-  bool m_stop_others;  /// Whether we should stop other threads.
 
 };
 


        


More information about the lldb-commits mailing list