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