1 //===-- StopInfo.h ----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_StopInfo_h_
11 #define liblldb_StopInfo_h_
17 // Other libraries and framework includes
19 #include "lldb/lldb-public.h"
20 #include "lldb/Target/Process.h"
22 namespace lldb_private {
26 friend class Process::ProcessEventData;
27 friend class ThreadPlanBase;
30 //------------------------------------------------------------------
31 // Constructors and Destructors
32 //------------------------------------------------------------------
33 StopInfo (Thread &thread, uint64_t value);
44 SetThread (const lldb::ThreadSP &thread_sp)
46 m_thread_wp = thread_sp;
52 return m_thread_wp.lock();
55 // The value of the StopInfo depends on the StopReason.
57 // ----------------------------------------------
58 // eStopReasonBreakpoint BreakpointSiteID
59 // eStopReasonSignal Signal number
60 // eStopReasonWatchpoint WatchpointLocationID
61 // eStopReasonPlanComplete No significance
69 virtual lldb::StopReason
70 GetStopReason () const = 0;
72 // ShouldStopSynchronous will get called before any thread plans are consulted, and if it says we should
73 // resume the target, then we will just immediately resume. This should not run any code in or resume the
77 ShouldStopSynchronous (Event *event_ptr)
83 OverrideShouldNotify (bool override_value)
85 m_override_should_notify = override_value ? eLazyBoolYes : eLazyBoolNo;
88 // If should stop returns false, check if we should notify of this event
90 ShouldNotify (Event *event_ptr)
92 if (m_override_should_notify == eLazyBoolCalculate)
93 return DoShouldNotify (event_ptr);
95 return m_override_should_notify == eLazyBoolYes;
99 WillResume (lldb::StateType resume_state)
101 // By default, don't do anything
107 return m_description.c_str();
111 SetDescription (const char *desc_cstr)
113 if (desc_cstr && desc_cstr[0])
114 m_description.assign (desc_cstr);
116 m_description.clear();
119 // Sometimes the thread plan logic will know that it wants a given stop to stop or not,
120 // regardless of what the ordinary logic for that StopInfo would dictate. The main example
121 // of this is the ThreadPlanCallFunction, which for instance knows - based on how that particular
122 // expression was executed - whether it wants all breakpoints to auto-continue or not.
123 // Use OverrideShouldStop on the StopInfo to implement this.
126 OverrideShouldStop (bool override_value)
128 m_override_should_stop = override_value ? eLazyBoolYes : eLazyBoolNo;
132 GetOverrideShouldStop()
134 return m_override_should_stop != eLazyBoolCalculate;
138 GetOverriddenShouldStopValue ()
140 return m_override_should_stop == eLazyBoolYes;
143 static lldb::StopInfoSP
144 CreateStopReasonWithBreakpointSiteID (Thread &thread, lldb::break_id_t break_id);
146 // This creates a StopInfo for the thread where the should_stop is already set, and won't be recalculated.
147 static lldb::StopInfoSP
148 CreateStopReasonWithBreakpointSiteID (Thread &thread, lldb::break_id_t break_id, bool should_stop);
150 static lldb::StopInfoSP
151 CreateStopReasonWithWatchpointID (Thread &thread, lldb::break_id_t watch_id);
153 static lldb::StopInfoSP
154 CreateStopReasonWithSignal (Thread &thread, int signo);
156 static lldb::StopInfoSP
157 CreateStopReasonToTrace (Thread &thread);
159 static lldb::StopInfoSP
160 CreateStopReasonWithPlan (lldb::ThreadPlanSP &plan, lldb::ValueObjectSP return_valobj_sp);
162 static lldb::StopInfoSP
163 CreateStopReasonWithException (Thread &thread, const char *description);
165 static lldb::StopInfoSP
166 CreateStopReasonWithExec (Thread &thread);
168 static lldb::ValueObjectSP
169 GetReturnValueObject (lldb::StopInfoSP &stop_info_sp);
172 // Perform any action that is associated with this stop. This is done as the
173 // Event is removed from the event queue. ProcessEventData::DoOnRemoval does the job.
176 PerformAction (Event *event_ptr)
181 DoShouldNotify (Event *event_ptr)
186 // Stop the thread by default. Subclasses can override this to allow
187 // the thread to continue if desired. The ShouldStop method should not do anything
188 // that might run code. If you need to run code when deciding whether to stop
189 // at this StopInfo, that must be done in the PerformAction.
190 // The PerformAction will always get called before the ShouldStop. This is done by the
191 // ProcessEventData::DoOnRemoval, though the ThreadPlanBase needs to consult this later on.
193 ShouldStop (Event *event_ptr)
198 //------------------------------------------------------------------
199 // Classes that inherit from StackID can see and modify these
200 //------------------------------------------------------------------
201 lldb::ThreadWP m_thread_wp; // The thread corresponding to the stop reason.
202 uint32_t m_stop_id; // The process stop ID for which this stop info is valid
203 uint32_t m_resume_id; // This is the resume ID when we made this stop ID.
204 uint64_t m_value; // A generic value that can be used for things pertaining to this stop info
205 std::string m_description; // A textual description describing this stop.
206 LazyBool m_override_should_notify;
207 LazyBool m_override_should_stop;
209 // This determines whether the target has run since this stop info.
210 // N.B. running to evaluate a user expression does not count.
211 bool HasTargetRunSinceMe ();
213 // MakeStopInfoValid is necessary to allow saved stop infos to resurrect themselves as valid.
214 // It should only be used by Thread::RestoreThreadStateFromCheckpoint and to make sure the one-step
215 // needed for before-the-fact watchpoints does not prevent us from stopping
217 MakeStopInfoValid ();
222 DISALLOW_COPY_AND_ASSIGN (StopInfo);
225 } // namespace lldb_private
227 #endif // liblldb_StopInfo_h_