-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb-dap] Adding support for cancelling a request. #130169
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
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c183231
[lldb-dap] Adding support for cancelling a request.
ashgti facdc77
Only apply the Transport::Read timeout to the initial read of the hea…
ashgti 6a474fe
Fixing missing includes and rebasing on main.
ashgti 1c2d19b
Applying clang-format.
ashgti d95773e
Adding fine grained locks for the DAP processing queue and tried to s…
ashgti 0cdd970
Ensure we clear the cancel requests that have been processed.
ashgti 8141476
Using a few helpers to simplify the cancel responses.
ashgti c8a3e84
Trying to isolate the Win32 timeout.
ashgti c6a9796
Fixing the EndOfFileError error code.
ashgti 8a1c97f
Adjusting includes and when we call CancelInterruptRequest.
ashgti f45bba5
Moving cancel checking into RequestHandler to try to conslidate the c…
ashgti ac7b789
Addressing feedback and reseting debugger interrupt requested sooner.
ashgti 093a3b5
Merge branch 'main' into cancel-request
ashgti a56e05a
Fixing post-merge changes.
ashgti 720e59f
Applying reviewer suggestions and have the reader loop break when the…
ashgti b30ba54
Merge remote-tracking branch 'origin/main' into cancel-request
ashgti 77130ca
Fixing post-merge issues.
ashgti 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
C_SOURCES := main.c | ||
|
||
include Makefile.rules |
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,101 @@ | ||
""" | ||
Test lldb-dap cancel request | ||
""" | ||
|
||
import time | ||
|
||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
import lldbdap_testcase | ||
|
||
|
||
class TestDAP_launch(lldbdap_testcase.DAPTestCaseBase): | ||
def send_async_req(self, command: str, arguments={}) -> int: | ||
seq = self.dap_server.sequence | ||
self.dap_server.send_packet( | ||
{ | ||
"type": "request", | ||
"command": command, | ||
"arguments": arguments, | ||
} | ||
) | ||
return seq | ||
|
||
def async_blocking_request(self, duration: float) -> int: | ||
""" | ||
Sends an evaluate request that will sleep for the specified duration to | ||
block the request handling thread. | ||
""" | ||
return self.send_async_req( | ||
command="evaluate", | ||
arguments={ | ||
"expression": '`script import time; print("starting sleep", file=lldb.debugger.GetOutputFileHandle()); time.sleep({})'.format( | ||
duration | ||
), | ||
"context": "repl", | ||
}, | ||
) | ||
|
||
def async_cancel(self, requestId: int) -> int: | ||
return self.send_async_req(command="cancel", arguments={"requestId": requestId}) | ||
|
||
def test_pending_request(self): | ||
""" | ||
Tests cancelling a pending request. | ||
""" | ||
program = self.getBuildArtifact("a.out") | ||
self.build_and_launch(program, stopOnEntry=True) | ||
self.continue_to_next_stop() | ||
|
||
# Use a relatively short timeout since this is only to ensure the | ||
# following request is queued. | ||
blocking_seq = self.async_blocking_request(duration=1.0) | ||
# Use a longer timeout to ensure we catch if the request was interrupted | ||
# properly. | ||
pending_seq = self.async_blocking_request(duration=self.timeoutval / 2) | ||
cancel_seq = self.async_cancel(requestId=pending_seq) | ||
|
||
blocking_resp = self.dap_server.recv_packet(filter_type=["response"]) | ||
self.assertEqual(blocking_resp["request_seq"], blocking_seq) | ||
self.assertEqual(blocking_resp["command"], "evaluate") | ||
self.assertEqual(blocking_resp["success"], True) | ||
|
||
pending_resp = self.dap_server.recv_packet(filter_type=["response"]) | ||
self.assertEqual(pending_resp["request_seq"], pending_seq) | ||
self.assertEqual(pending_resp["command"], "evaluate") | ||
self.assertEqual(pending_resp["success"], False) | ||
self.assertEqual(pending_resp["message"], "cancelled") | ||
|
||
cancel_resp = self.dap_server.recv_packet(filter_type=["response"]) | ||
self.assertEqual(cancel_resp["request_seq"], cancel_seq) | ||
self.assertEqual(cancel_resp["command"], "cancel") | ||
self.assertEqual(cancel_resp["success"], True) | ||
self.continue_to_exit() | ||
|
||
def test_inflight_request(self): | ||
""" | ||
Tests cancelling an inflight request. | ||
""" | ||
program = self.getBuildArtifact("a.out") | ||
self.build_and_launch(program, stopOnEntry=True) | ||
self.continue_to_next_stop() | ||
|
||
blocking_seq = self.async_blocking_request(duration=self.timeoutval / 2) | ||
# Wait for the sleep to start to cancel the inflight request. | ||
self.collect_stdout( | ||
timeout_secs=self.timeoutval, | ||
pattern="starting sleep", | ||
) | ||
cancel_seq = self.async_cancel(requestId=blocking_seq) | ||
|
||
blocking_resp = self.dap_server.recv_packet(filter_type=["response"]) | ||
self.assertEqual(blocking_resp["request_seq"], blocking_seq) | ||
self.assertEqual(blocking_resp["command"], "evaluate") | ||
self.assertEqual(blocking_resp["success"], False) | ||
self.assertEqual(blocking_resp["message"], "cancelled") | ||
|
||
cancel_resp = self.dap_server.recv_packet(filter_type=["response"]) | ||
self.assertEqual(cancel_resp["request_seq"], cancel_seq) | ||
self.assertEqual(cancel_resp["command"], "cancel") | ||
self.assertEqual(cancel_resp["success"], True) | ||
self.continue_to_exit() |
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,6 @@ | ||
#include <stdio.h> | ||
|
||
int main(int argc, char const *argv[]) { | ||
printf("Hello world!\n"); | ||
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? Did this test case work previously and was now broken by implementing cancellation support?