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 #include "lldb/Host/Config.h" 13 14 #if LLDB_ENABLE_PYTHON 15 16 #include "lldb/Breakpoint/BreakpointOptions.h" 17 #include "lldb/Core/IOHandler.h" 18 #include "lldb/Core/StructuredDataImpl.h" 19 #include "lldb/Interpreter/ScriptInterpreter.h" 20 #include "lldb/lldb-private.h" 21 22 #include <memory> 23 #include <string> 24 #include <vector> 25 26 namespace lldb_private { 27 /// Abstract interface for the Python script interpreter. 28 class ScriptInterpreterPython : public ScriptInterpreter, 29 public IOHandlerDelegateMultiline { 30 public: 31 class CommandDataPython : public BreakpointOptions::CommandData { 32 public: CommandDataPython()33 CommandDataPython() : BreakpointOptions::CommandData() { 34 interpreter = lldb::eScriptLanguagePython; 35 } CommandDataPython(StructuredData::ObjectSP extra_args_sp)36 CommandDataPython(StructuredData::ObjectSP extra_args_sp) : 37 BreakpointOptions::CommandData(), 38 m_extra_args_up(new StructuredDataImpl()) { 39 interpreter = lldb::eScriptLanguagePython; 40 m_extra_args_up->SetObjectSP(extra_args_sp); 41 } 42 lldb::StructuredDataImplUP m_extra_args_up; 43 }; 44 ScriptInterpreterPython(Debugger & debugger)45 ScriptInterpreterPython(Debugger &debugger) 46 : ScriptInterpreter(debugger, lldb::eScriptLanguagePython), 47 IOHandlerDelegateMultiline("DONE") {} 48 49 static void Initialize(); 50 static void Terminate(); 51 static lldb_private::ConstString GetPluginNameStatic(); 52 static const char *GetPluginDescriptionStatic(); 53 static FileSpec GetPythonDir(); 54 55 protected: 56 static void ComputePythonDirForApple(llvm::SmallVectorImpl<char> &path); 57 static void ComputePythonDir(llvm::SmallVectorImpl<char> &path); 58 }; 59 } // namespace lldb_private 60 61 #endif // LLDB_ENABLE_PYTHON 62 #endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H 63