[Lldb-commits] [lldb] Revert "[lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (Reland #70392)" (PR #93153)

2024-05-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)


Changes

Reverts llvm/llvm-project#93149 since it breaks 
https://lab.llvm.org/buildbot/#/builders/68/builds/74799

---

Patch is 60.44 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/93153.diff


25 Files Affected:

- (modified) lldb/bindings/python/python-swigsafecast.swig (+7-10) 
- (modified) lldb/bindings/python/python-wrapper.swig (+130-27) 
- (modified) lldb/include/lldb/API/SBEvent.h (+1-3) 
- (modified) lldb/include/lldb/API/SBStream.h (-6) 
- (modified) lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
(+2-2) 
- (removed) 
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h (-38) 
- (modified) lldb/include/lldb/Interpreter/ScriptInterpreter.h (+44-11) 
- (modified) lldb/include/lldb/Target/ThreadPlanPython.h (-2) 
- (modified) lldb/include/lldb/lldb-forward.h (-3) 
- (modified) lldb/source/Interpreter/ScriptInterpreter.cpp (-13) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt (-1) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp
 (-2) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp
 (+9-18) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
 (+2-32) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
 (+3-26) 
- (removed) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
 (-105) 
- (removed) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
 (-48) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp
 (+9-19) 
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h 
(+17-5) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
(+116-6) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h 
(+25-3) 
- (modified) lldb/source/Target/ThreadPlanPython.cpp (+43-55) 
- (modified) lldb/test/API/functionalities/step_scripted/Steps.py (+2-2) 
- (modified) lldb/test/API/functionalities/thread_plan/wrap_step_over.py (+1-1) 
- (modified) lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp 
(+20-30) 


``diff
diff --git a/lldb/bindings/python/python-swigsafecast.swig 
b/lldb/bindings/python/python-swigsafecast.swig
index 34f8c6f0ff8d3..d5ea514872713 100644
--- a/lldb/bindings/python/python-swigsafecast.swig
+++ b/lldb/bindings/python/python-swigsafecast.swig
@@ -37,6 +37,10 @@ PythonObject SWIGBridge::ToSWIGWrapper(const Status& status) 
{
   return ToSWIGHelper(new lldb::SBError(status), SWIGTYPE_p_lldb__SBError);
 }
 
+PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr 
stream_sb) {
+  return ToSWIGHelper(stream_sb.release(), SWIGTYPE_p_lldb__SBStream);
+}
+
 PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr 
data_sb) {
   return ToSWIGHelper(data_sb.release(), SWIGTYPE_p_lldb__SBStructuredData);
 }
@@ -111,16 +115,9 @@ SWIGBridge::ToSWIGWrapper(CommandReturnObject &cmd_retobj) 
{
   SWIGTYPE_p_lldb__SBCommandReturnObject);
 }
 
-PythonObject SWIGBridge::ToSWIGWrapper(const Stream *s) {
-  return ToSWIGHelper(new lldb::SBStream(), SWIGTYPE_p_lldb__SBStream);
-}
-
-PythonObject SWIGBridge::ToSWIGWrapper(std::shared_ptr 
stream_sb) {
-  return ToSWIGHelper(stream_sb.get(), SWIGTYPE_p_lldb__SBStream);
-}
-
-PythonObject SWIGBridge::ToSWIGWrapper(Event *event) {
-  return ToSWIGHelper(new lldb::SBEvent(event), SWIGTYPE_p_lldb__SBEvent);
+ScopedPythonObject SWIGBridge::ToSWIGWrapper(Event *event) {
+  return ScopedPythonObject(new lldb::SBEvent(event),
+   SWIGTYPE_p_lldb__SBEvent);
 }
 
 PythonObject SWIGBridge::ToSWIGWrapper(
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 28ab58f8ce495..1370afc885d43 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -229,6 +229,133 @@ PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject
   return pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger_sp)), dict);
 }
 
+PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan(
+const char *python_class_name, const char *session_dictionary_name,
+const lldb_private::StructuredDataImpl &args_impl,
+std::string &error_string, const lldb::ThreadPlanSP &thread_plan_sp) {
+  if (python_class_name == NULL || python_class_name[0] == '\0' ||
+  !session_dictionary_name)
+return PythonObject();
+
+  PyErr_Cleaner py_err_cleaner(true);
+
+  auto dict = PythonModule::MainModule().ResolveName(
+  session_dictionary_name);
+  auto pfunc = PythonObject::Reso

[Lldb-commits] [lldb] Revert "[lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (Reland #70392)" (PR #93153)

2024-05-23 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben closed 
https://github.com/llvm/llvm-project/pull/93153
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Revert "[lldb] Make use of Scripted{Python, }Interface for ScriptedThreadPlan (Reland #70392)" (PR #93153)

2024-05-23 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben created 
https://github.com/llvm/llvm-project/pull/93153

Reverts llvm/llvm-project#93149 since it breaks 
https://lab.llvm.org/buildbot/#/builders/68/builds/74799

>From 788e65c8171e233d399f3f1df645d6f9fb8f66bc Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Thu, 23 May 2024 01:45:18 -0700
Subject: [PATCH] =?UTF-8?q?Revert=20"[lldb]=20Make=20use=20of=20Scripted{P?=
 =?UTF-8?q?ython,}Interface=20for=20ScriptedThreadPlan=20=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 4cc6d0f4dfb26deb9863901c70258d6d7f0c8ba4.
---
 lldb/bindings/python/python-swigsafecast.swig |  17 +-
 lldb/bindings/python/python-wrapper.swig  | 157 +++---
 lldb/include/lldb/API/SBEvent.h   |   4 +-
 lldb/include/lldb/API/SBStream.h  |   6 -
 .../Interfaces/ScriptedInterface.h|   4 +-
 .../Interfaces/ScriptedThreadPlanInterface.h  |  38 -
 .../lldb/Interpreter/ScriptInterpreter.h  |  55 --
 lldb/include/lldb/Target/ThreadPlanPython.h   |   2 -
 lldb/include/lldb/lldb-forward.h  |   3 -
 lldb/source/Interpreter/ScriptInterpreter.cpp |  13 --
 .../Python/Interfaces/CMakeLists.txt  |   1 -
 .../ScriptedPlatformPythonInterface.cpp   |   2 -
 .../ScriptedProcessPythonInterface.cpp|  27 +--
 .../Interfaces/ScriptedPythonInterface.cpp|  34 +---
 .../Interfaces/ScriptedPythonInterface.h  |  29 +---
 .../ScriptedThreadPlanPythonInterface.cpp | 105 
 .../ScriptedThreadPlanPythonInterface.h   |  48 --
 .../ScriptedThreadPythonInterface.cpp |  28 +---
 .../Python/SWIGPythonBridge.h |  22 ++-
 .../Python/ScriptInterpreterPython.cpp| 122 +-
 .../Python/ScriptInterpreterPythonImpl.h  |  28 +++-
 lldb/source/Target/ThreadPlanPython.cpp   |  98 +--
 .../functionalities/step_scripted/Steps.py|   4 +-
 .../thread_plan/wrap_step_over.py |   2 +-
 .../Python/PythonTestSuite.cpp|  50 +++---
 25 files changed, 431 insertions(+), 468 deletions(-)
 delete mode 100644 
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h
 delete mode 100644 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
 delete mode 100644 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h

diff --git a/lldb/bindings/python/python-swigsafecast.swig 
b/lldb/bindings/python/python-swigsafecast.swig
index 34f8c6f0ff8d3..d5ea514872713 100644
--- a/lldb/bindings/python/python-swigsafecast.swig
+++ b/lldb/bindings/python/python-swigsafecast.swig
@@ -37,6 +37,10 @@ PythonObject SWIGBridge::ToSWIGWrapper(const Status& status) 
{
   return ToSWIGHelper(new lldb::SBError(status), SWIGTYPE_p_lldb__SBError);
 }
 
+PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr 
stream_sb) {
+  return ToSWIGHelper(stream_sb.release(), SWIGTYPE_p_lldb__SBStream);
+}
+
 PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr 
data_sb) {
   return ToSWIGHelper(data_sb.release(), SWIGTYPE_p_lldb__SBStructuredData);
 }
@@ -111,16 +115,9 @@ SWIGBridge::ToSWIGWrapper(CommandReturnObject &cmd_retobj) 
{
   SWIGTYPE_p_lldb__SBCommandReturnObject);
 }
 
-PythonObject SWIGBridge::ToSWIGWrapper(const Stream *s) {
-  return ToSWIGHelper(new lldb::SBStream(), SWIGTYPE_p_lldb__SBStream);
-}
-
-PythonObject SWIGBridge::ToSWIGWrapper(std::shared_ptr 
stream_sb) {
-  return ToSWIGHelper(stream_sb.get(), SWIGTYPE_p_lldb__SBStream);
-}
-
-PythonObject SWIGBridge::ToSWIGWrapper(Event *event) {
-  return ToSWIGHelper(new lldb::SBEvent(event), SWIGTYPE_p_lldb__SBEvent);
+ScopedPythonObject SWIGBridge::ToSWIGWrapper(Event *event) {
+  return ScopedPythonObject(new lldb::SBEvent(event),
+   SWIGTYPE_p_lldb__SBEvent);
 }
 
 PythonObject SWIGBridge::ToSWIGWrapper(
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 28ab58f8ce495..1370afc885d43 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -229,6 +229,133 @@ PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject
   return pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger_sp)), dict);
 }
 
+PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan(
+const char *python_class_name, const char *session_dictionary_name,
+const lldb_private::StructuredDataImpl &args_impl,
+std::string &error_string, const lldb::ThreadPlanSP &thread_plan_sp) {
+  if (python_class_name == NULL || python_class_name[0] == '\0' ||
+  !session_dictionary_name)
+return PythonObject();
+
+  PyErr_Cleaner py_err_cleaner(true);
+
+  auto dict = PythonModule::MainModule().ResolveName(
+  session_dictionary_name);
+  auto pfunc = PythonObject::ResolveNameWithDicti