2 Test watchpoint modify command to set condition on a watchpoint.
5 from __future__ import print_function
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
16 class WatchpointConditionCmdTestCase(TestBase):
18 mydir = TestBase.compute_mydir(__file__)
21 # Call super's setUp().
23 # Our simple source filename.
24 self.source = 'main.cpp'
25 # Find the line number to break inside main().
26 self.line = line_number(
27 self.source, '// Set break point at this line.')
28 # And the watchpoint variable declaration line number.
29 self.decl = line_number(self.source,
30 '// Watchpoint variable declaration.')
31 # Build dictionary to have unique executable names for each test
33 self.exe_name = self.testMethodName
34 self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}
36 # Watchpoints not supported
37 @expectedFailureAndroid(archs=['arm', 'aarch64'])
41 bugnumber="llvm.org/pr27710")
44 bugnumber="llvm.org/pr24446: WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows")
45 def test_watchpoint_cond(self):
46 """Test watchpoint condition."""
47 self.build(dictionary=self.d)
48 self.setTearDownCleanup(dictionary=self.d)
50 exe = os.path.join(os.getcwd(), self.exe_name)
51 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
53 # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
54 lldbutil.run_break_set_by_file_and_line(
55 self, None, self.line, num_expected_locations=1)
58 self.runCmd("run", RUN_SUCCEEDED)
60 # We should be stopped again due to the breakpoint.
61 # The stop reason of the thread should be breakpoint.
62 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
64 'stop reason = breakpoint'])
66 # Now let's set a write-type watchpoint for 'global'.
67 # With a condition of 'global==5'.
69 "watchpoint set variable -w write global",
79 self.runCmd("watchpoint modify -c 'global==5'")
81 # Use the '-v' option to do verbose listing of the watchpoint.
82 # The hit count should be 0 initially.
83 self.expect("watchpoint list -v",
84 substrs=['hit_count = 0', 'global==5'])
86 self.runCmd("process continue")
88 # We should be stopped again due to the watchpoint (write type).
89 # The stop reason of the thread should be watchpoint.
90 self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT,
91 substrs=['stop reason = watchpoint'])
92 self.expect("frame variable --show-globals global",
93 substrs=['(int32_t)', 'global = 5'])
95 # Use the '-v' option to do verbose listing of the watchpoint.
96 # The hit count should now be 2.
97 self.expect("watchpoint list -v",
98 substrs=['hit_count = 5'])