xref: /openbsd-src/gnu/llvm/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h (revision f6aab3d83b51b91c24247ad2c2573574de475a82)
1061da546Spatrick //===-- ScriptInterpreterPython.h -------------------------------*- C++ -*-===//
2061da546Spatrick //
3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information.
5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6061da546Spatrick //
7061da546Spatrick //===----------------------------------------------------------------------===//
8061da546Spatrick 
9061da546Spatrick #ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
10061da546Spatrick #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
11061da546Spatrick 
12061da546Spatrick #include "lldb/Host/Config.h"
13061da546Spatrick 
14061da546Spatrick #if LLDB_ENABLE_PYTHON
15061da546Spatrick 
16061da546Spatrick #include "lldb/Breakpoint/BreakpointOptions.h"
17061da546Spatrick #include "lldb/Core/IOHandler.h"
18061da546Spatrick #include "lldb/Core/StructuredDataImpl.h"
19061da546Spatrick #include "lldb/Interpreter/ScriptInterpreter.h"
20061da546Spatrick #include "lldb/lldb-private.h"
21061da546Spatrick 
22061da546Spatrick #include <memory>
23061da546Spatrick #include <string>
24061da546Spatrick #include <vector>
25061da546Spatrick 
26061da546Spatrick namespace lldb_private {
27061da546Spatrick /// Abstract interface for the Python script interpreter.
28061da546Spatrick class ScriptInterpreterPython : public ScriptInterpreter,
29061da546Spatrick                                 public IOHandlerDelegateMultiline {
30061da546Spatrick public:
31061da546Spatrick   class CommandDataPython : public BreakpointOptions::CommandData {
32061da546Spatrick   public:
CommandDataPython()33061da546Spatrick     CommandDataPython() : BreakpointOptions::CommandData() {
34061da546Spatrick       interpreter = lldb::eScriptLanguagePython;
35061da546Spatrick     }
CommandDataPython(StructuredData::ObjectSP extra_args_sp)36*f6aab3d8Srobert     CommandDataPython(StructuredData::ObjectSP extra_args_sp)
37*f6aab3d8Srobert         : BreakpointOptions::CommandData(),
38*f6aab3d8Srobert           m_extra_args(std::move(extra_args_sp)) {
39061da546Spatrick       interpreter = lldb::eScriptLanguagePython;
40061da546Spatrick     }
41*f6aab3d8Srobert     StructuredDataImpl m_extra_args;
42061da546Spatrick   };
43061da546Spatrick 
ScriptInterpreterPython(Debugger & debugger)44061da546Spatrick   ScriptInterpreterPython(Debugger &debugger)
45061da546Spatrick       : ScriptInterpreter(debugger, lldb::eScriptLanguagePython),
46061da546Spatrick         IOHandlerDelegateMultiline("DONE") {}
47061da546Spatrick 
48*f6aab3d8Srobert   StructuredData::DictionarySP GetInterpreterInfo() override;
49061da546Spatrick   static void Initialize();
50061da546Spatrick   static void Terminate();
GetPluginNameStatic()51*f6aab3d8Srobert   static llvm::StringRef GetPluginNameStatic() { return "script-python"; }
52*f6aab3d8Srobert   static llvm::StringRef GetPluginDescriptionStatic();
53061da546Spatrick   static FileSpec GetPythonDir();
54be691f3bSpatrick   static void SharedLibraryDirectoryHelper(FileSpec &this_file);
55061da546Spatrick 
56061da546Spatrick protected:
57061da546Spatrick   static void ComputePythonDirForApple(llvm::SmallVectorImpl<char> &path);
58061da546Spatrick   static void ComputePythonDir(llvm::SmallVectorImpl<char> &path);
59061da546Spatrick };
60061da546Spatrick } // namespace lldb_private
61061da546Spatrick 
62061da546Spatrick #endif // LLDB_ENABLE_PYTHON
63061da546Spatrick #endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
64