jingham created this revision. jingham added reviewers: jasonmolenda, JDevlieghere. Herald added a subscriber: kristof.beyls. Herald added a project: All. jingham requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
There were (at least) two problems that were causing TestStepOverWatchpoints.py to fail on arm64 Darwin systems. The first was that the "step over the watch instruction" plan that we pushed so we could report the watch stop when we knew the "old and new" values was a utility plan that wouldn't cause a user stop when it was done, and so instead of reporting the watchpoint we just continued on with the step. The second one may be specific to Darwin systems, but when you single-step the processor over an instruction that raises the watchpoint, when we stop the stop reason is Trace and not Watchpoint. That not lldb's interpretation, that what the exception we get from the kernel says. I don't have a good way to work around the second one yet, but I this patch fixes the first problem, and reworks the test so that we have a case that doesn't end up single-stepping over the instruction that triggers the watchpoint - which now succeeds on Darwin - and one that tests single-stepping over that instruction which still fails. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D146337 Files: lldb/source/Target/StopInfo.cpp lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py lldb/test/API/commands/watchpoints/step_over_watchpoint/main.c
Index: lldb/test/API/commands/watchpoints/step_over_watchpoint/main.c =================================================================== --- lldb/test/API/commands/watchpoints/step_over_watchpoint/main.c +++ lldb/test/API/commands/watchpoints/step_over_watchpoint/main.c @@ -11,8 +11,8 @@ } int main() { - watch_read(); - g_temp = g_watch_me_read; + watch_read(); // Set a breakpoint here + g_temp = g_watch_me_read; // Set breakpoint after call watch_write(); g_watch_me_write = g_temp; return 0; Index: lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py =================================================================== --- lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py +++ lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py @@ -11,36 +11,11 @@ class TestStepOverWatchpoint(TestBase): NO_DEBUG_INFO_TESTCASE = True - @expectedFailureAll( - oslist=["freebsd", "linux"], - archs=[ - 'aarch64', - 'arm'], - bugnumber="llvm.org/pr26031") - # Read-write watchpoints not supported on SystemZ - @expectedFailureAll(archs=['s390x']) - @expectedFailureAll( - oslist=["ios", "watchos", "tvos", "bridgeos", "macosx"], - archs=['aarch64', 'arm'], - bugnumber="<rdar://problem/34027183>") - @add_test_categories(["basic_process"]) - def test(self): + def get_to_start(self, bkpt_text): """Test stepping over watchpoints.""" self.build() - target = self.createTestTarget() - - lldbutil.run_break_set_by_symbol(self, 'main') - - process = target.LaunchSimple(None, None, - self.get_process_working_directory()) - self.assertTrue(process.IsValid(), PROCESS_IS_VALID) - self.assertState(process.GetState(), lldb.eStateStopped, - PROCESS_STOPPED) - - thread = lldbutil.get_stopped_thread(process, - lldb.eStopReasonBreakpoint) - self.assertTrue(thread.IsValid(), "Failed to get thread.") - + target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(self, bkpt_text, + lldb.SBFileSpec("main.c")) frame = thread.GetFrameAtIndex(0) self.assertTrue(frame.IsValid(), "Failed to get frame.") @@ -55,14 +30,45 @@ self.assertSuccess(error, "Error while setting watchpoint") self.assertTrue(read_watchpoint, "Failed to set read watchpoint.") + # Disable the breakpoint we hit so we don't muddy the waters with + # stepping off from the breakpoint: + bkpt.SetEnabled(False) + + return (target, process, thread, read_watchpoint) + + @expectedFailureAll( + oslist=["freebsd", "linux"], + archs=[ + 'aarch64', + 'arm'], + bugnumber="llvm.org/pr26031") + # Read-write watchpoints not supported on SystemZ + @expectedFailureAll(archs=['s390x']) + @add_test_categories(["basic_process"]) + def test_step_over(self): + target, process, thread, wp = self.get_to_start("Set a breakpoint here") + thread.StepOver() self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonWatchpoint, STOPPED_DUE_TO_WATCHPOINT) self.assertEquals(thread.GetStopDescription(20), 'watchpoint 1') - process.Continue() - self.assertState(process.GetState(), lldb.eStateStopped, - PROCESS_STOPPED) + @expectedFailureAll( + oslist=["freebsd", "linux"], + archs=[ + 'aarch64', + 'arm'], + bugnumber="llvm.org/pr26031") + # Read-write watchpoints not supported on SystemZ + @expectedFailureAll(archs=['s390x']) + @expectedFailureAll( + oslist=["ios", "watchos", "tvos", "bridgeos", "macosx"], + archs=['aarch64', 'arm'], + bugnumber="<rdar://problem/34027183>") + @add_test_categories(["basic_process"]) + def test_step_instruction(self): + target, process, thread, wp = self.get_to_start("Set breakpoint after call") + self.assertEquals(thread.GetStopDescription(20), 'step over') self.step_inst_for_watchpoint(1) Index: lldb/source/Target/StopInfo.cpp =================================================================== --- lldb/source/Target/StopInfo.cpp +++ lldb/source/Target/StopInfo.cpp @@ -831,6 +831,11 @@ = std::static_pointer_cast<StopInfoWatchpoint>(shared_from_this()); ThreadPlanSP step_over_wp_sp(new ThreadPlanStepOverWatchpoint( *(thread_sp.get()), me_as_siwp_sp, wp_sp)); + // When this plan is done we want to stop, so set this as a Controlling + // plan. + step_over_wp_sp->SetIsControllingPlan(true); + step_over_wp_sp->SetOkayToDiscard(false); + Status error; error = thread_sp->QueueThreadPlan(step_over_wp_sp, false); // If we couldn't push the thread plan, just stop here:
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits