diff options
author | Med Ismail Bennani <ismail@bennani.ma> | 2023-10-23 09:51:01 -0700 |
---|---|---|
committer | Med Ismail Bennani <ismail@bennani.ma> | 2023-10-23 09:51:01 -0700 |
commit | 77374d3b53cee7829ba70b13abf33e0d63d9d256 (patch) | |
tree | 5130fa75956fbafe4c16e811c1081a78d8a1387c /lldb/source/Plugins/ScriptInterpreter/Python | |
parent | 0c9358948b0478a169da3dabd82a49d15ba2aff4 (diff) | |
download | llvm-77374d3b53cee7829ba70b13abf33e0d63d9d256.zip llvm-77374d3b53cee7829ba70b13abf33e0d63d9d256.tar.gz llvm-77374d3b53cee7829ba70b13abf33e0d63d9d256.tar.bz2 |
[lldb] Move ScriptInterpreter Interfaces to subdirectory (NFC)
As we're consolidating and streamlining the various scripting
affordances of lldb, we keep creating new interface files.
This patch groups all the current interface files into a separate sub
directory called `Interfaces` both in the core `Interpreter` directory
and the `ScriptInterpreter` plugin directory.
Differential Revision: https://reviews.llvm.org/D158833
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
12 files changed, 81 insertions, 38 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt index 7236116..7523d65 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt +++ b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt @@ -19,14 +19,12 @@ if (LLDB_ENABLE_LIBEDIT) list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit) endif() +add_subdirectory(Interfaces) + add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN PythonDataObjects.cpp PythonReadline.cpp ScriptInterpreterPython.cpp - ScriptedPythonInterface.cpp - ScriptedProcessPythonInterface.cpp - ScriptedThreadPythonInterface.cpp - ScriptedPlatformPythonInterface.cpp LINK_LIBS lldbBreakpoint @@ -35,6 +33,7 @@ add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN lldbHost lldbInterpreter lldbTarget + lldbPluginScriptInterpreterPythonInterfaces ${Python3_LIBRARIES} ${LLDB_LIBEDIT_LIBS} diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt new file mode 100644 index 0000000..73aeb32 --- /dev/null +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt @@ -0,0 +1,38 @@ +if (APPLE AND LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY) + # Work around an issue with the Python headers, which have a modular include + # inside an extern "C" block. + remove_module_flags() +endif() + +if(NOT LLDB_PYTHON_RELATIVE_PATH) + message(FATAL_ERROR "LLDB_PYTHON_RELATIVE_PATH is not set.") +endif() +add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${LLDB_PYTHON_RELATIVE_PATH}") + +if(NOT LLDB_PYTHON_EXE_RELATIVE_PATH) + message(FATAL_ERROR "LLDB_PYTHON_EXE_RELATIVE_PATH is not set.") +endif() +add_definitions(-DLLDB_PYTHON_EXE_RELATIVE_PATH="${LLDB_PYTHON_EXE_RELATIVE_PATH}") + + +if (LLDB_ENABLE_LIBEDIT) + list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit) +endif() + +add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces + ScriptedPythonInterface.cpp + ScriptedProcessPythonInterface.cpp + ScriptedThreadPythonInterface.cpp + ScriptedPlatformPythonInterface.cpp + + LINK_LIBS + lldbCore + lldbHost + lldbInterpreter + lldbTarget + ${Python3_LIBRARIES} + ${LLDB_LIBEDIT_LIBS} + + LINK_COMPONENTS + Support + ) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp index a0c5587..9bed335 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp @@ -14,10 +14,10 @@ #if LLDB_ENABLE_PYTHON // LLDB Python header must be included first -#include "lldb-python.h" +#include "../lldb-python.h" -#include "SWIGPythonBridge.h" -#include "ScriptInterpreterPythonImpl.h" +#include "../SWIGPythonBridge.h" +#include "../ScriptInterpreterPythonImpl.h" #include "ScriptedPlatformPythonInterface.h" using namespace lldb; diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.h index 1e3ad99..02deecd 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.h @@ -6,15 +6,15 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPLATFORMPYTHONINTERFACE_H -#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPLATFORMPYTHONINTERFACE_H +#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPLATFORMPYTHONINTERFACE_H +#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPLATFORMPYTHONINTERFACE_H #include "lldb/Host/Config.h" #if LLDB_ENABLE_PYTHON #include "ScriptedPythonInterface.h" -#include "lldb/Interpreter/ScriptedPlatformInterface.h" +#include "lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h" namespace lldb_private { class ScriptedPlatformPythonInterface : public ScriptedPlatformInterface, @@ -41,4 +41,4 @@ public: } // namespace lldb_private #endif // LLDB_ENABLE_PYTHON -#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPLATFORMPYTHONINTERFACE_H +#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPLATFORMPYTHONINTERFACE_H diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp index 019924f..63a4db1 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp @@ -9,7 +9,7 @@ #include "lldb/Host/Config.h" #if LLDB_ENABLE_PYTHON // LLDB Python header must be included first -#include "lldb-python.h" +#include "../lldb-python.h" #endif #include "lldb/Target/Process.h" #include "lldb/Utility/Log.h" @@ -18,8 +18,8 @@ #if LLDB_ENABLE_PYTHON -#include "SWIGPythonBridge.h" -#include "ScriptInterpreterPythonImpl.h" +#include "../SWIGPythonBridge.h" +#include "../ScriptInterpreterPythonImpl.h" #include "ScriptedProcessPythonInterface.h" #include "ScriptedThreadPythonInterface.h" #include <optional> @@ -199,7 +199,7 @@ ScriptedProcessPythonInterface::GetScriptedThreadPluginName() { lldb::ScriptedThreadInterfaceSP ScriptedProcessPythonInterface::CreateScriptedThreadInterface() { - return std::make_shared<ScriptedThreadPythonInterface>(m_interpreter); + return m_interpreter.CreateScriptedThreadInterface(); } StructuredData::DictionarySP ScriptedProcessPythonInterface::GetMetadata() { diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h index ff03eab..11330f5 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h @@ -6,15 +6,15 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSPYTHONINTERFACE_H -#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSPYTHONINTERFACE_H +#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPROCESSPYTHONINTERFACE_H +#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPROCESSPYTHONINTERFACE_H #include "lldb/Host/Config.h" #if LLDB_ENABLE_PYTHON #include "ScriptedPythonInterface.h" -#include "lldb/Interpreter/ScriptedProcessInterface.h" +#include "lldb/Interpreter/Interfaces/ScriptedProcessInterface.h" #include <optional> namespace lldb_private { @@ -68,4 +68,4 @@ private: } // namespace lldb_private #endif // LLDB_ENABLE_PYTHON -#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSPYTHONINTERFACE_H +#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPROCESSPYTHONINTERFACE_H diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp index 1e36a81..6f22503 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp @@ -13,9 +13,9 @@ #if LLDB_ENABLE_PYTHON // LLDB Python header must be included first -#include "lldb-python.h" +#include "../lldb-python.h" -#include "ScriptInterpreterPythonImpl.h" +#include "../ScriptInterpreterPythonImpl.h" #include "ScriptedPythonInterface.h" #include <optional> diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h index 4d0645d..9163b8f 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPYTHONINTERFACE_H -#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPYTHONINTERFACE_H +#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPYTHONINTERFACE_H +#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPYTHONINTERFACE_H #if LLDB_ENABLE_PYTHON @@ -18,12 +18,12 @@ #include <utility> #include "lldb/Host/Config.h" -#include "lldb/Interpreter/ScriptedInterface.h" +#include "lldb/Interpreter/Interfaces/ScriptedInterface.h" #include "lldb/Utility/DataBufferHeap.h" -#include "PythonDataObjects.h" -#include "SWIGPythonBridge.h" -#include "ScriptInterpreterPythonImpl.h" +#include "../PythonDataObjects.h" +#include "../SWIGPythonBridge.h" +#include "../ScriptInterpreterPythonImpl.h" namespace lldb_private { class ScriptInterpreterPythonImpl; @@ -146,7 +146,6 @@ protected: original_arg = ExtractValueFromPythonObject<T>(transformed_arg, error); } - void ReverseTransform(bool &original_arg, python::PythonObject transformed_arg, Status &error) { python::PythonBoolean boolean_arg = python::PythonBoolean( @@ -254,4 +253,4 @@ ScriptedPythonInterface::ExtractValueFromPythonObject< } // namespace lldb_private #endif // LLDB_ENABLE_PYTHON -#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPYTHONINTERFACE_H +#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPYTHONINTERFACE_H diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp index 5603a15..6addcd4 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp @@ -13,10 +13,10 @@ #if LLDB_ENABLE_PYTHON // LLDB Python header must be included first -#include "lldb-python.h" +#include "../lldb-python.h" -#include "SWIGPythonBridge.h" -#include "ScriptInterpreterPythonImpl.h" +#include "../SWIGPythonBridge.h" +#include "../ScriptInterpreterPythonImpl.h" #include "ScriptedThreadPythonInterface.h" #include <optional> diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.h index eac4941..b63760fd 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.h @@ -6,15 +6,15 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDTHREADPYTHONINTERFACE_H -#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDTHREADPYTHONINTERFACE_H +#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDTHREADPYTHONINTERFACE_H +#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDTHREADPYTHONINTERFACE_H #include "lldb/Host/Config.h" #if LLDB_ENABLE_PYTHON #include "ScriptedPythonInterface.h" -#include "lldb/Interpreter/ScriptedProcessInterface.h" +#include "lldb/Interpreter/Interfaces/ScriptedThreadInterface.h" #include <optional> namespace lldb_private { @@ -49,4 +49,4 @@ public: } // namespace lldb_private #endif // LLDB_ENABLE_PYTHON -#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDTHREADPYTHONINTERFACE_H +#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDTHREADPYTHONINTERFACE_H diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 0d6ff66..66e6ac7 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -14,12 +14,13 @@ // LLDB Python header must be included first #include "lldb-python.h" +#include "Interfaces/ScriptedPlatformPythonInterface.h" +#include "Interfaces/ScriptedProcessPythonInterface.h" +#include "Interfaces/ScriptedThreadPythonInterface.h" #include "PythonDataObjects.h" #include "PythonReadline.h" #include "SWIGPythonBridge.h" #include "ScriptInterpreterPythonImpl.h" -#include "ScriptedPlatformPythonInterface.h" -#include "ScriptedProcessPythonInterface.h" #include "lldb/API/SBError.h" #include "lldb/API/SBFrame.h" @@ -1515,6 +1516,11 @@ ScriptInterpreterPythonImpl::CreateScriptedProcessInterface() { return std::make_unique<ScriptedProcessPythonInterface>(*this); } +ScriptedThreadInterfaceSP +ScriptInterpreterPythonImpl::CreateScriptedThreadInterface() { + return std::make_shared<ScriptedThreadPythonInterface>(*this); +} + StructuredData::ObjectSP ScriptInterpreterPythonImpl::CreateStructuredDataFromScriptObject( ScriptObject obj) { diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h index 01db6c5..00dc1d1 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h @@ -140,6 +140,7 @@ public: StructuredData::DictionarySP OSPlugin_RegisterInfo(StructuredData::ObjectSP os_plugin_object_sp) override; + lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() override; StructuredData::ArraySP OSPlugin_ThreadsInfo(StructuredData::ObjectSP os_plugin_object_sp) override; |