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 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr44429") 16 def test(self): 17 """Test breakpoint works correctly with dead-code stripping.""" 18 self.build() 19 exe = self.getBuildArtifact("a.out") 20 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 21 22 # Break by function name f1 (live code). 23 lldbutil.run_break_set_by_symbol( 24 self, "f1", num_expected_locations=1, module_name="a.out") 25 26 # Break by function name f2 (dead code). 27 lldbutil.run_break_set_by_symbol( 28 self, "f2", num_expected_locations=0, module_name="a.out") 29 30 # Break by function name f3 (live code). 31 lldbutil.run_break_set_by_symbol( 32 self, "f3", num_expected_locations=1, module_name="a.out") 33 34 self.runCmd("run", RUN_SUCCEEDED) 35 36 # The stop reason of the thread should be breakpoint (breakpoint #1). 37 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 38 substrs=['stopped', 39 'a.out`f1', 40 'stop reason = breakpoint']) 41 42 # The breakpoint should have a hit count of 1. 43 lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1) 44 45 self.runCmd("continue") 46 47 # The stop reason of the thread should be breakpoint (breakpoint #3). 48 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 49 substrs=['stopped', 50 'a.out`f3', 51 'stop reason = breakpoint']) 52 53 # The breakpoint should have a hit count of 1. 54 lldbutil.check_breakpoint(self, bpno = 3, expected_hit_count = 1) 55