1""" 2Test that breakpoint works correctly in the presence of dead-code stripping. 3""" 4 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class DeadStripTestCase(TestBase): 14 15 mydir = TestBase.compute_mydir(__file__) 16 17 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr44429") 18 def test(self): 19 """Test breakpoint works correctly with dead-code stripping.""" 20 self.build() 21 exe = self.getBuildArtifact("a.out") 22 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 23 24 # Break by function name f1 (live code). 25 lldbutil.run_break_set_by_symbol( 26 self, "f1", num_expected_locations=1, module_name="a.out") 27 28 # Break by function name f2 (dead code). 29 lldbutil.run_break_set_by_symbol( 30 self, "f2", num_expected_locations=0, module_name="a.out") 31 32 # Break by function name f3 (live code). 33 lldbutil.run_break_set_by_symbol( 34 self, "f3", num_expected_locations=1, module_name="a.out") 35 36 self.runCmd("run", RUN_SUCCEEDED) 37 38 # The stop reason of the thread should be breakpoint (breakpoint #1). 39 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 40 substrs=['stopped', 41 'a.out`f1', 42 'stop reason = breakpoint']) 43 44 # The breakpoint should have a hit count of 1. 45 lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1) 46 47 self.runCmd("continue") 48 49 # The stop reason of the thread should be breakpoint (breakpoint #3). 50 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 51 substrs=['stopped', 52 'a.out`f3', 53 'stop reason = breakpoint']) 54 55 # The breakpoint should have a hit count of 1. 56 lldbutil.check_breakpoint(self, bpno = 3, expected_hit_count = 1) 57