================
@@ -0,0 +1,92 @@
+"""
+Test that a watchpoint refreshes its "current value"
+when re-enabled.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ReEnableWatchpointTestCase(TestBase):
+    NO_DEBUG_INFO_TESTCASE = True
+
+    def continue_and_report_stop_reason(self, process, iter_str):
+        process.Continue()
+        self.assertIn(
+            process.GetState(), [lldb.eStateStopped, lldb.eStateExited], 
iter_str
+        )
+        thread = process.GetSelectedThread()
+        return thread.GetStopReason()
+
+    def test_reenable_watchpoint(self):
+        """Test that re-enabling a watchpoint updates its saved value."""
+        self.build()
+        src = lldb.SBFileSpec("main.c")
+        target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+            self, "break", src
+        )
+
+        #
+        # Variable c has value 0.
+        # Add watchpoint, check that it has cached value 0.
+        #
+        frame = thread.GetFrameAtIndex(0)
+        
self.assertEqual(frame.GetValueForVariablePath("c").GetValueAsUnsigned(), 0)
+
+        interp = self.dbg.GetCommandInterpreter()
+        result = lldb.SBCommandReturnObject()
+        interp.HandleCommand("watch set variable c", result)
+        self.assertTrue(result.Succeeded(), "watch set ran successfully")
+        results = result.GetOutput()
+        self.assertIn("new value: 0", results)
+
+        #
+        # We've hit the watchpoint, confirm c has value 1 now.
+        #
+        reason = self.continue_and_report_stop_reason(
----------------
jimingham wrote:

We already have `lldbutil.continue_to_breakpoint`, maybe instead of a local 
`continue_and_report_stop_reason` you could implement the equivalent 
`lldbutil.continue_to_watchpoint`?

https://github.com/llvm/llvm-project/pull/219333
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to