2 Test that the SBWatchpoint::SetEnable API works.
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."""
19 def test_disable_enable_works(self
):
20 """Set a watchpoint, disable it, and make sure it doesn't get hit."""
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
35 bkpt_before
.GetNumLocations(), 1, "Failed setting the before breakpoint."
38 bkpt_after
= self
.target
.BreakpointCreateBySourceRegex(
39 "We should have stopped", main_file_spec
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
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.")
64 wp
.GetWatchAddress(), lldb
.LLDB_INVALID_ADDRESS
, "Watch address is invalid"
68 self
.assertTrue(not wp
.IsEnabled(), "The watchpoint thinks it is still enabled")
72 stop_reason
= thread
.GetStopReason()
74 self
.assertStopReason(
75 stop_reason
, lldb
.eStopReasonBreakpoint
, "We didn't stop at our breakpoint."
81 wp
.IsEnabled(), "The watchpoint thinks it is still disabled."
84 stop_reason
= thread
.GetStopReason()
85 self
.assertStopReason(
87 lldb
.eStopReasonWatchpoint
,
88 "We didn't stop at our watchpoint",