diff options
Diffstat (limited to 'contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp')
| -rw-r--r-- | contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp b/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp index 313c597ce48f..f5fc337a8028 100644 --- a/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/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 +// clang-format off +// LLDB Python header must be included first +#include "../lldb-python.h" + #include "../SWIGPythonBridge.h" #include "../ScriptInterpreterPythonImpl.h" -#include "ScriptedProcessPythonInterface.h" #include "ScriptedThreadPythonInterface.h" +#include "ScriptedProcessPythonInterface.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; @@ -106,7 +111,7 @@ bool ScriptedProcessPythonInterface::CreateBreakpoint(lldb::addr_t addr, // If there was an error on the python call, surface it to the user. if (py_error.Fail()) - error = py_error; + error = std::move(py_error); if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error)) @@ -123,7 +128,7 @@ lldb::DataExtractorSP ScriptedProcessPythonInterface::ReadMemoryAtAddress( // If there was an error on the python call, surface it to the user. if (py_error.Fail()) - error = py_error; + error = std::move(py_error); return data_sp; } @@ -140,7 +145,7 @@ lldb::offset_t ScriptedProcessPythonInterface::WriteMemoryAtAddress( // If there was an error on the python call, surface it to the user. if (py_error.Fail()) - error = py_error; + error = std::move(py_error); return obj->GetUnsignedIntegerValue(LLDB_INVALID_OFFSET); } @@ -208,4 +213,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 |
