-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[lldb] Implement CLI support for reverse-continue #132783
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
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
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,3 @@ | ||
C_SOURCES := main.c | ||
|
||
include Makefile.rules |
66 changes: 66 additions & 0 deletions
66
lldb/test/API/commands/process/reverse-continue/TestReverseContinue.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,66 @@ | ||
""" | ||
Test the "process continue --reverse" and "--forward" options. | ||
""" | ||
|
||
|
||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.gdbclientutils import * | ||
from lldbsuite.test.lldbreverse import ReverseTestBase | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class TestReverseContinue(ReverseTestBase): | ||
@skipIfRemote | ||
def test_reverse_continue(self): | ||
target, _, _ = self.setup_recording() | ||
|
||
# Set breakpoint and reverse-continue | ||
trigger_bkpt = target.BreakpointCreateByName("trigger_breakpoint", None) | ||
self.assertTrue(trigger_bkpt.GetNumLocations() > 0) | ||
self.expect( | ||
"process continue --reverse", | ||
substrs=["stop reason = breakpoint {0}.1".format(trigger_bkpt.GetID())], | ||
) | ||
# `process continue` should preserve current base direction. | ||
self.expect( | ||
"process continue", | ||
STOPPED_DUE_TO_HISTORY_BOUNDARY, | ||
substrs=["stopped", "stop reason = history boundary"], | ||
) | ||
self.expect( | ||
"process continue --forward", | ||
substrs=["stop reason = breakpoint {0}.1".format(trigger_bkpt.GetID())], | ||
) | ||
|
||
def setup_recording(self): | ||
""" | ||
Record execution of code between "start_recording" and "stop_recording" breakpoints. | ||
|
||
Returns with the target stopped at "stop_recording", with recording disabled, | ||
ready to reverse-execute. | ||
""" | ||
self.build() | ||
target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) | ||
process = self.connect(target) | ||
|
||
# Record execution from the start of the function "start_recording" | ||
# to the start of the function "stop_recording". We want to keep the | ||
# interval that we record as small as possible to minimize the run-time | ||
# of our single-stepping recorder. | ||
start_recording_bkpt = target.BreakpointCreateByName("start_recording", None) | ||
self.assertTrue(start_recording_bkpt.GetNumLocations() > 0) | ||
initial_threads = lldbutil.continue_to_breakpoint(process, start_recording_bkpt) | ||
self.assertEqual(len(initial_threads), 1) | ||
target.BreakpointDelete(start_recording_bkpt.GetID()) | ||
self.start_recording() | ||
stop_recording_bkpt = target.BreakpointCreateByName("stop_recording", None) | ||
self.assertTrue(stop_recording_bkpt.GetNumLocations() > 0) | ||
lldbutil.continue_to_breakpoint(process, stop_recording_bkpt) | ||
target.BreakpointDelete(stop_recording_bkpt.GetID()) | ||
self.stop_recording() | ||
|
||
self.dbg.SetAsync(False) | ||
|
||
return target, process, initial_threads |
51 changes: 51 additions & 0 deletions
51
lldb/test/API/commands/process/reverse-continue/TestReverseContinueNotSupported.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,51 @@ | ||
""" | ||
Test the "process continue --reverse" and "--forward" options | ||
when reverse-continue is not supported. | ||
""" | ||
|
||
|
||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class TestReverseContinueNotSupported(TestBase): | ||
def test_reverse_continue_not_supported(self): | ||
target = self.connect() | ||
|
||
# Set breakpoint and reverse-continue | ||
trigger_bkpt = target.BreakpointCreateByName("trigger_breakpoint", None) | ||
self.assertTrue(trigger_bkpt, VALID_BREAKPOINT) | ||
# `process continue --forward` should work. | ||
self.expect( | ||
"process continue --forward", | ||
substrs=["stop reason = breakpoint {0}.1".format(trigger_bkpt.GetID())], | ||
) | ||
self.expect( | ||
"process continue --reverse", | ||
error=True, | ||
substrs=["target does not support reverse-continue"], | ||
) | ||
|
||
def test_reverse_continue_forward_and_reverse(self): | ||
self.connect() | ||
|
||
self.expect( | ||
"process continue --forward --reverse", | ||
error=True, | ||
substrs=["invalid combination of options for the given command"], | ||
) | ||
|
||
def connect(self): | ||
self.build() | ||
exe = self.getBuildArtifact("a.out") | ||
target = self.dbg.CreateTarget(exe) | ||
self.assertTrue(target, VALID_TARGET) | ||
|
||
main_bkpt = target.BreakpointCreateByName("main", None) | ||
self.assertTrue(main_bkpt, VALID_BREAKPOINT) | ||
|
||
process = target.LaunchSimple(None, None, self.get_process_working_directory()) | ||
self.assertTrue(process, PROCESS_IS_VALID) | ||
return target |
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,12 @@ | ||
static void start_recording() {} | ||
|
||
static void trigger_breakpoint() {} | ||
|
||
static void stop_recording() {} | ||
|
||
int main() { | ||
start_recording(); | ||
trigger_breakpoint(); | ||
stop_recording(); | ||
return 0; | ||
} |
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
Oops, something went wrong.
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.