summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2018-04-12 09:58:20 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2018-04-12 09:58:20 +0000
commit0045c72f9c40192fd6e1905a82dca94ecb1ec8b5 (patch)
tree4274f2baa121a554a0bbb9deef12a2615e131438 /lldb/packages/Python
parent4955c77c2df3e00b96fa71e20aee119ba0d991e9 (diff)
downloadbcm5719-llvm-0045c72f9c40192fd6e1905a82dca94ecb1ec8b5.tar.gz
bcm5719-llvm-0045c72f9c40192fd6e1905a82dca94ecb1ec8b5.zip
Don't assume backing thread shares protocol ID.
When we're dealing with virtual (memory) threads created by the OS plugins, there's no guarantee that the real thread and the backing thread share a protocol ID. Instead, we should iterate over the memory threads to find the virtual thread that is backed by the current real thread. Differential revision: https://reviews.llvm.org/D45497 rdar://36485830 llvm-svn: 329891
Diffstat (limited to 'lldb/packages/Python')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestThreadSelectionBug.py50
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system.py45
2 files changed, 95 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestThreadSelectionBug.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestThreadSelectionBug.py
new file mode 100644
index 00000000000..400a9366103
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestThreadSelectionBug.py
@@ -0,0 +1,50 @@
+from __future__ import print_function
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestThreadSelectionBug(GDBRemoteTestBase):
+ def test(self):
+ class MyResponder(MockGDBServerResponder):
+ def cont(self):
+ # Simulate process stopping due to a raise(SIGINT)
+ return "T01reason:signal"
+
+ self.server.responder = MyResponder()
+ target = self.createTarget("a.yaml")
+ process = self.connect(target)
+ python_os_plugin_path = os.path.join(self.getSourceDir(),
+ 'operating_system.py')
+ command = "settings set target.process.python-os-plugin-path '{}'".format(
+ python_os_plugin_path)
+ self.dbg.HandleCommand(command)
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+ self.assertEqual(process.GetNumThreads(), 3)
+
+ # Verify our OS plug-in threads showed up
+ thread = process.GetThreadByID(0x1)
+ self.assertTrue(
+ thread.IsValid(),
+ "Make sure there is a thread 0x1 after we load the python OS plug-in")
+ thread = process.GetThreadByID(0x2)
+ self.assertTrue(
+ thread.IsValid(),
+ "Make sure there is a thread 0x2 after we load the python OS plug-in")
+ thread = process.GetThreadByID(0x3)
+ self.assertTrue(
+ thread.IsValid(),
+ "Make sure there is a thread 0x3 after we load the python OS plug-in")
+
+ # Verify that a thread other than 3 is selected.
+ thread = process.GetSelectedThread()
+ self.assertNotEqual(thread.GetThreadID(), 0x3)
+
+ # Verify that we select the thread backed by physical thread 1, rather
+ # than virtual thread 1. The mapping comes from the OS plugin, where we
+ # specified that thread 3 is backed by real thread 1.
+ process.Continue()
+ thread = process.GetSelectedThread()
+ self.assertEqual(thread.GetThreadID(), 0x3)
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system.py
new file mode 100644
index 00000000000..ad9b6fd4e55
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/operating_system.py
@@ -0,0 +1,45 @@
+import lldb
+import struct
+
+
+class OperatingSystemPlugIn(object):
+ """Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class"""
+
+ def __init__(self, process):
+ '''Initialization needs a valid.SBProcess object.
+
+ This plug-in will get created after a live process is valid and has stopped for the first time.
+ '''
+ self.process = None
+ self.registers = None
+ self.threads = None
+ if isinstance(process, lldb.SBProcess) and process.IsValid():
+ self.process = process
+ self.threads = None # Will be an dictionary containing info for each thread
+
+ def get_target(self):
+ return self.process.target
+
+ def get_thread_info(self):
+ if not self.threads:
+ self.threads = [{
+ 'tid': 0x1,
+ 'name': 'one',
+ 'queue': 'queue1',
+ 'state': 'stopped',
+ 'stop_reason': 'none'
+ }, {
+ 'tid': 0x2,
+ 'name': 'two',
+ 'queue': 'queue2',
+ 'state': 'stopped',
+ 'stop_reason': 'none'
+ }, {
+ 'tid': 0x3,
+ 'name': 'three',
+ 'queue': 'queue3',
+ 'state': 'stopped',
+ 'stop_reason': 'sigstop',
+ 'core': 0
+ }]
+ return self.threads
OpenPOWER on IntegriCloud