1 //===-- ThreadPlanStepInRange.h ---------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef liblldb_ThreadPlanStepInRange_h_
11 #define liblldb_ThreadPlanStepInRange_h_
12 
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/Core/AddressRange.h"
18 #include "lldb/Target/StackID.h"
19 #include "lldb/Target/Thread.h"
20 #include "lldb/Target/ThreadPlanStepRange.h"
21 #include "lldb/Target/ThreadPlanShouldStopHere.h"
22 
23 namespace lldb_private {
24 
25 class ThreadPlanStepInRange :
26     public ThreadPlanStepRange,
27     public ThreadPlanShouldStopHere
28 {
29 public:
30     ThreadPlanStepInRange (Thread &thread,
31                            const AddressRange &range,
32                            const SymbolContext &addr_context,
33                            lldb::RunMode stop_others,
34                             LazyBool step_in_avoids_code_without_debug_info,
35                             LazyBool step_out_avoids_code_without_debug_info);
36 
37     ThreadPlanStepInRange (Thread &thread,
38                            const AddressRange &range,
39                            const SymbolContext &addr_context,
40                            const char *step_into_function_name,
41                            lldb::RunMode stop_others,
42                             LazyBool step_in_avoids_code_without_debug_info,
43                             LazyBool step_out_avoids_code_without_debug_info);
44 
45     virtual
46     ~ThreadPlanStepInRange ();
47 
48     virtual void
49     GetDescription (Stream *s, lldb::DescriptionLevel level);
50 
51     virtual bool
52     ShouldStop (Event *event_ptr);
53 
54     void SetAvoidRegexp(const char *name);
55 
56     void SetStepInTarget (const char *target)
57     {
58         m_step_into_target.SetCString(target);
59     }
60 
61     static void
62     SetDefaultFlagValue (uint32_t new_value);
63 
64     bool
65     IsVirtualStep();
66 
67 protected:
68     static bool
69     DefaultShouldStopHereCallback (ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, void *baton);
70 
71     virtual bool DoWillResume (lldb::StateType resume_state, bool current_plan);
72 
73     virtual bool
74     DoPlanExplainsStop (Event *event_ptr);
75 
76     virtual void
77     SetFlagsToDefault ()
78     {
79         GetFlags().Set(ThreadPlanStepInRange::s_default_flag_values);
80     }
81 
82     void
83     SetCallbacks()
84     {
85         ThreadPlanShouldStopHere::ThreadPlanShouldStopHereCallbacks callbacks(ThreadPlanStepInRange::DefaultShouldStopHereCallback, nullptr);
86         SetShouldStopHereCallbacks (&callbacks, nullptr);
87     }
88 
89     bool
90     FrameMatchesAvoidCriteria ();
91 
92 private:
93 
94     friend lldb::ThreadPlanSP
95     Thread::QueueThreadPlanForStepOverRange (bool abort_other_plans,
96                                          const AddressRange &range,
97                                          const SymbolContext &addr_context,
98                                          lldb::RunMode stop_others,
99                                          LazyBool avoid_code_without_debug_info);
100     friend lldb::ThreadPlanSP
101     Thread::QueueThreadPlanForStepInRange (bool abort_other_plans,
102                                          const AddressRange &range,
103                                          const SymbolContext &addr_context,
104                                          const char *step_in_target,
105                                          lldb::RunMode stop_others,
106                                          LazyBool step_in_avoids_code_without_debug_info,
107                                          LazyBool step_out_avoids_code_without_debug_info);
108 
109     void SetupAvoidNoDebug(LazyBool step_in_avoids_code_without_debug_info,
110                            LazyBool step_out_avoids_code_without_debug_info);
111     // Need an appropriate marker for the current stack so we can tell step out
112     // from step in.
113 
114     static uint32_t s_default_flag_values;  // These are the default flag values for the ThreadPlanStepThrough.
115     lldb::ThreadPlanSP m_sub_plan_sp;  // Keep track of the last plan we were running.  If it fails, we should stop.
116     std::unique_ptr<RegularExpression> m_avoid_regexp_ap;
117     bool m_step_past_prologue;  // FIXME: For now hard-coded to true, we could put a switch in for this if there's
118                                 // demand for that.
119     bool m_virtual_step;        // true if we've just done a "virtual step", i.e. just moved the inline stack depth.
120     ConstString m_step_into_target;
121     DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepInRange);
122 
123 };
124 
125 } // namespace lldb_private
126 
127 #endif  // liblldb_ThreadPlanStepInRange_h_
128