2 Test watchpoint modify command to set condition on a watchpoint.
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
13 class WatchpointConditionCmdTestCase(TestBase):
15 mydir = TestBase.compute_mydir(__file__)
16 NO_DEBUG_INFO_TESTCASE = True
19 # Call super's setUp().
21 # Our simple source filename.
22 self.source = 'main.cpp'
23 # Find the line number to break inside main().
24 self.line = line_number(
25 self.source, '// Set break point at this line.')
26 # And the watchpoint variable declaration line number.
27 self.decl = line_number(self.source,
28 '// Watchpoint variable declaration.')
29 # Build dictionary to have unique executable names for each test
31 self.exe_name = self.testMethodName
32 self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}
34 def test_watchpoint_cond(self):
35 """Test watchpoint condition."""
36 self.build(dictionary=self.d)
37 self.setTearDownCleanup(dictionary=self.d)
39 exe = self.getBuildArtifact(self.exe_name)
40 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
42 # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
43 lldbutil.run_break_set_by_file_and_line(
44 self, None, self.line, num_expected_locations=1)
47 self.runCmd("run", RUN_SUCCEEDED)
49 # We should be stopped again due to the breakpoint.
50 # The stop reason of the thread should be breakpoint.
51 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
53 'stop reason = breakpoint'])
55 # Now let's set a write-type watchpoint for 'global'.
56 # With a condition of 'global==5'.
58 "watchpoint set variable -w write global",
68 self.runCmd("watchpoint modify -c 'global==5'")
70 # Use the '-v' option to do verbose listing of the watchpoint.
71 # The hit count should be 0 initially.
72 self.expect("watchpoint list -v",
73 substrs=['hit_count = 0', 'global==5'])
75 self.runCmd("process continue")
77 # We should be stopped again due to the watchpoint (write type).
78 # The stop reason of the thread should be watchpoint.
79 self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT,
80 substrs=['stop reason = watchpoint'])
81 self.expect("frame variable --show-globals global",
82 substrs=['(int32_t)', 'global = 5'])
84 # Use the '-v' option to do verbose listing of the watchpoint.
85 # The hit count should now be 2.
86 self.expect("watchpoint list -v",
87 substrs=['hit_count = 5'])