9#include "lldb/Host/Config.h"
27ScriptedPythonInterface::ScriptedPythonInterface(
28 ScriptInterpreterPythonImpl &interpreter)
33ScriptedPythonInterface::ExtractValueFromPythonObject<StructuredData::ArraySP>(
35 python::PythonList result_list(python::PyRefType::Borrowed, p.get());
36 return result_list.CreateStructuredArray();
41ScriptedPythonInterface::ExtractValueFromPythonObject<
43 python::PythonDictionary result_dict(python::PyRefType::Borrowed, p.get());
44 return result_dict.CreateStructuredDictionary();
48Status ScriptedPythonInterface::ExtractValueFromPythonObject<Status>(
51 python::LLDBSWIGPython_CastPyObjectToSBError(p.get())))
52 return m_interpreter.GetStatusFromSBError(*sb_error);
60Event *ScriptedPythonInterface::ExtractValueFromPythonObject<Event *>(
63 python::LLDBSWIGPython_CastPyObjectToSBEvent(p.get())))
64 return m_interpreter.GetOpaqueTypeFromSBEvent(*sb_event);
66 "Couldn't cast lldb::SBEvent to lldb_private::Event.");
73ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StreamSP>(
76 python::LLDBSWIGPython_CastPyObjectToSBStream(p.get())))
77 return m_interpreter.GetOpaqueTypeFromSBStream(*sb_stream);
79 "Couldn't cast lldb::SBStream to lldb_private::Stream.");
86ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StackFrameSP>(
89 python::LLDBSWIGPython_CastPyObjectToSBFrame(p.get())))
90 return m_interpreter.GetOpaqueTypeFromSBFrame(*sb_frame);
92 "Couldn't cast lldb::SBFrame to lldb_private::StackFrame.");
99ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::ThreadSP>(
102 python::LLDBSWIGPython_CastPyObjectToSBThread(p.get())))
103 return m_interpreter.GetOpaqueTypeFromSBThread(*sb_thread);
105 "Couldn't cast lldb::SBThread to lldb_private::Thread.");
112ScriptedPythonInterface::ExtractValueFromPythonObject<SymbolContext>(
116 python::LLDBSWIGPython_CastPyObjectToSBSymbolContext(p.get())))
117 return m_interpreter.GetOpaqueTypeFromSBSymbolContext(*sb_symbol_context);
119 "Couldn't cast lldb::SBSymbolContext to lldb_private::SymbolContext.");
126ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DataExtractorSP>(
129 python::LLDBSWIGPython_CastPyObjectToSBData(p.get()));
133 "Couldn't cast lldb::SBData to lldb::DataExtractorSP.");
137 return m_interpreter.GetDataExtractorFromSBData(*sb_data);
142ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::BreakpointSP>(
145 python::LLDBSWIGPython_CastPyObjectToSBBreakpoint(p.get()));
147 if (!sb_breakpoint) {
149 "Couldn't cast lldb::SBBreakpoint to lldb::BreakpointSP.");
153 return m_interpreter.GetOpaqueTypeFromSBBreakpoint(*sb_breakpoint);
158ScriptedPythonInterface::ExtractValueFromPythonObject<
162 python::LLDBSWIGPython_CastPyObjectToSBBreakpointLocation(p.get()));
166 "Couldn't cast lldb::SBBreakpointLocation to "
167 "lldb::BreakpointLocationSP.");
171 return m_interpreter.GetOpaqueTypeFromSBBreakpointLocation(*sb_break_loc);
178 python::LLDBSWIGPython_CastPyObjectToSBAttachInfo(p.get()));
180 if (!sb_attach_info) {
182 "Couldn't cast lldb::SBAttachInfo to lldb::ProcessAttachInfoSP.");
186 return m_interpreter.GetOpaqueTypeFromSBAttachInfo(*sb_attach_info);
193 python::LLDBSWIGPython_CastPyObjectToSBLaunchInfo(p.get()));
195 if (!sb_launch_info) {
197 "Couldn't cast lldb::SBLaunchInfo to lldb::ProcessLaunchInfoSP.");
201 return m_interpreter.GetOpaqueTypeFromSBLaunchInfo(*sb_launch_info);
205std::optional<MemoryRegionInfo>
206ScriptedPythonInterface::ExtractValueFromPythonObject<
207 std::optional<MemoryRegionInfo>>(python::PythonObject &p,
Status &
error) {
211 python::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(p.get()));
213 if (!sb_mem_reg_info) {
215 "Couldn't cast lldb::SBMemoryRegionInfo to "
216 "lldb_private::MemoryRegionInfo.");
220 return m_interpreter.GetOpaqueTypeFromSBMemoryRegionInfo(*sb_mem_reg_info);
225ScriptedPythonInterface::ExtractValueFromPythonObject<
230 python::LLDBSWIGPython_CastPyObjectToSBExecutionContext(p.get()));
234 "Couldn't cast lldb::SBExecutionContext to "
235 "lldb::ExecutionContextRefSP.");
239 return m_interpreter.GetOpaqueTypeFromSBExecutionContext(*sb_exe_ctx);
244ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DescriptionLevel>(
247 llvm::Expected<unsigned long long> unsigned_or_err = p.AsUnsignedLongLong();
248 if (!unsigned_or_err) {
252 unsigned long long unsigned_val = *unsigned_or_err;
254 error =
Status(
"value too large for lldb::DescriptionLevel.");
262ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StackFrameListSP>(
266 python::LLDBSWIGPython_CastPyObjectToSBFrameList(p.get()));
268 if (!sb_frame_list) {
270 "couldn't cast lldb::SBFrameList to lldb::StackFrameListSP.");
274 return m_interpreter.GetOpaqueTypeFromSBFrameList(*sb_frame_list);
279ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::ValueObjectSP>(
282 python::LLDBSWIGPython_CastPyObjectToSBValue(p.get()));
285 "couldn't cast lldb::SBValue to lldb::ValueObjectSP");
289 return m_interpreter.GetOpaqueTypeFromSBValue(*sb_value);
294ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::ValueObjectListSP>(
297 python::LLDBSWIGPython_CastPyObjectToSBValueList(p.get()));
299 if (!sb_value_list) {
301 "couldn't cast lldb::SBValueList to lldb::ValueObjectListSP");
306 for (uint32_t i = 0, e = sb_value_list->
GetSize(); i < e; ++i) {
308 out->Append(m_interpreter.GetOpaqueTypeFromSBValue(value));
static llvm::raw_ostream & error(Stream &strm)
lldb::SBValue GetValueAtIndex(uint32_t index)
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::ValueObject > ValueObjectSP
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::ValueObjectList > ValueObjectListSP
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