[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (#70392)
This patch makes ScriptedThreadPlan conforming to the ScriptedInterface
& ScriptedPythonInterface facilities by introducing 2
ScriptedThreadPlanInterface & ScriptedThreadPlanPythonInterface classes.
This allows us to get rid of every ScriptedThreadPlan-specific SWIG
method and re-use the same affordances as other scripting offordances,
like Scripted{Process,Thread,Platform} & OperatingSystem.
To do so, this adds new transformer methods for `ThreadPlan`, `Stream` &
`Event`, to allow the bijection between C++ objects and their python
counterparts.
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
This commit is contained in:
1 parent
c2f642d90d
commit
4b3cd379cc
23 files changed
+401
-407
No files matched your search
+32
-2
@@ -26,6 +26,15 @@ ScriptedPythonInterface::ScriptedPythonInterface(
|
||||
ScriptInterpreterPythonImpl &interpreter)
|
||||
: ScriptedInterface(), m_interpreter(interpreter) {}
|
||||
|
||||
template <>
|
||||
void ScriptedPythonInterface::ReverseTransform(
|
||||
lldb_private::Stream *&original_arg, python::PythonObject transformed_arg,
|
||||
Status &error) {
|
||||
Stream *s = ExtractValueFromPythonObject<Stream *>(transformed_arg, error);
|
||||
*original_arg = *s;
|
||||
original_arg->PutCString(static_cast<StreamString *>(s)->GetData());
|
||||
}
|
||||
|
||||
template <>
|
||||
StructuredData::ArraySP
|
||||
ScriptedPythonInterface::ExtractValueFromPythonObject<StructuredData::ArraySP>(
|
||||
@@ -48,12 +57,33 @@ Status ScriptedPythonInterface::ExtractValueFromPythonObject<Status>(
|
||||
if (lldb::SBError *sb_error = reinterpret_cast<lldb::SBError *>(
|
||||
python::LLDBSWIGPython_CastPyObjectToSBError(p.get())))
|
||||
return m_interpreter.GetStatusFromSBError(*sb_error);
|
||||
else
|
||||
error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status.");
|
||||
error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status.");
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
template <>
|
||||
Event *ScriptedPythonInterface::ExtractValueFromPythonObject<Event *>(
|
||||
python::PythonObject &p, Status &error) {
|
||||
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.");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
Stream *ScriptedPythonInterface::ExtractValueFromPythonObject<Stream *>(
|
||||
python::PythonObject &p, Status &error) {
|
||||
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.");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
lldb::DataExtractorSP
|
||||
ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DataExtractorSP>(
|
||||
|
||||
Reference in new issue
Block a user