[Lldb-commits] [lldb] 4858fe0 - [lldb/Plugins] Add ScriptedProcess::GetThreadsInfo interface
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Mon Jan 24 11:26:10 PST 2022
Author: Med Ismail Bennani
Date: 2022-01-24T20:25:53+01:00
New Revision: 4858fe04a1571e78ff97b778c0fb6a46855c3d6a
URL: https://github.com/llvm/llvm-project/commit/4858fe04a1571e78ff97b778c0fb6a46855c3d6a
DIFF: https://github.com/llvm/llvm-project/commit/4858fe04a1571e78ff97b778c0fb6a46855c3d6a.diff
LOG: [lldb/Plugins] Add ScriptedProcess::GetThreadsInfo interface
This patch adds a new method to the Scripted Process interface to
retrive a dictionary of Scripted Threads. It uses the thread ID as a key
and the Scripted Thread instance as the value.
This dictionary will be used to create Scripted Threads in lldb and
perform calls to the python scripted thread object.
rdar://87427126
Differential Revision: https://reviews.llvm.org/D117068
Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>
Added:
Modified:
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
Removed:
################################################################################
diff --git a/lldb/examples/python/scripted_process/scripted_process.py b/lldb/examples/python/scripted_process/scripted_process.py
index 16dcc72748532..ec751b495fdb6 100644
--- a/lldb/examples/python/scripted_process/scripted_process.py
+++ b/lldb/examples/python/scripted_process/scripted_process.py
@@ -19,6 +19,7 @@ class ScriptedProcess:
memory_regions = None
stack_memory_dump = None
loaded_images = None
+ threads = {}
@abstractmethod
def __init__(self, target, args):
@@ -51,6 +52,16 @@ def get_memory_region_containing_address(self, addr):
"""
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
index 26fd956f96bbc..efdea6df2d417 100644
--- a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
+++ b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
@@ -41,6 +41,8 @@ class ScriptedProcessInterface : virtual public ScriptedInterface {
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.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
index da8ff42213552..447bceebb00b4 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
@@ -92,6 +92,17 @@ ScriptedProcessPythonInterface::GetMemoryRegionContainingAddress(
return mem_region;
}
+StructuredData::DictionarySP ScriptedProcessPythonInterface::GetThreadsInfo() {
+ Status error;
+ StructuredData::DictionarySP dict =
+ Dispatch<StructuredData::DictionarySP>("get_threads_info", error);
+
+ if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict, error))
+ return {};
+
+ return dict;
+}
+
StructuredData::DictionarySP
ScriptedProcessPythonInterface::GetThreadWithID(lldb::tid_t tid) {
Status error;
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
index 421bdd59887ce..ac4e768b2d31b 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
@@ -39,6 +39,8 @@ class ScriptedProcessPythonInterface : public ScriptedProcessInterface,
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;
More information about the lldb-commits
mailing list