-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] WatchAddress ignores modify option #124847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
lldb/test/API/python_api/watchpoint/TestWatchpointRead.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
""" | ||
Use lldb Python SBTarget API to set read watchpoints | ||
""" | ||
|
||
import lldb | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class SetReadOnlyWatchpointTestCase(TestBase): | ||
NO_DEBUG_INFO_TESTCASE = True | ||
|
||
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.build() | ||
|
||
# Intel hardware does not support read-only watchpoints | ||
@expectedFailureAll(archs=["i386", "x86_64"]) | ||
def test_read_watchpoint_watch_address(self): | ||
exe = self.getBuildArtifact("a.out") | ||
|
||
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, self.get_process_working_directory()) | ||
|
||
# We should be stopped due to the breakpoint. Get frame #0. | ||
process = target.GetProcess() | ||
self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) | ||
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) | ||
frame0 = thread.GetFrameAtIndex(0) | ||
|
||
value = frame0.FindValue("global", lldb.eValueTypeVariableGlobal) | ||
local = frame0.FindValue("local", lldb.eValueTypeVariableLocal) | ||
error = lldb.SBError() | ||
|
||
watchpoint = target.WatchAddress(value.GetLoadAddress(), 1, True, False, error) | ||
self.assertTrue( | ||
value and local and watchpoint, | ||
"Successfully found the values and set a watchpoint", | ||
) | ||
self.DebugSBValue(value) | ||
self.DebugSBValue(local) | ||
|
||
# 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 | ||
# read, but *not* written to. | ||
process.Continue() | ||
|
||
if self.TraceOn(): | ||
lldbutil.print_stacktraces(process) | ||
|
||
self.assertTrue( | ||
local.GetValueAsSigned() > 0, "The local variable has been incremented" | ||
) | ||
|
||
# Intel hardware does not support read-only watchpoints | ||
@expectedFailureAll(archs=["i386", "x86_64"]) | ||
def test_read_watchpoint_watch_create_by_address(self): | ||
exe = self.getBuildArtifact("a.out") | ||
|
||
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, self.get_process_working_directory()) | ||
|
||
# We should be stopped due to the breakpoint. Get frame #0. | ||
process = target.GetProcess() | ||
self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) | ||
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) | ||
frame0 = thread.GetFrameAtIndex(0) | ||
|
||
value = frame0.FindValue("global", lldb.eValueTypeVariableGlobal) | ||
local = frame0.FindValue("local", lldb.eValueTypeVariableLocal) | ||
error = lldb.SBError() | ||
|
||
wp_opts = lldb.SBWatchpointOptions() | ||
wp_opts.SetWatchpointTypeRead(True) | ||
watchpoint = target.WatchpointCreateByAddress( | ||
value.GetLoadAddress(), 1, wp_opts, error | ||
) | ||
self.assertTrue( | ||
value and local and watchpoint, | ||
"Successfully found the values and set a watchpoint", | ||
) | ||
self.DebugSBValue(value) | ||
self.DebugSBValue(local) | ||
|
||
# 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 | ||
# read, but *not* written to. | ||
process.Continue() | ||
|
||
if self.TraceOn(): | ||
lldbutil.print_stacktraces(process) | ||
|
||
self.assertTrue( | ||
local.GetValueAsSigned() > 0, "The local variable has been incremented" | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.