mib created this revision. mib added reviewers: bulbazord, JDevlieghere. mib added a project: LLDB. Herald added a project: All. mib requested review of this revision. Herald added a subscriber: lldb-commits.
This patch introduces a new method to the Scripted Process interface, GetCapabilities. This returns a dictionary that contains a list of flags that the ScriptedProcess instance supports. This can be used for instance, to force symbol lookup, when loading dynamic libraries in the scripted process. Signed-off-by: Med Ismail Bennani <medismail.benn...@gmail.com> Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D142059 Files: lldb/examples/python/scripted_process/scripted_process.py lldb/include/lldb/Interpreter/ScriptedProcessInterface.h lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h +++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h @@ -29,6 +29,8 @@ StructuredData::DictionarySP args_sp, StructuredData::Generic *script_obj = nullptr) override; + StructuredData::ArraySP GetCapabilities() override; + Status Launch() override; Status Resume() override; Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp +++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp @@ -56,6 +56,23 @@ return m_object_instance_sp; } +StructuredData::ArraySP ScriptedProcessPythonInterface::GetCapabilities() { + Status error; + StructuredData::ArraySP array = + Dispatch<StructuredData::ArraySP>("get_capabilities", error); + + if (!array || !array->IsValid() || error.Fail()) { + return ScriptedInterface::ErrorWithMessage<StructuredData::ArraySP>( + LLVM_PRETTY_FUNCTION, + llvm::Twine("Null or invalid object (" + + llvm::Twine(error.AsCString()) + llvm::Twine(").")) + .str(), + error); + } + + return array; +} + Status ScriptedProcessPythonInterface::Launch() { return GetStatusFromMethod("launch"); } Index: lldb/include/lldb/Interpreter/ScriptedProcessInterface.h =================================================================== --- lldb/include/lldb/Interpreter/ScriptedProcessInterface.h +++ lldb/include/lldb/Interpreter/ScriptedProcessInterface.h @@ -28,6 +28,8 @@ return {}; } + virtual StructuredData::ArraySP GetCapabilities() { return {}; } + virtual Status Launch() { return Status("ScriptedProcess did not launch"); } virtual Status Resume() { return Status("ScriptedProcess did not resume"); } Index: lldb/examples/python/scripted_process/scripted_process.py =================================================================== --- lldb/examples/python/scripted_process/scripted_process.py +++ lldb/examples/python/scripted_process/scripted_process.py @@ -14,6 +14,7 @@ THE METHODS EXPOSED MIGHT CHANGE IN THE FUTURE. """ + capabilities = None memory_regions = None loaded_images = None threads = None @@ -45,6 +46,11 @@ self.threads = {} self.loaded_images = [] self.metadata = {} + self.capabilities = {} + + @abstractmethod + def get_capabilities(self): + return self.capabilities @abstractmethod def get_memory_region_containing_address(self, addr):
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h +++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h @@ -29,6 +29,8 @@ StructuredData::DictionarySP args_sp, StructuredData::Generic *script_obj = nullptr) override; + StructuredData::ArraySP GetCapabilities() override; + Status Launch() override; Status Resume() override; Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp +++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp @@ -56,6 +56,23 @@ return m_object_instance_sp; } +StructuredData::ArraySP ScriptedProcessPythonInterface::GetCapabilities() { + Status error; + StructuredData::ArraySP array = + Dispatch<StructuredData::ArraySP>("get_capabilities", error); + + if (!array || !array->IsValid() || error.Fail()) { + return ScriptedInterface::ErrorWithMessage<StructuredData::ArraySP>( + LLVM_PRETTY_FUNCTION, + llvm::Twine("Null or invalid object (" + + llvm::Twine(error.AsCString()) + llvm::Twine(").")) + .str(), + error); + } + + return array; +} + Status ScriptedProcessPythonInterface::Launch() { return GetStatusFromMethod("launch"); } Index: lldb/include/lldb/Interpreter/ScriptedProcessInterface.h =================================================================== --- lldb/include/lldb/Interpreter/ScriptedProcessInterface.h +++ lldb/include/lldb/Interpreter/ScriptedProcessInterface.h @@ -28,6 +28,8 @@ return {}; } + virtual StructuredData::ArraySP GetCapabilities() { return {}; } + virtual Status Launch() { return Status("ScriptedProcess did not launch"); } virtual Status Resume() { return Status("ScriptedProcess did not resume"); } Index: lldb/examples/python/scripted_process/scripted_process.py =================================================================== --- lldb/examples/python/scripted_process/scripted_process.py +++ lldb/examples/python/scripted_process/scripted_process.py @@ -14,6 +14,7 @@ THE METHODS EXPOSED MIGHT CHANGE IN THE FUTURE. """ + capabilities = None memory_regions = None loaded_images = None threads = None @@ -45,6 +46,11 @@ self.threads = {} self.loaded_images = [] self.metadata = {} + self.capabilities = {} + + @abstractmethod + def get_capabilities(self): + return self.capabilities @abstractmethod def get_memory_region_containing_address(self, addr):
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits