]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / watchpoint / watchpoint_commands / condition / TestWatchpointConditionCmd.py
1 """
2 Test watchpoint modify command to set condition on a watchpoint.
3 """
4
5 from __future__ import print_function
6
7
8 import os
9 import time
10 import lldb
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
14
15
16 class WatchpointConditionCmdTestCase(TestBase):
17
18     mydir = TestBase.compute_mydir(__file__)
19
20     def setUp(self):
21         # Call super's setUp().
22         TestBase.setUp(self)
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
32         # method.
33         self.exe_name = self.testMethodName
34         self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}
35
36     # Watchpoints not supported
37     @expectedFailureAndroid(archs=['arm', 'aarch64'])
38     @expectedFailureAll(
39         oslist=["linux"],
40         archs=["aarch64"],
41         bugnumber="llvm.org/pr27710")
42     @expectedFailureAll(
43         oslist=["windows"],
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)
49
50         exe = os.path.join(os.getcwd(), self.exe_name)
51         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
52
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)
56
57         # Run the program.
58         self.runCmd("run", RUN_SUCCEEDED)
59
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,
63                     substrs=['stopped',
64                              'stop reason = breakpoint'])
65
66         # Now let's set a write-type watchpoint for 'global'.
67         # With a condition of 'global==5'.
68         self.expect(
69             "watchpoint set variable -w write global",
70             WATCHPOINT_CREATED,
71             substrs=[
72                 'Watchpoint created',
73                 'size = 4',
74                 'type = w',
75                 '%s:%d' %
76                 (self.source,
77                  self.decl)])
78
79         self.runCmd("watchpoint modify -c 'global==5'")
80
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'])
85
86         self.runCmd("process continue")
87
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'])
94
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'])