xref: /llvm-project/lldb/test/API/functionalities/watchpoint/modify-watchpoints/TestModifyWatchpoint.py (revision 75e862077834c06e574d34e8958dd2ee7cc1d334)
1"""
2Confirm that lldb modify watchpoints only stop
3when the value being watched changes.
4"""
5
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11
12
13@skipIfWindows
14class ModifyWatchpointTestCase(TestBase):
15    NO_DEBUG_INFO_TESTCASE = True
16
17    def test_modify_watchpoint(self):
18        """Test that a modify watchpoint only stops when the value changes."""
19        self.build()
20        self.main_source_file = lldb.SBFileSpec("main.c")
21        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
22            self, "break here", self.main_source_file
23        )
24
25        self.runCmd("watch set variable value")
26        process.Continue()
27        frame = process.GetSelectedThread().GetFrameAtIndex(0)
28        self.assertEqual(frame.locals["value"][0].GetValueAsUnsigned(), 10)
29
30        process.Continue()
31        frame = process.GetSelectedThread().GetFrameAtIndex(0)
32        self.assertEqual(frame.locals["value"][0].GetValueAsUnsigned(), 5)
33
34        process.Continue()
35        frame = process.GetSelectedThread().GetFrameAtIndex(0)
36        self.assertEqual(frame.locals["value"][0].GetValueAsUnsigned(), 7)
37
38        process.Continue()
39        frame = process.GetSelectedThread().GetFrameAtIndex(0)
40        self.assertEqual(frame.locals["value"][0].GetValueAsUnsigned(), 9)
41