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