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<lldb::ThreadSP>(
101 python::LLDBSWIGPython_CastPyObjectToSBThread(p.get())))
102 return m_interpreter.GetOpaqueTypeFromSBThread(*sb_thread);
104 "Couldn't cast lldb::SBThread to lldb_private::Thread.");
111ScriptedPythonInterface::ExtractValueFromPythonObject<SymbolContext>(
115 python::LLDBSWIGPython_CastPyObjectToSBSymbolContext(p.get())))
116 return m_interpreter.GetOpaqueTypeFromSBSymbolContext(*sb_symbol_context);
118 "Couldn't cast lldb::SBSymbolContext to lldb_private::SymbolContext.");
125ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DataExtractorSP>(
128 python::LLDBSWIGPython_CastPyObjectToSBData(p.get()));
132 "Couldn't cast lldb::SBData to lldb::DataExtractorSP.");
136 return m_interpreter.GetDataExtractorFromSBData(*sb_data);
141ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::BreakpointSP>(
144 python::LLDBSWIGPython_CastPyObjectToSBBreakpoint(p.get()));
146 if (!sb_breakpoint) {
148 "Couldn't cast lldb::SBBreakpoint to lldb::BreakpointSP.");
152 return m_interpreter.GetOpaqueTypeFromSBBreakpoint(*sb_breakpoint);
157ScriptedPythonInterface::ExtractValueFromPythonObject<
161 python::LLDBSWIGPython_CastPyObjectToSBBreakpointLocation(p.get()));
165 "Couldn't cast lldb::SBBreakpointLocation to "
166 "lldb::BreakpointLocationSP.");
170 return m_interpreter.GetOpaqueTypeFromSBBreakpointLocation(*sb_break_loc);
177 python::LLDBSWIGPython_CastPyObjectToSBAttachInfo(p.get()));
179 if (!sb_attach_info) {
181 "Couldn't cast lldb::SBAttachInfo to lldb::ProcessAttachInfoSP.");
185 return m_interpreter.GetOpaqueTypeFromSBAttachInfo(*sb_attach_info);
192 python::LLDBSWIGPython_CastPyObjectToSBLaunchInfo(p.get()));
194 if (!sb_launch_info) {
196 "Couldn't cast lldb::SBLaunchInfo to lldb::ProcessLaunchInfoSP.");
200 return m_interpreter.GetOpaqueTypeFromSBLaunchInfo(*sb_launch_info);
204std::optional<MemoryRegionInfo>
205ScriptedPythonInterface::ExtractValueFromPythonObject<
206 std::optional<MemoryRegionInfo>>(python::PythonObject &p,
Status &
error) {
210 python::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(p.get()));
212 if (!sb_mem_reg_info) {
214 "Couldn't cast lldb::SBMemoryRegionInfo to "
215 "lldb_private::MemoryRegionInfo.");
219 return m_interpreter.GetOpaqueTypeFromSBMemoryRegionInfo(*sb_mem_reg_info);
224ScriptedPythonInterface::ExtractValueFromPythonObject<
229 python::LLDBSWIGPython_CastPyObjectToSBExecutionContext(p.get()));
233 "Couldn't cast lldb::SBExecutionContext to "
234 "lldb::ExecutionContextRefSP.");
238 return m_interpreter.GetOpaqueTypeFromSBExecutionContext(*sb_exe_ctx);
243ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DescriptionLevel>(
246 llvm::Expected<unsigned long long> unsigned_or_err = p.AsUnsignedLongLong();
247 if (!unsigned_or_err) {
251 unsigned long long unsigned_val = *unsigned_or_err;
253 error =
Status(
"value too large for lldb::DescriptionLevel.");
261ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StackFrameListSP>(
265 python::LLDBSWIGPython_CastPyObjectToSBFrameList(p.get()));
267 if (!sb_frame_list) {
269 "couldn't cast lldb::SBFrameList to lldb::StackFrameListSP.");
273 return m_interpreter.GetOpaqueTypeFromSBFrameList(*sb_frame_list);
static llvm::raw_ostream & error(Stream &strm)
Represents a list of SBFrame objects.
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::Thread > ThreadSP
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::StackFrameList > StackFrameListSP
std::shared_ptr< lldb_private::ExecutionContextRef > ExecutionContextRefSP