2 Test watchpoint modify command to set condition on a watchpoint.
5 from __future__ import print_function
11 from lldbsuite.test.lldbtest import *
12 import lldbsuite.test.lldbutil as lldbutil
14 class WatchpointConditionCmdTestCase(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
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(self.source, '// Set break point at this line.')
25 # And the watchpoint variable declaration line number.
26 self.decl = line_number(self.source, '// Watchpoint variable declaration.')
27 # Build dictionary to have unique executable names for each test method.
28 self.exe_name = self.testMethodName
29 self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}
31 @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported
32 @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows
33 def test_watchpoint_cond(self):
34 """Test watchpoint condition."""
35 self.build(dictionary=self.d)
36 self.setTearDownCleanup(dictionary=self.d)
38 exe = os.path.join(os.getcwd(), self.exe_name)
39 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
41 # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
42 lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1)
45 self.runCmd("run", RUN_SUCCEEDED)
47 # We should be stopped again due to the breakpoint.
48 # The stop reason of the thread should be breakpoint.
49 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
51 'stop reason = breakpoint'])
53 # Now let's set a write-type watchpoint for 'global'.
54 # With a condition of 'global==5'.
55 self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED,
56 substrs = ['Watchpoint created', 'size = 4', 'type = w',
57 '%s:%d' % (self.source, self.decl)])
59 self.runCmd("watchpoint modify -c 'global==5'")
61 # Use the '-v' option to do verbose listing of the watchpoint.
62 # The hit count should be 0 initially.
63 self.expect("watchpoint list -v",
64 substrs = ['hit_count = 0', 'global==5'])
66 self.runCmd("process continue")
68 # We should be stopped again due to the watchpoint (write type).
69 # The stop reason of the thread should be watchpoint.
70 self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT,
71 substrs = ['stop reason = watchpoint'])
72 self.expect("frame variable --show-globals global",
73 substrs = ['(int32_t)', 'global = 5'])
75 # Use the '-v' option to do verbose listing of the watchpoint.
76 # The hit count should now be 2.
77 self.expect("watchpoint list -v",
78 substrs = ['hit_count = 5'])