xref: /src/contrib/llvm-project/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
1e81d9d49SDimitry Andric //===-- OperatingSystemPython.h ---------------------------------*- C++ -*-===//
2f034231aSEd Maste //
35f29bb8aSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45f29bb8aSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
55f29bb8aSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6f034231aSEd Maste //
7f034231aSEd Maste //===----------------------------------------------------------------------===//
8f034231aSEd Maste 
9f034231aSEd Maste #ifndef liblldb_OperatingSystemPython_h_
10f034231aSEd Maste #define liblldb_OperatingSystemPython_h_
11f034231aSEd Maste 
12706b4fc4SDimitry Andric #include "lldb/Host/Config.h"
13706b4fc4SDimitry Andric 
14706b4fc4SDimitry Andric #if LLDB_ENABLE_PYTHON
15e81d9d49SDimitry Andric 
16c0981da4SDimitry Andric #include "lldb/Target/DynamicRegisterInfo.h"
17f034231aSEd Maste #include "lldb/Target/OperatingSystem.h"
181b306c26SDimitry Andric #include "lldb/Utility/StructuredData.h"
19f034231aSEd Maste 
2014f1b3e8SDimitry Andric namespace lldb_private {
215e95aa85SEd Maste class ScriptInterpreter;
225e95aa85SEd Maste }
235e95aa85SEd Maste 
2414f1b3e8SDimitry Andric class OperatingSystemPython : public lldb_private::OperatingSystem {
25f034231aSEd Maste public:
26e81d9d49SDimitry Andric   OperatingSystemPython(lldb_private::Process *process,
27e81d9d49SDimitry Andric                         const lldb_private::FileSpec &python_module_path);
28e81d9d49SDimitry Andric 
29e81d9d49SDimitry Andric   ~OperatingSystemPython() override;
30e81d9d49SDimitry Andric 
31f034231aSEd Maste   // Static Functions
32f034231aSEd Maste   static lldb_private::OperatingSystem *
33f034231aSEd Maste   CreateInstance(lldb_private::Process *process, bool force);
34f034231aSEd Maste 
3514f1b3e8SDimitry Andric   static void Initialize();
36f034231aSEd Maste 
3714f1b3e8SDimitry Andric   static void Terminate();
38f034231aSEd Maste 
GetPluginNameStatic()39c0981da4SDimitry Andric   static llvm::StringRef GetPluginNameStatic() { return "python"; }
40f034231aSEd Maste 
41c0981da4SDimitry Andric   static llvm::StringRef GetPluginDescriptionStatic();
42f034231aSEd Maste 
43f034231aSEd Maste   // lldb_private::PluginInterface Methods
GetPluginName()44c0981da4SDimitry Andric   llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
45f034231aSEd Maste 
46f034231aSEd Maste   // lldb_private::OperatingSystem Methods
4714f1b3e8SDimitry Andric   bool UpdateThreadList(lldb_private::ThreadList &old_thread_list,
48f034231aSEd Maste                         lldb_private::ThreadList &real_thread_list,
49e81d9d49SDimitry Andric                         lldb_private::ThreadList &new_thread_list) override;
50f034231aSEd Maste 
5114f1b3e8SDimitry Andric   void ThreadWasSelected(lldb_private::Thread *thread) override;
52f034231aSEd Maste 
53e81d9d49SDimitry Andric   lldb::RegisterContextSP
54f034231aSEd Maste   CreateRegisterContextForThread(lldb_private::Thread *thread,
55e81d9d49SDimitry Andric                                  lldb::addr_t reg_data_addr) override;
56f034231aSEd Maste 
57e81d9d49SDimitry Andric   lldb::StopInfoSP
58e81d9d49SDimitry Andric   CreateThreadStopReason(lldb_private::Thread *thread) override;
59f034231aSEd Maste 
60f034231aSEd Maste   // Method for lazy creation of threads on demand
6114f1b3e8SDimitry Andric   lldb::ThreadSP CreateThread(lldb::tid_t tid, lldb::addr_t context) override;
62f034231aSEd Maste 
63f034231aSEd Maste protected:
IsValid()6414f1b3e8SDimitry Andric   bool IsValid() const {
65b1c73532SDimitry Andric     return m_script_object_sp && m_script_object_sp->IsValid();
66f034231aSEd Maste   }
67f034231aSEd Maste 
6814f1b3e8SDimitry Andric   lldb::ThreadSP CreateThreadFromThreadInfo(
6914f1b3e8SDimitry Andric       lldb_private::StructuredData::Dictionary &thread_dict,
7014f1b3e8SDimitry Andric       lldb_private::ThreadList &core_thread_list,
7114f1b3e8SDimitry Andric       lldb_private::ThreadList &old_thread_list,
725e95aa85SEd Maste       std::vector<bool> &core_used_map, bool *did_create_ptr);
73f034231aSEd Maste 
74c0981da4SDimitry Andric   lldb_private::DynamicRegisterInfo *GetDynamicRegisterInfo();
75f034231aSEd Maste 
76f034231aSEd Maste   lldb::ValueObjectSP m_thread_list_valobj_sp;
77c0981da4SDimitry Andric   std::unique_ptr<lldb_private::DynamicRegisterInfo> m_register_info_up;
78b1c73532SDimitry Andric   lldb_private::ScriptInterpreter *m_interpreter = nullptr;
79b1c73532SDimitry Andric   lldb::OperatingSystemInterfaceSP m_operating_system_interface_sp = nullptr;
80b1c73532SDimitry Andric   lldb_private::StructuredData::GenericSP m_script_object_sp = nullptr;
81f034231aSEd Maste };
82f034231aSEd Maste 
83c0981da4SDimitry Andric #endif // LLDB_ENABLE_PYTHON
84e81d9d49SDimitry Andric 
85e81d9d49SDimitry Andric #endif // liblldb_OperatingSystemPython_h_
86