14#include "lldb/Host/Config.h"
32llvm::Expected<StructuredData::ArraySP>
36 return result_list.CreateStructuredArray();
40llvm::Expected<StructuredData::DictionarySP>
44 return result_dict.CreateStructuredDictionary();
54 return llvm::createStringError(
"couldn't cast lldb::SBError to lldb::Status");
58llvm::Expected<Event *>
64 return llvm::createStringError(
65 "couldn't cast lldb::SBEvent to lldb_private::Event");
69llvm::Expected<CommandReturnObject *>
77 return llvm::createStringError(
"couldn't cast lldb::SBCommandReturnObject to "
78 "lldb_private::CommandReturnObject");
82llvm::Expected<lldb::StreamSP>
88 return llvm::createStringError(
89 "couldn't cast lldb::SBStream to lldb_private::Stream");
93llvm::Expected<lldb::StackFrameSP>
99 return llvm::createStringError(
100 "couldn't cast lldb::SBFrame to lldb_private::StackFrame");
104llvm::Expected<lldb::ThreadSP>
110 return llvm::createStringError(
111 "couldn't cast lldb::SBThread to lldb_private::Thread");
115llvm::Expected<SymbolContext>
122 return llvm::createStringError(
123 "couldn't cast lldb::SBSymbolContext to lldb_private::SymbolContext");
127llvm::Expected<lldb::DataExtractorSP>
134 return llvm::createStringError(
135 "couldn't cast lldb::SBData to lldb::DataExtractorSP");
142llvm::Expected<lldb::BreakpointSP>
148 if (!sb_breakpoint) {
149 return llvm::createStringError(
150 "couldn't cast lldb::SBBreakpoint to lldb::BreakpointSP");
157llvm::Expected<lldb::BreakpointLocationSP>
165 return llvm::createStringError(
166 "couldn't cast lldb::SBBreakpointLocation to "
167 "lldb::BreakpointLocationSP");
174llvm::Expected<lldb::ProcessAttachInfoSP>
180 if (!sb_attach_info) {
181 return llvm::createStringError(
182 "couldn't cast lldb::SBAttachInfo to lldb::ProcessAttachInfoSP");
189llvm::Expected<lldb::ProcessLaunchInfoSP>
195 if (!sb_launch_info) {
196 return llvm::createStringError(
197 "couldn't cast lldb::SBLaunchInfo to lldb::ProcessLaunchInfoSP");
204llvm::Expected<lldb::ThreadPlanSP>
210 if (!sb_thread_plan) {
211 return llvm::createStringError(
212 "couldn't cast lldb::SBThreadPlan to lldb::ThreadPlanSP");
219llvm::Expected<std::optional<MemoryRegionInfo>>
227 if (!sb_mem_reg_info) {
228 return llvm::createStringError(
"couldn't cast lldb::SBMemoryRegionInfo to "
229 "lldb_private::MemoryRegionInfo");
236llvm::Expected<lldb::ExecutionContextRefSP>
245 return llvm::createStringError(
"couldn't cast lldb::SBExecutionContext to "
246 "lldb::ExecutionContextRefSP");
253llvm::Expected<lldb::DescriptionLevel>
257 if (!unsigned_or_err)
258 return unsigned_or_err.takeError();
259 unsigned long long unsigned_val = *unsigned_or_err;
261 return llvm::createStringError(
262 "value too large for lldb::DescriptionLevel");
267llvm::Expected<lldb::StepType>
271 if (!unsigned_or_err)
272 return unsigned_or_err.takeError();
273 unsigned long long unsigned_val = *unsigned_or_err;
275 return llvm::createStringError(
"value too large for lldb::StepType");
280llvm::Expected<lldb::StackFrameListSP>
287 if (!sb_frame_list) {
288 return llvm::createStringError(
289 "couldn't cast lldb::SBFrameList to lldb::StackFrameListSP");
296llvm::Expected<lldb::ValueObjectSP>
302 return llvm::createStringError(
303 "couldn't cast lldb::SBValue to lldb::ValueObjectSP");
310llvm::Expected<lldb::TargetSP>
316 return llvm::createStringError(
317 "couldn't cast lldb::SBTarget to lldb::TargetSP");
324llvm::Expected<lldb::ValueObjectListSP>
334 for (uint32_t i = 0, e = sb_value_list->GetSize(); i < e; ++i) {
335 SBValue value = sb_value_list->GetValueAtIndex(i);
350 llvm::Error extract_error = llvm::Error::success();
352 const size_t item_index = index++;
358 llvm::joinErrors(std::move(extract_error),
359 llvm::createStringError(llvm::formatv(
360 "ValueObjectList item at index {0} is not a "
361 "StructuredData::Generic",
367 static_cast<PyObject *
>(generic->GetValue())));
370 out->Append(valobj_sp);
374 return std::move(extract_error);
378 return llvm::createStringError(
379 "couldn't extract ValueObjectList from Python return value");
383llvm::Expected<std::optional<lldb::ValueType>>
391 return val.takeError();
392 unsigned long long unmasked = *val & ~kValueTypeFlagsMask;
395 return llvm::createStringError(llvm::formatv(
396 "value type invalid or too large (got {0} | {1:x})", unmasked, flags));
398 return static_cast<ValueType>(unmasked | flags);
402llvm::Expected<lldb::DebuggerSP>
408 return llvm::createStringError(
409 "couldn't cast lldb::SBDebugger to lldb::DebuggerSP");
413llvm::Expected<std::vector<std::string>>
416 std::vector<std::string> result;
418 if (!list.IsValid()) {
419 return llvm::createStringError(
420 "couldn't extract std::vector<std::string>: not a Python list");
423 const uint32_t size = list.GetSize();
424 result.reserve(size);
425 for (uint32_t i = 0; i < size; ++i) {
427 list.GetItemAtIndex(i).get());
430 result.push_back(item.GetString().str());
static SymbolContext GetSymbolContext(const lldb::SBSymbolContext &sym_ctx)
static lldb::DataExtractorSP GetDataExtractor(const lldb::SBData &data)
static lldb::BreakpointLocationSP GetBreakpointLocation(const lldb::SBBreakpointLocation &break_loc)
static lldb::ProcessLaunchInfoSP GetProcessLaunchInfo(const lldb::SBLaunchInfo &launch_info)
static CommandReturnObject * GetCommandReturnObject(const lldb::SBCommandReturnObject &cmd_retobj)
static lldb::BreakpointSP GetBreakpoint(const lldb::SBBreakpoint &breakpoint)
static lldb::ThreadSP GetThread(const lldb::SBThread &thread)
static lldb::ExecutionContextRefSP GetExecutionContextRef(const lldb::SBExecutionContext &exe_ctx)
static lldb::TargetSP GetTarget(const lldb::SBTarget &target)
static lldb::DebuggerSP GetDebugger(const lldb::SBDebugger &debugger)
static lldb::ProcessAttachInfoSP GetProcessAttachInfo(const lldb::SBAttachInfo &attach_info)
static lldb::StackFrameSP GetStackFrame(const lldb::SBFrame &frame)
static lldb::StackFrameListSP GetStackFrameList(const lldb::SBFrameList &frame_list)
static lldb::StreamSP GetStream(const lldb::SBStream &stream)
static Event * GetEvent(const lldb::SBEvent &event)
static std::optional< MemoryRegionInfo > GetMemoryRegionInfo(const lldb::SBMemoryRegionInfo &mem_region)
static lldb::ValueObjectSP GetValueObject(const lldb::SBValue &value)
static lldb::ThreadPlanSP GetThreadPlan(const lldb::SBThreadPlan &thread_plan)
static Status GetStatus(const lldb::SBError &error)
ScriptedInterface()=default
ScriptInterpreterPythonImpl & m_interpreter
llvm::Expected< T > ExtractValueFromPythonObject(python::PythonObject &p)
ScriptedPythonInterface(ScriptInterpreterPythonImpl &interpreter)
bool ForEach(std::function< bool(Object *object)> const &foreach_callback) const
virtual bool IsValid() const
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
StructuredData::ObjectSP CreateStructuredObject() const
llvm::Expected< unsigned long long > AsUnsignedLongLong() const
void * LLDBSWIGPython_CastPyObjectToSBExecutionContext(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBFrameList(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBThread(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBData(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBTarget(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBSymbolContext(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBStream(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBCommandReturnObject(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBDebugger(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBBreakpointLocation(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBError(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBAttachInfo(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBThreadPlan(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBLaunchInfo(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBValueList(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBValue(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBEvent(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBBreakpoint(PyObject *data)
void * LLDBSWIGPython_CastPyObjectToSBFrame(PyObject *data)
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
class LLDB_API SBValueList
std::shared_ptr< lldb_private::ProcessAttachInfo > ProcessAttachInfoSP
class LLDB_API SBExecutionContext
std::shared_ptr< lldb_private::ValueObjectList > ValueObjectListSP
class LLDB_API SBFrameList
class LLDB_API SBAttachInfo
class LLDB_API SBBreakpointLocation
class LLDB_API SBMemoryRegionInfo
@ eStepTypeScripted
A step type implemented by the script interpreter.
class LLDB_API SBThreadPlan
class LLDB_API SBBreakpoint
class LLDB_API SBSymbolContext
class LLDB_API SBDebugger
std::shared_ptr< lldb_private::ProcessLaunchInfo > ProcessLaunchInfoSP
class LLDB_API SBCommandReturnObject
class LLDB_API SBLaunchInfo
std::shared_ptr< lldb_private::ExecutionContextRef > ExecutionContextRefSP