1349cc55cSDimitry Andric //===-- ScriptedThread.h ----------------------------------------*- C++ -*-===//
2349cc55cSDimitry Andric //
3349cc55cSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4349cc55cSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5349cc55cSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6349cc55cSDimitry Andric //
7349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
8349cc55cSDimitry Andric 
9349cc55cSDimitry Andric #ifndef LLDB_SOURCE_PLUGINS_SCRIPTED_THREAD_H
10349cc55cSDimitry Andric #define LLDB_SOURCE_PLUGINS_SCRIPTED_THREAD_H
11349cc55cSDimitry Andric 
12349cc55cSDimitry Andric #include <string>
13349cc55cSDimitry Andric 
14349cc55cSDimitry Andric #include "ScriptedProcess.h"
15349cc55cSDimitry Andric 
16349cc55cSDimitry Andric #include "Plugins/Process/Utility/RegisterContextMemory.h"
17349cc55cSDimitry Andric #include "lldb/Interpreter/ScriptInterpreter.h"
18349cc55cSDimitry Andric #include "lldb/Target/DynamicRegisterInfo.h"
19349cc55cSDimitry Andric #include "lldb/Target/Thread.h"
20349cc55cSDimitry Andric 
21349cc55cSDimitry Andric namespace lldb_private {
22349cc55cSDimitry Andric class ScriptedProcess;
23349cc55cSDimitry Andric }
24349cc55cSDimitry Andric 
25349cc55cSDimitry Andric namespace lldb_private {
26349cc55cSDimitry Andric 
27349cc55cSDimitry Andric class ScriptedThread : public lldb_private::Thread {
2804eeddc0SDimitry Andric 
29349cc55cSDimitry Andric public:
3004eeddc0SDimitry Andric   ScriptedThread(ScriptedProcess &process,
3104eeddc0SDimitry Andric                  lldb::ScriptedThreadInterfaceSP interface_sp, lldb::tid_t tid,
3204eeddc0SDimitry Andric                  StructuredData::GenericSP script_object_sp = nullptr);
33349cc55cSDimitry Andric 
34349cc55cSDimitry Andric   ~ScriptedThread() override;
35349cc55cSDimitry Andric 
3604eeddc0SDimitry Andric   static llvm::Expected<std::shared_ptr<ScriptedThread>>
3704eeddc0SDimitry Andric   Create(ScriptedProcess &process,
3804eeddc0SDimitry Andric          StructuredData::Generic *script_object = nullptr);
3904eeddc0SDimitry Andric 
40349cc55cSDimitry Andric   lldb::RegisterContextSP GetRegisterContext() override;
41349cc55cSDimitry Andric 
42349cc55cSDimitry Andric   lldb::RegisterContextSP
43349cc55cSDimitry Andric   CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
44349cc55cSDimitry Andric 
4581ad6265SDimitry Andric   bool LoadArtificialStackFrames();
4681ad6265SDimitry Andric 
47349cc55cSDimitry Andric   bool CalculateStopInfo() override;
48349cc55cSDimitry Andric 
GetInfo()49349cc55cSDimitry Andric   const char *GetInfo() override { return nullptr; }
50349cc55cSDimitry Andric 
51349cc55cSDimitry Andric   const char *GetName() override;
52349cc55cSDimitry Andric 
53349cc55cSDimitry Andric   const char *GetQueueName() override;
54349cc55cSDimitry Andric 
55349cc55cSDimitry Andric   void WillResume(lldb::StateType resume_state) override;
56349cc55cSDimitry Andric 
57349cc55cSDimitry Andric   void RefreshStateAfterStop() override;
58349cc55cSDimitry Andric 
59349cc55cSDimitry Andric   void ClearStackFrames() override;
60349cc55cSDimitry Andric 
61*bdd1243dSDimitry Andric   StructuredData::ObjectSP FetchThreadExtendedInfo() override;
62*bdd1243dSDimitry Andric 
63349cc55cSDimitry Andric private:
64349cc55cSDimitry Andric   void CheckInterpreterAndScriptObject() const;
65349cc55cSDimitry Andric   lldb::ScriptedThreadInterfaceSP GetInterface() const;
66349cc55cSDimitry Andric 
67349cc55cSDimitry Andric   ScriptedThread(const ScriptedThread &) = delete;
68349cc55cSDimitry Andric   const ScriptedThread &operator=(const ScriptedThread &) = delete;
69349cc55cSDimitry Andric 
70349cc55cSDimitry Andric   std::shared_ptr<DynamicRegisterInfo> GetDynamicRegisterInfo();
71349cc55cSDimitry Andric 
72349cc55cSDimitry Andric   const ScriptedProcess &m_scripted_process;
7304eeddc0SDimitry Andric   lldb::ScriptedThreadInterfaceSP m_scripted_thread_interface_sp = nullptr;
7404eeddc0SDimitry Andric   lldb_private::StructuredData::GenericSP m_script_object_sp = nullptr;
75349cc55cSDimitry Andric   std::shared_ptr<DynamicRegisterInfo> m_register_info_sp = nullptr;
76349cc55cSDimitry Andric };
77349cc55cSDimitry Andric 
78349cc55cSDimitry Andric } // namespace lldb_private
79349cc55cSDimitry Andric 
80349cc55cSDimitry Andric #endif // LLDB_SOURCE_PLUGINS_SCRIPTED_THREAD_H
81