0419b4df5dd11242d13a7aaaa0bac53092d52d95
[openbsd] /
1 """
2 Test breakpoint command for different options.
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.lldbtest import *
9 import lldbsuite.test.lldbutil as lldbutil
10
11
12 class BreakpointOptionsTestCase(TestBase):
13
14     mydir = TestBase.compute_mydir(__file__)
15
16     def test(self):
17         """Test breakpoint command for different options."""
18         self.build()
19         self.breakpoint_options_test()
20
21     def setUp(self):
22         # Call super's setUp().
23         TestBase.setUp(self)
24         # Find the line number to break inside main().
25         self.line = line_number('main.cpp', '// Set break point at this line.')
26
27     def breakpoint_options_test(self):
28         """Test breakpoint command for different options."""
29         exe = self.getBuildArtifact("a.out")
30         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
31
32         # This should create a breakpoint with 1 locations.
33         lldbutil.run_break_set_by_file_and_line(
34             self,
35             "main.cpp",
36             self.line,
37             extra_options="-K 1",
38             num_expected_locations=1)
39         lldbutil.run_break_set_by_file_and_line(
40             self,
41             "main.cpp",
42             self.line,
43             extra_options="-K 0",
44             num_expected_locations=1)
45
46         # Run the program.
47         self.runCmd("run", RUN_SUCCEEDED)
48
49         # Stopped once.
50         self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
51                     substrs=["stop reason = breakpoint 2."])
52
53         # Check the list of breakpoint.
54         self.expect(
55             "breakpoint list -f",
56             "Breakpoint locations shown correctly",
57             substrs=[
58                 "1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" %
59                 self.line,
60                 "2: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" %
61                 self.line])
62
63         # Continue the program, there should be another stop.
64         self.runCmd("process continue")
65
66         # Stopped again.
67         self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
68                     substrs=["stop reason = breakpoint 1."])
69
70         # Continue the program, we should exit.
71         self.runCmd("process continue")
72
73         # We should exit.
74         self.expect("process status", "Process exited successfully",
75                     patterns=["^Process [0-9]+ exited with status = 0"])
76
77     def breakpoint_options_language_test(self):
78         """Test breakpoint command for language option."""
79         exe = self.getBuildArtifact("a.out")
80         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
81
82         # This should create a breakpoint with 1 locations.
83         lldbutil.run_break_set_by_symbol(
84             self,
85             'ns::func',
86             sym_exact=False,
87             extra_options="-L c++",
88             num_expected_locations=1)
89
90         # This should create a breakpoint with 0 locations.
91         lldbutil.run_break_set_by_symbol(
92             self,
93             'ns::func',
94             sym_exact=False,
95             extra_options="-L c",
96             num_expected_locations=0)
97         self.runCmd("settings set target.language c")
98         lldbutil.run_break_set_by_symbol(
99             self, 'ns::func', sym_exact=False, num_expected_locations=0)
100
101         # Run the program.
102         self.runCmd("run", RUN_SUCCEEDED)
103
104         # Stopped once.
105         self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
106                     substrs=["stop reason = breakpoint 1."])
107
108         # Continue the program, we should exit.
109         self.runCmd("process continue")
110
111         # We should exit.
112         self.expect("process status", "Process exited successfully",
113                     patterns=["^Process [0-9]+ exited with status = 0"])