summaryrefslogtreecommitdiffstats
path: root/lldb/test
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/test')
-rw-r--r--lldb/test/lldbutil.py7
-rw-r--r--lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py8
-rw-r--r--lldb/test/python_api/default-constructor/sb_frame.py1
-rw-r--r--lldb/test/python_api/default-constructor/sb_target.py17
-rw-r--r--lldb/test/python_api/default-constructor/sb_value.py2
-rw-r--r--lldb/test/python_api/default-constructor/sb_watchpoint.py (renamed from lldb/test/python_api/default-constructor/sb_watchpointlocation.py)0
-rw-r--r--lldb/test/python_api/watchpoint/TestSetWatchpoint.py21
-rw-r--r--lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py52
-rw-r--r--lldb/test/python_api/watchpoint/TestWatchpointIter.py (renamed from lldb/test/python_api/watchpoint/TestWatchpointLocationIter.py)64
-rw-r--r--lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py24
10 files changed, 108 insertions, 88 deletions
diff --git a/lldb/test/lldbutil.py b/lldb/test/lldbutil.py
index 740c932fc8f..9c7a5265b6d 100644
--- a/lldb/test/lldbutil.py
+++ b/lldb/test/lldbutil.py
@@ -105,8 +105,9 @@ def bytearray_to_int(bytes, bytesize):
def get_description(obj, option=None):
"""Calls lldb_obj.GetDescription() and returns a string, or None.
- For SBTarget and SBBreakpointLocation lldb objects, an extra option can be
- passed in to describe the detailed level of description desired:
+ For SBTarget, SBBreakpointLocation, and SBWatchpoint lldb objects, an extra
+ option can be passed in to describe the detailed level of description
+ desired:
o lldb.eDescriptionLevelBrief
o lldb.eDescriptionLevelFull
o lldb.eDescriptionLevelVerbose
@@ -114,7 +115,7 @@ def get_description(obj, option=None):
method = getattr(obj, 'GetDescription')
if not method:
return None
- tuple = (lldb.SBTarget, lldb.SBBreakpointLocation, lldb.SBWatchpointLocation)
+ tuple = (lldb.SBTarget, lldb.SBBreakpointLocation, lldb.SBWatchpoint)
if isinstance(obj, tuple):
if option is None:
option = lldb.eDescriptionLevelBrief
diff --git a/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py b/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
index 2340a6130a7..f5f9aef0014 100644
--- a/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
+++ b/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py
@@ -350,14 +350,14 @@ class APIDefaultConstructorTestCase(TestBase):
sb_valuelist.fuzz_obj(obj)
@python_api_test
- def test_SBWatchpointLocation(self):
- obj = lldb.SBWatchpointLocation()
+ def test_SBWatchpoint(self):
+ obj = lldb.SBWatchpoint()
if self.TraceOn():
print obj
self.assertFalse(obj)
# Do fuzz testing on the invalid obj, it should not crash lldb.
- import sb_watchpointlocation
- sb_watchpointlocation.fuzz_obj(obj)
+ import sb_watchpoint
+ sb_watchpoint.fuzz_obj(obj)
if __name__ == '__main__':
diff --git a/lldb/test/python_api/default-constructor/sb_frame.py b/lldb/test/python_api/default-constructor/sb_frame.py
index db0e82d4307..41edaff02ed 100644
--- a/lldb/test/python_api/default-constructor/sb_frame.py
+++ b/lldb/test/python_api/default-constructor/sb_frame.py
@@ -33,6 +33,5 @@ def fuzz_obj(obj):
obj.FindVariable("my_var", lldb.eDynamicCanRunTarget)
obj.FindValue("your_var", lldb.eValueTypeVariableGlobal)
obj.FindValue("your_var", lldb.eValueTypeVariableStatic, lldb.eDynamicCanRunTarget)
- obj.WatchValue("global_var", lldb.eValueTypeVariableGlobal, lldb.LLDB_WATCH_TYPE_READ)
obj.GetDescription(lldb.SBStream())
obj.Clear()
diff --git a/lldb/test/python_api/default-constructor/sb_target.py b/lldb/test/python_api/default-constructor/sb_target.py
index 6b7bf777a06..3f15a1a0565 100644
--- a/lldb/test/python_api/default-constructor/sb_target.py
+++ b/lldb/test/python_api/default-constructor/sb_target.py
@@ -40,14 +40,13 @@ def fuzz_obj(obj):
obj.EnableAllBreakpoints()
obj.DisableAllBreakpoints()
obj.DeleteAllBreakpoints()
- obj.GetNumWatchpointLocations()
- obj.GetLastCreatedWatchpointLocation()
- obj.GetWatchpointLocationAtIndex(0)
- obj.WatchpointLocationDelete(0)
- obj.FindWatchpointLocationByID(0)
- obj.EnableAllWatchpointLocations()
- obj.DisableAllWatchpointLocations()
- obj.DeleteAllWatchpointLocations()
+ obj.GetNumWatchpoints()
+ obj.GetWatchpointAtIndex(0)
+ obj.DeleteWatchpoint(0)
+ obj.FindWatchpointByID(0)
+ obj.EnableAllWatchpoints()
+ obj.DisableAllWatchpoints()
+ obj.DeleteAllWatchpoints()
obj.GetBroadcaster()
obj.GetDescription(lldb.SBStream(), lldb.eDescriptionLevelBrief)
obj.Clear()
@@ -55,5 +54,5 @@ def fuzz_obj(obj):
print module
for bp in obj.breakpoint_iter():
print bp
- for wp_loc in obj.watchpoint_location_iter():
+ for wp_loc in obj.watchpoint_iter():
print wp_loc
diff --git a/lldb/test/python_api/default-constructor/sb_value.py b/lldb/test/python_api/default-constructor/sb_value.py
index 715ba1ce493..b3a26def772 100644
--- a/lldb/test/python_api/default-constructor/sb_value.py
+++ b/lldb/test/python_api/default-constructor/sb_value.py
@@ -33,5 +33,7 @@ def fuzz_obj(obj):
obj.GetDescription(stream)
obj.GetExpressionPath(stream)
obj.GetExpressionPath(stream, True)
+ obj.Watch(True, True, False)
+ obj.WatchPointee(True, False, True)
for child_val in obj:
print child_val
diff --git a/lldb/test/python_api/default-constructor/sb_watchpointlocation.py b/lldb/test/python_api/default-constructor/sb_watchpoint.py
index 8b0b1ecc481..8b0b1ecc481 100644
--- a/lldb/test/python_api/default-constructor/sb_watchpointlocation.py
+++ b/lldb/test/python_api/default-constructor/sb_watchpoint.py
diff --git a/lldb/test/python_api/watchpoint/TestSetWatchpoint.py b/lldb/test/python_api/watchpoint/TestSetWatchpoint.py
index 61526ab0f02..d16d0cb058f 100644
--- a/lldb/test/python_api/watchpoint/TestSetWatchpoint.py
+++ b/lldb/test/python_api/watchpoint/TestSetWatchpoint.py
@@ -1,5 +1,5 @@
"""
-Use lldb Python SBFrame API to create a watchpoint for read_write of 'globl' var.
+Use lldb Python SBValue API to create a watchpoint for read_write of 'globl' var.
"""
import os, time
@@ -23,13 +23,13 @@ class SetWatchpointAPITestCase(TestBase):
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@python_api_test
def test_watch_val_with_dsym(self):
- """Exercise SBFrame.WatchValue() API to set a watchpoint."""
+ """Exercise SBValue.Watch() API to set a watchpoint."""
self.buildDsym()
self.do_set_watchpoint()
@python_api_test
def test_watch_val_with_dwarf(self):
- """Exercise SBFrame.WatchValue() API to set a watchpoint."""
+ """Exercise SBValue.Watch() API to set a watchpoint."""
self.buildDwarf()
self.do_set_watchpoint()
@@ -57,12 +57,19 @@ class SetWatchpointAPITestCase(TestBase):
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
frame0 = thread.GetFrameAtIndex(0)
- 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")
+ # Watch 'global' for read and write.
+ value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal)
+ watchpoint = value.Watch(True, True, True)
+ self.assertTrue(value and watchpoint,
+ "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()
+
+ print watchpoint
+
# Continue. Expect the program to stop due to the variable being written to.
process.Continue()
diff --git a/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py b/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
index 7b16a10d02e..53b86bc9706 100644
--- a/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
+++ b/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py
@@ -1,5 +1,5 @@
"""
-Use lldb Python SBWatchpointLocation API to set the ignore count.
+Use lldb Python SBWatchpoint API to set the ignore count.
"""
import os, time
@@ -22,19 +22,19 @@ class WatchpointIgnoreCountTestCase(TestBase):
@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."""
+ def test_set_watch_ignore_count_with_dsym(self):
+ """Test SBWatchpoint.SetIgnoreCount() API."""
self.buildDsym()
- self.do_watchpoint_location_ignore_count()
+ self.do_watchpoint_ignore_count()
@python_api_test
- def test_set_watch_loc_ignore_count_with_dwarf(self):
- """Test SBWatchpointLocation.SetIgnoreCount() API."""
+ def test_set_watch_ignore_count_with_dwarf(self):
+ """Test SBWatchpoint.SetIgnoreCount() API."""
self.buildDwarf()
- self.do_watchpoint_location_ignore_count()
+ self.do_watchpoint_ignore_count()
- def do_watchpoint_location_ignore_count(self):
- """Test SBWatchpointLocation.SetIgnoreCount() API."""
+ def do_watchpoint_ignore_count(self):
+ """Test SBWatchpoint.SetIgnoreCount() API."""
exe = os.path.join(os.getcwd(), "a.out")
# Create a target by the debugger.
@@ -58,10 +58,10 @@ class WatchpointIgnoreCountTestCase(TestBase):
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")
+ value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal)
+ watchpoint = value.Watch(True, True, True)
+ self.assertTrue(value and watchpoint,
+ "Successfully found the variable and set a watchpoint")
self.DebugSBValue(value)
# Hide stdout if not running with '-t' option.
@@ -69,30 +69,28 @@ class WatchpointIgnoreCountTestCase(TestBase):
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(target.GetNumWatchpoints() == 1)
+ watchpoint = target.GetWatchpointAtIndex(0)
+ self.assertTrue(watchpoint.IsEnabled())
+ self.assertTrue(watchpoint.GetIgnoreCount() == 0)
+ watch_id = watchpoint.GetID()
self.assertTrue(watch_id != 0)
- print wp_loc
+ print watchpoint
# 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
+ watchpoint.SetIgnoreCount(2)
+ print watchpoint
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
+ self.assertTrue(watchpoint)
+ self.assertTrue(watchpoint.GetWatchSize() == 4)
+ self.assertTrue(watchpoint.GetHitCount() == 2)
+ print watchpoint
if __name__ == '__main__':
diff --git a/lldb/test/python_api/watchpoint/TestWatchpointLocationIter.py b/lldb/test/python_api/watchpoint/TestWatchpointIter.py
index ec67831b68a..2d70648fde1 100644
--- a/lldb/test/python_api/watchpoint/TestWatchpointLocationIter.py
+++ b/lldb/test/python_api/watchpoint/TestWatchpointIter.py
@@ -8,7 +8,7 @@ import unittest2
import lldb, lldbutil
from lldbtest import *
-class WatchpointLocationIteratorTestCase(TestBase):
+class WatchpointIteratorTestCase(TestBase):
mydir = os.path.join("python_api", "watchpoint")
@@ -22,19 +22,19 @@ class WatchpointLocationIteratorTestCase(TestBase):
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@python_api_test
- def test_watch_loc_iter_with_dsym(self):
- """Exercise SBTarget.watchpoint_location_iter() API to iterate on the available watchpoint locations."""
+ def test_watch_iter_with_dsym(self):
+ """Exercise SBTarget.watchpoint_iter() API to iterate on the available watchpoints."""
self.buildDsym()
- self.do_watchpoint_location_iter()
+ self.do_watchpoint_iter()
@python_api_test
- def test_watch_loc_iter_with_dwarf(self):
- """Exercise SBTarget.watchpoint_location_iter() API to iterate on the available watchpoint locations."""
+ def test_watch_iter_with_dwarf(self):
+ """Exercise SBTarget.watchpoint_iter() API to iterate on the available watchpoints."""
self.buildDwarf()
- self.do_watchpoint_location_iter()
+ self.do_watchpoint_iter()
- def do_watchpoint_location_iter(self):
- """Use SBTarget.watchpoint_location_iter() to do Pythonic iteration on the available watchpoint locations."""
+ def do_watchpoint_iter(self):
+ """Use SBTarget.watchpoint_iter() to do Pythonic iteration on the available watchpoints."""
exe = os.path.join(os.getcwd(), "a.out")
# Create a target by the debugger.
@@ -57,19 +57,21 @@ class WatchpointLocationIteratorTestCase(TestBase):
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
frame0 = thread.GetFrameAtIndex(0)
- 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")
+ # Watch 'global' for read and write.
+ value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal)
+ watchpoint = value.Watch(True, True, True)
+ self.assertTrue(value and watchpoint,
+ "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())
- watch_id = wp_loc.GetID()
+ self.assertTrue(target.GetNumWatchpoints() == 1)
+ self.assertTrue(watchpoint.IsEnabled())
+ watch_id = watchpoint.GetID()
self.assertTrue(watch_id != 0)
# Continue. Expect the program to stop due to the variable being written to.
@@ -89,17 +91,17 @@ class WatchpointLocationIteratorTestCase(TestBase):
# We currently only support hardware watchpoint. Verify that we have a
# meaningful hardware index at this point. Exercise the printed repr of
# SBWatchpointLocation.
- print wp_loc
- self.assertTrue(wp_loc.GetHardwareIndex() != -1)
+ print watchpoint
+ self.assertTrue(watchpoint.GetHardwareIndex() != -1)
- # SBWatchpointLocation.GetDescription() takes a description level arg.
- print lldbutil.get_description(wp_loc, lldb.eDescriptionLevelFull)
+ # SBWatchpoint.GetDescription() takes a description level arg.
+ print lldbutil.get_description(watchpoint, lldb.eDescriptionLevelFull)
# Now disable the 'rw' watchpoint. The program won't stop when it reads
# 'global' next.
- wp_loc.SetEnabled(False)
- self.assertTrue(wp_loc.GetHardwareIndex() == -1)
- self.assertFalse(wp_loc.IsEnabled())
+ watchpoint.SetEnabled(False)
+ self.assertTrue(watchpoint.GetHardwareIndex() == -1)
+ self.assertFalse(watchpoint.IsEnabled())
# Continue. The program does not stop again when the variable is being
# read from because the watchpoint location has been disabled.
@@ -109,11 +111,11 @@ class WatchpointLocationIteratorTestCase(TestBase):
self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED)
# Verify some vital statistics and exercise the iterator API.
- for wp_loc in target.watchpoint_location_iter():
- self.assertTrue(wp_loc)
- self.assertTrue(wp_loc.GetWatchSize() == 4)
- self.assertTrue(wp_loc.GetHitCount() == 1)
- print wp_loc
+ for watchpoint in target.watchpoint_iter():
+ self.assertTrue(watchpoint)
+ self.assertTrue(watchpoint.GetWatchSize() == 4)
+ self.assertTrue(watchpoint.GetHitCount() == 1)
+ print watchpoint
if __name__ == '__main__':
diff --git a/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py b/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
index 7a78b1533fc..455a8c27483 100644
--- a/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
+++ b/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
@@ -1,5 +1,5 @@
"""
-Use lldb Python SBFrame.WatchLocation() API to create a watchpoint for write of '*g_char_ptr'.
+Use lldb Python SBValue.WatchPointee() API to create a watchpoint for write of '*g_char_ptr'.
"""
import os, time
@@ -59,12 +59,23 @@ class SetWatchlocationAPITestCase(TestBase):
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
frame0 = thread.GetFrameAtIndex(0)
- value = frame0.WatchLocation('g_char_ptr',
- lldb.eValueTypeVariableGlobal,
- lldb.LLDB_WATCH_TYPE_WRITE,
- 1)
- self.assertTrue(value, "Successfully found the location and set a watchpoint")
+ 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.
+ watchpoint = value.WatchPointee(True, False, True)
+ self.assertTrue(value and watchpoint,
+ "Successfully found the pointer and set a watchpoint")
self.DebugSBValue(value)
+ self.DebugSBValue(pointee)
+
+ # Hide stdout if not running with '-t' option.
+ if not self.TraceOn():
+ self.HideStdout()
+
+ print watchpoint
# Continue. Expect the program to stop due to the variable being written to.
process.Continue()
@@ -75,6 +86,7 @@ class SetWatchlocationAPITestCase(TestBase):
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonWatchpoint)
self.assertTrue(thread, "The thread stopped due to watchpoint")
self.DebugSBValue(value)
+ self.DebugSBValue(pointee)
self.expect(lldbutil.print_stacktrace(thread, string_buffer=True), exe=False,
substrs = [self.violating_func])
OpenPOWER on IntegriCloud