diff --git a/lldb/examples/python/scripted_process/scripted_process.py b/lldb/examples/python/scripted_process/scripted_process.py --- a/lldb/examples/python/scripted_process/scripted_process.py +++ b/lldb/examples/python/scripted_process/scripted_process.py @@ -19,6 +19,7 @@ memory_regions = None stack_memory_dump = None loaded_images = None + threads = {} @abstractmethod def __init__(self, target, args): @@ -51,6 +52,16 @@ """ pass + def get_threads_info(self): + """ Get the dictionary describing the process' Scripted Threads. + + Returns: + Dict: The dictionary of threads, with the thread ID as the key and + a Scripted Thread instance as the value. + The dictionary can be empty. + """ + return self.threads + @abstractmethod def get_thread_with_id(self, tid): """ Get the scripted process thread with a specific ID. diff --git a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h --- a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h +++ b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h @@ -41,6 +41,8 @@ return {}; } + virtual StructuredData::DictionarySP GetThreadsInfo() { return nullptr; } + virtual StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) { return nullptr; } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h @@ -39,6 +39,8 @@ GetMemoryRegionContainingAddress(lldb::addr_t address, Status &error) override; + StructuredData::DictionarySP GetThreadsInfo() override; + StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) override; StructuredData::DictionarySP GetRegistersForThread(lldb::tid_t tid) override; diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp @@ -92,6 +92,17 @@ return mem_region; } +StructuredData::DictionarySP ScriptedProcessPythonInterface::GetThreadsInfo() { + Status error; + StructuredData::DictionarySP dict = + Dispatch("get_threads_info", error); + + if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict, error)) + return {}; + + return dict; +} + StructuredData::DictionarySP ScriptedProcessPythonInterface::GetThreadWithID(lldb::tid_t tid) { Status error;