[clang] Fix implicit integer conversion for opaque enums declared in class templates...
[llvm-project.git] / lldb / test / API / commands / watchpoints / watchpoint_disable / TestWatchpointDisable.py
blob5fe5d17ca21cae489b223b654c0139beb07175dc
1 """
2 Test that the SBWatchpoint::SetEnable API works.
3 """
5 import lldb
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test.decorators import *
8 from lldbsuite.test import lldbplatform, lldbplatformutil
11 class TestWatchpointSetEnable(TestBase):
12 NO_DEBUG_INFO_TESTCASE = True
14 def test_disable_works(self):
15 """Set a watchpoint, disable it, and make sure it doesn't get hit."""
16 self.build()
17 self.do_test(False)
19 def test_disable_enable_works(self):
20 """Set a watchpoint, disable it, and make sure it doesn't get hit."""
21 self.build()
22 self.do_test(True)
24 def do_test(self, test_enable):
25 """Set a watchpoint, disable it and make sure it doesn't get hit."""
27 main_file_spec = lldb.SBFileSpec("main.c")
29 self.target = self.createTestTarget()
31 bkpt_before = self.target.BreakpointCreateBySourceRegex(
32 "Set a breakpoint here", main_file_spec
34 self.assertEqual(
35 bkpt_before.GetNumLocations(), 1, "Failed setting the before breakpoint."
38 bkpt_after = self.target.BreakpointCreateBySourceRegex(
39 "We should have stopped", main_file_spec
41 self.assertEqual(
42 bkpt_after.GetNumLocations(), 1, "Failed setting the after breakpoint."
45 process = self.target.LaunchSimple(
46 None, None, self.get_process_working_directory()
48 self.assertTrue(process, PROCESS_IS_VALID)
50 thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, bkpt_before)
51 self.assertTrue(thread.IsValid(), "We didn't stop at the before breakpoint.")
53 ret_val = lldb.SBCommandReturnObject()
54 self.dbg.GetCommandInterpreter().HandleCommand(
55 "watchpoint set variable -w write global_var", ret_val
57 self.assertTrue(
58 ret_val.Succeeded(), "Watchpoint set variable did not return success."
61 wp = self.target.FindWatchpointByID(1)
62 self.assertTrue(wp.IsValid(), "Didn't make a valid watchpoint.")
63 self.assertNotEqual(
64 wp.GetWatchAddress(), lldb.LLDB_INVALID_ADDRESS, "Watch address is invalid"
67 wp.SetEnabled(False)
68 self.assertTrue(not wp.IsEnabled(), "The watchpoint thinks it is still enabled")
70 process.Continue()
72 stop_reason = thread.GetStopReason()
74 self.assertStopReason(
75 stop_reason, lldb.eStopReasonBreakpoint, "We didn't stop at our breakpoint."
78 if test_enable:
79 wp.SetEnabled(True)
80 self.assertTrue(
81 wp.IsEnabled(), "The watchpoint thinks it is still disabled."
83 process.Continue()
84 stop_reason = thread.GetStopReason()
85 self.assertStopReason(
86 stop_reason,
87 lldb.eStopReasonWatchpoint,
88 "We didn't stop at our watchpoint",