xref: /freebsd/contrib/llvm-project/lldb/include/lldb/Target/ThreadPlanStepInRange.h (revision fe6060f10f634930ff71b7c50291ddc610da2475)
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                         const char *step_into_target, 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   static void SetDefaultFlagValue(uint32_t new_value);
38 
39   bool IsVirtualStep() override;
40 
41   // Plans that are implementing parts of a step in might need to follow the
42   // behavior of this plan w.r.t. StepThrough.  They can get that from here.
GetDefaultFlagsValue()43   static uint32_t GetDefaultFlagsValue() {
44     return s_default_flag_values;
45   }
46 
47 protected:
48   static bool DefaultShouldStopHereCallback(ThreadPlan *current_plan,
49                                             Flags &flags,
50                                             lldb::FrameComparison operation,
51                                             Status &status, void *baton);
52 
53   bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
54 
55   bool DoPlanExplainsStop(Event *event_ptr) override;
56 
SetFlagsToDefault()57   void SetFlagsToDefault() override {
58     GetFlags().Set(ThreadPlanStepInRange::s_default_flag_values);
59   }
60 
SetCallbacks()61   void SetCallbacks() {
62     ThreadPlanShouldStopHere::ThreadPlanShouldStopHereCallbacks callbacks(
63         ThreadPlanStepInRange::DefaultShouldStopHereCallback, nullptr);
64     SetShouldStopHereCallbacks(&callbacks, nullptr);
65   }
66 
67   bool FrameMatchesAvoidCriteria();
68 
69 private:
70   void SetupAvoidNoDebug(LazyBool step_in_avoids_code_without_debug_info,
71                          LazyBool step_out_avoids_code_without_debug_info);
72   // Need an appropriate marker for the current stack so we can tell step out
73   // from step in.
74 
75   static uint32_t s_default_flag_values; // These are the default flag values
76                                          // for the ThreadPlanStepThrough.
77   lldb::ThreadPlanSP m_sub_plan_sp;      // Keep track of the last plan we were
78                                     // running.  If it fails, we should stop.
79   std::unique_ptr<RegularExpression> m_avoid_regexp_up;
80   bool m_step_past_prologue; // FIXME: For now hard-coded to true, we could put
81                              // a switch in for this if there's
82                              // demand for that.
83   bool m_virtual_step; // true if we've just done a "virtual step", i.e. just
84                        // moved the inline stack depth.
85   ConstString m_step_into_target;
86   ThreadPlanStepInRange(const ThreadPlanStepInRange &) = delete;
87   const ThreadPlanStepInRange &
88   operator=(const ThreadPlanStepInRange &) = delete;
89 };
90 
91 } // namespace lldb_private
92 
93 #endif // LLDB_TARGET_THREADPLANSTEPINRANGE_H
94