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_SCRIPTEDPROCESSPYTHONINTERFACE_H
10 #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSPYTHONINTERFACE_H
11 
12 #include "lldb/Host/Config.h"
13 
14 #if LLDB_ENABLE_PYTHON
15 
16 #include "lldb/Interpreter/ScriptedProcessInterface.h"
17 
18 namespace lldb_private {
19 class ScriptInterpreterPythonImpl;
20 class ScriptedProcessPythonInterface : public ScriptedProcessInterface {
21 public:
22   ScriptedProcessPythonInterface(ScriptInterpreterPythonImpl &interpreter)
23       : ScriptedProcessInterface(), m_interpreter(interpreter) {}
24 
25   StructuredData::GenericSP
26   CreatePluginObject(const llvm::StringRef class_name, lldb::TargetSP target_sp,
27                      StructuredData::DictionarySP args_sp) override;
28 
29   Status Launch() override;
30 
31   Status Resume() override;
32 
33   bool ShouldStop() override;
34 
35   Status Stop() override;
36 
37   lldb::MemoryRegionInfoSP
38   GetMemoryRegionContainingAddress(lldb::addr_t address) override;
39 
40   StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) override;
41 
42   StructuredData::DictionarySP GetRegistersForThread(lldb::tid_t tid) override;
43 
44   lldb::DataExtractorSP ReadMemoryAtAddress(lldb::addr_t address, size_t size,
45                                             Status &error) override;
46 
47   StructuredData::DictionarySP GetLoadedImages() override;
48 
49   lldb::pid_t GetProcessID() override;
50 
51   bool IsAlive() override;
52 
53 protected:
54   llvm::Optional<unsigned long long>
55   GetGenericInteger(llvm::StringRef method_name);
56   Status GetStatusFromMethod(llvm::StringRef method_name);
57 
58 private:
59   // The lifetime is managed by the ScriptInterpreter
60   ScriptInterpreterPythonImpl &m_interpreter;
61   StructuredData::GenericSP m_object_instance_sp;
62 };
63 } // namespace lldb_private
64 
65 #endif // LLDB_ENABLE_PYTHON
66 #endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSPYTHONINTERFACE_H
67