blob: a26b0fb87b3a4c30b7ff6bc7a88de6e4f65931b1 [file] [log] [blame]
Andrew Walbran3d2c1972020-04-07 12:24:26 +01001//===-- 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
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02009#ifndef LLDB_TARGET_THREADPLANSTEPINRANGE_H
10#define LLDB_TARGET_THREADPLANSTEPINRANGE_H
Andrew Walbran3d2c1972020-04-07 12:24:26 +010011
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
18namespace lldb_private {
19
20class ThreadPlanStepInRange : public ThreadPlanStepRange,
21 public ThreadPlanShouldStopHere {
22public:
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
Andrew Walbran3d2c1972020-04-07 12:24:26 +010029 ~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
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020045 // 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
Andrew Walbran3d2c1972020-04-07 12:24:26 +010051protected:
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
73private:
Andrew Walbran3d2c1972020-04-07 12:24:26 +010074 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;
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020090 ThreadPlanStepInRange(const ThreadPlanStepInRange &) = delete;
91 const ThreadPlanStepInRange &
92 operator=(const ThreadPlanStepInRange &) = delete;
Andrew Walbran3d2c1972020-04-07 12:24:26 +010093};
94
95} // namespace lldb_private
96
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020097#endif // LLDB_TARGET_THREADPLANSTEPINRANGE_H