2 Test breakpoint commands for a breakpoint ID with multiple locations.
5 from __future__ import print_function
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
16 class BreakpointLocationsTestCase(TestBase):
18 mydir = TestBase.compute_mydir(__file__)
20 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
22 """Test breakpoint enable/disable for a breakpoint ID with multiple locations."""
24 self.breakpoint_locations_test()
27 # Call super's setUp().
29 # Find the line number to break inside main().
30 self.line = line_number('main.c', '// Set break point at this line.')
32 def breakpoint_locations_test(self):
33 """Test breakpoint enable/disable for a breakpoint ID with multiple locations."""
34 exe = os.path.join(os.getcwd(), "a.out")
35 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
37 # This should create a breakpoint with 3 locations.
38 lldbutil.run_break_set_by_file_and_line(
39 self, "main.c", self.line, num_expected_locations=3)
41 # The breakpoint list should show 3 locations.
44 "Breakpoint locations shown correctly",
46 "1: file = 'main.c', line = %d, exact_match = 0, locations = 3" %
49 "where = a.out`func_inlined .+unresolved, hit count = 0",
50 "where = a.out`main .+\[inlined\].+unresolved, hit count = 0"])
52 # The 'breakpoint disable 3.*' command should fail gracefully.
53 self.expect("breakpoint disable 3.*",
54 "Disabling an invalid breakpoint should fail gracefully",
56 startstr="error: '3' is not a valid breakpoint ID.")
58 # The 'breakpoint disable 1.*' command should disable all 3 locations.
60 "breakpoint disable 1.*",
61 "All 3 breakpoint locatons disabled correctly",
62 startstr="3 breakpoints disabled.")
65 self.runCmd("run", RUN_SUCCEEDED)
67 # We should not stopped on any breakpoint at all.
68 self.expect("process status", "No stopping on any disabled breakpoint",
69 patterns=["^Process [0-9]+ exited with status = 0"])
71 # The 'breakpoint enable 1.*' command should enable all 3 breakpoints.
73 "breakpoint enable 1.*",
74 "All 3 breakpoint locatons enabled correctly",
75 startstr="3 breakpoints enabled.")
77 # The 'breakpoint disable 1.1' command should disable 1 location.
79 "breakpoint disable 1.1",
80 "1 breakpoint locatons disabled correctly",
81 startstr="1 breakpoints disabled.")
83 # Run the program againt. We should stop on the two breakpoint
85 self.runCmd("run", RUN_SUCCEEDED)
88 self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
89 substrs=["stop reason = breakpoint 1."])
91 # Continue the program, there should be another stop.
92 self.runCmd("process continue")
95 self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
96 substrs=["stop reason = breakpoint 1."])
98 # At this point, 1.1 has a hit count of 0 and the other a hit count of
101 "breakpoint list -f",
102 "The breakpoints should report correct hit counts",
104 "1\.1: .+ unresolved, hit count = 0 +Options: disabled",
105 "1\.2: .+ resolved, hit count = 1",
106 "1\.3: .+ resolved, hit count = 1"])