1 //===-- ScriptInterpreterPython.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 LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H 10 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H 11 12 #if LLDB_ENABLE_PYTHON 13 14 // clang-format off 15 // LLDB Python header must be included first 16 #include "lldb-python.h" 17 //clang-format on 18 #endif 19 20 #include "lldb/Host/Config.h" 21 22 #if LLDB_ENABLE_PYTHON 23 24 #include "lldb/Breakpoint/BreakpointOptions.h" 25 #include "lldb/Core/IOHandler.h" 26 #include "lldb/Core/StructuredDataImpl.h" 27 #include "lldb/Interpreter/ScriptInterpreter.h" 28 #include "lldb/lldb-private.h" 29 30 #include <memory> 31 #include <string> 32 #include <vector> 33 34 namespace lldb_private { 35 /// Abstract interface for the Python script interpreter. 36 class ScriptInterpreterPython : public ScriptInterpreter, 37 public IOHandlerDelegateMultiline { 38 public: 39 class CommandDataPython : public BreakpointOptions::CommandData { 40 public: 41 CommandDataPython() : BreakpointOptions::CommandData() { 42 interpreter = lldb::eScriptLanguagePython; 43 } 44 CommandDataPython(StructuredData::ObjectSP extra_args_sp) 45 : BreakpointOptions::CommandData(), 46 m_extra_args(std::move(extra_args_sp)) { 47 interpreter = lldb::eScriptLanguagePython; 48 } 49 StructuredDataImpl m_extra_args; 50 }; 51 52 ScriptInterpreterPython(Debugger &debugger) 53 : ScriptInterpreter(debugger, lldb::eScriptLanguagePython), 54 IOHandlerDelegateMultiline("DONE") {} 55 56 StructuredData::DictionarySP GetInterpreterInfo() override; 57 static void Initialize(); 58 static void Terminate(); 59 static llvm::StringRef GetPluginNameStatic() { return "script-python"; } 60 static llvm::StringRef GetPluginDescriptionStatic(); 61 static FileSpec GetPythonDir(); 62 static void SharedLibraryDirectoryHelper(FileSpec &this_file); 63 64 protected: 65 static void ComputePythonDirForApple(llvm::SmallVectorImpl<char> &path); 66 static void ComputePythonDir(llvm::SmallVectorImpl<char> &path); 67 }; 68 } // namespace lldb_private 69 70 #endif // LLDB_ENABLE_PYTHON 71 #endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H 72