diff options
author | David Spickett <david.spickett@linaro.org> | 2024-08-02 16:55:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-02 08:55:26 -0700 |
commit | 9d07f43676f03460d913aabd503ae8154cabdda1 (patch) | |
tree | 021ba12ac341e15af7406c1887a2696c8eea909b /lldb/source/Plugins/ScriptInterpreter/Python | |
parent | 60054dcd81d027db72b9ef305184e97c55465458 (diff) | |
download | llvm-9d07f43676f03460d913aabd503ae8154cabdda1.zip llvm-9d07f43676f03460d913aabd503ae8154cabdda1.tar.gz llvm-9d07f43676f03460d913aabd503ae8154cabdda1.tar.bz2 |
Reland "[lldb] Reland 2402b3213c2f with `/H` to debug the windows build issue (#101672)
This reverts commit 9effefbae8d96006a4dd29bb9ab8532fd408559d.
With the include order in ScriptedProcessPythonInterface.cpp fixed
(though I cannot explain exactly why it works) and removes the /H flag
intended for debugging this issue.
I think it is something to do with Process.h pulling in PosixApi.h
somewhere along the line, and including Process.h after lldb-python.h
means that NO_PID_T is defined to prevent a redefinition of pid_t.
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt | 2 | ||||
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/CMakeLists.txt | 16 | ||||
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp (renamed from lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp) | 43 | ||||
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.h (renamed from lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h) | 18 | ||||
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp | 2 |
5 files changed, 68 insertions, 13 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt index 8c7e92b..eb22a96 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt @@ -21,7 +21,6 @@ endif() add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces ScriptedPythonInterface.cpp - ScriptedProcessPythonInterface.cpp ScriptedThreadPythonInterface.cpp LINK_LIBS @@ -38,5 +37,6 @@ add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces add_subdirectory(OperatingSystemPythonInterface) add_subdirectory(ScriptedPlatformPythonInterface) +add_subdirectory(ScriptedProcessPythonInterface) add_subdirectory(ScriptedThreadPlanPythonInterface) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/CMakeLists.txt new file mode 100644 index 0000000..66ed041 --- /dev/null +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/CMakeLists.txt @@ -0,0 +1,16 @@ +add_lldb_library(lldbPluginScriptInterpreterPythonScriptedProcessPythonInterface PLUGIN + + ScriptedProcessPythonInterface.cpp + + LINK_LIBS + lldbCore + lldbHost + lldbInterpreter + lldbTarget + lldbPluginScriptInterpreterPython + ${Python3_LIBRARIES} + ${LLDB_LIBEDIT_LIBS} + + LINK_COMPONENTS + Support + ) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp index 313c597..c744d70 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.cpp @@ -6,22 +6,27 @@ // //===----------------------------------------------------------------------===// +#include "lldb/Core/PluginManager.h" #include "lldb/Host/Config.h" -#if LLDB_ENABLE_PYTHON -// LLDB Python header must be included first -#include "../lldb-python.h" -#endif -#include "lldb/Target/Process.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-enumerations.h" #if LLDB_ENABLE_PYTHON -#include "../SWIGPythonBridge.h" -#include "../ScriptInterpreterPythonImpl.h" +// clang-format off +// LLDB Python header must be included first +#include "../../lldb-python.h" + +#include "../../SWIGPythonBridge.h" +#include "../../ScriptInterpreterPythonImpl.h" +#include "../ScriptedThreadPythonInterface.h" #include "ScriptedProcessPythonInterface.h" -#include "ScriptedThreadPythonInterface.h" + +// Included in this position to prevent redefinition of pid_t on Windows. +#include "lldb/Target/Process.h" +//clang-format off + #include <optional> using namespace lldb; @@ -29,6 +34,8 @@ using namespace lldb_private; using namespace lldb_private::python; using Locker = ScriptInterpreterPythonImpl::Locker; +LLDB_PLUGIN_DEFINE_ADV(ScriptedProcessPythonInterface, ScriptInterpreterPythonScriptedProcessPythonInterface) + ScriptedProcessPythonInterface::ScriptedProcessPythonInterface( ScriptInterpreterPythonImpl &interpreter) : ScriptedProcessInterface(), ScriptedPythonInterface(interpreter) {} @@ -208,4 +215,24 @@ StructuredData::DictionarySP ScriptedProcessPythonInterface::GetMetadata() { return dict; } +void ScriptedProcessPythonInterface::Initialize() { + const std::vector<llvm::StringRef> ci_usages = { + "process attach -C <script-name> [-k key -v value ...]", + "process launch -C <script-name> [-k key -v value ...]"}; + const std::vector<llvm::StringRef> api_usages = { + "SBAttachInfo.SetScriptedProcessClassName", + "SBAttachInfo.SetScriptedProcessDictionary", + "SBTarget.Attach", + "SBLaunchInfo.SetScriptedProcessClassName", + "SBLaunchInfo.SetScriptedProcessDictionary", + "SBTarget.Launch"}; + PluginManager::RegisterPlugin( + GetPluginNameStatic(), llvm::StringRef("Mock process state"), + CreateInstance, eScriptLanguagePython, {ci_usages, api_usages}); +} + +void ScriptedProcessPythonInterface::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); +} + #endif diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.h index c75caa9..bb27734 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.h @@ -10,16 +10,18 @@ #define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPROCESSPYTHONINTERFACE_H #include "lldb/Host/Config.h" +#include "lldb/Interpreter/Interfaces/ScriptedProcessInterface.h" #if LLDB_ENABLE_PYTHON -#include "ScriptedPythonInterface.h" -#include "lldb/Interpreter/Interfaces/ScriptedProcessInterface.h" +#include "../ScriptedPythonInterface.h" + #include <optional> namespace lldb_private { class ScriptedProcessPythonInterface : public ScriptedProcessInterface, - public ScriptedPythonInterface { + public ScriptedPythonInterface, + public PluginInterface { public: ScriptedProcessPythonInterface(ScriptInterpreterPythonImpl &interpreter); @@ -67,6 +69,16 @@ public: StructuredData::DictionarySP GetMetadata() override; + static void Initialize(); + + static void Terminate(); + + static llvm::StringRef GetPluginNameStatic() { + return "ScriptedProcessPythonInterface"; + } + + llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); } + private: lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() override; }; diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index d34fdf1..a78c76b 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -16,7 +16,7 @@ #include "Interfaces/OperatingSystemPythonInterface/OperatingSystemPythonInterface.h" #include "Interfaces/ScriptedPlatformPythonInterface/ScriptedPlatformPythonInterface.h" -#include "Interfaces/ScriptedProcessPythonInterface.h" +#include "Interfaces/ScriptedProcessPythonInterface/ScriptedProcessPythonInterface.h" #include "Interfaces/ScriptedThreadPlanPythonInterface/ScriptedThreadPlanPythonInterface.h" #include "PythonDataObjects.h" #include "PythonReadline.h" |