1""" 2Test basics of mach core file debugging. 3""" 4 5 6import lldb 7from lldbsuite.test.decorators import * 8from lldbsuite.test.lldbtest import * 9from lldbsuite.test import lldbutil 10 11 12class MachCoreTestCase(TestBase): 13 NO_DEBUG_INFO_TESTCASE = True 14 15 # This was originally marked as expected failure on Windows, but it has 16 # started timing out instead, so the expectedFailure attribute no longer 17 # correctly tracks it: llvm.org/pr37371 18 @skipIfWindows 19 def test_selected_thread(self): 20 """Test that the right thread is selected after a core is loaded.""" 21 # Create core form YAML. 22 self.yaml2obj("test.core.yaml", self.getBuildArtifact("test.core")) 23 24 # Set debugger into synchronous mode 25 self.dbg.SetAsync(False) 26 27 # Create a target by the debugger. 28 target = self.dbg.CreateTarget("") 29 30 # Load OS plugin. 31 python_os_plugin_path = os.path.join(self.getSourceDir(), "operating_system.py") 32 command = "settings set target.process.python-os-plugin-path '{}'".format( 33 python_os_plugin_path 34 ) 35 self.dbg.HandleCommand(command) 36 37 # Load core. 38 process = target.LoadCore(self.getBuildArtifact("test.core")) 39 self.assertTrue(process, PROCESS_IS_VALID) 40 self.assertEqual(process.GetNumThreads(), 3) 41 42 # Verify our OS plug-in threads showed up 43 thread = process.GetThreadByID(0x111111111) 44 self.assertTrue( 45 thread.IsValid(), 46 "Make sure there is a thread 0x111111111 after we load the python OS plug-in", 47 ) 48 thread = process.GetThreadByID(0x222222222) 49 self.assertTrue( 50 thread.IsValid(), 51 "Make sure there is a thread 0x222222222 after we load the python OS plug-in", 52 ) 53 thread = process.GetThreadByID(0x333333333) 54 self.assertTrue( 55 thread.IsValid(), 56 "Make sure there is a thread 0x333333333 after we load the python OS plug-in", 57 ) 58 59 # Verify that the correct thread is selected 60 thread = process.GetSelectedThread() 61 self.assertEqual(thread.GetThreadID(), 0x111111111) 62