Skip to content

Commit 4a43ee0

Browse files
committed
Re-enable StepOverWatchpoint test, make it more focused
This is my second recent change to TestStepOverWatchpoint.py, the first was to change the two global variables it is watching from 'char' to 'long' so they're more likely to be on separate words/doublewords of memory that can be watched indepdently. I believe this removes the need for the MIPS and S390X skips. The test was testing a combination of read and write watchpoints, stepping over a function that hits them, and then instruction stepping over a source line which hits them. But previously it was always starting with the read watchpoint in both of them, it didn't test the instruction-stepping for the read watchpoint. I now have to tests in TestStepOverWatchpoint.py, one which runs to the read-watchpoint function, sets that watchpoint, steps over another function which reads from that global, then instruction steps over a source line that reads from that global. The second test runs to the write-watchpoint function, sets that watchpoint. Steps over another function which writes to that global, then instruction steps over a source line that writes to that global. These are both xfailed on Darwin systems because watchpoints and hardware breakpoints are currently disabled by the kernel when instruction stepping.
1 parent e749757 commit 4a43ee0

File tree

2 files changed

+50
-35
lines changed

2 files changed

+50
-35
lines changed

lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Test stepping over watchpoints."""
1+
"""Test stepping over watchpoints and instruction stepping past watchpoints."""
22

33

44
import lldb
@@ -11,11 +11,25 @@ class TestStepOverWatchpoint(TestBase):
1111
NO_DEBUG_INFO_TESTCASE = True
1212

1313
def get_to_start(self, bkpt_text):
14-
"""Test stepping over watchpoints."""
14+
"""Test stepping over watchpoints and instruction stepping past watchpoints.."""
1515
self.build()
1616
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
1717
self, bkpt_text, lldb.SBFileSpec("main.c")
1818
)
19+
return (target, process, thread, frame, read_watchpoint)
20+
21+
@add_test_categories(["basic_process"])
22+
@expectedFailureAll(
23+
oslist=["ios", "watchos", "tvos", "bridgeos", "macosx"],
24+
archs=["aarch64", "arm"],
25+
bugnumber="<rdar://problem/106868647>",
26+
)
27+
def test_step_over_read_watchpoint(self):
28+
self.build()
29+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
30+
self, "break here for read watchpoints", lldb.SBFileSpec("main.c")
31+
)
32+
1933
frame = thread.GetFrameAtIndex(0)
2034
self.assertTrue(frame.IsValid(), "Failed to get frame.")
2135

@@ -33,14 +47,6 @@ def get_to_start(self, bkpt_text):
3347
# stepping off from the breakpoint:
3448
bkpt.SetEnabled(False)
3549

36-
return (target, process, thread, frame, read_watchpoint)
37-
38-
# Read-write watchpoints not supported on SystemZ
39-
@expectedFailureAll(archs=["s390x"])
40-
@add_test_categories(["basic_process"])
41-
def test_step_over(self):
42-
target, process, thread, frame, wp = self.get_to_start("Set a breakpoint here")
43-
4450
thread.StepOver()
4551
self.assertStopReason(
4652
thread.GetStopReason(),
@@ -49,39 +55,42 @@ def test_step_over(self):
4955
)
5056
self.assertEquals(thread.GetStopDescription(20), "watchpoint 1")
5157

58+
process.Continue()
59+
self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
60+
self.assertEquals(thread.GetStopDescription(20), "step over")
61+
62+
self.step_inst_for_watchpoint(1)
63+
5264
# Skip everywhere while modify watchpoints are sorted out.
53-
@skipTestIfFn(lambda : True)
5465
@expectedFailureAll(
5566
oslist=["freebsd", "linux"],
5667
archs=["aarch64", "arm"],
5768
bugnumber="llvm.org/pr26031",
5869
)
59-
# Read-write watchpoints not supported on SystemZ
60-
@expectedFailureAll(archs=["s390x"])
70+
@add_test_categories(["basic_process"])
6171
@expectedFailureAll(
6272
oslist=["ios", "watchos", "tvos", "bridgeos", "macosx"],
6373
archs=["aarch64", "arm"],
64-
bugnumber="<rdar://problem/34027183>",
74+
bugnumber="<rdar://problem/106868647>",
6575
)
66-
@add_test_categories(["basic_process"])
67-
def test_step_instruction(self):
68-
target, process, thread, frame, wp = self.get_to_start(
69-
"Set breakpoint after call"
76+
def test_step_over_write_watchpoint(self):
77+
self.build()
78+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
79+
self, "break here for modify watchpoints", lldb.SBFileSpec("main.c")
7080
)
7181

72-
self.step_inst_for_watchpoint(1)
82+
# Disable the breakpoint we hit so we don't muddy the waters with
83+
# stepping off from the breakpoint:
84+
bkpt.SetEnabled(False)
85+
86+
frame = thread.GetFrameAtIndex(0)
87+
self.assertTrue(frame.IsValid(), "Failed to get frame.")
7388

7489
write_value = frame.FindValue("g_watch_me_write", lldb.eValueTypeVariableGlobal)
7590
self.assertTrue(write_value, "Failed to find write value.")
7691

77-
# Most of the MIPS boards provide only one H/W watchpoints, and S/W
78-
# watchpoints are not supported yet
79-
arch = self.getArchitecture()
80-
if re.match("^mips", arch) or re.match("powerpc64le", arch):
81-
self.runCmd("watchpoint delete 1")
82-
8392
error = lldb.SBError()
84-
# resolve_location=True, read=False, write=True
93+
# resolve_location=True, read=False, modify=True
8594
write_watchpoint = write_value.Watch(True, False, True, error)
8695
self.assertTrue(write_watchpoint, "Failed to set write watchpoint.")
8796
self.assertSuccess(error, "Error while setting watchpoint")
@@ -92,13 +101,13 @@ def test_step_instruction(self):
92101
lldb.eStopReasonWatchpoint,
93102
STOPPED_DUE_TO_WATCHPOINT,
94103
)
95-
self.assertEquals(thread.GetStopDescription(20), "watchpoint 2")
104+
self.assertEquals(thread.GetStopDescription(20), "watchpoint 1")
96105

97106
process.Continue()
98107
self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
99108
self.assertEquals(thread.GetStopDescription(20), "step over")
100109

101-
self.step_inst_for_watchpoint(2)
110+
self.step_inst_for_watchpoint(1)
102111

103112
def step_inst_for_watchpoint(self, wp_id):
104113
watchpoint_hit = False

lldb/test/API/commands/watchpoints/step_over_watchpoint/main.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@ void watch_read() {
66
g_temp = g_watch_me_read;
77
}
88

9-
void watch_write() {
10-
g_watch_me_write = g_temp;
9+
void watch_write() { g_watch_me_write = g_temp++; }
10+
11+
void read_watchpoint_testing() {
12+
watch_read(); // break here for read watchpoints
13+
g_temp = g_watch_me_read;
14+
}
15+
16+
void watch_breakpoint_testing() {
17+
watch_write(); // break here for modify watchpoints
18+
g_watch_me_write = g_temp;
1119
}
1220

1321
int main() {
14-
watch_read(); // Set a breakpoint here
15-
g_temp = g_watch_me_read; // Set breakpoint after call
16-
watch_write();
17-
g_watch_me_write = g_temp + 1;
18-
return 0;
22+
read_watchpoint_testing();
23+
watch_breakpoint_testing();
24+
return 0;
1925
}

0 commit comments

Comments
 (0)