1 //===-- OperatingSystemPython.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 liblldb_OperatingSystemPython_h_ 10 #define liblldb_OperatingSystemPython_h_ 11 12 #include "lldb/Host/Config.h" 13 14 #if LLDB_ENABLE_PYTHON 15 16 #include "lldb/Target/OperatingSystem.h" 17 #include "lldb/Utility/StructuredData.h" 18 19 class DynamicRegisterInfo; 20 21 namespace lldb_private { 22 class ScriptInterpreter; 23 } 24 25 class OperatingSystemPython : public lldb_private::OperatingSystem { 26 public: 27 OperatingSystemPython(lldb_private::Process *process, 28 const lldb_private::FileSpec &python_module_path); 29 30 ~OperatingSystemPython() override; 31 32 // Static Functions 33 static lldb_private::OperatingSystem * 34 CreateInstance(lldb_private::Process *process, bool force); 35 36 static void Initialize(); 37 38 static void Terminate(); 39 40 static lldb_private::ConstString GetPluginNameStatic(); 41 42 static const char *GetPluginDescriptionStatic(); 43 44 // lldb_private::PluginInterface Methods 45 lldb_private::ConstString GetPluginName() override; 46 47 uint32_t GetPluginVersion() override; 48 49 // lldb_private::OperatingSystem Methods 50 bool UpdateThreadList(lldb_private::ThreadList &old_thread_list, 51 lldb_private::ThreadList &real_thread_list, 52 lldb_private::ThreadList &new_thread_list) override; 53 54 void ThreadWasSelected(lldb_private::Thread *thread) override; 55 56 lldb::RegisterContextSP 57 CreateRegisterContextForThread(lldb_private::Thread *thread, 58 lldb::addr_t reg_data_addr) override; 59 60 lldb::StopInfoSP 61 CreateThreadStopReason(lldb_private::Thread *thread) override; 62 63 // Method for lazy creation of threads on demand 64 lldb::ThreadSP CreateThread(lldb::tid_t tid, lldb::addr_t context) override; 65 66 protected: IsValid()67 bool IsValid() const { 68 return m_python_object_sp && m_python_object_sp->IsValid(); 69 } 70 71 lldb::ThreadSP CreateThreadFromThreadInfo( 72 lldb_private::StructuredData::Dictionary &thread_dict, 73 lldb_private::ThreadList &core_thread_list, 74 lldb_private::ThreadList &old_thread_list, 75 std::vector<bool> &core_used_map, bool *did_create_ptr); 76 77 DynamicRegisterInfo *GetDynamicRegisterInfo(); 78 79 lldb::ValueObjectSP m_thread_list_valobj_sp; 80 std::unique_ptr<DynamicRegisterInfo> m_register_info_up; 81 lldb_private::ScriptInterpreter *m_interpreter; 82 lldb_private::StructuredData::ObjectSP m_python_object_sp; 83 }; 84 85 #endif 86 87 #endif // liblldb_OperatingSystemPython_h_ 88