2 Test that a variable watchpoint should only hit when in scope.
7 from lldbsuite
.test
.lldbtest
import *
8 import lldbsuite
.test
.lldbutil
as lldbutil
9 from lldbsuite
.test
.decorators
import *
12 class WatchedVariableHitWhenInScopeTestCase(TestBase
):
13 NO_DEBUG_INFO_TESTCASE
= True
15 # This test depends on not tracking watchpoint expression hits if we have
16 # left the watchpoint scope. We will provide such an ability at some point
17 # but the way this was done was incorrect, and it is unclear that for the
18 # most part that's not what folks mostly want, so we have to provide a
19 # clearer API to express this.
22 # Call super's setUp().
24 # Our simple source filename.
25 self
.source
= "main.c"
26 self
.exe_name
= self
.testMethodName
27 self
.d
= {"C_SOURCES": self
.source
, "EXE": self
.exe_name
}
29 # Test hangs due to a kernel bug, see fdfeff0f in the linux kernel for details
30 @skipIfTargetAndroid(api_levels
=list(range(25 + 1)), archs
=["aarch64", "arm"])
32 def test_watched_var_should_only_hit_when_in_scope(self
):
33 """Test that a variable watchpoint should only hit when in scope."""
34 self
.build(dictionary
=self
.d
)
35 self
.setTearDownCleanup(dictionary
=self
.d
)
37 exe
= self
.getBuildArtifact(self
.exe_name
)
38 self
.runCmd("file " + exe
, CURRENT_EXECUTABLE_SET
)
40 # Add a breakpoint to set a watchpoint when stopped in main.
41 lldbutil
.run_break_set_by_symbol(self
, "main", num_expected_locations
=-1)
44 self
.runCmd("run", RUN_SUCCEEDED
)
46 # We should be stopped again due to the breakpoint.
47 # The stop reason of the thread should be breakpoint.
50 STOPPED_DUE_TO_BREAKPOINT
,
51 substrs
=["stopped", "stop reason = breakpoint"],
54 # Now let's set a watchpoint for 'c.a'.
55 # There should be only one watchpoint hit (see main.c).
57 "watchpoint set variable c.a",
59 substrs
=["Watchpoint created", "size = 4", "type = w"],
62 # Use the '-v' option to do verbose listing of the watchpoint.
63 # The hit count should be 0 initially.
64 self
.expect("watchpoint list -v", substrs
=["hit_count = 0"])
66 self
.runCmd("process continue")
68 # We should be stopped again due to the watchpoint (write type), but
69 # only once. The stop reason of the thread should be watchpoint.
72 STOPPED_DUE_TO_WATCHPOINT
,
73 substrs
=["stopped", "stop reason = watchpoint"],
76 self
.runCmd("process continue")
77 # Don't expect the read of 'global' to trigger a stop exception.
78 # The process status should be 'exited'.
79 self
.expect("process status", substrs
=["exited"])
81 # Use the '-v' option to do verbose listing of the watchpoint.
82 # The hit count should now be 1.
83 self
.expect("watchpoint list -v", substrs
=["hit_count = 1"])