summaryrefslogtreecommitdiff
path: root/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
diff options
context:
space:
mode:
authorFelipe de Azevedo Piovezan <fpiovezan@apple.com>2025-02-28 16:13:12 -0800
committerGitHub <noreply@github.com>2025-02-28 16:13:12 -0800
commit11b9466c04db4da7439fc1d9d8ba7241a9d68705 (patch)
tree76836aa31c460fc7ba8545be08a838f01fcb1737 /lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
parent45d018097c8e92f1978478382426c683b19be88f (diff)
[lldb] Add ability to inspect backing threads with `thread info` (#129275)
When OS plugins are present, it can be helpful to query information about the backing thread behind an OS thread, if it exists. There is no mechanism to do so prior to this commit. As a first step, this commit enhances `thread info` with a `--backing-thread` flag, causing the command to use the backing thread of the selected thread, if it exists.
Diffstat (limited to 'lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py')
-rw-r--r--lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py b/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
index fe78edd98f4d..e4997f0742d0 100644
--- a/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
+++ b/lldb/test/API/functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py
@@ -131,6 +131,26 @@ class PluginPythonOSPlugin(TestBase):
"Make sure there is no thread 0x333333333 after we unload the python OS plug-in",
)
+ tid_regex = re.compile(r"tid = ((0x)?[0-9a-fA-F]+)")
+
+ def get_tid_from_thread_info_command(self, thread, use_backing_thread):
+ interp = self.dbg.GetCommandInterpreter()
+ result = lldb.SBCommandReturnObject()
+
+ backing_thread_arg = ""
+ if use_backing_thread:
+ backing_thread_arg = "--backing-thread"
+
+ interp.HandleCommand(
+ "thread info {0} {1}".format(thread.GetIndexID(), backing_thread_arg),
+ result,
+ True,
+ )
+ self.assertTrue(result.Succeeded(), "failed to run thread info")
+ match = self.tid_regex.search(result.GetOutput())
+ self.assertNotEqual(match, None)
+ return int(match.group(1), 0)
+
def run_python_os_step(self):
"""Test that the Python operating system plugin works correctly and allows single stepping of a virtual thread that is backed by a real thread"""
@@ -209,6 +229,11 @@ class PluginPythonOSPlugin(TestBase):
# it to
thread.StepOver()
+ tid_os = self.get_tid_from_thread_info_command(thread, False)
+ self.assertEqual(tid_os, 0x111111111)
+ tid_real = self.get_tid_from_thread_info_command(thread, True)
+ self.assertNotEqual(tid_os, tid_real)
+
frame = thread.GetFrameAtIndex(0)
self.assertTrue(
frame.IsValid(), "Make sure we get a frame from thread 0x111111111"