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