9#include "lldb/Host/Config.h"
12#include "../lldb-python.h"
21#include "../SWIGPythonBridge.h"
22#include "../ScriptInterpreterPythonImpl.h"
30using Locker = ScriptInterpreterPythonImpl::Locker;
32ScriptedProcessPythonInterface::ScriptedProcessPythonInterface(
33 ScriptInterpreterPythonImpl &interpreter)
36llvm::Expected<StructuredData::GenericSP>
37ScriptedProcessPythonInterface::CreatePluginObject(
41 std::make_shared<ExecutionContextRef>(exe_ctx);
43 return ScriptedPythonInterface::CreatePluginObject(class_name, script_obj,
44 exe_ctx_ref_sp, sd_impl);
50 Dispatch<StructuredData::DictionarySP>(
"get_capabilities",
error);
52 if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict,
error))
61 std::make_shared<ProcessAttachInfo>(attach_info);
62 return GetStatusFromMethod(
"attach", attach_info_sp);
65Status ScriptedProcessPythonInterface::Launch() {
66 return GetStatusFromMethod(
"launch");
69Status ScriptedProcessPythonInterface::Resume() {
71 return GetStatusFromMethod(
"resume",
true);
74std::optional<MemoryRegionInfo>
75ScriptedProcessPythonInterface::GetMemoryRegionContainingAddress(
77 auto mem_region = Dispatch<std::optional<MemoryRegionInfo>>(
78 "get_memory_region_containing_address",
error, address);
81 return ErrorWithMessage<MemoryRegionInfo>(LLVM_PRETTY_FUNCTION,
91 Dispatch<StructuredData::DictionarySP>(
"get_threads_info",
error);
93 if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict,
error))
99bool ScriptedProcessPythonInterface::CreateBreakpoint(
lldb::addr_t addr,
103 Dispatch(
"create_breakpoint", py_error, addr,
error);
109 if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,
error))
112 return obj->GetBooleanValue();
119 "read_memory_at_address", py_error, address, size,
error);
128lldb::offset_t ScriptedProcessPythonInterface::WriteMemoryAtAddress(
132 Dispatch(
"write_memory_at_address", py_error, addr, data_sp,
error);
134 if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,
error))
147 Dispatch<StructuredData::ArraySP>(
"get_loaded_images",
error);
149 if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, array,
error))
155lldb::pid_t ScriptedProcessPythonInterface::GetProcessID() {
159 if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,
error))
165bool ScriptedProcessPythonInterface::IsAlive() {
169 if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,
error))
172 return obj->GetBooleanValue();
175std::optional<std::string>
176ScriptedProcessPythonInterface::GetScriptedThreadPluginName() {
180 if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,
error))
183 return obj->GetStringValue().str();
187ScriptedProcessPythonInterface::CreateScriptedThreadInterface() {
188 return m_interpreter.CreateScriptedThreadInterface();
194 Dispatch<StructuredData::DictionarySP>(
"get_process_metadata",
error);
196 if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict,
error))
static llvm::raw_ostream & error(Stream &strm)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
bool Fail() const
Test for error condition.
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
std::shared_ptr< Array > ArraySP
#define LLDB_INVALID_OFFSET
#define LLDB_INVALID_PROCESS_ID
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ProcessAttachInfo > ProcessAttachInfoSP
std::shared_ptr< lldb_private::ScriptedThreadInterface > ScriptedThreadInterfaceSP
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::ExecutionContextRef > ExecutionContextRefSP