9#include "lldb/Host/Config.h"
16#include "../lldb-python.h"
18#include "../ScriptInterpreterPythonImpl.h"
25ScriptedPythonInterface::ScriptedPythonInterface(
26 ScriptInterpreterPythonImpl &interpreter)
31ScriptedPythonInterface::ExtractValueFromPythonObject<StructuredData::ArraySP>(
33 python::PythonList result_list(python::PyRefType::Borrowed, p.get());
34 return result_list.CreateStructuredArray();
39ScriptedPythonInterface::ExtractValueFromPythonObject<
41 python::PythonDictionary result_dict(python::PyRefType::Borrowed, p.get());
42 return result_dict.CreateStructuredDictionary();
46Status ScriptedPythonInterface::ExtractValueFromPythonObject<Status>(
49 python::LLDBSWIGPython_CastPyObjectToSBError(p.get())))
50 return m_interpreter.GetStatusFromSBError(*sb_error);
52 error.SetErrorString(
"Couldn't cast lldb::SBError to lldb::Status.");
59ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DataExtractorSP>(
62 python::LLDBSWIGPython_CastPyObjectToSBData(p.get()));
66 "Couldn't cast lldb::SBData to lldb::DataExtractorSP.");
70 return m_interpreter.GetDataExtractorFromSBData(*sb_data);
75ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::BreakpointSP>(
78 python::LLDBSWIGPython_CastPyObjectToSBBreakpoint(p.get()));
82 "Couldn't cast lldb::SBBreakpoint to lldb::BreakpointSP.");
86 return m_interpreter.GetOpaqueTypeFromSBBreakpoint(*sb_breakpoint);
93 python::LLDBSWIGPython_CastPyObjectToSBAttachInfo(p.get()));
95 if (!sb_attach_info) {
97 "Couldn't cast lldb::SBAttachInfo to lldb::ProcessAttachInfoSP.");
101 return m_interpreter.GetOpaqueTypeFromSBAttachInfo(*sb_attach_info);
108 python::LLDBSWIGPython_CastPyObjectToSBLaunchInfo(p.get()));
110 if (!sb_launch_info) {
111 error.SetErrorString(
112 "Couldn't cast lldb::SBLaunchInfo to lldb::ProcessLaunchInfoSP.");
116 return m_interpreter.GetOpaqueTypeFromSBLaunchInfo(*sb_launch_info);
120std::optional<MemoryRegionInfo>
121ScriptedPythonInterface::ExtractValueFromPythonObject<
122 std::optional<MemoryRegionInfo>>(python::PythonObject &p,
Status &
error) {
126 python::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(p.get()));
128 if (!sb_mem_reg_info) {
129 error.SetErrorString(
130 "Couldn't cast lldb::SBMemoryRegionInfo to lldb::MemoryRegionInfoSP.");
134 return m_interpreter.GetOpaqueTypeFromSBMemoryRegionInfo(*sb_mem_reg_info);
static llvm::raw_ostream & error(Stream &strm)
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Array > ArraySP
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ProcessAttachInfo > ProcessAttachInfoSP
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::ProcessLaunchInfo > ProcessLaunchInfoSP