1 //===-- ScriptedProcessPythonInterface.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_INTERFACES_SCRIPTEDPROCESSPYTHONINTERFACE_H
10 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPROCESSPYTHONINTERFACE_H
11 
12 #include "lldb/Host/Config.h"
13 #include "lldb/Interpreter/Interfaces/ScriptedProcessInterface.h"
14 
15 #if LLDB_ENABLE_PYTHON
16 
17 #include "ScriptedPythonInterface.h"
18 
19 #include <optional>
20 
21 namespace lldb_private {
22 class ScriptedProcessPythonInterface : public ScriptedProcessInterface,
23                                        public ScriptedPythonInterface,
24                                        public PluginInterface {
25 public:
26   ScriptedProcessPythonInterface(ScriptInterpreterPythonImpl &interpreter);
27 
28   llvm::Expected<StructuredData::GenericSP>
29   CreatePluginObject(const llvm::StringRef class_name,
30                      ExecutionContext &exe_ctx,
31                      StructuredData::DictionarySP args_sp,
32                      StructuredData::Generic *script_obj = nullptr) override;
33 
34   llvm::SmallVector<AbstractMethodRequirement>
35   GetAbstractMethodRequirements() const override {
36     return llvm::SmallVector<AbstractMethodRequirement>(
37         {{"read_memory_at_address", 4},
38          {"is_alive"},
39          {"get_scripted_thread_plugin"}});
40   }
41 
42   StructuredData::DictionarySP GetCapabilities() override;
43 
44   Status Attach(const ProcessAttachInfo &attach_info) override;
45 
46   Status Launch() override;
47 
48   Status Resume() override;
49 
50   std::optional<MemoryRegionInfo>
51   GetMemoryRegionContainingAddress(lldb::addr_t address,
52                                    Status &error) override;
53 
54   StructuredData::DictionarySP GetThreadsInfo() override;
55 
56   bool CreateBreakpoint(lldb::addr_t addr, Status &error) override;
57 
58   lldb::DataExtractorSP ReadMemoryAtAddress(lldb::addr_t address, size_t size,
59                                             Status &error) override;
60 
61   lldb::offset_t WriteMemoryAtAddress(lldb::addr_t addr,
62                                       lldb::DataExtractorSP data_sp,
63                                       Status &error) override;
64 
65   StructuredData::ArraySP GetLoadedImages() override;
66 
67   lldb::pid_t GetProcessID() override;
68 
69   bool IsAlive() override;
70 
71   std::optional<std::string> GetScriptedThreadPluginName() override;
72 
73   StructuredData::DictionarySP GetMetadata() override;
74 
75   static void Initialize();
76 
77   static void Terminate();
78 
79   static llvm::StringRef GetPluginNameStatic() {
80     return "ScriptedProcessPythonInterface";
81   }
82 
83   llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
84 
85 private:
86   lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() override;
87 };
88 } // namespace lldb_private
89 
90 #endif // LLDB_ENABLE_PYTHON
91 #endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPROCESSPYTHONINTERFACE_H
92