diff options
| author | Johnny Chen <johnny.chen@apple.com> | 2012-06-04 23:19:54 +0000 |
|---|---|---|
| committer | Johnny Chen <johnny.chen@apple.com> | 2012-06-04 23:19:54 +0000 |
| commit | b90827e66c6576a229b9018ba8400a2e3e300d02 (patch) | |
| tree | 982b29230add06d804c9c61b0299fd05fd992d3e /lldb/test/python_api | |
| parent | 188d830405a47a6c1b5c87f85cd46bce587c2ec7 (diff) | |
| download | bcm5719-llvm-b90827e66c6576a229b9018ba8400a2e3e300d02.tar.gz bcm5719-llvm-b90827e66c6576a229b9018ba8400a2e3e300d02.zip | |
rdar://problem/11584012
Refactorings of watchpoint creation APIs so that SBTarget::WatchAddress(), SBValue::Watch(), and SBValue::WatchPointee()
now take an additional 'SBError &error' parameter (at the end) to contain the reason if there is some failure in the
operation. Update 'watchpoint set variable/expression' commands to take advantage of that.
Update existing test cases to reflect the API change and add test cases to verify that the SBError mechanism works for
SBTarget::WatchAddress() by passing an invalid watch_size.
llvm-svn: 157964
Diffstat (limited to 'lldb/test/python_api')
9 files changed, 68 insertions, 10 deletions
diff --git a/lldb/test/python_api/default-constructor/sb_target.py b/lldb/test/python_api/default-constructor/sb_target.py index 3e6c6f63056..823b49f6243 100644 --- a/lldb/test/python_api/default-constructor/sb_target.py +++ b/lldb/test/python_api/default-constructor/sb_target.py @@ -52,7 +52,8 @@ def fuzz_obj(obj): obj.GetAddressByteSize() obj.GetByteOrder() obj.GetTriple() - obj.WatchAddress(123, 8, True, True) + error = lldb.SBError() + obj.WatchAddress(123, 8, True, True, error) obj.GetBroadcaster() obj.GetDescription(lldb.SBStream(), lldb.eDescriptionLevelBrief) obj.Clear() diff --git a/lldb/test/python_api/default-constructor/sb_value.py b/lldb/test/python_api/default-constructor/sb_value.py index a82a3e38f78..d103551635f 100644 --- a/lldb/test/python_api/default-constructor/sb_value.py +++ b/lldb/test/python_api/default-constructor/sb_value.py @@ -34,8 +34,9 @@ def fuzz_obj(obj): obj.GetDescription(stream) obj.GetExpressionPath(stream) obj.GetExpressionPath(stream, True) - obj.Watch(True, True, False) - obj.WatchPointee(True, False, True) + error = lldb.SBError() + obj.Watch(True, True, False, error) + obj.WatchPointee(True, False, True, error) for child_val in obj: print child_val error = lldb.SBError() diff --git a/lldb/test/python_api/default-constructor/sb_watchpoint.py b/lldb/test/python_api/default-constructor/sb_watchpoint.py index a028cb48c4c..f462e62ff16 100644 --- a/lldb/test/python_api/default-constructor/sb_watchpoint.py +++ b/lldb/test/python_api/default-constructor/sb_watchpoint.py @@ -8,7 +8,6 @@ import lldb def fuzz_obj(obj): obj.GetID() obj.IsValid() - obj.GetError() obj.GetHardwareIndex() obj.GetWatchAddress() obj.GetWatchSize() diff --git a/lldb/test/python_api/watchpoint/TestSetWatchpoint.py b/lldb/test/python_api/watchpoint/TestSetWatchpoint.py index e283ab0762c..124dec11cbd 100644 --- a/lldb/test/python_api/watchpoint/TestSetWatchpoint.py +++ b/lldb/test/python_api/watchpoint/TestSetWatchpoint.py @@ -61,7 +61,8 @@ class SetWatchpointAPITestCase(TestBase): # Watch 'global' for read and write. value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal) - watchpoint = value.Watch(True, True, True) + error = lldb.SBError(); + watchpoint = value.Watch(True, True, True, error) self.assertTrue(value and watchpoint, "Successfully found the variable and set a watchpoint") self.DebugSBValue(value) diff --git a/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py b/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py index 2076ea6b6c5..ffe770852e5 100644 --- a/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py +++ b/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py @@ -61,7 +61,8 @@ class WatchpointIgnoreCountTestCase(TestBase): # Watch 'global' for read and write. value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal) - watchpoint = value.Watch(True, True, True) + error = lldb.SBError(); + watchpoint = value.Watch(True, True, True, error) self.assertTrue(value and watchpoint, "Successfully found the variable and set a watchpoint") self.DebugSBValue(value) diff --git a/lldb/test/python_api/watchpoint/TestWatchpointIter.py b/lldb/test/python_api/watchpoint/TestWatchpointIter.py index db6d70f5bbc..c6d37502ec3 100644 --- a/lldb/test/python_api/watchpoint/TestWatchpointIter.py +++ b/lldb/test/python_api/watchpoint/TestWatchpointIter.py @@ -61,7 +61,8 @@ class WatchpointIteratorTestCase(TestBase): # Watch 'global' for read and write. value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal) - watchpoint = value.Watch(True, True, True) + error = lldb.SBError(); + watchpoint = value.Watch(True, True, True, error) self.assertTrue(value and watchpoint, "Successfully found the variable and set a watchpoint") self.DebugSBValue(value) diff --git a/lldb/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py b/lldb/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py index 8f46670db28..d3707bad21e 100644 --- a/lldb/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py +++ b/lldb/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py @@ -66,7 +66,8 @@ class WatchpointConditionAPITestCase(TestBase): # Watch 'global' for write. value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal) - watchpoint = value.Watch(True, False, True) + error = lldb.SBError(); + watchpoint = value.Watch(True, False, True, error) self.assertTrue(value and watchpoint, "Successfully found the variable and set a watchpoint") self.DebugSBValue(value) diff --git a/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py b/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py index 21ac809420b..2310fdc7489 100644 --- a/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py +++ b/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py @@ -67,7 +67,8 @@ class SetWatchlocationAPITestCase(TestBase): value.GetValueAsUnsigned(0), value.GetType().GetPointeeType()) # Watch for write to *g_char_ptr. - watchpoint = value.WatchPointee(True, False, True) + error = lldb.SBError(); + watchpoint = value.WatchPointee(True, False, True, error) self.assertTrue(value and watchpoint, "Successfully found the pointer and set a watchpoint") self.DebugSBValue(value) diff --git a/lldb/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py b/lldb/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py index 34c2daefe2d..407e7919d0d 100644 --- a/lldb/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py +++ b/lldb/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py @@ -37,6 +37,21 @@ class TargetWatchAddressAPITestCase(TestBase): self.buildDwarf() self.do_set_watchaddress() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + @dsym_test + def test_watch_address_with_invalid_watch_size_with_dsym(self): + """Exercise SBTarget.WatchAddress() API but pass an invalid watch_size.""" + self.buildDsym() + self.do_set_watchaddress_with_invalid_watch_size() + + @python_api_test + @dwarf_test + def test_watch_address_with_invalid_watch_size_with_dwarf(self): + """Exercise SBTarget.WatchAddress() API but pass an invalid watch_size.""" + self.buildDwarf() + self.do_set_watchaddress_with_invalid_watch_size() + def do_set_watchaddress(self): """Use SBTarget.WatchAddress() to set a watchpoint and verify that the program stops later due to the watchpoint.""" exe = os.path.join(os.getcwd(), "a.out") @@ -67,7 +82,8 @@ class TargetWatchAddressAPITestCase(TestBase): value.GetValueAsUnsigned(0), value.GetType().GetPointeeType()) # Watch for write to *g_char_ptr. - watchpoint = target.WatchAddress(value.GetValueAsUnsigned(), 1, False, True) + error = lldb.SBError(); + watchpoint = target.WatchAddress(value.GetValueAsUnsigned(), 1, False, True, error) self.assertTrue(value and watchpoint, "Successfully found the pointer and set a watchpoint") self.DebugSBValue(value) @@ -95,6 +111,42 @@ class TargetWatchAddressAPITestCase(TestBase): # This finishes our test. + def do_set_watchaddress_with_invalid_watch_size(self): + """Use SBTarget.WatchAddress() to set a watchpoint with invalid watch_size and verify we get a meaningful error message.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Now create a breakpoint on main.c. + 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) + + value = frame0.FindValue('g_char_ptr', + lldb.eValueTypeVariableGlobal) + pointee = value.CreateValueFromAddress("pointee", + value.GetValueAsUnsigned(0), + value.GetType().GetPointeeType()) + # Watch for write to *g_char_ptr. + error = lldb.SBError(); + watchpoint = target.WatchAddress(value.GetValueAsUnsigned(), 365, False, True, error) + self.assertFalse(watchpoint) + self.expect(error.GetCString(), exe=False, + substrs = ['watch size of %d is not supported' % 365]) + if __name__ == '__main__': import atexit |

