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.
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
14 class WatchpointSlotsTestCase(TestBase):
15 NO_DEBUG_INFO_TESTCASE = True
17 mydir = TestBase.compute_mydir(__file__)
20 # Call super's setUp().
24 self.source = 'main.c'
27 self.exe_name = self.getBuildArtifact("a.out")
28 self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}
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):
34 self.build(dictionary=self.d)
35 self.setTearDownCleanup(dictionary=self.d)
37 exe = self.getBuildArtifact(self.exe_name)
38 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
40 # Detect line number after which we are going to increment arrayName.
41 loc_line = line_number('main.c', '// About to write byteArray')
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)
48 self.runCmd("run", RUN_SUCCEEDED)
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'])
54 # Delete breakpoint we just hit.
55 self.expect("breakpoint delete 1", substrs=['1 breakpoints deleted'])
57 # Set a watchpoint at byteArray[0]
58 self.expect("watchpoint set variable byteArray[0]", WATCHPOINT_CREATED,
59 substrs=['Watchpoint created','size = 1'])
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'])
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'])
72 self.runCmd("process continue")
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'])
79 # Delete the watchpoint we hit above successfully.
80 self.expect("watchpoint delete 1", substrs=['1 watchpoints deleted'])
82 # Set a watchpoint at byteArray[3]
83 self.expect("watchpoint set variable byteArray[3]", WATCHPOINT_CREATED,
84 substrs=['Watchpoint created','size = 1'])
87 self.runCmd("process continue")
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'])
96 self.expect("thread list -v", STOPPED_DUE_TO_WATCHPOINT,
97 substrs=['stopped', 'stop reason = watchpoint 3'])
100 self.runCmd("process continue")