diff options
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp')
| -rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp index 8083ccae0402..4fdf2b12a550 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp @@ -81,6 +81,19 @@ ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StreamSP>( } template <> +lldb::StackFrameSP +ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StackFrameSP>( + python::PythonObject &p, Status &error) { + if (lldb::SBFrame *sb_frame = reinterpret_cast<lldb::SBFrame *>( + python::LLDBSWIGPython_CastPyObjectToSBFrame(p.get()))) + return m_interpreter.GetOpaqueTypeFromSBFrame(*sb_frame); + error = Status::FromErrorString( + "Couldn't cast lldb::SBFrame to lldb_private::StackFrame."); + + return nullptr; +} + +template <> SymbolContext ScriptedPythonInterface::ExtractValueFromPythonObject<SymbolContext>( python::PythonObject &p, Status &error) { @@ -127,6 +140,24 @@ ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::BreakpointSP>( } template <> +lldb::BreakpointLocationSP +ScriptedPythonInterface::ExtractValueFromPythonObject< + lldb::BreakpointLocationSP>(python::PythonObject &p, Status &error) { + lldb::SBBreakpointLocation *sb_break_loc = + reinterpret_cast<lldb::SBBreakpointLocation *>( + python::LLDBSWIGPython_CastPyObjectToSBBreakpointLocation(p.get())); + + if (!sb_break_loc) { + error = Status::FromErrorStringWithFormat( + "Couldn't cast lldb::SBBreakpointLocation to " + "lldb::BreakpointLocationSP."); + return nullptr; + } + + return m_interpreter.GetOpaqueTypeFromSBBreakpointLocation(*sb_break_loc); +} + +template <> lldb::ProcessAttachInfoSP ScriptedPythonInterface::ExtractValueFromPythonObject< lldb::ProcessAttachInfoSP>(python::PythonObject &p, Status &error) { lldb::SBAttachInfo *sb_attach_info = reinterpret_cast<lldb::SBAttachInfo *>( @@ -194,4 +225,22 @@ ScriptedPythonInterface::ExtractValueFromPythonObject< return m_interpreter.GetOpaqueTypeFromSBExecutionContext(*sb_exe_ctx); } +template <> +lldb::DescriptionLevel +ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DescriptionLevel>( + python::PythonObject &p, Status &error) { + lldb::DescriptionLevel ret_val = lldb::eDescriptionLevelBrief; + llvm::Expected<unsigned long long> unsigned_or_err = p.AsUnsignedLongLong(); + if (!unsigned_or_err) { + error = (Status::FromError(unsigned_or_err.takeError())); + return ret_val; + } + unsigned long long unsigned_val = *unsigned_or_err; + if (unsigned_val >= lldb::DescriptionLevel::kNumDescriptionLevels) { + error = Status("value too large for lldb::DescriptionLevel."); + return ret_val; + } + return static_cast<lldb::DescriptionLevel>(unsigned_val); +} + #endif |
