xref: /freebsd/contrib/llvm-project/lldb/include/lldb/Target/ThreadPlanPython.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1 //===-- ThreadPlanPython.h --------------------------------------------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLDB_TARGET_THREADPLANPYTHON_H
11 #define LLDB_TARGET_THREADPLANPYTHON_H
12 
13 #include <string>
14 
15 #include "lldb/Core/StructuredDataImpl.h"
16 #include "lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h"
17 #include "lldb/Target/Process.h"
18 #include "lldb/Target/StopInfo.h"
19 #include "lldb/Target/Target.h"
20 #include "lldb/Target/Thread.h"
21 #include "lldb/Target/ThreadPlan.h"
22 #include "lldb/Target/ThreadPlanTracer.h"
23 #include "lldb/Utility/StructuredData.h"
24 #include "lldb/Utility/UserID.h"
25 #include "lldb/lldb-forward.h"
26 #include "lldb/lldb-private.h"
27 
28 namespace lldb_private {
29 
30 //  ThreadPlanPython:
31 //
32 
33 class ThreadPlanPython : public ThreadPlan {
34 public:
35   ThreadPlanPython(Thread &thread, const char *class_name,
36                    const StructuredDataImpl &args_data);
37 
38   void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
39 
40   bool ValidatePlan(Stream *error) override;
41 
42   bool ShouldStop(Event *event_ptr) override;
43 
44   bool MischiefManaged() override;
45 
46   bool WillStop() override;
47 
StopOthers()48   bool StopOthers() override { return m_stop_others; }
49 
SetStopOthers(bool new_value)50   void SetStopOthers(bool new_value) override { m_stop_others = new_value; }
51 
52   void DidPush() override;
53 
54   bool IsPlanStale() override;
55 
56   bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
57 
58 
59 protected:
60   bool DoPlanExplainsStop(Event *event_ptr) override;
61 
62   lldb::StateType GetPlanRunState() override;
63 
64   ScriptInterpreter *GetScriptInterpreter();
65 
66 private:
67   std::string m_class_name;
68   StructuredDataImpl m_args_data;
69   std::string m_error_str;
70   StructuredData::ObjectSP m_implementation_sp;
71   StreamString m_stop_description; // Cache the stop description here
72   bool m_did_push;
73   bool m_stop_others;
74   lldb::ScriptedThreadPlanInterfaceSP m_interface;
75 
76   ThreadPlanPython(const ThreadPlanPython &) = delete;
77   const ThreadPlanPython &operator=(const ThreadPlanPython &) = delete;
78 };
79 
80 } // namespace lldb_private
81 
82 #endif // LLDB_TARGET_THREADPLANPYTHON_H
83