xref: /freebsd-src/contrib/llvm-project/lldb/source/Plugins/Process/scripted/ScriptedThread.h (revision 5e801ac66d24704442eba426ed13c3effb8a34e7)
1 //===-- ScriptedThread.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_SOURCE_PLUGINS_SCRIPTED_THREAD_H
10 #define LLDB_SOURCE_PLUGINS_SCRIPTED_THREAD_H
11 
12 #include <string>
13 
14 #include "ScriptedProcess.h"
15 
16 #include "Plugins/Process/Utility/RegisterContextMemory.h"
17 #include "lldb/Interpreter/ScriptInterpreter.h"
18 #include "lldb/Target/DynamicRegisterInfo.h"
19 #include "lldb/Target/Thread.h"
20 
21 namespace lldb_private {
22 class ScriptedProcess;
23 }
24 
25 namespace lldb_private {
26 
27 class ScriptedThread : public lldb_private::Thread {
28 public:
29   ScriptedThread(ScriptedProcess &process, Status &error);
30 
31   ~ScriptedThread() override;
32 
33   lldb::RegisterContextSP GetRegisterContext() override;
34 
35   lldb::RegisterContextSP
36   CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
37 
38   bool CalculateStopInfo() override;
39 
40   const char *GetInfo() override { return nullptr; }
41 
42   const char *GetName() override;
43 
44   const char *GetQueueName() override;
45 
46   void WillResume(lldb::StateType resume_state) override;
47 
48   void RefreshStateAfterStop() override;
49 
50   void ClearStackFrames() override;
51 
52 private:
53   void CheckInterpreterAndScriptObject() const;
54   lldb::ScriptedThreadInterfaceSP GetInterface() const;
55 
56   ScriptedThread(const ScriptedThread &) = delete;
57   const ScriptedThread &operator=(const ScriptedThread &) = delete;
58 
59   std::shared_ptr<DynamicRegisterInfo> GetDynamicRegisterInfo();
60 
61   const ScriptedProcess &m_scripted_process;
62   std::shared_ptr<DynamicRegisterInfo> m_register_info_sp = nullptr;
63   lldb_private::StructuredData::ObjectSP m_script_object_sp = nullptr;
64 };
65 
66 } // namespace lldb_private
67 
68 #endif // LLDB_SOURCE_PLUGINS_SCRIPTED_THREAD_H
69