[Lldb-commits] [PATCH] D142059: [lldb/Plugins] Add ScriptedProcess::GetCapabilities affordance (NFC)
Med Ismail Bennani via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 3 19:33:23 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2d5348be2561: [lldb/Plugins] Add ScriptedProcess::GetCapabilities affordance (NFC) (authored by mib).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142059/new/
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::DictionarySP 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,17 @@
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 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;
}
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::DictionarySP 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,17 @@
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):
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142059.502337.patch
Type: text/x-patch
Size: 3511 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230304/caf892d8/attachment-0001.bin>
More information about the lldb-commits
mailing list