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);
51 error.SetErrorString(
"Couldn't cast lldb::SBError to lldb::Status.");
57Event *ScriptedPythonInterface::ExtractValueFromPythonObject<Event *>(
60 python::LLDBSWIGPython_CastPyObjectToSBEvent(p.get())))
61 return m_interpreter.GetOpaqueTypeFromSBEvent(*sb_event);
62 error.SetErrorString(
"Couldn't cast lldb::SBEvent to lldb_private::Event.");
69ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StreamSP>(
72 python::LLDBSWIGPython_CastPyObjectToSBStream(p.get())))
73 return m_interpreter.GetOpaqueTypeFromSBStream(*sb_stream);
74 error.SetErrorString(
"Couldn't cast lldb::SBStream to lldb_private::Stream.");
81ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DataExtractorSP>(
84 python::LLDBSWIGPython_CastPyObjectToSBData(p.get()));
88 "Couldn't cast lldb::SBData to lldb::DataExtractorSP.");
92 return m_interpreter.GetDataExtractorFromSBData(*sb_data);
97ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::BreakpointSP>(
100 python::LLDBSWIGPython_CastPyObjectToSBBreakpoint(p.get()));
102 if (!sb_breakpoint) {
103 error.SetErrorString(
104 "Couldn't cast lldb::SBBreakpoint to lldb::BreakpointSP.");
108 return m_interpreter.GetOpaqueTypeFromSBBreakpoint(*sb_breakpoint);
115 python::LLDBSWIGPython_CastPyObjectToSBAttachInfo(p.get()));
117 if (!sb_attach_info) {
118 error.SetErrorString(
119 "Couldn't cast lldb::SBAttachInfo to lldb::ProcessAttachInfoSP.");
123 return m_interpreter.GetOpaqueTypeFromSBAttachInfo(*sb_attach_info);
130 python::LLDBSWIGPython_CastPyObjectToSBLaunchInfo(p.get()));
132 if (!sb_launch_info) {
133 error.SetErrorString(
134 "Couldn't cast lldb::SBLaunchInfo to lldb::ProcessLaunchInfoSP.");
138 return m_interpreter.GetOpaqueTypeFromSBLaunchInfo(*sb_launch_info);
142std::optional<MemoryRegionInfo>
143ScriptedPythonInterface::ExtractValueFromPythonObject<
144 std::optional<MemoryRegionInfo>>(python::PythonObject &p,
Status &
error) {
148 python::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(p.get()));
150 if (!sb_mem_reg_info) {
151 error.SetErrorString(
152 "Couldn't cast lldb::SBMemoryRegionInfo to lldb::MemoryRegionInfoSP.");
156 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::Stream > StreamSP
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::ProcessLaunchInfo > ProcessLaunchInfoSP