From 680ca7f21a7716698227966a9e70e7efb75cff7e Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Fri, 4 Mar 2022 11:22:32 -0800 Subject: [lldb/Plugins] Add ability to load modules to Scripted Processes This patch introduces a new way to load modules programatically with Scripted Processes. To do so, the scripted process blueprint holds a list of dictionary describing the modules to load, which their path or uuid, load address and eventually a slide offset. LLDB will fetch that list after launching the ScriptedProcess, and iterate over each entry to create the module that will be loaded in the Scripted Process' target. The patch also refactors the StackCoreScriptedProcess test to stop inside the `libbaz` module and make sure it's loaded correctly and that we can fetch some variables from it. rdar://74520238 Differential Revision: https://reviews.llvm.org/D120969 Signed-off-by: Med Ismail Bennani --- .../Python/ScriptedProcessPythonInterface.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp index f8edf22..576bf69 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp @@ -124,9 +124,21 @@ lldb::DataExtractorSP ScriptedProcessPythonInterface::ReadMemoryAtAddress( address, size); } -StructuredData::DictionarySP ScriptedProcessPythonInterface::GetLoadedImages() { - // TODO: Implement - return {}; +StructuredData::ArraySP ScriptedProcessPythonInterface::GetLoadedImages() { + Status error; + StructuredData::ArraySP array = + Dispatch("get_loaded_images", error); + + if (!array || !array->IsValid() || error.Fail()) { + return ScriptedInterface::ErrorWithMessage( + LLVM_PRETTY_FUNCTION, + llvm::Twine("Null or invalid object (" + + llvm::Twine(error.AsCString()) + llvm::Twine(").")) + .str(), + error); + } + + return array; } lldb::pid_t ScriptedProcessPythonInterface::GetProcessID() { -- cgit v1.1