This adds two custom requests to the DAP-over-DDS handler to translate between VM/DAP instance IDs:
- $/createVariableForInstance (String isolateId, String instanceId)
- $/getVariablesInstanceId (int variablesReference)
Because DAP's variables request only fetches _child_ variables (eg. fields) but we'd likely want to align the top-level string display of a variable, the wrapped variable will first be returned as a single variable named "value", which contains both the string display value and also a variablesReference to then get the child variables (usually invoked when expanded).
These methods currently live directly in the DDS DAP adapter since I figure they're only useful for clients using the VM Service, but we can move them to the base adapter if in future this turns out to not be the case.
Change-Id: I60f28edd86c3468cc592175cb665557a1fc85056
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312987
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
This is for an internal debug adapter to extend the test debug adapter and provide a custom URI converter to provide internal local paths during breakpoints.
Change-Id: I3b61b70fe07e14f08ff37443ef87facc523bf7fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313000
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Helin Shiah <helinx@google.com>
We used to generate our own thread ID starting at 1 and counting up. There was always a 1:1 mapping from a DAP thread to a VM Isolate. With this change, we always use the Isolate number as the thread ID which makes it easier for tools using both VM Service and DAP at the same time.
Change-Id: Id8d82f6fd5134987f2ecfeaa761765d55999405d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312906
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
This fixes a bug where we'd produce the wrong absolute path for stack frames that had absolute paths (because `package:stack_trace` uses `path.absolute()` on them).
It also adds support for making stack frames in printed stack traces faded if they are not part of the users own code. This is something the legacy DAPs did. I've also made it possible to perform this stack parsing on non-error events because I'd like to use it on Flutter structured errors (again, something we supported in legacy adapters and was missing here).
Fixes https://github.com/Dart-Code/Dart-Code/issues/4573,
Change-Id: I6c1c3ab69915eca9a1eeef5dcba7f1eb558086de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311842
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
When there are multiple isolates, we may get breakpoint responses/events like this:
- Request/Response to add breakpoint to Isolate 1
- Request/Response to add breakpoint to Isolate 2
- BreakpointAdded for Isolate 1
- BreakpointResolved for Isolate 1
- BreakpointAdded for Isolate 2
Because Isolate 2 did not load the script, the last breakpoint was never resolved. However because the breakpoint ID matched, we would forward this event to the client and un-resolve the previously resolved breakpoint. This would result in odd behaviour in VS Code.
Additionally, the VM may return the same BM breakpoint ID for what the client thinks are two breakpoints (they are on different lines, but resolve to the same location) so when we get a resolved breakpoint, we need to handle both:
- Client breakpoints that have already been transmitted
- Future client breakpoints that may resolve to this same VM breakpoint
The previous code assumed that a BreakpointResolved event could be handled just once. Either for an existing breakpoint, or a future one.
This change swaps from storing queued events to storing the resolution information for each breakpoint, and it does this even if there was an existing breakpoint (in case the breakpoint is reused in future).
Fixes at least some of https://github.com/Dart-Code/Dart-Code/issues/4598
Change-Id: I53b92debfaa0c8f538dc8d67966854bb89634708
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311480
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
The existing 'evaluateGettersInDebugViews' evaluates getters eagerly which can have side-effects. This adds a setting that allows showing getters in a way that can be shown lazily instead.
I added a new setting (instead of just making evaluateGettersInDebugViews=false be lazy) to preserve the ability to have getters not shown at all (since some users are using that today and might prefer this over lots of lazy getters showing up).
Fixes https://github.com/Dart-Code/Dart-Code/issues/4234
Change-Id: I56c2a7c8f85aa8c4cc85cfb3120a8cfec6b54c70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310164
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
When adding new breakpoints, DAP clients send a full new set of breakpoints which results in us removing and re-adding all breakpoints (for a file).
When we re-add a breakpoint that already existed, we would sometimes get the BreakpointAdded event _before_ the addBreakpointWithScriptUri request completed. We couldn't process the event because without the original request completing we could not map the VM breakpoint back to the clients breakpoint to generate the event.
This could result in resolution events being lost, and breakpoints becoming unresolved when you modified them (depending on timing).
This change collects queues and replays any BreakpointAdded/BreakpointResolved events that arrived when the breakpoint ID is unknown, and when `addBreakpointWithScriptUri` completes, it immediately processes any items in this queue.
Fixes https://github.com/Dart-Code/Dart-Code/issues/4599
Change-Id: I11daaf99b786ab94f1cc93f9fd38a4f1e241320f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310620
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
When an isolate is paused, we store some data for things like variables, stack frames, etc. to round-trip an identifier to the client that it can ask about later.
Previously we never cleared these, so over time in a long debug session they could build up. The DAP spec says these references become invalid when execution is resumed:
> To simplify the management of object references in debug adapters, their lifetime is limited to the current suspended state. Once execution resumes, object references become invalid and DAP clients must not use them.
Because it's possible to resume one thread without another, I'm clearing up only the specific thread (isolate)s data when it resumes, rather than all of it.
Fixes https://github.com/Dart-Code/Dart-Code/issues/4420
Change-Id: I2ba7d9cd3f23b5a628d9e279e49edf2bee5afd29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310342
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Currently when the user configures a Dart CLI program to be run in the terminal, we ask VS Code to launch it in the terminal before we respond to the launch request. This (depending on settings) can cause VS Code to show the terminal and then switch to the Debug Console (which is both confusing and frustrating for users that opt-in to do this to access stdin of the terminal process).
This change reverses the order when using `runInTerminal` so that `launch` is responded to first.
See https://github.com/microsoft/vscode/issues/168295
Fixes https://github.com/Dart-Code/Dart-Code/issues/4287
Change-Id: If9a221361cc3329fb86fb17ba532043266b3438c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307481
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
This will allow for communication to custom streams through a connection to DDS. The primary use case for this is so Dart DevTools can communicate to the running app's custom streams, and by extension VSCode.
Bug: https://github.com/flutter/devtools/issues/5819
Change-Id: Ib22181a55a15baa4a85f49fb20d86d1ca8f0e5e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304981
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Dan Chevalier <danchevalier@google.com>
Reland "Reland "Use dap package in dds, dds_service_extensions""
This is a reland of commit a48d2cf02c
This was failing in g3 because it seemed dependencies weren't added to the g3 files. There's now a fix in g3.
Original change's description:
> Reland "Use dap package in dds, dds_service_extensions"
>
> This is a reland of commit 59bb1fce82
>
> Original change's description:
> > Use dap package in dds, dds_service_extensions
> >
> > Change-Id: I678c810e02a5989ee1b4edebaf9d741e2fc7d026
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302849
> > Reviewed-by: Ben Konyi <bkonyi@google.com>
> > Commit-Queue: Helin Shiah <helinx@google.com>
>
> Change-Id: Ib5b9cad1d0c19dac79c73e65c5de8721d1768285
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304105
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Helin Shiah <helinx@google.com>
Change-Id: Ie6618c761ce57b33c36260b52076f6335da2a102
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304326
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Helin Shiah <helinx@google.com>
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>
This adds functionality that exists in the legacy VS Code DAP but was not reproduced here.
Calling `inspect(var)` (from `dart:developer`) would print the inspected variable to the Debug Console where the user can expand and review it (similar to using the Watch window).
Fixes https://github.com/Dart-Code/Dart-Code/issues/4330.
Change-Id: Ic63e6b6eb9f149dc8d80c4efdf622fb1c05bd580
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284183
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>
Fixes#51095
TEST=ci
CoreLibraryReviewExempt: There are no API changes, just removal of superfluous words in the comments.
Change-Id: Ib1020c62fe6baed5ca68f0074323f025cc90e9f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279500
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Siva Annamalai <asiva@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>