Author: Med Ismail Bennani Date: 2023-03-03T19:33:02-08:00 New Revision: e02a355f9846d5ec9cd64b086674770ecc795c26
URL: https://github.com/llvm/llvm-project/commit/e02a355f9846d5ec9cd64b086674770ecc795c26 DIFF: https://github.com/llvm/llvm-project/commit/e02a355f9846d5ec9cd64b086674770ecc795c26.diff LOG: [lldb/Plugins] Clean-up Scripted Process interface requirements (NFC) The goal of the simple patch is to clean-up the scripted process interface by removing methods that were introduced with the interface originally, but that were never really implemented (get_thread_with_id & get_registers_for_thread). This patch also changes `get_memory_region_containing_address` to have a base implementation (that retunrs `None`), instead of forcing the user to override it in their derived class. Signed-off-by: Med Ismail Bennani <medismail.benn...@gmail.com> Added: Modified: lldb/examples/python/scripted_process/crashlog_scripted_process.py 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 lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py Removed: ################################################################################ diff --git a/lldb/examples/python/scripted_process/crashlog_scripted_process.py b/lldb/examples/python/scripted_process/crashlog_scripted_process.py index dfb32aae6d3f..8c32b40d8c8a 100644 --- a/lldb/examples/python/scripted_process/crashlog_scripted_process.py +++ b/lldb/examples/python/scripted_process/crashlog_scripted_process.py @@ -94,15 +94,6 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args : lldb.SBStructuredDat self.extended_thread_info = None self.parse_crashlog() - def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo: - return None - - def get_thread_with_id(self, tid: int): - return {} - - def get_registers_for_thread(self, tid: int): - return {} - def read_memory_at_address(self, addr: int, size: int, error: lldb.SBError) -> lldb.SBData: # NOTE: CrashLogs don't contain any memory. return lldb.SBData() diff --git a/lldb/examples/python/scripted_process/scripted_process.py b/lldb/examples/python/scripted_process/scripted_process.py index 8f896fc5acce..60b65fc4b4c9 100644 --- a/lldb/examples/python/scripted_process/scripted_process.py +++ b/lldb/examples/python/scripted_process/scripted_process.py @@ -58,7 +58,6 @@ def get_capabilities(self): """ return self.capabilities - @abstractmethod def get_memory_region_containing_address(self, addr): """ Get the memory region for the scripted process, containing a specific address. @@ -71,7 +70,7 @@ def get_memory_region_containing_address(self, addr): lldb.SBMemoryRegionInfo: The memory region containing the address. None if out of bounds. """ - pass + return None def get_threads_info(self): """ Get the dictionary describing the process' Scripted Threads. @@ -83,35 +82,6 @@ def get_threads_info(self): """ return self.threads - @abstractmethod - def get_thread_with_id(self, tid): - """ Get the scripted process thread with a specific ID. - - Args: - tid (int): Thread ID to look for in the scripted process. - - Returns: - Dict: The thread represented as a dictionary, with the - tid thread ID. None if tid doesn't match any of the scripted - process threads. - """ - pass - - @abstractmethod - def get_registers_for_thread(self, tid): - """ Get the register context dictionary for a certain thread of - the scripted process. - - Args: - tid (int): Thread ID for the thread's register context. - - Returns: - Dict: The register context represented as a dictionary, for the - tid thread. None if tid doesn't match any of the scripted - process threads. - """ - pass - @abstractmethod def read_memory_at_address(self, addr, size, error): """ Get a memory buffer from the scripted process at a certain address, diff --git a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h index 1fdac762e51e..ec0d7deac01b 100644 --- a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h +++ b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h @@ -50,14 +50,6 @@ class ScriptedProcessInterface : virtual public ScriptedInterface { virtual StructuredData::DictionarySP GetThreadsInfo() { return {}; } - virtual StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) { - return {}; - } - - virtual StructuredData::DictionarySP GetRegistersForThread(lldb::tid_t tid) { - return {}; - } - virtual lldb::DataExtractorSP ReadMemoryAtAddress(lldb::addr_t address, size_t size, Status &error) { return {}; diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp index c231828471bf..3ca4664587df 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp @@ -122,25 +122,6 @@ StructuredData::DictionarySP ScriptedProcessPythonInterface::GetThreadsInfo() { return dict; } -StructuredData::DictionarySP -ScriptedProcessPythonInterface::GetThreadWithID(lldb::tid_t tid) { - Status error; - StructuredData::ObjectSP obj = Dispatch("get_thread_with_id", error, tid); - - if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error)) - return {}; - - StructuredData::DictionarySP dict{obj->GetAsDictionary()}; - - return dict; -} - -StructuredData::DictionarySP -ScriptedProcessPythonInterface::GetRegistersForThread(lldb::tid_t tid) { - // TODO: Implement - return {}; -} - lldb::DataExtractorSP ScriptedProcessPythonInterface::ReadMemoryAtAddress( lldb::addr_t address, size_t size, Status &error) { Status py_error; diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h index 076ac37b0420..44273f1d0d0c 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h @@ -47,12 +47,9 @@ class ScriptedProcessPythonInterface : public ScriptedProcessInterface, StructuredData::DictionarySP GetThreadsInfo() override; - StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) override; - - StructuredData::DictionarySP GetRegistersForThread(lldb::tid_t tid) override; - lldb::DataExtractorSP ReadMemoryAtAddress(lldb::addr_t address, size_t size, Status &error) override; + StructuredData::ArraySP GetLoadedImages() override; diff --git a/lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py b/lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py index 94664114430e..47038144bb08 100644 --- a/lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py +++ b/lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py @@ -11,15 +11,6 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args : lldb.SBStructuredDat super().__init__(exe_ctx, args) self.threads[0] = DummyScriptedThread(self, None) - def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo: - return None - - def get_thread_with_id(self, tid: int): - return {} - - def get_registers_for_thread(self, tid: int): - return {} - def read_memory_at_address(self, addr: int, size: int, error: lldb.SBError) -> lldb.SBData: debugger = self.target.GetDebugger() index = debugger.GetIndexOfTarget(self.target) diff --git a/lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py b/lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py index 5852df9625d9..b931076b8978 100644 --- a/lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py +++ b/lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py @@ -11,15 +11,6 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args : lldb.SBStructuredDat super().__init__(exe_ctx, args) self.threads[0] = InvalidScriptedThread(self, None) - def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo: - return None - - def get_thread_with_id(self, tid: int): - return {} - - def get_registers_for_thread(self, tid: int): - return {} - def read_memory_at_address(self, addr: int, size: int, error: lldb.SBError) -> lldb.SBData: error.SetErrorString("This is an invalid scripted process!") return lldb.SBData() diff --git a/lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py b/lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py index 44a2a37fcc3f..e7e27fde98cc 100644 --- a/lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py +++ b/lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py @@ -59,12 +59,6 @@ def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegion return None return mem_region - def get_thread_with_id(self, tid: int): - return {} - - def get_registers_for_thread(self, tid: int): - return {} - def read_memory_at_address(self, addr: int, size: int, error: lldb.SBError) -> lldb.SBData: data = lldb.SBData() bytes_read = self.corefile_process.ReadMemory(addr, size, error) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits