]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / breakpoint / breakpoint_locations / TestBreakpointLocations.py
1 """
2 Test breakpoint commands for a breakpoint ID with multiple locations.
3 """
4
5 from __future__ import print_function
6
7
8 import os
9 import time
10 import lldb
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
14
15
16 class BreakpointLocationsTestCase(TestBase):
17
18     mydir = TestBase.compute_mydir(__file__)
19
20     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
21     def test(self):
22         """Test breakpoint enable/disable for a breakpoint ID with multiple locations."""
23         self.build()
24         self.breakpoint_locations_test()
25
26     def setUp(self):
27         # Call super's setUp().
28         TestBase.setUp(self)
29         # Find the line number to break inside main().
30         self.line = line_number('main.c', '// Set break point at this line.')
31
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)
36
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)
40
41         # The breakpoint list should show 3 locations.
42         self.expect(
43             "breakpoint list -f",
44             "Breakpoint locations shown correctly",
45             substrs=[
46                 "1: file = 'main.c', line = %d, exact_match = 0, locations = 3" %
47                 self.line],
48             patterns=[
49                 "where = a.out`func_inlined .+unresolved, hit count = 0",
50                 "where = a.out`main .+\[inlined\].+unresolved, hit count = 0"])
51
52         # The 'breakpoint disable 3.*' command should fail gracefully.
53         self.expect("breakpoint disable 3.*",
54                     "Disabling an invalid breakpoint should fail gracefully",
55                     error=True,
56                     startstr="error: '3' is not a valid breakpoint ID.")
57
58         # The 'breakpoint disable 1.*' command should disable all 3 locations.
59         self.expect(
60             "breakpoint disable 1.*",
61             "All 3 breakpoint locatons disabled correctly",
62             startstr="3 breakpoints disabled.")
63
64         # Run the program.
65         self.runCmd("run", RUN_SUCCEEDED)
66
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"])
70
71         # The 'breakpoint enable 1.*' command should enable all 3 breakpoints.
72         self.expect(
73             "breakpoint enable 1.*",
74             "All 3 breakpoint locatons enabled correctly",
75             startstr="3 breakpoints enabled.")
76
77         # The 'breakpoint disable 1.1' command should disable 1 location.
78         self.expect(
79             "breakpoint disable 1.1",
80             "1 breakpoint locatons disabled correctly",
81             startstr="1 breakpoints disabled.")
82
83         # Run the program againt.  We should stop on the two breakpoint
84         # locations.
85         self.runCmd("run", RUN_SUCCEEDED)
86
87         # Stopped once.
88         self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
89                     substrs=["stop reason = breakpoint 1."])
90
91         # Continue the program, there should be another stop.
92         self.runCmd("process continue")
93
94         # Stopped again.
95         self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
96                     substrs=["stop reason = breakpoint 1."])
97
98         # At this point, 1.1 has a hit count of 0 and the other a hit count of
99         # 1".
100         self.expect(
101             "breakpoint list -f",
102             "The breakpoints should report correct hit counts",
103             patterns=[
104                 "1\.1: .+ unresolved, hit count = 0 +Options: disabled",
105                 "1\.2: .+ resolved, hit count = 1",
106                 "1\.3: .+ resolved, hit count = 1"])