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