diff options
Diffstat (limited to 'contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp')
| -rw-r--r-- | contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp b/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp index 699412e437a1..cf11c06e8a95 100644 --- a/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp @@ -48,7 +48,8 @@ Status ScriptedPythonInterface::ExtractValueFromPythonObject<Status>( if (lldb::SBError *sb_error = reinterpret_cast<lldb::SBError *>( python::LLDBSWIGPython_CastPyObjectToSBError(p.get()))) return m_interpreter.GetStatusFromSBError(*sb_error); - error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status."); + error = + Status::FromErrorString("Couldn't cast lldb::SBError to lldb::Status."); return {}; } @@ -59,7 +60,8 @@ Event *ScriptedPythonInterface::ExtractValueFromPythonObject<Event *>( if (lldb::SBEvent *sb_event = reinterpret_cast<lldb::SBEvent *>( python::LLDBSWIGPython_CastPyObjectToSBEvent(p.get()))) return m_interpreter.GetOpaqueTypeFromSBEvent(*sb_event); - error.SetErrorString("Couldn't cast lldb::SBEvent to lldb_private::Event."); + error = Status::FromErrorString( + "Couldn't cast lldb::SBEvent to lldb_private::Event."); return nullptr; } @@ -71,7 +73,8 @@ ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StreamSP>( if (lldb::SBStream *sb_stream = reinterpret_cast<lldb::SBStream *>( python::LLDBSWIGPython_CastPyObjectToSBStream(p.get()))) return m_interpreter.GetOpaqueTypeFromSBStream(*sb_stream); - error.SetErrorString("Couldn't cast lldb::SBStream to lldb_private::Stream."); + error = Status::FromErrorString( + "Couldn't cast lldb::SBStream to lldb_private::Stream."); return nullptr; } @@ -84,7 +87,7 @@ ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DataExtractorSP>( python::LLDBSWIGPython_CastPyObjectToSBData(p.get())); if (!sb_data) { - error.SetErrorString( + error = Status::FromErrorStringWithFormat( "Couldn't cast lldb::SBData to lldb::DataExtractorSP."); return nullptr; } @@ -100,7 +103,7 @@ ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::BreakpointSP>( python::LLDBSWIGPython_CastPyObjectToSBBreakpoint(p.get())); if (!sb_breakpoint) { - error.SetErrorString( + error = Status::FromErrorStringWithFormat( "Couldn't cast lldb::SBBreakpoint to lldb::BreakpointSP."); return nullptr; } @@ -115,7 +118,7 @@ lldb::ProcessAttachInfoSP ScriptedPythonInterface::ExtractValueFromPythonObject< python::LLDBSWIGPython_CastPyObjectToSBAttachInfo(p.get())); if (!sb_attach_info) { - error.SetErrorString( + error = Status::FromErrorStringWithFormat( "Couldn't cast lldb::SBAttachInfo to lldb::ProcessAttachInfoSP."); return nullptr; } @@ -130,7 +133,7 @@ lldb::ProcessLaunchInfoSP ScriptedPythonInterface::ExtractValueFromPythonObject< python::LLDBSWIGPython_CastPyObjectToSBLaunchInfo(p.get())); if (!sb_launch_info) { - error.SetErrorString( + error = Status::FromErrorStringWithFormat( "Couldn't cast lldb::SBLaunchInfo to lldb::ProcessLaunchInfoSP."); return nullptr; } @@ -148,7 +151,7 @@ ScriptedPythonInterface::ExtractValueFromPythonObject< python::LLDBSWIGPython_CastPyObjectToSBMemoryRegionInfo(p.get())); if (!sb_mem_reg_info) { - error.SetErrorString( + error = Status::FromErrorStringWithFormat( "Couldn't cast lldb::SBMemoryRegionInfo to lldb::MemoryRegionInfoSP."); return {}; } @@ -156,4 +159,23 @@ ScriptedPythonInterface::ExtractValueFromPythonObject< return m_interpreter.GetOpaqueTypeFromSBMemoryRegionInfo(*sb_mem_reg_info); } +template <> +lldb::ExecutionContextRefSP +ScriptedPythonInterface::ExtractValueFromPythonObject< + lldb::ExecutionContextRefSP>(python::PythonObject &p, Status &error) { + + lldb::SBExecutionContext *sb_exe_ctx = + reinterpret_cast<lldb::SBExecutionContext *>( + python::LLDBSWIGPython_CastPyObjectToSBExecutionContext(p.get())); + + if (!sb_exe_ctx) { + error = Status::FromErrorStringWithFormat( + "Couldn't cast lldb::SBExecutionContext to " + "lldb::ExecutionContextRefSP."); + return {}; + } + + return m_interpreter.GetOpaqueTypeFromSBExecutionContext(*sb_exe_ctx); +} + #endif |
