1import lldb 2from lldbsuite.test.lldbtest import * 3from lldbsuite.test.decorators import * 4from gdbclientutils import * 5 6 7class TestThreadSelectionBug(GDBRemoteTestBase): 8 def test(self): 9 class MyResponder(MockGDBServerResponder): 10 def cont(self): 11 # Simulate process stopping due to a raise(SIGINT) 12 return "T01reason:signal" 13 14 self.server.responder = MyResponder() 15 target = self.createTarget("a.yaml") 16 process = self.connect(target) 17 python_os_plugin_path = os.path.join(self.getSourceDir(), 18 'operating_system.py') 19 command = "settings set target.process.python-os-plugin-path '{}'".format( 20 python_os_plugin_path) 21 self.dbg.HandleCommand(command) 22 23 self.assertTrue(process, PROCESS_IS_VALID) 24 self.assertEqual(process.GetNumThreads(), 3) 25 26 # Verify our OS plug-in threads showed up 27 thread = process.GetThreadByID(0x1) 28 self.assertTrue( 29 thread.IsValid(), 30 "Make sure there is a thread 0x1 after we load the python OS plug-in") 31 thread = process.GetThreadByID(0x2) 32 self.assertTrue( 33 thread.IsValid(), 34 "Make sure there is a thread 0x2 after we load the python OS plug-in") 35 thread = process.GetThreadByID(0x3) 36 self.assertTrue( 37 thread.IsValid(), 38 "Make sure there is a thread 0x3 after we load the python OS plug-in") 39 40 # Verify that a thread other than 3 is selected. 41 thread = process.GetSelectedThread() 42 self.assertNotEqual(thread.GetThreadID(), 0x3) 43 44 # Verify that we select the thread backed by physical thread 1, rather 45 # than virtual thread 1. The mapping comes from the OS plugin, where we 46 # specified that thread 3 is backed by real thread 1. 47 process.Continue() 48 thread = process.GetSelectedThread() 49 self.assertEqual(thread.GetThreadID(), 0x3) 50