1import lldb
2from lldbsuite.test.decorators import *
3from lldbsuite.test.lldbtest import *
4from lldbsuite.test import lldbutil
5
6class TestWatchpointCount(TestBase):
7    mydir = TestBase.compute_mydir(__file__)
8    NO_DEBUG_INFO_TESTCASE = True
9
10    def setUp(self):
11        TestBase.setUp(self)
12
13    @skipIf(oslist=["freebsd", "linux"], archs=["arm", "aarch64"],
14            bugnumber="llvm.org/pr26031")
15    def test_watchpoint_count(self):
16        self.build()
17        (_, process, thread, _) = lldbutil.run_to_source_breakpoint(self, "patatino", lldb.SBFileSpec("main.c"))
18        frame = thread.GetFrameAtIndex(0)
19        first_var = frame.FindVariable("x1")
20        second_var = frame.FindVariable("x2")
21
22        error = lldb.SBError()
23        first_watch = first_var.Watch(True, False, True, error)
24        if not error.Success():
25            self.fail(
26                "Failed to make watchpoint for x1: %s" %
27                (error.GetCString()))
28
29        second_watch = second_var.Watch(True, False, True, error)
30        if not error.Success():
31            self.fail(
32                "Failed to make watchpoint for x2: %s" %
33                (error.GetCString()))
34        process.Continue()
35
36        stop_reason = thread.GetStopReason()
37        self.assertEqual(stop_reason, lldb.eStopReasonWatchpoint, "watchpoint for x1 not hit")
38        stop_reason_descr = thread.GetStopDescription(256)
39        self.assertEqual(stop_reason_descr, "watchpoint 1")
40
41        process.Continue()
42        stop_reason = thread.GetStopReason()
43        self.assertEqual(stop_reason, lldb.eStopReasonWatchpoint, "watchpoint for x2 not hit")
44        stop_reason_descr = thread.GetStopDescription(256)
45        self.assertEqual(stop_reason_descr, "watchpoint 2")
46