Reland "[lldb] Add 'modify' type watchpoints, make it default (#66308)"

This reverts commit a7b78cac9a.

With updates to the tests.

TestWatchTaggedAddress.py: Updated the expected watchpoint types,
though I'm not sure there should be a differnt default for the two
ways of setting them, that needs to be confirmed.

TestStepOverWatchpoint.py: Skipped this everywhere because I think
what used to happen is you couldn't put 2 watchpoints on the same
address (after alignment). I guess that this is now allowed because
modify watchpoints aren't accounted for, but likely should be.
Needs investigating.
This commit is contained in:
David Spickett
2023-09-21 10:21:53 +00:00
parent 618e5d2c2d
commit 75e8620778
34 changed files with 397 additions and 63 deletions

View File

@@ -53,7 +53,10 @@ def fuzz_obj(obj):
obj.GetByteOrder()
obj.GetTriple()
error = lldb.SBError()
obj.WatchAddress(123, 8, True, True, error)
wp_opts = lldb.SBWatchpointOptions()
wp_opts.SetWatchpointTypeRead(True)
wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify)
obj.WatchpointCreateByAddress(123, 8, wp_opts, error)
obj.GetBroadcaster()
obj.GetDescription(lldb.SBStream(), lldb.eDescriptionLevelBrief)
obj.Clear()

View File

@@ -1,5 +1,5 @@
"""
Use lldb Python SBtarget.WatchAddress() API to create a watchpoint for write of '*g_char_ptr'.
Use lldb Python SBtarget.WatchpointCreateByAddress() API to create a watchpoint for write of '*g_char_ptr'.
"""
import lldb
@@ -8,7 +8,7 @@ from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TargetWatchAddressAPITestCase(TestBase):
class TargetWatchpointCreateByAddressPITestCase(TestBase):
NO_DEBUG_INFO_TESTCASE = True
def setUp(self):
@@ -22,7 +22,7 @@ class TargetWatchAddressAPITestCase(TestBase):
self.violating_func = "do_bad_thing_with_location"
def test_watch_address(self):
"""Exercise SBTarget.WatchAddress() API to set a watchpoint."""
"""Exercise SBTarget.WatchpointCreateByAddress() API to set a watchpoint."""
self.build()
exe = self.getBuildArtifact("a.out")
@@ -51,8 +51,10 @@ class TargetWatchAddressAPITestCase(TestBase):
)
# Watch for write to *g_char_ptr.
error = lldb.SBError()
watchpoint = target.WatchAddress(
value.GetValueAsUnsigned(), 1, False, True, error
wp_opts = lldb.SBWatchpointOptions()
wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify)
watchpoint = target.WatchpointCreateByAddress(
value.GetValueAsUnsigned(), 1, wp_opts, error
)
self.assertTrue(
value and watchpoint, "Successfully found the pointer and set a watchpoint"
@@ -90,7 +92,7 @@ class TargetWatchAddressAPITestCase(TestBase):
@skipIf(archs=["mips", "mipsel", "mips64", "mips64el"])
@skipIf(archs=["s390x"]) # Likewise on SystemZ
def test_watch_address_with_invalid_watch_size(self):
"""Exercise SBTarget.WatchAddress() API but pass an invalid watch_size."""
"""Exercise SBTarget.WatchpointCreateByAddress() API but pass an invalid watch_size."""
self.build()
exe = self.getBuildArtifact("a.out")
@@ -124,8 +126,10 @@ class TargetWatchAddressAPITestCase(TestBase):
if self.getArchitecture() not in ["arm64", "arm64e", "arm64_32"]:
# Watch for write to *g_char_ptr.
error = lldb.SBError()
watchpoint = target.WatchAddress(
value.GetValueAsUnsigned(), 365, False, True, error
wp_opts = lldb.SBWatchpointOptions()
wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify)
watchpoint = target.WatchpointCreateByAddress(
value.GetValueAsUnsigned(), 365, wp_opts, error
)
self.assertFalse(watchpoint)
self.expect(