Skip to content

Commit 7c7884b

Browse files
authored
Merge pull request #6911 from jimingham/partial-step-over-wp
Fix the part of stepping over watchpoints that lldb can fix
2 parents 8971304 + 91e01de commit 7c7884b

File tree

3 files changed

+45
-34
lines changed

3 files changed

+45
-34
lines changed

lldb/source/Target/StopInfo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,11 @@ class StopInfoWatchpoint : public StopInfo {
831831
= std::static_pointer_cast<StopInfoWatchpoint>(shared_from_this());
832832
ThreadPlanSP step_over_wp_sp(new ThreadPlanStepOverWatchpoint(
833833
*(thread_sp.get()), me_as_siwp_sp, wp_sp));
834+
// When this plan is done we want to stop, so set this as a Controlling
835+
// plan.
836+
step_over_wp_sp->SetIsControllingPlan(true);
837+
step_over_wp_sp->SetOkayToDiscard(false);
838+
834839
Status error;
835840
error = thread_sp->QueueThreadPlan(step_over_wp_sp, false);
836841
// If we couldn't push the thread plan, just stop here:

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

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,11 @@
1111
class TestStepOverWatchpoint(TestBase):
1212
NO_DEBUG_INFO_TESTCASE = True
1313

14-
@expectedFailureAll(
15-
oslist=["freebsd", "linux"],
16-
archs=[
17-
'aarch64',
18-
'arm'],
19-
bugnumber="llvm.org/pr26031")
20-
@expectedFailureAll(oslist=["linux"], bugnumber="bugs.swift.org/SR-796")
21-
# Read-write watchpoints not supported on SystemZ
22-
@expectedFailureAll(archs=['s390x'])
23-
@expectedFailureAll(
24-
oslist=["ios", "watchos", "tvos", "bridgeos", "macosx"],
25-
archs=['aarch64', 'arm'],
26-
bugnumber="<rdar://problem/34027183>")
27-
@add_test_categories(["basic_process"])
28-
def test(self):
14+
def get_to_start(self, bkpt_text):
2915
"""Test stepping over watchpoints."""
3016
self.build()
31-
target = self.createTestTarget()
32-
33-
lldbutil.run_break_set_by_symbol(self, 'main')
34-
35-
process = target.LaunchSimple(None, None,
36-
self.get_process_working_directory())
37-
self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
38-
self.assertState(process.GetState(), lldb.eStateStopped,
39-
PROCESS_STOPPED)
40-
41-
thread = lldbutil.get_stopped_thread(process,
42-
lldb.eStopReasonBreakpoint)
43-
self.assertTrue(thread.IsValid(), "Failed to get thread.")
44-
17+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(self, bkpt_text,
18+
lldb.SBFileSpec("main.c"))
4519
frame = thread.GetFrameAtIndex(0)
4620
self.assertTrue(frame.IsValid(), "Failed to get frame.")
4721

@@ -56,14 +30,45 @@ def test(self):
5630
self.assertSuccess(error, "Error while setting watchpoint")
5731
self.assertTrue(read_watchpoint, "Failed to set read watchpoint.")
5832

33+
# Disable the breakpoint we hit so we don't muddy the waters with
34+
# stepping off from the breakpoint:
35+
bkpt.SetEnabled(False)
36+
37+
return (target, process, thread, frame, read_watchpoint)
38+
39+
@expectedFailureAll(
40+
oslist=["freebsd", "linux"],
41+
archs=[
42+
'aarch64',
43+
'arm'],
44+
bugnumber="llvm.org/pr26031")
45+
# Read-write watchpoints not supported on SystemZ
46+
@expectedFailureAll(archs=['s390x'])
47+
@add_test_categories(["basic_process"])
48+
def test_step_over(self):
49+
target, process, thread, frame, wp = self.get_to_start("Set a breakpoint here")
50+
5951
thread.StepOver()
6052
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonWatchpoint,
6153
STOPPED_DUE_TO_WATCHPOINT)
6254
self.assertEquals(thread.GetStopDescription(20), 'watchpoint 1')
6355

64-
process.Continue()
65-
self.assertState(process.GetState(), lldb.eStateStopped,
66-
PROCESS_STOPPED)
56+
@expectedFailureAll(
57+
oslist=["freebsd", "linux"],
58+
archs=[
59+
'aarch64',
60+
'arm'],
61+
bugnumber="llvm.org/pr26031")
62+
# Read-write watchpoints not supported on SystemZ
63+
@expectedFailureAll(archs=['s390x'])
64+
@expectedFailureAll(
65+
oslist=["ios", "watchos", "tvos", "bridgeos", "macosx"],
66+
archs=['aarch64', 'arm'],
67+
bugnumber="<rdar://problem/34027183>")
68+
@add_test_categories(["basic_process"])
69+
def test_step_instruction(self):
70+
target, process, thread, frame, wp = self.get_to_start("Set breakpoint after call")
71+
6772
self.assertEquals(thread.GetStopDescription(20), 'step over')
6873

6974
self.step_inst_for_watchpoint(1)
@@ -78,6 +83,7 @@ def test(self):
7883
if re.match("^mips", arch) or re.match("powerpc64le", arch):
7984
self.runCmd("watchpoint delete 1")
8085

86+
error = lldb.SBError()
8187
# resolve_location=True, read=False, write=True
8288
write_watchpoint = write_value.Watch(True, False, True, error)
8389
self.assertTrue(write_watchpoint, "Failed to set write watchpoint.")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ void watch_write() {
1111
}
1212

1313
int main() {
14-
watch_read();
15-
g_temp = g_watch_me_read;
14+
watch_read(); // Set a breakpoint here
15+
g_temp = g_watch_me_read; // Set breakpoint after call
1616
watch_write();
1717
g_watch_me_write = g_temp;
1818
return 0;

0 commit comments

Comments
 (0)