1 //===-- ScriptedThreadPlan.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_SCRIPTEDTHREADPLAN_H 10 #define LLDB_TARGET_SCRIPTEDTHREADPLAN_H 11 12 #include <string> 13 14 #include "lldb/Core/StructuredDataImpl.h" 15 #include "lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h" 16 #include "lldb/Target/Process.h" 17 #include "lldb/Target/StopInfo.h" 18 #include "lldb/Target/Target.h" 19 #include "lldb/Target/Thread.h" 20 #include "lldb/Target/ThreadPlan.h" 21 #include "lldb/Target/ThreadPlanTracer.h" 22 #include "lldb/Utility/StructuredData.h" 23 #include "lldb/Utility/UserID.h" 24 #include "lldb/lldb-forward.h" 25 #include "lldb/lldb-private.h" 26 27 namespace lldb_private { 28 29 class ScriptedThreadPlan : public ThreadPlan { 30 public: 31 ScriptedThreadPlan(Thread &thread, const char *class_name, 32 const StructuredDataImpl &args_data); 33 34 void GetDescription(Stream *s, lldb::DescriptionLevel level) override; 35 36 bool ValidatePlan(Stream *error) override; 37 38 bool ShouldStop(Event *event_ptr) override; 39 40 bool MischiefManaged() override; 41 42 bool WillStop() override; 43 StopOthers()44 bool StopOthers() override { return m_stop_others; } 45 SetStopOthers(bool new_value)46 void SetStopOthers(bool new_value) override { m_stop_others = new_value; } 47 48 void DidPush() override; 49 50 bool IsPlanStale() override; 51 52 bool DoWillResume(lldb::StateType resume_state, bool current_plan) override; 53 54 protected: 55 bool DoPlanExplainsStop(Event *event_ptr) override; 56 57 lldb::StateType GetPlanRunState() override; 58 59 ScriptInterpreter *GetScriptInterpreter(); 60 61 private: 62 std::string m_class_name; 63 StructuredDataImpl m_args_data; 64 std::string m_error_str; 65 StructuredData::ObjectSP m_implementation_sp; 66 StreamString m_stop_description; // Cache the stop description here 67 bool m_did_push; 68 bool m_stop_others; 69 lldb::ScriptedThreadPlanInterfaceSP m_interface; 70 71 ScriptedThreadPlan(const ScriptedThreadPlan &) = delete; 72 const ScriptedThreadPlan &operator=(const ScriptedThreadPlan &) = delete; 73 }; 74 75 } // namespace lldb_private 76 77 #endif // LLDB_TARGET_SCRIPTEDTHREADPLAN_H 78