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