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
13
14namespace 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
35public:
57
58 enum {
59 eNone = 0,
60 eAvoidInlines = (1 << 0),
64 eStepPastLine0 = (1 << 4) // Only source level plans should handle
65 // step past line 0 - not trampoline handlers.
66 };
67
68 // Constructors and Destructors
70
72 const ThreadPlanShouldStopHereCallbacks *callbacks,
73 void *baton = nullptr);
75
76 // Set the ShouldStopHere callbacks. Pass in null to clear them and have no
77 // special behavior (though you can also call ClearShouldStopHereCallbacks
78 // for that purpose. If you pass in a valid pointer, it will adopt the non-
79 // null fields, and any null fields will be set to the default values.
80
81 void
83 void *baton) {
84 if (callbacks) {
85 m_callbacks = *callbacks;
86 if (!m_callbacks.should_stop_here_callback)
87 m_callbacks.should_stop_here_callback =
89 if (!m_callbacks.step_from_here_callback)
90 m_callbacks.step_from_here_callback =
92 } else {
94 }
95 m_baton = baton;
96 }
97
99
101 Status &status);
102
105 Status &status);
106
108
109 const lldb_private::Flags &GetFlags() const { return m_flags; }
110
111protected:
112 static bool DefaultShouldStopHereCallback(ThreadPlan *current_plan,
113 Flags &flags,
114 lldb::FrameComparison operation,
115 Status &status, void *baton);
116
117 static lldb::ThreadPlanSP
118 DefaultStepFromHereCallback(ThreadPlan *current_plan, Flags &flags,
119 lldb::FrameComparison operation, Status &status,
120 void *baton);
121
122 virtual lldb::ThreadPlanSP
124 Status &status);
125
126 // Implement this, and call it in the plan's constructor to set the default
127 // flags.
128 virtual void SetFlagsToDefault() = 0;
129
131 void *m_baton;
134
135private:
139};
140
141} // namespace lldb_private
142
143#endif // LLDB_TARGET_THREADPLANSHOULDSTOPHERE_H
A class to manage flags.
Definition Flags.h:22
An error handling class.
Definition Status.h:118
virtual lldb::ThreadPlanSP QueueStepOutFromHerePlan(Flags &flags, lldb::FrameComparison operation, Status &status)
ThreadPlanShouldStopHereCallbacks m_callbacks
const lldb_private::Flags & GetFlags() const
void SetShouldStopHereCallbacks(const ThreadPlanShouldStopHereCallbacks *callbacks, void *baton)
static bool DefaultShouldStopHereCallback(ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, Status &status, void *baton)
ThreadPlanShouldStopHere(const ThreadPlanShouldStopHere &)=delete
static lldb::ThreadPlanSP DefaultStepFromHereCallback(ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, Status &status, void *baton)
bool InvokeShouldStopHereCallback(lldb::FrameComparison operation, Status &status)
lldb::ThreadPlanSP CheckShouldStopHereAndQueueStepOut(lldb::FrameComparison operation, Status &status)
const ThreadPlanShouldStopHere & operator=(const ThreadPlanShouldStopHere &)=delete
A class that represents a running process on the host machine.
bool(* ThreadPlanShouldStopHereCallback)(ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, Status &status, void *baton)
lldb::ThreadPlanSP(* ThreadPlanStepFromHereCallback)(ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, Status &status, void *baton)
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
FrameComparison
This is the return value for frame comparisons.
ThreadPlanShouldStopHereCallbacks(ThreadPlanShouldStopHereCallback should_stop, ThreadPlanStepFromHereCallback step_from_here)