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