xref: /src/contrib/llvm-project/lldb/source/Plugins/Process/scripted/ScriptedThread.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1c0981da4SDimitry Andric //===-- ScriptedThread.h ----------------------------------------*- C++ -*-===//
2c0981da4SDimitry Andric //
3c0981da4SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4c0981da4SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5c0981da4SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6c0981da4SDimitry Andric //
7c0981da4SDimitry Andric //===----------------------------------------------------------------------===//
8c0981da4SDimitry Andric 
9c0981da4SDimitry Andric #ifndef LLDB_SOURCE_PLUGINS_SCRIPTED_THREAD_H
10c0981da4SDimitry Andric #define LLDB_SOURCE_PLUGINS_SCRIPTED_THREAD_H
11c0981da4SDimitry Andric 
12c0981da4SDimitry Andric #include <string>
13c0981da4SDimitry Andric 
14c0981da4SDimitry Andric #include "ScriptedProcess.h"
15c0981da4SDimitry Andric 
16c0981da4SDimitry Andric #include "Plugins/Process/Utility/RegisterContextMemory.h"
17c0981da4SDimitry Andric #include "lldb/Interpreter/ScriptInterpreter.h"
18c0981da4SDimitry Andric #include "lldb/Target/DynamicRegisterInfo.h"
19c0981da4SDimitry Andric #include "lldb/Target/Thread.h"
20c0981da4SDimitry Andric 
21c0981da4SDimitry Andric namespace lldb_private {
22c0981da4SDimitry Andric class ScriptedProcess;
23c0981da4SDimitry Andric }
24c0981da4SDimitry Andric 
25c0981da4SDimitry Andric namespace lldb_private {
26c0981da4SDimitry Andric 
27c0981da4SDimitry Andric class ScriptedThread : public lldb_private::Thread {
286f8fc217SDimitry Andric 
29c0981da4SDimitry Andric public:
306f8fc217SDimitry Andric   ScriptedThread(ScriptedProcess &process,
316f8fc217SDimitry Andric                  lldb::ScriptedThreadInterfaceSP interface_sp, lldb::tid_t tid,
326f8fc217SDimitry Andric                  StructuredData::GenericSP script_object_sp = nullptr);
33c0981da4SDimitry Andric 
34c0981da4SDimitry Andric   ~ScriptedThread() override;
35c0981da4SDimitry Andric 
366f8fc217SDimitry Andric   static llvm::Expected<std::shared_ptr<ScriptedThread>>
376f8fc217SDimitry Andric   Create(ScriptedProcess &process,
386f8fc217SDimitry Andric          StructuredData::Generic *script_object = nullptr);
396f8fc217SDimitry Andric 
40c0981da4SDimitry Andric   lldb::RegisterContextSP GetRegisterContext() override;
41c0981da4SDimitry Andric 
42c0981da4SDimitry Andric   lldb::RegisterContextSP
43c0981da4SDimitry Andric   CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
44c0981da4SDimitry Andric 
45145449b1SDimitry Andric   bool LoadArtificialStackFrames();
46145449b1SDimitry Andric 
47c0981da4SDimitry Andric   bool CalculateStopInfo() override;
48c0981da4SDimitry Andric 
GetInfo()49c0981da4SDimitry Andric   const char *GetInfo() override { return nullptr; }
50c0981da4SDimitry Andric 
51c0981da4SDimitry Andric   const char *GetName() override;
52c0981da4SDimitry Andric 
53c0981da4SDimitry Andric   const char *GetQueueName() override;
54c0981da4SDimitry Andric 
55c0981da4SDimitry Andric   void WillResume(lldb::StateType resume_state) override;
56c0981da4SDimitry Andric 
57c0981da4SDimitry Andric   void RefreshStateAfterStop() override;
58c0981da4SDimitry Andric 
59c0981da4SDimitry Andric   void ClearStackFrames() override;
60c0981da4SDimitry Andric 
61e3b55780SDimitry Andric   StructuredData::ObjectSP FetchThreadExtendedInfo() override;
62e3b55780SDimitry Andric 
63c0981da4SDimitry Andric private:
64c0981da4SDimitry Andric   void CheckInterpreterAndScriptObject() const;
65c0981da4SDimitry Andric   lldb::ScriptedThreadInterfaceSP GetInterface() const;
66c0981da4SDimitry Andric 
67c0981da4SDimitry Andric   ScriptedThread(const ScriptedThread &) = delete;
68c0981da4SDimitry Andric   const ScriptedThread &operator=(const ScriptedThread &) = delete;
69c0981da4SDimitry Andric 
70c0981da4SDimitry Andric   std::shared_ptr<DynamicRegisterInfo> GetDynamicRegisterInfo();
71c0981da4SDimitry Andric 
72c0981da4SDimitry Andric   const ScriptedProcess &m_scripted_process;
736f8fc217SDimitry Andric   lldb::ScriptedThreadInterfaceSP m_scripted_thread_interface_sp = nullptr;
746f8fc217SDimitry Andric   lldb_private::StructuredData::GenericSP m_script_object_sp = nullptr;
75c0981da4SDimitry Andric   std::shared_ptr<DynamicRegisterInfo> m_register_info_sp = nullptr;
76c0981da4SDimitry Andric };
77c0981da4SDimitry Andric 
78c0981da4SDimitry Andric } // namespace lldb_private
79c0981da4SDimitry Andric 
80c0981da4SDimitry Andric #endif // LLDB_SOURCE_PLUGINS_SCRIPTED_THREAD_H
81