843a2ac747727160f75f18adf4f4f8305b2b9d00
[openbsd] /
1 """
2 Test watchpoint slots we should not be able to install multiple watchpoints
3 within same word boundary. We should be able to install individual watchpoints
4 on any of the bytes, half-word, or word. This is only for ARM/AArch64 targets.
5 """
6
7
8 import lldb
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
12
13
14 class WatchpointSlotsTestCase(TestBase):
15     NO_DEBUG_INFO_TESTCASE = True
16
17     mydir = TestBase.compute_mydir(__file__)
18
19     def setUp(self):
20         # Call super's setUp().
21         TestBase.setUp(self)
22
23         # Source filename.
24         self.source = 'main.c'
25
26         # Output filename.
27         self.exe_name = self.getBuildArtifact("a.out")
28         self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}
29
30     # This is a arm and aarch64 specific test case. No other architectures tested.
31     @skipIf(archs=no_match(['arm', 'aarch64']))
32     def test_multiple_watchpoints_on_same_word(self):
33
34         self.build(dictionary=self.d)
35         self.setTearDownCleanup(dictionary=self.d)
36
37         exe = self.getBuildArtifact(self.exe_name)
38         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
39
40         # Detect line number after which we are going to increment arrayName.
41         loc_line = line_number('main.c', '// About to write byteArray')
42
43         # Set a breakpoint on the line detected above.
44         lldbutil.run_break_set_by_file_and_line(
45             self, "main.c", loc_line, num_expected_locations=1, loc_exact=True)
46
47         # Run the program.
48         self.runCmd("run", RUN_SUCCEEDED)
49
50         # The stop reason of the thread should be breakpoint.
51         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
52                      substrs=['stopped', 'stop reason = breakpoint'])
53
54         # Delete breakpoint we just hit.
55         self.expect("breakpoint delete 1", substrs=['1 breakpoints deleted'])
56
57         # Set a watchpoint at byteArray[0]
58         self.expect("watchpoint set variable byteArray[0]", WATCHPOINT_CREATED,
59                     substrs=['Watchpoint created','size = 1'])
60
61         # Use the '-v' option to do verbose listing of the watchpoint.
62         # The hit count should be 0 initially.
63         self.expect("watchpoint list -v 1", substrs=['hit_count = 0'])
64
65         # debugserver on ios doesn't give an error, it creates another watchpoint,
66         # only expect errors on non-darwin platforms.
67         if not self.platformIsDarwin():
68             # Try setting a watchpoint at byteArray[1]
69             self.expect("watchpoint set variable byteArray[1]", error=True,
70                         substrs=['Watchpoint creation failed'])
71
72         self.runCmd("process continue")
73
74         # We should be stopped due to the watchpoint.
75         # The stop reason of the thread should be watchpoint.
76         self.expect("thread list", STOPPED_DUE_TO_WATCHPOINT,
77                     substrs=['stopped', 'stop reason = watchpoint 1'])
78
79         # Delete the watchpoint we hit above successfully.
80         self.expect("watchpoint delete 1", substrs=['1 watchpoints deleted'])
81
82         # Set a watchpoint at byteArray[3]
83         self.expect("watchpoint set variable byteArray[3]", WATCHPOINT_CREATED,
84                     substrs=['Watchpoint created','size = 1'])
85
86         # Resume inferior.
87         self.runCmd("process continue")
88
89         # We should be stopped due to the watchpoint.
90         # The stop reason of the thread should be watchpoint.
91         if self.platformIsDarwin():
92             # On darwin we'll hit byteArray[3] which is watchpoint 2
93             self.expect("thread list -v", STOPPED_DUE_TO_WATCHPOINT,
94                         substrs=['stopped', 'stop reason = watchpoint 2'])
95         else:
96             self.expect("thread list -v", STOPPED_DUE_TO_WATCHPOINT,
97                         substrs=['stopped', 'stop reason = watchpoint 3'])
98
99         # Resume inferior.
100         self.runCmd("process continue")