mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 04:56:07 +00:00
[lldb/Plugins] Add ScriptedProcess::GetCapabilities affordance (NFC)
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. Differential Revision: https://reviews.llvm.org/D142059 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
This commit is contained in:
parent
e6cac17b56
commit
2d5348be25
@ -14,6 +14,7 @@ class ScriptedProcess(metaclass=ABCMeta):
|
||||
THE METHODS EXPOSED MIGHT CHANGE IN THE FUTURE.
|
||||
"""
|
||||
|
||||
capabilities = None
|
||||
memory_regions = None
|
||||
loaded_images = None
|
||||
threads = None
|
||||
@ -45,6 +46,17 @@ class ScriptedProcess(metaclass=ABCMeta):
|
||||
self.threads = {}
|
||||
self.loaded_images = []
|
||||
self.metadata = {}
|
||||
self.capabilities = {}
|
||||
|
||||
def get_capabilities(self):
|
||||
""" Get a dictionary containing the process capabilities.
|
||||
|
||||
Returns:
|
||||
Dict[str:bool]: The dictionary of capability, with the capability
|
||||
name as the key and a boolean flag as the value.
|
||||
The dictionary can be empty.
|
||||
"""
|
||||
return self.capabilities
|
||||
|
||||
@abstractmethod
|
||||
def get_memory_region_containing_address(self, addr):
|
||||
|
@ -28,6 +28,8 @@ public:
|
||||
return {};
|
||||
}
|
||||
|
||||
virtual StructuredData::DictionarySP GetCapabilities() { return {}; }
|
||||
|
||||
virtual Status Launch() { return Status("ScriptedProcess did not launch"); }
|
||||
|
||||
virtual Status Resume() { return Status("ScriptedProcess did not resume"); }
|
||||
|
@ -56,6 +56,17 @@ StructuredData::GenericSP ScriptedProcessPythonInterface::CreatePluginObject(
|
||||
return m_object_instance_sp;
|
||||
}
|
||||
|
||||
StructuredData::DictionarySP ScriptedProcessPythonInterface::GetCapabilities() {
|
||||
Status error;
|
||||
StructuredData::DictionarySP dict =
|
||||
Dispatch<StructuredData::DictionarySP>("get_capabilities", error);
|
||||
|
||||
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict, error))
|
||||
return {};
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
Status ScriptedProcessPythonInterface::Launch() {
|
||||
return GetStatusFromMethod("launch");
|
||||
}
|
||||
@ -140,14 +151,8 @@ StructuredData::ArraySP ScriptedProcessPythonInterface::GetLoadedImages() {
|
||||
StructuredData::ArraySP array =
|
||||
Dispatch<StructuredData::ArraySP>("get_loaded_images", 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);
|
||||
}
|
||||
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, array, error))
|
||||
return {};
|
||||
|
||||
return array;
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ public:
|
||||
StructuredData::DictionarySP args_sp,
|
||||
StructuredData::Generic *script_obj = nullptr) override;
|
||||
|
||||
StructuredData::DictionarySP GetCapabilities() override;
|
||||
|
||||
Status Launch() override;
|
||||
|
||||
Status Resume() override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user