|
| 1 | +""" |
| 2 | +Test basics of mach core file debugging. |
| 3 | +""" |
| 4 | + |
| 5 | +from __future__ import print_function |
| 6 | + |
| 7 | +import shutil |
| 8 | +import struct |
| 9 | + |
| 10 | +import lldb |
| 11 | +from lldbsuite.test.decorators import * |
| 12 | +from lldbsuite.test.lldbtest import * |
| 13 | +from lldbsuite.test import lldbutil |
| 14 | + |
| 15 | + |
| 16 | +class MachCoreTestCase(TestBase): |
| 17 | + NO_DEBUG_INFO_TESTCASE = True |
| 18 | + |
| 19 | + mydir = TestBase.compute_mydir(__file__) |
| 20 | + |
| 21 | + def setUp(self): |
| 22 | + super(MachCoreTestCase, self).setUp() |
| 23 | + self._initial_platform = lldb.DBG.GetSelectedPlatform() |
| 24 | + |
| 25 | + def tearDown(self): |
| 26 | + lldb.DBG.SetSelectedPlatform(self._initial_platform) |
| 27 | + super(MachCoreTestCase, self).tearDown() |
| 28 | + |
| 29 | + def test_selected_thread(self): |
| 30 | + """Test that the right thread is selected after a core is loaded.""" |
| 31 | + # Create core form YAML. |
| 32 | + self.yaml2obj("test.core.yaml", self.getBuildArtifact("test.core")) |
| 33 | + |
| 34 | + # Set debugger into synchronous mode |
| 35 | + self.dbg.SetAsync(False) |
| 36 | + |
| 37 | + # Create a target by the debugger. |
| 38 | + target = self.dbg.CreateTarget("") |
| 39 | + |
| 40 | + # Load OS plugin. |
| 41 | + python_os_plugin_path = os.path.join(self.getSourceDir(), |
| 42 | + 'operating_system.py') |
| 43 | + command = "settings set target.process.python-os-plugin-path '{}'".format( |
| 44 | + python_os_plugin_path) |
| 45 | + self.dbg.HandleCommand(command) |
| 46 | + |
| 47 | + # Load core. |
| 48 | + process = target.LoadCore(self.getBuildArtifact("test.core")) |
| 49 | + self.assertTrue(process, PROCESS_IS_VALID) |
| 50 | + self.assertEqual(process.GetNumThreads(), 3) |
| 51 | + |
| 52 | + # Verify our OS plug-in threads showed up |
| 53 | + thread = process.GetThreadByID(0x111111111) |
| 54 | + self.assertTrue(thread.IsValid( |
| 55 | + ), "Make sure there is a thread 0x111111111 after we load the python OS plug-in" |
| 56 | + ) |
| 57 | + thread = process.GetThreadByID(0x222222222) |
| 58 | + self.assertTrue(thread.IsValid( |
| 59 | + ), "Make sure there is a thread 0x222222222 after we load the python OS plug-in" |
| 60 | + ) |
| 61 | + thread = process.GetThreadByID(0x333333333) |
| 62 | + self.assertTrue(thread.IsValid( |
| 63 | + ), "Make sure there is a thread 0x333333333 after we load the python OS plug-in" |
| 64 | + ) |
| 65 | + |
| 66 | + # Verify that the correct thread is selected |
| 67 | + thread = process.GetSelectedThread() |
| 68 | + self.assertEqual(thread.GetThreadID(), 0x333333333) |
0 commit comments