Changes to support DAP in DDS introduced a subtle bug where we could send the `InitializedEvent` before the response to the `Initialize` request because `sendResponse` used a `Completer` and would delay adding the response to the stream until the next iteration of the task queue.
Although there were comments stating this order must be preserved, there were no tests that verified this and it breaks VS Code (https://github.com/dart-lang/sdk/issues/52222).
I've added tests for this, and changed how this works slightly so instead of using a `Completer` we pass in a "responseWriter" function that must write the response to the stream synchronously.
Since the DDS path isn't using events yet and it would require a little more refactoring, I've used a Completer there and added a TODO.
Fixes https://github.com/dart-lang/sdk/issues/52222.
Change-Id: I1832126f5015b466c721dbda192da4b8a5d83b62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300601
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
There are two cases where we might be trying to resume an exited isolate:
1. Another debugger resumed the isolate and it exited before we got here
2. We were starting to resume an isolate but then the app was shut down so the isolate exited
Because of async code, we can never guarantee the isolate hasn't exited before we send this event, so the exception we throw should only ever be because the ID was invalid.
Fixes https://github.com/Dart-Code/Dart-Code/issues/4515.
Change-Id: If3500d5d1adf3ba9179e6a571130256783b23c2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299640
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
I'm unable to reproduce this, but there are probably many reasons an isolate could go away while we're doing this async work (such as the app shutting down or a restart). If it does, we should never throw because the results of configuring an isolate are not important if the isolate has gone.
Fixes https://github.com/flutter/flutter/issues/125064
Change-Id: Idb8972a5e77109783799fed70dd8b64e3f702bf5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296201
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
There were two issues here:
1. During shutdown, when trying to unpause and resume all threads we could get "Service has Disappeared" responses if the app was already shutting down. These need ignoring. This is fixed with `_withErrorHandling` in preventBreakingAndResume.
2. The test teardown would always try to send a terminate request even if the test had already sent it, which could result in a second terminate request not being responded to (because the app shutdown before it could respond, because it had already had a terminate request). This is fixed by the teardown code only sending terminate() if it hadn't already been sent.
Fixes https://github.com/dart-lang/sdk/issues/51970.
Change-Id: I1baa857eb4bb7e5616fccdb193fe9213cd9452f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294020
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
In the response to setBreakpoints we provide IDs for each breakpoint and it's important the client gets these before we sent any "breakpoint resolved" events.
Change-Id: I776304b67b12d8e090480ea2a25a849ad4c1ac5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291763
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Previously we just always sent verified:true for all breakpoints and never handled resolution. This meant breakpoints always appeared verified in VS Code, and did not update to their correct locations when resolved.
This change sends verified:false initially, and then uses the BreakpointAdded/BreakpointResolved events to send verified:true and an updated location as the events arrive.
Fixes https://github.com/Dart-Code/Dart-Code/issues/764.
Change-Id: I5b008bef802bb1c31219175a03498f5015ec4a04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285909
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
"evaluateNames" are returned to the client along with any variables, so the client can provide the user an expression that evaluates to that variable (used by "copy expression" or "add to watch".
DAP doesn't round-trip these as you expand variables, so we have to track them ourselves, but we were only doing so for map values. This fixes that to handle lists, getters, fields correctly too.
Fixes https://github.com/Dart-Code/Dart-Code/issues/4352.
Change-Id: Id57e46a1cecf8bd22473911340b649ac05da65fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284223
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
This handles cases where the running app/VM was unable to provide a file:/// URI (such as google3) by calling the VM Service to translate the URIs before providing them to the client (which likely only understands file URIs).
Change-Id: Ib0b5d554a21e14e04fac6c05e489f5cc03b8301c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280107
Reviewed-by: Helin Shiah <helinx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
This adds support for hex formatting that is part of the DAP protocol.
VS Code does not support this natively, so it will require some custom client work. Part of that requires the ability to invalidate the variables view when formatting options change, but this can only be done by the server over DAP, so this also includes a small custom ("private") request "_invalidateAreas" that lets the client bounce this request through the server when it knows the formatting config has changed.
Change-Id: Ic005e9cdf13069b848047cf0a7ac1b8bb39da48f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279963
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
This adds some new classes to support different formatting of values in expression evaluation/watch/variables panes.
Some existing code that passed a flag around to suppress quotes has been converted to this use, and in addition, we support some C#-inspired "format specifiers" that allow you to influence the formatting of returned values by adding a suffix to a watch/evaluation expression:
https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/e514eeby(v=vs.100)?redirectedfrom=MSDN
So if you add "foo" and "foo,nq" to your watch window, the latter will format the string without quotes. If you add "a" and "a,h" then the latter will format a in hex.
Format specifiers are carried down, so you can add ",h" to a class or list variable, and each value down the tree will be formatted that way.
Partly fixes https://github.com/Dart-Code/Dart-Code/issues/3940.
Change-Id: I78001bd046ee2586bd828752f9ea08da01e7180c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279961
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
DevTools no longer expects a fragment (i.e., '#') in its path, which was
causing issues when attempting to redirect to an external DevTools
instance.
Also removes unnecessary query parameter encoding.
TEST=Existing tests
Change-Id: Ifbeba62c173141a754951527f44ab337318a21d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278669
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
External DevTools instances can be registered with DDS at runtime, allowing for DDS
to redirect DevTools requests to the external DevTools server.
TEST=pkg/dds/test/external_devtools_instance_test.dart
Change-Id: I0bed34029b6ea7d935f77a031ff99b73b986b068
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278663
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>