summaryrefslogtreecommitdiffstats
path: root/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands')
-rw-r--r--packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py313
-rw-r--r--packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py139
-rw-r--r--packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py87
-rw-r--r--packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/main.cpp28
-rw-r--r--packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py78
-rw-r--r--packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp28
-rw-r--r--packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/main.c24
10 files changed, 712 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/Makefile b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/Makefile
new file mode 100644
index 0000000..b09a579
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py
new file mode 100644
index 0000000..339de45
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py
@@ -0,0 +1,313 @@
+"""
+Test watchpoint list, enable, disable, and delete commands.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class WatchpointCommandsTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Our simple source filename.
+ self.source = 'main.c'
+ # Find the line number to break inside main().
+ self.line = line_number(self.source, '// Set break point at this line.')
+ self.line2 = line_number(self.source, '// Set 2nd break point for disable_then_enable test case.')
+ # And the watchpoint variable declaration line number.
+ self.decl = line_number(self.source, '// Watchpoint variable declaration.')
+ # Build dictionary to have unique executable names for each test method.
+ self.exe_name = self.testMethodName
+ self.d = {'C_SOURCES': self.source, 'EXE': self.exe_name}
+
+ @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported
+ @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows
+ def test_rw_watchpoint(self):
+ """Test read_write watchpoint and expect to stop two times."""
+ self.build(dictionary=self.d)
+ self.setTearDownCleanup(dictionary=self.d)
+
+ exe = os.path.join(os.getcwd(), self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
+ lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1)
+
+ # Run the program.
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # We should be stopped again due to the breakpoint.
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # Now let's set a read_write-type watchpoint for 'global'.
+ # There should be two watchpoint hits (see main.c).
+ self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED,
+ substrs = ['Watchpoint created', 'size = 4', 'type = rw',
+ '%s:%d' % (self.source, self.decl)])
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ # The hit count should be 0 initially.
+ self.expect("watchpoint list -v",
+ substrs = ['Number of supported hardware watchpoints:',
+ 'hit_count = 0'])
+
+ self.runCmd("process continue")
+
+ # We should be stopped again due to the watchpoint (read_write type).
+ # The stop reason of the thread should be watchpoint.
+ self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT,
+ substrs = ['stop reason = watchpoint'])
+
+ self.runCmd("process continue")
+
+ # We should be stopped again due to the watchpoint (read_write type).
+ # The stop reason of the thread should be watchpoint.
+ self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT,
+ substrs = ['stop reason = watchpoint'])
+
+ self.runCmd("process continue")
+
+ # There should be no more watchpoint hit and the process status should
+ # be 'exited'.
+ self.expect("process status",
+ substrs = ['exited'])
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ # The hit count should now be 2.
+ self.expect("watchpoint list -v",
+ substrs = ['hit_count = 2'])
+
+ @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported
+ @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows
+ def test_rw_watchpoint_delete(self):
+ """Test delete watchpoint and expect not to stop for watchpoint."""
+ self.build(dictionary=self.d)
+ self.setTearDownCleanup(dictionary=self.d)
+
+ exe = os.path.join(os.getcwd(), self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
+ lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1)
+
+ # Run the program.
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # We should be stopped again due to the breakpoint.
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # Now let's set a read_write-type watchpoint for 'global'.
+ # There should be two watchpoint hits (see main.c).
+ self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED,
+ substrs = ['Watchpoint created', 'size = 4', 'type = rw',
+ '%s:%d' % (self.source, self.decl)])
+
+ # Delete the watchpoint immediately, but set auto-confirm to true first.
+ self.runCmd("settings set auto-confirm true")
+ self.expect("watchpoint delete",
+ substrs = ['All watchpoints removed.'])
+ # Restore the original setting of auto-confirm.
+ self.runCmd("settings clear auto-confirm")
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ self.runCmd("watchpoint list -v")
+
+ self.runCmd("process continue")
+
+ # There should be no more watchpoint hit and the process status should
+ # be 'exited'.
+ self.expect("process status",
+ substrs = ['exited'])
+
+ @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported
+ @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows
+ def test_rw_watchpoint_set_ignore_count(self):
+ """Test watchpoint ignore count and expect to not to stop at all."""
+ self.build(dictionary=self.d)
+ self.setTearDownCleanup(dictionary=self.d)
+
+ exe = os.path.join(os.getcwd(), self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
+ lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1)
+
+ # Run the program.
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # We should be stopped again due to the breakpoint.
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # Now let's set a read_write-type watchpoint for 'global'.
+ # There should be two watchpoint hits (see main.c).
+ self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED,
+ substrs = ['Watchpoint created', 'size = 4', 'type = rw',
+ '%s:%d' % (self.source, self.decl)])
+
+ # Set the ignore count of the watchpoint immediately.
+ self.expect("watchpoint ignore -i 2",
+ substrs = ['All watchpoints ignored.'])
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ # Expect to find an ignore_count of 2.
+ self.expect("watchpoint list -v",
+ substrs = ['hit_count = 0', 'ignore_count = 2'])
+
+ self.runCmd("process continue")
+
+ # There should be no more watchpoint hit and the process status should
+ # be 'exited'.
+ self.expect("process status",
+ substrs = ['exited'])
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ # Expect to find a hit_count of 2 as well.
+ self.expect("watchpoint list -v",
+ substrs = ['hit_count = 2', 'ignore_count = 2'])
+
+ @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported
+ @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows
+ def test_rw_disable_after_first_stop(self):
+ """Test read_write watchpoint but disable it after the first stop."""
+ self.build(dictionary=self.d)
+ self.setTearDownCleanup(dictionary=self.d)
+
+ exe = os.path.join(os.getcwd(), self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
+ lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1)
+
+ # Run the program.
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # We should be stopped again due to the breakpoint.
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # Now let's set a read_write-type watchpoint for 'global'.
+ # There should be two watchpoint hits (see main.c).
+ self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED,
+ substrs = ['Watchpoint created', 'size = 4', 'type = rw',
+ '%s:%d' % (self.source, self.decl)])
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ # The hit count should be 0 initially.
+ self.expect("watchpoint list -v",
+ substrs = ['state = enabled', 'hit_count = 0'])
+
+ self.runCmd("process continue")
+
+ # We should be stopped again due to the watchpoint (read_write type).
+ # The stop reason of the thread should be watchpoint.
+ self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT,
+ substrs = ['stop reason = watchpoint'])
+
+ # Before continuing, we'll disable the watchpoint, which means we won't
+ # stop again after this.
+ self.runCmd("watchpoint disable")
+
+ self.expect("watchpoint list -v",
+ substrs = ['state = disabled', 'hit_count = 1'])
+
+ self.runCmd("process continue")
+
+ # There should be no more watchpoint hit and the process status should
+ # be 'exited'.
+ self.expect("process status",
+ substrs = ['exited'])
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ # The hit count should be 1.
+ self.expect("watchpoint list -v",
+ substrs = ['hit_count = 1'])
+
+ @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported
+ @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows
+ def test_rw_disable_then_enable(self):
+ """Test read_write watchpoint, disable initially, then enable it."""
+ self.build(dictionary=self.d)
+ self.setTearDownCleanup(dictionary=self.d)
+
+ exe = os.path.join(os.getcwd(), self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
+ lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1)
+ lldbutil.run_break_set_by_file_and_line (self, None, self.line2, num_expected_locations=1)
+
+ # Run the program.
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # We should be stopped again due to the breakpoint.
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # Now let's set a read_write-type watchpoint for 'global'.
+ # There should be two watchpoint hits (see main.c).
+ self.expect("watchpoint set variable -w read_write global", WATCHPOINT_CREATED,
+ substrs = ['Watchpoint created', 'size = 4', 'type = rw',
+ '%s:%d' % (self.source, self.decl)])
+
+ # Immediately, we disable the watchpoint. We won't be stopping due to a
+ # watchpoint after this.
+ self.runCmd("watchpoint disable")
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ # The hit count should be 0 initially.
+ self.expect("watchpoint list -v",
+ substrs = ['state = disabled', 'hit_count = 0'])
+
+ self.runCmd("process continue")
+
+ # We should be stopped again due to the breakpoint.
+ self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stop reason = breakpoint'])
+
+ # Before continuing, we'll enable the watchpoint, which means we will
+ # stop again after this.
+ self.runCmd("watchpoint enable")
+
+ self.expect("watchpoint list -v",
+ substrs = ['state = enabled', 'hit_count = 0'])
+
+ self.runCmd("process continue")
+
+ # We should be stopped again due to the watchpoint (read_write type).
+ # The stop reason of the thread should be watchpoint.
+ self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT,
+ substrs = ['stop reason = watchpoint'])
+
+ self.runCmd("process continue")
+
+ # There should be no more watchpoint hit and the process status should
+ # be 'exited'.
+ self.expect("process status",
+ substrs = ['exited'])
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ # The hit count should be 1.
+ self.expect("watchpoint list -v",
+ substrs = ['hit_count = 1'])
diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/Makefile b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/Makefile
new file mode 100644
index 0000000..ee6b9cc
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py
new file mode 100644
index 0000000..f2bf908
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandLLDB.py
@@ -0,0 +1,139 @@
+"""
+Test 'watchpoint command'.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class WatchpointLLDBCommandTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Our simple source filename.
+ self.source = 'main.cpp'
+ # Find the line number to break inside main().
+ self.line = line_number(self.source, '// Set break point at this line.')
+ # And the watchpoint variable declaration line number.
+ self.decl = line_number(self.source, '// Watchpoint variable declaration.')
+ # Build dictionary to have unique executable names for each test method.
+ self.exe_name = 'a%d.out' % self.test_number
+ self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}
+
+ @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported
+ @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows
+ def test_watchpoint_command(self):
+ """Test 'watchpoint command'."""
+ self.build(dictionary=self.d)
+ self.setTearDownCleanup(dictionary=self.d)
+
+ exe = os.path.join(os.getcwd(), self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
+ lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1)
+
+ # Run the program.
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # We should be stopped again due to the breakpoint.
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # Now let's set a write-type watchpoint for 'global'.
+ self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED,
+ substrs = ['Watchpoint created', 'size = 4', 'type = w',
+ '%s:%d' % (self.source, self.decl)])
+
+ self.runCmd('watchpoint command add 1 -o "expr -- cookie = 777"')
+
+ # List the watchpoint command we just added.
+ self.expect("watchpoint command list 1",
+ substrs = ['expr -- cookie = 777'])
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ # The hit count should be 0 initially.
+ self.expect("watchpoint list -v",
+ substrs = ['hit_count = 0'])
+
+ self.runCmd("process continue")
+
+ # We should be stopped again due to the watchpoint (write type).
+ # The stop reason of the thread should be watchpoint.
+ self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT,
+ substrs = ['stop reason = watchpoint'])
+
+ # Check that the watchpoint snapshoting mechanism is working.
+ self.expect("watchpoint list -v",
+ substrs = ['old value:', ' = 0',
+ 'new value:', ' = 1'])
+
+ # The watchpoint command "forced" our global variable 'cookie' to become 777.
+ self.expect("frame variable --show-globals cookie",
+ substrs = ['(int32_t)', 'cookie = 777'])
+
+ @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported
+ @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows
+ def test_watchpoint_command_can_disable_a_watchpoint(self):
+ """Test that 'watchpoint command' action can disable a watchpoint after it is triggered."""
+ self.build(dictionary=self.d)
+ self.setTearDownCleanup(dictionary=self.d)
+
+ exe = os.path.join(os.getcwd(), self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
+ lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1)
+
+ # Run the program.
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # We should be stopped again due to the breakpoint.
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # Now let's set a write-type watchpoint for 'global'.
+ self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED,
+ substrs = ['Watchpoint created', 'size = 4', 'type = w',
+ '%s:%d' % (self.source, self.decl)])
+
+ self.runCmd('watchpoint command add 1 -o "watchpoint disable 1"')
+
+ # List the watchpoint command we just added.
+ self.expect("watchpoint command list 1",
+ substrs = ['watchpoint disable 1'])
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ # The hit count should be 0 initially.
+ self.expect("watchpoint list -v",
+ substrs = ['hit_count = 0'])
+
+ self.runCmd("process continue")
+
+ # We should be stopped again due to the watchpoint (write type).
+ # The stop reason of the thread should be watchpoint.
+ self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT,
+ substrs = ['stop reason = watchpoint'])
+
+ # Check that the watchpoint has been disabled.
+ self.expect("watchpoint list -v",
+ substrs = ['disabled'])
+
+ self.runCmd("process continue")
+
+ # There should be no more watchpoint hit and the process status should
+ # be 'exited'.
+ self.expect("process status",
+ substrs = ['exited'])
diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py
new file mode 100644
index 0000000..a476aeb
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/TestWatchpointCommandPython.py
@@ -0,0 +1,87 @@
+"""
+Test 'watchpoint command'.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class WatchpointPythonCommandTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Our simple source filename.
+ self.source = 'main.cpp'
+ # Find the line number to break inside main().
+ self.line = line_number(self.source, '// Set break point at this line.')
+ # And the watchpoint variable declaration line number.
+ self.decl = line_number(self.source, '// Watchpoint variable declaration.')
+ # Build dictionary to have unique executable names for each test method.
+ self.exe_name = self.testMethodName
+ self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}
+
+ @skipIfFreeBSD # timing out on buildbot
+ @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows
+ @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported
+ def test_watchpoint_command(self):
+ """Test 'watchpoint command'."""
+ self.build(dictionary=self.d)
+ self.setTearDownCleanup(dictionary=self.d)
+
+ exe = os.path.join(os.getcwd(), self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
+ lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1)
+# self.expect("breakpoint set -l %d" % self.line, BREAKPOINT_CREATED,
+# startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" %
+# (self.source, self.line))#
+
+ # Run the program.
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # We should be stopped again due to the breakpoint.
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # Now let's set a write-type watchpoint for 'global'.
+ self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED,
+ substrs = ['Watchpoint created', 'size = 4', 'type = w',
+ '%s:%d' % (self.source, self.decl)])
+
+ self.runCmd('watchpoint command add -s python 1 -o \'frame.EvaluateExpression("cookie = 777")\'')
+
+ # List the watchpoint command we just added.
+ self.expect("watchpoint command list 1",
+ substrs = ['frame.EvaluateExpression', 'cookie = 777'])
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ # The hit count should be 0 initially.
+ self.expect("watchpoint list -v",
+ substrs = ['hit_count = 0'])
+
+ self.runCmd("process continue")
+
+ # We should be stopped again due to the watchpoint (write type).
+ # The stop reason of the thread should be watchpoint.
+ self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT,
+ substrs = ['stop reason = watchpoint'])
+
+ # Check that the watchpoint snapshoting mechanism is working.
+ self.expect("watchpoint list -v",
+ substrs = ['old value:', ' = 0',
+ 'new value:', ' = 1'])
+
+ # The watchpoint command "forced" our global variable 'cookie' to become 777.
+ self.expect("frame variable --show-globals cookie",
+ substrs = ['(int32_t)', 'cookie = 777'])
diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/main.cpp b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/main.cpp
new file mode 100644
index 0000000..6cb80c6
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/command/main.cpp
@@ -0,0 +1,28 @@
+//===-- main.c --------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+#include <stdint.h>
+
+int32_t global = 0; // Watchpoint variable declaration.
+int32_t cookie = 0;
+
+static void modify(int32_t &var) {
+ ++var;
+}
+
+int main(int argc, char** argv) {
+ int local = 0;
+ printf("&global=%p\n", &global);
+ printf("about to write to 'global'...\n"); // Set break point at this line.
+ for (int i = 0; i < 10; ++i)
+ modify(global);
+
+ printf("global=%d\n", global);
+ printf("cookie=%d\n", cookie);
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/Makefile b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/Makefile
new file mode 100644
index 0000000..ee6b9cc
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py
new file mode 100644
index 0000000..355204a
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py
@@ -0,0 +1,78 @@
+"""
+Test watchpoint modify command to set condition on a watchpoint.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class WatchpointConditionCmdTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Our simple source filename.
+ self.source = 'main.cpp'
+ # Find the line number to break inside main().
+ self.line = line_number(self.source, '// Set break point at this line.')
+ # And the watchpoint variable declaration line number.
+ self.decl = line_number(self.source, '// Watchpoint variable declaration.')
+ # Build dictionary to have unique executable names for each test method.
+ self.exe_name = self.testMethodName
+ self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}
+
+ @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported
+ @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows
+ def test_watchpoint_cond(self):
+ """Test watchpoint condition."""
+ self.build(dictionary=self.d)
+ self.setTearDownCleanup(dictionary=self.d)
+
+ exe = os.path.join(os.getcwd(), self.exe_name)
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
+ lldbutil.run_break_set_by_file_and_line (self, None, self.line, num_expected_locations=1)
+
+ # Run the program.
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # We should be stopped again due to the breakpoint.
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # Now let's set a write-type watchpoint for 'global'.
+ # With a condition of 'global==5'.
+ self.expect("watchpoint set variable -w write global", WATCHPOINT_CREATED,
+ substrs = ['Watchpoint created', 'size = 4', 'type = w',
+ '%s:%d' % (self.source, self.decl)])
+
+ self.runCmd("watchpoint modify -c 'global==5'")
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ # The hit count should be 0 initially.
+ self.expect("watchpoint list -v",
+ substrs = ['hit_count = 0', 'global==5'])
+
+ self.runCmd("process continue")
+
+ # We should be stopped again due to the watchpoint (write type).
+ # The stop reason of the thread should be watchpoint.
+ self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT,
+ substrs = ['stop reason = watchpoint'])
+ self.expect("frame variable --show-globals global",
+ substrs = ['(int32_t)', 'global = 5'])
+
+ # Use the '-v' option to do verbose listing of the watchpoint.
+ # The hit count should now be 2.
+ self.expect("watchpoint list -v",
+ substrs = ['hit_count = 5'])
diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp
new file mode 100644
index 0000000..f4c3527
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp
@@ -0,0 +1,28 @@
+//===-- main.c --------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+#include <stdint.h>
+
+int32_t global = 0; // Watchpoint variable declaration.
+
+static void modify(int32_t &var) {
+ ++var;
+}
+
+int main(int argc, char** argv) {
+ int local = 0;
+ printf("&global=%p\n", &global);
+ printf("about to write to 'global'...\n"); // Set break point at this line.
+ // When stopped, watch 'global',
+ // for the condition "global == 5".
+ for (int i = 0; i < 10; ++i)
+ modify(global);
+
+ printf("global=%d\n", global);
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/main.c b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/main.c
new file mode 100644
index 0000000..b20eaf4
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_commands/main.c
@@ -0,0 +1,24 @@
+//===-- main.c --------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+#include <stdint.h>
+
+int32_t global = 10; // Watchpoint variable declaration.
+
+int main(int argc, char** argv) {
+ int local = 0;
+ printf("&global=%p\n", &global);
+ printf("about to write to 'global'...\n"); // Set break point at this line.
+ // When stopped, watch 'global'.
+ global = 20;
+ local += argc;
+ ++local; // Set 2nd break point for disable_then_enable test case.
+ printf("local: %d\n", local);
+ printf("global=%d\n", global);
+}
OpenPOWER on IntegriCloud