|
18 | 18 | #include "../ScriptInterpreterPythonImpl.h" |
19 | 19 | #include "ScriptedPythonInterface.h" |
20 | 20 | #include "lldb/Symbol/SymbolContext.h" |
| 21 | +#include "lldb/ValueObject/ValueObjectList.h" |
21 | 22 | #include <optional> |
22 | 23 |
|
23 | 24 | using namespace lldb; |
@@ -273,4 +274,41 @@ ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StackFrameListSP>( |
273 | 274 | return m_interpreter.GetOpaqueTypeFromSBFrameList(*sb_frame_list); |
274 | 275 | } |
275 | 276 |
|
| 277 | +template <> |
| 278 | +lldb::ValueObjectSP |
| 279 | +ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::ValueObjectSP>( |
| 280 | + python::PythonObject &p, Status &error) { |
| 281 | + lldb::SBValue *sb_value = reinterpret_cast<lldb::SBValue *>( |
| 282 | + python::LLDBSWIGPython_CastPyObjectToSBValue(p.get())); |
| 283 | + if (!sb_value) { |
| 284 | + error = Status::FromErrorStringWithFormat( |
| 285 | + "couldn't cast lldb::SBValue to lldb::ValueObjectSP"); |
| 286 | + return {}; |
| 287 | + } |
| 288 | + |
| 289 | + return m_interpreter.GetOpaqueTypeFromSBValue(*sb_value); |
| 290 | +} |
| 291 | + |
| 292 | +template <> |
| 293 | +lldb::ValueObjectListSP |
| 294 | +ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::ValueObjectListSP>( |
| 295 | + python::PythonObject &p, Status &error) { |
| 296 | + lldb::SBValueList *sb_value_list = reinterpret_cast<lldb::SBValueList *>( |
| 297 | + python::LLDBSWIGPython_CastPyObjectToSBValueList(p.get())); |
| 298 | + |
| 299 | + if (!sb_value_list) { |
| 300 | + error = Status::FromErrorStringWithFormat( |
| 301 | + "couldn't cast lldb::SBValueList to lldb::ValueObjectListSP"); |
| 302 | + return {}; |
| 303 | + } |
| 304 | + |
| 305 | + lldb::ValueObjectListSP out = std::make_shared<ValueObjectList>(); |
| 306 | + for (uint32_t i = 0, e = sb_value_list->GetSize(); i < e; ++i) { |
| 307 | + SBValue value = sb_value_list->GetValueAtIndex(i); |
| 308 | + out->Append(m_interpreter.GetOpaqueTypeFromSBValue(value)); |
| 309 | + } |
| 310 | + |
| 311 | + return out; |
| 312 | +} |
| 313 | + |
276 | 314 | #endif |
0 commit comments