9#include "lldb/Host/Config.h"
26ScriptedPythonInterface::ScriptedPythonInterface(
27 ScriptInterpreterPythonImpl &interpreter)
32ScriptedPythonInterface::ExtractValueFromPythonObject<StructuredData::ArraySP>(
34 python::PythonList result_list(python::PyRefType::Borrowed, p.get());
35 return result_list.CreateStructuredArray();
40ScriptedPythonInterface::ExtractValueFromPythonObject<
42 python::PythonDictionary result_dict(python::PyRefType::Borrowed, p.get());
43 return result_dict.CreateStructuredDictionary();
47Status ScriptedPythonInterface::ExtractValueFromPythonObject<Status>(
50 python::LLDBSWIGPython_CastPyObjectToSBError(p.get())))
51 return m_interpreter.GetStatusFromSBError(*sb_error);
59Event *ScriptedPythonInterface::ExtractValueFromPythonObject<Event *>(
62 python::LLDBSWIGPython_CastPyObjectToSBEvent(p.get())))
63 return m_interpreter.GetOpaqueTypeFromSBEvent(*sb_event);
65 "Couldn't cast lldb::SBEvent to lldb_private::Event.");
72ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StreamSP>(
75 python::LLDBSWIGPython_CastPyObjectToSBStream(p.get())))
76 return m_interpreter.GetOpaqueTypeFromSBStream(*sb_stream);
78 "Couldn't cast lldb::SBStream to lldb_private::Stream.");
85ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StackFrameSP>(
88 python::LLDBSWIGPython_CastPyObjectToSBFrame(p.get())))
89 return m_interpreter.GetOpaqueTypeFromSBFrame(*sb_frame);
91 "Couldn't cast lldb::SBFrame to lldb_private::StackFrame.");
98ScriptedPythonInterface::ExtractValueFromPythonObject<SymbolContext>(
102 python::LLDBSWIGPython_CastPyObjectToSBSymbolContext(p.get())))
103 return m_interpreter.GetOpaqueTypeFromSBSymbolContext(*sb_symbol_context);
105 "Couldn't cast lldb::SBSymbolContext to lldb_private::SymbolContext.");
112ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DataExtractorSP>(
115 python::LLDBSWIGPython_CastPyObjectToSBData(p.get()));
119 "Couldn't cast lldb::SBData to lldb::DataExtractorSP.");
123 return m_interpreter.GetDataExtractorFromSBData(*sb_data);
128ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::BreakpointSP>(
131 python::LLDBSWIGPython_CastPyObjectToSBBreakpoint(p.get()));
133 if (!sb_breakpoint) {
135 "Couldn't cast lldb::SBBreakpoint to lldb::BreakpointSP.");
139 return m_interpreter.GetOpaqueTypeFromSBBreakpoint(*sb_breakpoint);
144ScriptedPythonInterface::ExtractValueFromPythonObject<
148 python::LLDBSWIGPython_CastPyObjectToSBBreakpointLocation(p.get()));
152 "Couldn't cast lldb::SBBreakpointLocation to "
153 "lldb::BreakpointLocationSP.");
157 return m_interpreter.GetOpaqueTypeFromSBBreakpointLocation(*sb_break_loc);
164 python::LLDBSWIGPython_CastPyObjectToSBAttachInfo(p.get()));
166 if (!sb_attach_info) {
168 "Couldn't cast lldb::SBAttachInfo to lldb::ProcessAttachInfoSP.");
172 return m_interpreter.GetOpaqueTypeFromSBAttachInfo(*sb_attach_info);
179 python::LLDBSWIGPython_CastPyObjectToSBLaunchInfo(p.get()));
181 if (!sb_launch_info) {
183 "Couldn't cast lldb::SBLaunchInfo to lldb::ProcessLaunchInfoSP.");
187 return m_interpreter.GetOpaqueTypeFromSBLaunchInfo(*sb_launch_info);
191std::optional<MemoryRegionInfo>
192ScriptedPythonInterface::ExtractValueFromPythonObject<
193 std::optional<MemoryRegionInfo>>(python::PythonObject &p,
Status &
error) {
197 python::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(p.get()));
199 if (!sb_mem_reg_info) {
201 "Couldn't cast lldb::SBMemoryRegionInfo to "
202 "lldb_private::MemoryRegionInfo.");
206 return m_interpreter.GetOpaqueTypeFromSBMemoryRegionInfo(*sb_mem_reg_info);
211ScriptedPythonInterface::ExtractValueFromPythonObject<
216 python::LLDBSWIGPython_CastPyObjectToSBExecutionContext(p.get()));
220 "Couldn't cast lldb::SBExecutionContext to "
221 "lldb::ExecutionContextRefSP.");
225 return m_interpreter.GetOpaqueTypeFromSBExecutionContext(*sb_exe_ctx);
230ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DescriptionLevel>(
233 llvm::Expected<unsigned long long> unsigned_or_err = p.AsUnsignedLongLong();
234 if (!unsigned_or_err) {
238 unsigned long long unsigned_val = *unsigned_or_err;
240 error =
Status(
"value too large for lldb::DescriptionLevel.");
static llvm::raw_ostream & error(Stream &strm)
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Array > ArraySP
Defines a symbol context baton that can be handed other debug core functions.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
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
std::shared_ptr< lldb_private::ExecutionContextRef > ExecutionContextRefSP