diff options
| author | Johnny Chen <johnny.chen@apple.com> | 2011-10-05 21:35:46 +0000 |
|---|---|---|
| committer | Johnny Chen <johnny.chen@apple.com> | 2011-10-05 21:35:46 +0000 |
| commit | 6cc60e86686b61e8cb636b3f04105a4f508d6336 (patch) | |
| tree | 5dd841f285da2b3894a4c561be5106d14bbe2610 /lldb/test/python_api | |
| parent | a2e40934d5f31998237ba962793d7577603c035b (diff) | |
| download | bcm5719-llvm-6cc60e86686b61e8cb636b3f04105a4f508d6336.tar.gz bcm5719-llvm-6cc60e86686b61e8cb636b3f04105a4f508d6336.zip | |
Add capability to set ignore count for watchpoint on the command line:
watchpoint ignore -i <count> [<watchpt-id | watchpt-id-list>]
Add tests of watchpoint ignore_count for command line as well as API.
llvm-svn: 141217
Diffstat (limited to 'lldb/test/python_api')
| -rw-r--r-- | lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py b/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py new file mode 100644 index 00000000000..7b16a10d02e --- /dev/null +++ b/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py @@ -0,0 +1,102 @@ +""" +Use lldb Python SBWatchpointLocation API to set the ignore count. +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class WatchpointIgnoreCountTestCase(TestBase): + + mydir = os.path.join("python_api", "watchpoint") + + 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.') + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_set_watch_loc_ignore_count_with_dsym(self): + """Test SBWatchpointLocation.SetIgnoreCount() API.""" + self.buildDsym() + self.do_watchpoint_location_ignore_count() + + @python_api_test + def test_set_watch_loc_ignore_count_with_dwarf(self): + """Test SBWatchpointLocation.SetIgnoreCount() API.""" + self.buildDwarf() + self.do_watchpoint_location_ignore_count() + + def do_watchpoint_location_ignore_count(self): + """Test SBWatchpointLocation.SetIgnoreCount() API.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Create a breakpoint on main.c in order to set our watchpoint later. + breakpoint = target.BreakpointCreateByLocation(self.source, self.line) + self.assertTrue(breakpoint and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Now launch the process, and do not stop at the entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + + # We should be stopped due to the breakpoint. Get frame #0. + process = target.GetProcess() + self.assertTrue(process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + frame0 = thread.GetFrameAtIndex(0) + + # Watch 'global' for read and write. + value = frame0.WatchValue('global', + lldb.eValueTypeVariableGlobal, + lldb.LLDB_WATCH_TYPE_READ|lldb.LLDB_WATCH_TYPE_WRITE) + self.assertTrue(value, "Successfully found the variable and set a watchpoint") + self.DebugSBValue(value) + + # Hide stdout if not running with '-t' option. + if not self.TraceOn(): + self.HideStdout() + + # There should be only 1 watchpoint location under the target. + self.assertTrue(target.GetNumWatchpointLocations() == 1) + wp_loc = target.GetWatchpointLocationAtIndex(0) + last_created = target.GetLastCreatedWatchpointLocation() + self.assertTrue(wp_loc == last_created) + self.assertTrue(wp_loc.IsEnabled()) + self.assertTrue(wp_loc.GetIgnoreCount() == 0) + watch_id = wp_loc.GetID() + self.assertTrue(watch_id != 0) + print wp_loc + + # Now immediately set the ignore count to 2. When we continue, expect the + # inferior to run to its completion without stopping due to watchpoint. + wp_loc.SetIgnoreCount(2) + print wp_loc + process.Continue() + + # At this point, the inferior process should have exited. + self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) + + # Verify some vital statistics. + self.assertTrue(wp_loc) + self.assertTrue(wp_loc.GetWatchSize() == 4) + self.assertTrue(wp_loc.GetHitCount() == 2) + print wp_loc + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() |

