From 20dbb29a1a94c60b556f8880ab841b150e83ab25 Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Mon, 6 Mar 2023 13:17:43 -0800 Subject: Revert "[lldb] Move ScriptedProcess private state update to implementation" This reverts commit 3c33d72e7fa83beb8a9b39fb3b8ecf4ee00c697d. --- .../ScriptInterpreter/Python/PythonDataObjects.h | 1 - .../Python/ScriptedProcessPythonInterface.cpp | 17 +++++++++++++++-- .../Python/ScriptedProcessPythonInterface.h | 4 ++++ .../ScriptInterpreter/Python/ScriptedPythonInterface.h | 14 -------------- 4 files changed, 19 insertions(+), 17 deletions(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h index 33092209..365d499 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h @@ -201,7 +201,6 @@ template <> struct PythonFormat : PassthroughFormat {}; template <> struct PythonFormat : PassthroughFormat {}; template <> struct PythonFormat : PassthroughFormat {}; -template <> struct PythonFormat : PassthroughFormat {}; template <> struct PythonFormat : PassthroughFormat {}; template <> struct PythonFormat : PassthroughFormat {}; diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp index 0c6f308..cffa3bd 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp @@ -80,8 +80,21 @@ Status ScriptedProcessPythonInterface::Launch() { } Status ScriptedProcessPythonInterface::Resume() { - // When calling ScriptedProcess.Resume from lldb we should always stop. - return GetStatusFromMethod("resume", /*should_stop=*/true); + return GetStatusFromMethod("resume"); +} + +bool ScriptedProcessPythonInterface::ShouldStop() { + Status error; + StructuredData::ObjectSP obj = Dispatch("is_alive", error); + + if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error)) + return {}; + + return obj->GetBooleanValue(); +} + +Status ScriptedProcessPythonInterface::Stop() { + return GetStatusFromMethod("stop"); } std::optional diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h index d1fedfe..b7b12b9 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h @@ -37,6 +37,10 @@ public: Status Resume() override; + bool ShouldStop() override; + + Status Stop() override; + std::optional GetMemoryRegionContainingAddress(lldb::addr_t address, Status &error) override; diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h index 31757a2..a015bd1 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h @@ -113,11 +113,6 @@ protected: return {object}; } - python::PythonObject Transform(bool arg) { - // Boolean arguments need to be turned into python objects. - return python::PythonBoolean(arg); - } - python::PythonObject Transform(Status arg) { return python::ToSWIGWrapper(arg); } @@ -146,15 +141,6 @@ protected: original_arg = ExtractValueFromPythonObject(transformed_arg, error); } - template <> - void ReverseTransform(bool &original_arg, - python::PythonObject transformed_arg, Status &error) { - python::PythonBoolean boolean_arg = python::PythonBoolean( - python::PyRefType::Borrowed, transformed_arg.get()); - if (boolean_arg.IsValid()) - original_arg = boolean_arg.GetValue(); - } - template auto TransformTuple(const std::tuple &args, std::index_sequence) { -- cgit v1.1