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