1 //===-- ThreadPlanStepInRange.h ---------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_TARGET_THREADPLANSTEPINRANGE_H
10 #define LLDB_TARGET_THREADPLANSTEPINRANGE_H
11 
12 #include "lldb/Core/AddressRange.h"
13 #include "lldb/Target/StackID.h"
14 #include "lldb/Target/Thread.h"
15 #include "lldb/Target/ThreadPlanShouldStopHere.h"
16 #include "lldb/Target/ThreadPlanStepRange.h"
17 
18 namespace lldb_private {
19 
20 class ThreadPlanStepInRange : public ThreadPlanStepRange,
21                               public ThreadPlanShouldStopHere {
22 public:
23   ThreadPlanStepInRange(Thread &thread, const AddressRange &range,
24                         const SymbolContext &addr_context,
25                         lldb::RunMode stop_others,
26                         LazyBool step_in_avoids_code_without_debug_info,
27                         LazyBool step_out_avoids_code_without_debug_info);
28 
29   ~ThreadPlanStepInRange() override;
30 
31   void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
32 
33   bool ShouldStop(Event *event_ptr) override;
34 
35   void SetAvoidRegexp(const char *name);
36 
37   void SetStepInTarget(const char *target) {
38     m_step_into_target.SetCString(target);
39   }
40 
41   static void SetDefaultFlagValue(uint32_t new_value);
42 
43   bool IsVirtualStep() override;
44 
45   // Plans that are implementing parts of a step in might need to follow the
46   // behavior of this plan w.r.t. StepThrough.  They can get that from here.
47   static uint32_t GetDefaultFlagsValue() {
48     return s_default_flag_values;
49   }
50 
51 protected:
52   static bool DefaultShouldStopHereCallback(ThreadPlan *current_plan,
53                                             Flags &flags,
54                                             lldb::FrameComparison operation,
55                                             Status &status, void *baton);
56 
57   bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
58 
59   bool DoPlanExplainsStop(Event *event_ptr) override;
60 
61   void SetFlagsToDefault() override {
62     GetFlags().Set(ThreadPlanStepInRange::s_default_flag_values);
63   }
64 
65   void SetCallbacks() {
66     ThreadPlanShouldStopHere::ThreadPlanShouldStopHereCallbacks callbacks(
67         ThreadPlanStepInRange::DefaultShouldStopHereCallback, nullptr);
68     SetShouldStopHereCallbacks(&callbacks, nullptr);
69   }
70 
71   bool FrameMatchesAvoidCriteria();
72 
73 private:
74   void SetupAvoidNoDebug(LazyBool step_in_avoids_code_without_debug_info,
75                          LazyBool step_out_avoids_code_without_debug_info);
76   // Need an appropriate marker for the current stack so we can tell step out
77   // from step in.
78 
79   static uint32_t s_default_flag_values; // These are the default flag values
80                                          // for the ThreadPlanStepThrough.
81   lldb::ThreadPlanSP m_sub_plan_sp;      // Keep track of the last plan we were
82                                     // running.  If it fails, we should stop.
83   std::unique_ptr<RegularExpression> m_avoid_regexp_up;
84   bool m_step_past_prologue; // FIXME: For now hard-coded to true, we could put
85                              // a switch in for this if there's
86                              // demand for that.
87   bool m_virtual_step; // true if we've just done a "virtual step", i.e. just
88                        // moved the inline stack depth.
89   ConstString m_step_into_target;
90   ThreadPlanStepInRange(const ThreadPlanStepInRange &) = delete;
91   const ThreadPlanStepInRange &
92   operator=(const ThreadPlanStepInRange &) = delete;
93 };
94 
95 } // namespace lldb_private
96 
97 #endif // LLDB_TARGET_THREADPLANSTEPINRANGE_H
98