File indexing completed on 2026-05-10 08:42:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_TARGET_STOPINFO_H
0010 #define LLDB_TARGET_STOPINFO_H
0011
0012 #include <string>
0013
0014 #include "lldb/Target/Process.h"
0015 #include "lldb/Utility/StructuredData.h"
0016 #include "lldb/lldb-public.h"
0017
0018 namespace lldb_private {
0019
0020 class StopInfo : public std::enable_shared_from_this<StopInfo> {
0021 friend class Process::ProcessEventData;
0022 friend class ThreadPlanBase;
0023
0024 public:
0025
0026 StopInfo(Thread &thread, uint64_t value);
0027
0028 virtual ~StopInfo() = default;
0029
0030 bool IsValid() const;
0031
0032 void SetThread(const lldb::ThreadSP &thread_sp) { m_thread_wp = thread_sp; }
0033
0034 lldb::ThreadSP GetThread() const { return m_thread_wp.lock(); }
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 uint64_t GetValue() const { return m_value; }
0046
0047 virtual lldb::StopReason GetStopReason() const = 0;
0048
0049
0050
0051
0052
0053 virtual bool ShouldStopSynchronous(Event *event_ptr) { return true; }
0054
0055 void OverrideShouldNotify(bool override_value) {
0056 m_override_should_notify = override_value ? eLazyBoolYes : eLazyBoolNo;
0057 }
0058
0059
0060 virtual bool ShouldNotify(Event *event_ptr) {
0061 if (m_override_should_notify == eLazyBoolCalculate)
0062 return DoShouldNotify(event_ptr);
0063 else
0064 return m_override_should_notify == eLazyBoolYes;
0065 }
0066
0067 virtual void WillResume(lldb::StateType resume_state) {
0068
0069 }
0070
0071 virtual const char *GetDescription() { return m_description.c_str(); }
0072
0073 virtual void SetDescription(const char *desc_cstr) {
0074 if (desc_cstr && desc_cstr[0])
0075 m_description.assign(desc_cstr);
0076 else
0077 m_description.clear();
0078 }
0079
0080
0081
0082
0083
0084
0085
0086
0087 virtual std::optional<uint32_t>
0088 GetSuggestedStackFrameIndex(bool inlined_stack) {
0089 return {};
0090 }
0091
0092 virtual bool IsValidForOperatingSystemThread(Thread &thread) { return true; }
0093
0094
0095
0096
0097 virtual bool WasContinueInterrupted(Thread &thread) { return false; }
0098
0099
0100
0101
0102
0103
0104
0105
0106 void OverrideShouldStop(bool override_value) {
0107 m_override_should_stop = override_value ? eLazyBoolYes : eLazyBoolNo;
0108 }
0109
0110 bool GetOverrideShouldStop() {
0111 return m_override_should_stop != eLazyBoolCalculate;
0112 }
0113
0114 bool GetOverriddenShouldStopValue() {
0115 return m_override_should_stop == eLazyBoolYes;
0116 }
0117
0118 StructuredData::ObjectSP GetExtendedInfo() { return m_extended_info; }
0119
0120 static lldb::StopInfoSP
0121 CreateStopReasonWithBreakpointSiteID(Thread &thread,
0122 lldb::break_id_t break_id);
0123
0124
0125
0126 static lldb::StopInfoSP CreateStopReasonWithBreakpointSiteID(
0127 Thread &thread, lldb::break_id_t break_id, bool should_stop);
0128
0129 static lldb::StopInfoSP
0130 CreateStopReasonWithWatchpointID(Thread &thread, lldb::break_id_t watch_id,
0131 bool silently_continue = false);
0132
0133 static lldb::StopInfoSP
0134 CreateStopReasonWithSignal(Thread &thread, int signo,
0135 const char *description = nullptr,
0136 std::optional<int> code = std::nullopt);
0137
0138 static lldb::StopInfoSP
0139 CreateStopReasonWithInterrupt(Thread &thread, int signo,
0140 const char *description);
0141
0142 static lldb::StopInfoSP CreateStopReasonToTrace(Thread &thread);
0143
0144 static lldb::StopInfoSP
0145 CreateStopReasonWithPlan(lldb::ThreadPlanSP &plan,
0146 lldb::ValueObjectSP return_valobj_sp,
0147 lldb::ExpressionVariableSP expression_variable_sp);
0148
0149 static lldb::StopInfoSP
0150 CreateStopReasonWithException(Thread &thread, const char *description);
0151
0152 static lldb::StopInfoSP CreateStopReasonWithExec(Thread &thread);
0153
0154 static lldb::StopInfoSP
0155 CreateStopReasonProcessorTrace(Thread &thread, const char *description);
0156
0157 static lldb::StopInfoSP CreateStopReasonFork(Thread &thread,
0158 lldb::pid_t child_pid,
0159 lldb::tid_t child_tid);
0160
0161 static lldb::StopInfoSP CreateStopReasonVFork(Thread &thread,
0162 lldb::pid_t child_pid,
0163 lldb::tid_t child_tid);
0164
0165 static lldb::StopInfoSP CreateStopReasonVForkDone(Thread &thread);
0166
0167 static lldb::ValueObjectSP
0168 GetReturnValueObject(lldb::StopInfoSP &stop_info_sp);
0169
0170 static lldb::ExpressionVariableSP
0171 GetExpressionVariable(lldb::StopInfoSP &stop_info_sp);
0172
0173 static lldb::ValueObjectSP
0174 GetCrashingDereference(lldb::StopInfoSP &stop_info_sp,
0175 lldb::addr_t *crashing_address = nullptr);
0176
0177 protected:
0178
0179
0180
0181
0182 virtual void PerformAction(Event *event_ptr) {}
0183
0184 virtual bool DoShouldNotify(Event *event_ptr) { return false; }
0185
0186
0187
0188
0189
0190
0191
0192
0193 virtual bool ShouldStop(Event *event_ptr) { return true; }
0194
0195
0196 lldb::ThreadWP m_thread_wp;
0197 uint32_t m_stop_id;
0198 uint32_t m_resume_id;
0199 uint64_t m_value;
0200
0201 std::string m_description;
0202 LazyBool m_override_should_notify;
0203 LazyBool m_override_should_stop;
0204
0205 StructuredData::ObjectSP
0206 m_extended_info;
0207
0208
0209
0210 bool HasTargetRunSinceMe();
0211
0212
0213
0214
0215
0216 void MakeStopInfoValid();
0217
0218 private:
0219 friend class Thread;
0220
0221 StopInfo(const StopInfo &) = delete;
0222 const StopInfo &operator=(const StopInfo &) = delete;
0223 };
0224
0225 }
0226
0227 #endif