diff options
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/Interfaces')
7 files changed, 6 insertions, 187 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt index ee5e48a..6ba714e 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt @@ -25,7 +25,6 @@ add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces PLUGIN ScriptedPlatformPythonInterface.cpp ScriptedProcessPythonInterface.cpp ScriptedPythonInterface.cpp - ScriptedStopHookPythonInterface.cpp ScriptedThreadPlanPythonInterface.cpp ScriptedThreadPythonInterface.cpp diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptInterpreterPythonInterfaces.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptInterpreterPythonInterfaces.cpp index 1fd3299..38b6443 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptInterpreterPythonInterfaces.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptInterpreterPythonInterfaces.cpp @@ -28,7 +28,6 @@ void ScriptInterpreterPythonInterfaces::Initialize() { OperatingSystemPythonInterface::Initialize(); ScriptedPlatformPythonInterface::Initialize(); ScriptedProcessPythonInterface::Initialize(); - ScriptedStopHookPythonInterface::Initialize(); ScriptedThreadPlanPythonInterface::Initialize(); } @@ -36,7 +35,6 @@ void ScriptInterpreterPythonInterfaces::Terminate() { OperatingSystemPythonInterface::Terminate(); ScriptedPlatformPythonInterface::Terminate(); ScriptedProcessPythonInterface::Terminate(); - ScriptedStopHookPythonInterface::Terminate(); ScriptedThreadPlanPythonInterface::Terminate(); } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptInterpreterPythonInterfaces.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptInterpreterPythonInterfaces.h index 26c80b7..36b5214 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptInterpreterPythonInterfaces.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptInterpreterPythonInterfaces.h @@ -18,7 +18,6 @@ #include "OperatingSystemPythonInterface.h" #include "ScriptedPlatformPythonInterface.h" #include "ScriptedProcessPythonInterface.h" -#include "ScriptedStopHookPythonInterface.h" #include "ScriptedThreadPlanPythonInterface.h" namespace lldb_private { diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp index cf11c06..a8e1d09 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp @@ -159,23 +159,4 @@ ScriptedPythonInterface::ExtractValueFromPythonObject< return m_interpreter.GetOpaqueTypeFromSBMemoryRegionInfo(*sb_mem_reg_info); } -template <> -lldb::ExecutionContextRefSP -ScriptedPythonInterface::ExtractValueFromPythonObject< - lldb::ExecutionContextRefSP>(python::PythonObject &p, Status &error) { - - lldb::SBExecutionContext *sb_exe_ctx = - reinterpret_cast<lldb::SBExecutionContext *>( - python::LLDBSWIGPython_CastPyObjectToSBExecutionContext(p.get())); - - if (!sb_exe_ctx) { - error = Status::FromErrorStringWithFormat( - "Couldn't cast lldb::SBExecutionContext to " - "lldb::ExecutionContextRefSP."); - return {}; - } - - return m_interpreter.GetOpaqueTypeFromSBExecutionContext(*sb_exe_ctx); -} - #endif diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h index 4b9f463..c715295 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h @@ -180,35 +180,12 @@ public: llvm::Expected<PythonObject> expected_return_object = create_error("Resulting object is not initialized."); - // This relax the requirement on the number of argument for - // initializing scripting extension if the size of the interface - // parameter pack contains 1 less element than the extension maximum - // number of positional arguments for this initializer. - // - // This addresses the cases where the embedded interpreter session - // dictionary is passed to the extension initializer which is not used - // most of the time. - size_t num_args = sizeof...(Args); - if (num_args != arg_info->max_positional_args) { - if (num_args != arg_info->max_positional_args - 1) - return create_error("Passed arguments ({0}) doesn't match the number " - "of expected arguments ({1}).", - num_args, arg_info->max_positional_args); - - std::apply( - [&init, &expected_return_object](auto &&...args) { - llvm::consumeError(expected_return_object.takeError()); - expected_return_object = init(args...); - }, - std::tuple_cat(transformed_args, std::make_tuple(dict))); - } else { - std::apply( - [&init, &expected_return_object](auto &&...args) { - llvm::consumeError(expected_return_object.takeError()); - expected_return_object = init(args...); - }, - transformed_args); - } + std::apply( + [&init, &expected_return_object](auto &&...args) { + llvm::consumeError(expected_return_object.takeError()); + expected_return_object = init(args...); + }, + transformed_args); if (!expected_return_object) return expected_return_object.takeError(); @@ -428,10 +405,6 @@ protected: return python::SWIGBridge::ToSWIGWrapper(arg); } - python::PythonObject Transform(lldb::TargetSP arg) { - return python::SWIGBridge::ToSWIGWrapper(arg); - } - python::PythonObject Transform(lldb::ProcessSP arg) { return python::SWIGBridge::ToSWIGWrapper(arg); } @@ -584,11 +557,6 @@ std::optional<MemoryRegionInfo> ScriptedPythonInterface::ExtractValueFromPythonObject< std::optional<MemoryRegionInfo>>(python::PythonObject &p, Status &error); -template <> -lldb::ExecutionContextRefSP -ScriptedPythonInterface::ExtractValueFromPythonObject< - lldb::ExecutionContextRefSP>(python::PythonObject &p, Status &error); - } // namespace lldb_private #endif // LLDB_ENABLE_PYTHON diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedStopHookPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedStopHookPythonInterface.cpp deleted file mode 100644 index 6cec7d6..0000000 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedStopHookPythonInterface.cpp +++ /dev/null @@ -1,75 +0,0 @@ -//===-- ScriptedStopHookPythonInterface.cpp -------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "lldb/Core/PluginManager.h" -#include "lldb/Host/Config.h" -#include "lldb/Target/ExecutionContext.h" -#include "lldb/Utility/Log.h" -#include "lldb/lldb-enumerations.h" - -#if LLDB_ENABLE_PYTHON - -// clang-format off -// LLDB Python header must be included first -#include "../lldb-python.h" -//clang-format on - -#include "../SWIGPythonBridge.h" -#include "../ScriptInterpreterPythonImpl.h" -#include "ScriptedStopHookPythonInterface.h" - -using namespace lldb; -using namespace lldb_private; -using namespace lldb_private::python; - -ScriptedStopHookPythonInterface::ScriptedStopHookPythonInterface( - ScriptInterpreterPythonImpl &interpreter) - : ScriptedStopHookInterface(), ScriptedPythonInterface(interpreter) {} - -llvm::Expected<StructuredData::GenericSP> -ScriptedStopHookPythonInterface::CreatePluginObject(llvm::StringRef class_name, - lldb::TargetSP target_sp, - const StructuredDataImpl &args_sp) { - return ScriptedPythonInterface::CreatePluginObject(class_name, nullptr, - target_sp, args_sp); -} - -llvm::Expected<bool> -ScriptedStopHookPythonInterface::HandleStop(ExecutionContext &exe_ctx, - lldb::StreamSP output_sp) { - ExecutionContextRefSP exe_ctx_ref_sp = - std::make_shared<ExecutionContextRef>(exe_ctx); - Status error; - StructuredData::ObjectSP obj = Dispatch("handle_stop", error, exe_ctx_ref_sp, output_sp); - - if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, - error)) { - if (!obj) - return true; - return error.ToError(); - } - - return obj->GetBooleanValue(); -} - - -void ScriptedStopHookPythonInterface::Initialize() { - const std::vector<llvm::StringRef> ci_usages = { - "target stop-hook add -P <script-name> [-k key -v value ...]"}; - const std::vector<llvm::StringRef> api_usages = {}; - PluginManager::RegisterPlugin( - GetPluginNameStatic(), - llvm::StringRef("Perform actions whenever the process stops, before control is returned to the user."), - CreateInstance, eScriptLanguagePython, {ci_usages, api_usages}); -} - -void ScriptedStopHookPythonInterface::Terminate() { - PluginManager::UnregisterPlugin(CreateInstance); -} - -#endif diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedStopHookPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedStopHookPythonInterface.h deleted file mode 100644 index 8548d8d..0000000 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedStopHookPythonInterface.h +++ /dev/null @@ -1,51 +0,0 @@ -//===-- ScriptedStopHookPythonInterface.h -----------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDSTOPHOOKPYTHONINTERFACE_H -#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDSTOPHOOKPYTHONINTERFACE_H - -#include "lldb/Host/Config.h" -#include "lldb/Interpreter/Interfaces/ScriptedStopHookInterface.h" - -#if LLDB_ENABLE_PYTHON - -#include "ScriptedPythonInterface.h" - -namespace lldb_private { -class ScriptedStopHookPythonInterface : public ScriptedStopHookInterface, - public ScriptedPythonInterface, - public PluginInterface { -public: - ScriptedStopHookPythonInterface(ScriptInterpreterPythonImpl &interpreter); - - llvm::Expected<StructuredData::GenericSP> - CreatePluginObject(llvm::StringRef class_name, lldb::TargetSP target_sp, - const StructuredDataImpl &args_sp) override; - - llvm::SmallVector<AbstractMethodRequirement> - GetAbstractMethodRequirements() const override { - return llvm::SmallVector<AbstractMethodRequirement>({{"handle_stop", 2}}); - } - - llvm::Expected<bool> HandleStop(ExecutionContext &exe_ctx, - lldb::StreamSP output_sp) override; - - static void Initialize(); - - static void Terminate(); - - static llvm::StringRef GetPluginNameStatic() { - return "ScriptedStopHookPythonInterface"; - } - - llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); } -}; -} // namespace lldb_private - -#endif // LLDB_ENABLE_PYTHON -#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDSTOPHOOKPYTHONINTERFACE_H |