xref: /src/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h (revision 0eae32dcef82f6f06de6419a0d623d7def0cc8f6)
1f034231aSEd Maste //===-- ScriptInterpreterPython.h -------------------------------*- C++ -*-===//
2f034231aSEd Maste //
35f29bb8aSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45f29bb8aSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
55f29bb8aSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6f034231aSEd Maste //
7f034231aSEd Maste //===----------------------------------------------------------------------===//
8f034231aSEd Maste 
9e81d9d49SDimitry Andric #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
10e81d9d49SDimitry Andric #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
11f034231aSEd Maste 
12706b4fc4SDimitry Andric #include "lldb/Host/Config.h"
13f034231aSEd Maste 
14706b4fc4SDimitry Andric #if LLDB_ENABLE_PYTHON
15f034231aSEd Maste 
165f29bb8aSDimitry Andric #include "lldb/Breakpoint/BreakpointOptions.h"
175f29bb8aSDimitry Andric #include "lldb/Core/IOHandler.h"
18706b4fc4SDimitry Andric #include "lldb/Core/StructuredDataImpl.h"
195f29bb8aSDimitry Andric #include "lldb/Interpreter/ScriptInterpreter.h"
205f29bb8aSDimitry Andric #include "lldb/lldb-private.h"
215f29bb8aSDimitry Andric 
22e81d9d49SDimitry Andric #include <memory>
23e81d9d49SDimitry Andric #include <string>
24e81d9d49SDimitry Andric #include <vector>
25e81d9d49SDimitry Andric 
26f034231aSEd Maste namespace lldb_private {
275f29bb8aSDimitry Andric /// Abstract interface for the Python script interpreter.
2814f1b3e8SDimitry Andric class ScriptInterpreterPython : public ScriptInterpreter,
2914f1b3e8SDimitry Andric                                 public IOHandlerDelegateMultiline {
30f034231aSEd Maste public:
3114f1b3e8SDimitry Andric   class CommandDataPython : public BreakpointOptions::CommandData {
3214f1b3e8SDimitry Andric   public:
CommandDataPython()3314f1b3e8SDimitry Andric     CommandDataPython() : BreakpointOptions::CommandData() {
3414f1b3e8SDimitry Andric       interpreter = lldb::eScriptLanguagePython;
3514f1b3e8SDimitry Andric     }
CommandDataPython(StructuredData::ObjectSP extra_args_sp)3677fc4c14SDimitry Andric     CommandDataPython(StructuredData::ObjectSP extra_args_sp)
3777fc4c14SDimitry Andric         : BreakpointOptions::CommandData(),
3877fc4c14SDimitry Andric           m_extra_args(std::move(extra_args_sp)) {
39706b4fc4SDimitry Andric       interpreter = lldb::eScriptLanguagePython;
40706b4fc4SDimitry Andric     }
4177fc4c14SDimitry Andric     StructuredDataImpl m_extra_args;
4214f1b3e8SDimitry Andric   };
4314f1b3e8SDimitry Andric 
ScriptInterpreterPython(Debugger & debugger)445f29bb8aSDimitry Andric   ScriptInterpreterPython(Debugger &debugger)
455f29bb8aSDimitry Andric       : ScriptInterpreter(debugger, lldb::eScriptLanguagePython),
465f29bb8aSDimitry Andric         IOHandlerDelegateMultiline("DONE") {}
47866dcdacSEd Maste 
48c0981da4SDimitry Andric   StructuredData::DictionarySP GetInterpreterInfo() override;
4914f1b3e8SDimitry Andric   static void Initialize();
5014f1b3e8SDimitry Andric   static void Terminate();
GetPluginNameStatic()51c0981da4SDimitry Andric   static llvm::StringRef GetPluginNameStatic() { return "script-python"; }
52c0981da4SDimitry Andric   static llvm::StringRef GetPluginDescriptionStatic();
53f73363f1SDimitry Andric   static FileSpec GetPythonDir();
54344a3780SDimitry Andric   static void SharedLibraryDirectoryHelper(FileSpec &this_file);
55f73363f1SDimitry Andric 
560cac4ca3SEd Maste protected:
57f73363f1SDimitry Andric   static void ComputePythonDirForApple(llvm::SmallVectorImpl<char> &path);
58ead24645SDimitry Andric   static void ComputePythonDir(llvm::SmallVectorImpl<char> &path);
59f034231aSEd Maste };
60f034231aSEd Maste } // namespace lldb_private
61f034231aSEd Maste 
62706b4fc4SDimitry Andric #endif // LLDB_ENABLE_PYTHON
63e81d9d49SDimitry Andric #endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
64