LLDB  mainline
ThreadPlanShouldStopHere.h
Go to the documentation of this file.
1 //===-- ThreadPlanShouldStopHere.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_THREADPLANSHOULDSTOPHERE_H
10 #define LLDB_TARGET_THREADPLANSHOULDSTOPHERE_H
11 
12 #include "lldb/Target/ThreadPlan.h"
13 
14 namespace lldb_private {
15 
16 // This is an interface that ThreadPlans can adopt to allow flexible
17 // modifications of the behavior when a thread plan comes to a place where it
18 // would ordinarily stop. If such modification makes sense for your plan,
19 // inherit from this class, and when you would be about to stop (in your
20 // ShouldStop method), call InvokeShouldStopHereCallback, passing in the frame
21 // comparison between where the step operation started and where you arrived.
22 // If it returns true, then QueueStepOutFromHere will queue the plan to execute
23 // instead of stopping.
24 //
25 // The classic example of the use of this is ThreadPlanStepInRange not stopping
26 // in frames that have no debug information.
27 //
28 // This class also defines a set of flags to control general aspects of this
29 // "ShouldStop" behavior.
30 // A class implementing this protocol needs to define a default set of flags,
31 // and can provide access to
32 // changing that default flag set if it wishes.
33 
35 public:
38  should_stop_here_callback = nullptr;
39  step_from_here_callback = nullptr;
40  }
41 
43  ThreadPlanShouldStopHereCallback should_stop,
44  ThreadPlanStepFromHereCallback step_from_here) {
45  should_stop_here_callback = should_stop;
46  step_from_here_callback = step_from_here;
47  }
48 
49  void Clear() {
50  should_stop_here_callback = nullptr;
51  step_from_here_callback = nullptr;
52  }
53 
54  ThreadPlanShouldStopHereCallback should_stop_here_callback;
55  ThreadPlanStepFromHereCallback step_from_here_callback;
56  };
57 
58  enum {
59  eNone = 0,
60  eAvoidInlines = (1 << 0),
61  eStepInAvoidNoDebug = (1 << 1),
63  };
64 
65  // Constructors and Destructors
67 
69  const ThreadPlanShouldStopHereCallbacks *callbacks,
70  void *baton = nullptr);
71  virtual ~ThreadPlanShouldStopHere();
72 
73  // Set the ShouldStopHere callbacks. Pass in null to clear them and have no
74  // special behavior (though you can also call ClearShouldStopHereCallbacks
75  // for that purpose. If you pass in a valid pointer, it will adopt the non-
76  // null fields, and any null fields will be set to the default values.
77 
78  void
80  void *baton) {
81  if (callbacks) {
82  m_callbacks = *callbacks;
89  } else {
91  }
92  m_baton = baton;
93  }
94 
96 
98  Status &status);
99 
100  lldb::ThreadPlanSP
102  Status &status);
103 
105 
106  const lldb_private::Flags &GetFlags() const { return m_flags; }
107 
108 protected:
109  static bool DefaultShouldStopHereCallback(ThreadPlan *current_plan,
110  Flags &flags,
111  lldb::FrameComparison operation,
112  Status &status, void *baton);
113 
114  static lldb::ThreadPlanSP
115  DefaultStepFromHereCallback(ThreadPlan *current_plan, Flags &flags,
116  lldb::FrameComparison operation, Status &status,
117  void *baton);
118 
119  virtual lldb::ThreadPlanSP
121  Status &status);
122 
123  // Implement this, and call it in the plan's constructor to set the default
124  // flags.
125  virtual void SetFlagsToDefault() = 0;
126 
128  void *m_baton;
131 
132 private:
135  operator=(const ThreadPlanShouldStopHere &) = delete;
136 };
137 
138 } // namespace lldb_private
139 
140 #endif // LLDB_TARGET_THREADPLANSHOULDSTOPHERE_H
lldb_private::ThreadPlanShouldStopHere::ThreadPlanShouldStopHereCallbacks::ThreadPlanShouldStopHereCallbacks
ThreadPlanShouldStopHereCallbacks(ThreadPlanShouldStopHereCallback should_stop, ThreadPlanStepFromHereCallback step_from_here)
Definition: ThreadPlanShouldStopHere.h:42
lldb::FrameComparison
FrameComparison
This is the return value for frame comparisons.
Definition: lldb-enumerations.h:860
lldb_private::ThreadPlanShouldStopHere::DefaultShouldStopHereCallback
static bool DefaultShouldStopHereCallback(ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, Status &status, void *baton)
Definition: ThreadPlanShouldStopHere.cpp:57
lldb_private::ThreadPlanShouldStopHere::m_flags
lldb_private::Flags m_flags
Definition: ThreadPlanShouldStopHere.h:130
lldb_private::ThreadPlanShouldStopHere::m_owner
ThreadPlan * m_owner
Definition: ThreadPlanShouldStopHere.h:129
lldb_private::Flags
Definition: Flags.h:22
lldb_private::ThreadPlanShouldStopHere::ClearShouldStopHereCallbacks
void ClearShouldStopHereCallbacks()
Definition: ThreadPlanShouldStopHere.h:95
lldb_private::ThreadPlanShouldStopHere::operator=
const ThreadPlanShouldStopHere & operator=(const ThreadPlanShouldStopHere &)=delete
lldb_private::ThreadPlan
Definition: ThreadPlan.h:282
lldb_private::ThreadPlanShouldStopHere::eAvoidInlines
@ eAvoidInlines
Definition: ThreadPlanShouldStopHere.h:60
lldb_private::ThreadPlanShouldStopHere::eStepOutAvoidNoDebug
@ eStepOutAvoidNoDebug
Definition: ThreadPlanShouldStopHere.h:62
lldb_private::ThreadPlanShouldStopHere::eNone
@ eNone
Definition: ThreadPlanShouldStopHere.h:59
lldb_private::ThreadPlanShouldStopHere::GetFlags
const lldb_private::Flags & GetFlags() const
Definition: ThreadPlanShouldStopHere.h:106
lldb_private::ThreadPlanShouldStopHere::QueueStepOutFromHerePlan
virtual lldb::ThreadPlanSP QueueStepOutFromHerePlan(Flags &flags, lldb::FrameComparison operation, Status &status)
Definition: ThreadPlanShouldStopHere.cpp:143
lldb_private::ThreadPlanShouldStopHere::ThreadPlanShouldStopHereCallbacks::Clear
void Clear()
Definition: ThreadPlanShouldStopHere.h:49
lldb_private::ThreadPlanShouldStopHere
Definition: ThreadPlanShouldStopHere.h:34
lldb_private::ThreadPlanShouldStopHere::ThreadPlanShouldStopHereCallbacks::ThreadPlanShouldStopHereCallbacks
ThreadPlanShouldStopHereCallbacks()
Definition: ThreadPlanShouldStopHere.h:37
lldb_private::ThreadPlanShouldStopHere::ThreadPlanShouldStopHere
ThreadPlanShouldStopHere(ThreadPlan *owner)
Definition: ThreadPlanShouldStopHere.cpp:19
lldb_private::ThreadPlanShouldStopHere::GetFlags
lldb_private::Flags & GetFlags()
Definition: ThreadPlanShouldStopHere.h:104
lldb_private::ThreadPlanShouldStopHere::ThreadPlanShouldStopHereCallbacks::should_stop_here_callback
ThreadPlanShouldStopHereCallback should_stop_here_callback
Definition: ThreadPlanShouldStopHere.h:54
lldb_private::ThreadPlanShouldStopHere::DefaultStepFromHereCallback
static lldb::ThreadPlanSP DefaultStepFromHereCallback(ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, Status &status, void *baton)
Definition: ThreadPlanShouldStopHere.cpp:93
lldb_private::ThreadPlanShouldStopHere::~ThreadPlanShouldStopHere
virtual ~ThreadPlanShouldStopHere()
lldb_private::ThreadPlanShouldStopHere::ThreadPlanShouldStopHereCallbacks
Definition: ThreadPlanShouldStopHere.h:36
ThreadPlan.h
lldb_private::Status
Definition: Status.h:44
lldb_private::ThreadPlanShouldStopHere::ThreadPlanShouldStopHereCallbacks::step_from_here_callback
ThreadPlanStepFromHereCallback step_from_here_callback
Definition: ThreadPlanShouldStopHere.h:55
lldb_private::ThreadPlanShouldStopHere::eStepInAvoidNoDebug
@ eStepInAvoidNoDebug
Definition: ThreadPlanShouldStopHere.h:61
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::ThreadPlanShouldStopHere::m_baton
void * m_baton
Definition: ThreadPlanShouldStopHere.h:128
lldb_private::ThreadPlanShouldStopHere::InvokeShouldStopHereCallback
bool InvokeShouldStopHereCallback(lldb::FrameComparison operation, Status &status)
Definition: ThreadPlanShouldStopHere.cpp:38
lldb_private::ThreadPlanShouldStopHere::SetShouldStopHereCallbacks
void SetShouldStopHereCallbacks(const ThreadPlanShouldStopHereCallbacks *callbacks, void *baton)
Definition: ThreadPlanShouldStopHere.h:79
lldb_private::ThreadPlanShouldStopHere::m_callbacks
ThreadPlanShouldStopHereCallbacks m_callbacks
Definition: ThreadPlanShouldStopHere.h:127
lldb_private::ThreadPlanShouldStopHere::SetFlagsToDefault
virtual void SetFlagsToDefault()=0
lldb_private::ThreadPlanShouldStopHere::CheckShouldStopHereAndQueueStepOut
lldb::ThreadPlanSP CheckShouldStopHereAndQueueStepOut(lldb::FrameComparison operation, Status &status)
Definition: ThreadPlanShouldStopHere.cpp:154