[AMDGPU] Add True16 register classes.
[llvm-project.git] / lldb / test / API / commands / watchpoints / watchpoint_commands / condition / TestWatchpointConditionCmd.py
blob9e8db7025219daabdeb443c263a193f7ffd8bc9a
1 """
2 Test watchpoint modify command to set condition on a watchpoint.
3 """
6 import lldb
7 from lldbsuite.test.decorators import *
8 from lldbsuite.test.lldbtest import *
9 from lldbsuite.test import lldbutil
12 class WatchpointConditionCmdTestCase(TestBase):
13 NO_DEBUG_INFO_TESTCASE = True
15 def setUp(self):
16 # Call super's setUp().
17 TestBase.setUp(self)
18 # Our simple source filename.
19 self.source = "main.cpp"
20 # Find the line number to break inside main().
21 self.line = line_number(self.source, "// Set break point at this line.")
22 # And the watchpoint variable declaration line number.
23 self.decl = line_number(self.source, "// Watchpoint variable declaration.")
24 # Build dictionary to have unique executable names for each test
25 # method.
26 self.exe_name = self.testMethodName
27 self.d = {"CXX_SOURCES": self.source, "EXE": self.exe_name}
29 def test_watchpoint_cond(self):
30 """Test watchpoint condition."""
31 self.build(dictionary=self.d)
32 self.setTearDownCleanup(dictionary=self.d)
34 exe = self.getBuildArtifact(self.exe_name)
35 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
37 # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
38 lldbutil.run_break_set_by_file_and_line(
39 self, None, self.line, num_expected_locations=1
42 # Run the program.
43 self.runCmd("run", RUN_SUCCEEDED)
45 # We should be stopped again due to the breakpoint.
46 # The stop reason of the thread should be breakpoint.
47 self.expect(
48 "thread list",
49 STOPPED_DUE_TO_BREAKPOINT,
50 substrs=["stopped", "stop reason = breakpoint"],
53 # Now let's set a write-type watchpoint for 'global'.
54 # With a condition of 'global==5'.
55 self.expect(
56 "watchpoint set variable -w write global",
57 WATCHPOINT_CREATED,
58 substrs=[
59 "Watchpoint created",
60 "size = 4",
61 "type = w",
62 "%s:%d" % (self.source, self.decl),
66 self.runCmd("watchpoint modify -c 'global==5'")
68 # Use the '-v' option to do verbose listing of the watchpoint.
69 # The hit count should be 0 initially.
70 self.expect("watchpoint list -v", substrs=["global==5", "hit_count = 0"])
72 self.runCmd("process continue")
74 # We should be stopped again due to the watchpoint (write type).
75 # The stop reason of the thread should be watchpoint.
76 self.expect(
77 "thread backtrace",
78 STOPPED_DUE_TO_WATCHPOINT,
79 substrs=["stop reason = watchpoint"],
81 self.expect(
82 "frame variable --show-globals global", substrs=["(int32_t)", "global = 5"]
85 # Use the '-v' option to do verbose listing of the watchpoint.
86 # The hit count should now be 2.
87 self.expect("watchpoint list -v", substrs=["hit_count = 1"])