Commit Graph

301 Commits

Author SHA1 Message Date
Ben Konyi 5536951738 [ DDS ] Rework client resume permissions API
This change reworks the client resume permissions API to make it easier
for clients to deal with user provided `--pause-isolates-on-start` and
`--pause-isolates-on-exit` flags.

`requireUserPermissionToResume` should be called by the tool that
launches the Dart process to indicate whether or not the user provided
`--pause-isolates-on-{start,exit}`. The default behavior is to assume
that a tool set these flags for its own use (e.g., resetting breakpoints
after a hot restart in Flutter), where isolates will resume immediately
after each client that has indicated interest in that pause event has
invoked `readyToResume`.

If a user provided one of the previously mentioned flags, isolates will
not immediately resume after each relevant client has invoked
`readyToResume`. Instead, a call to `resume()` must be made to indicate
the user has triggered the resume request instead of tooling. If the
user permissions to resume are changed while the isolate is paused and
all relevant clients have invoked `readyToResume`, the isolate will
automatically resume if the user no longer requires us to wait for a
user resume.

`resume()` now also acts as a "force resume", bypassing any required
permissions set by tooling.

This behavior change is breaking, so the DDS protocol version is being
bumped to 2.0.

`package:dds_service_extensions` has also been updated to include the
following DDS RPCs:

 - `requireUserPermissionToResume`
 - `readyToResume`

Change-Id: Id5f0806b3c56507d39eb00b6305b8896bab13ae7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357420
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-03-21 21:09:42 +00:00
Ben Konyi 6eb85949fd [ VM / DDS ] Add --print-dtd-uri flag and launch DTD from the correct snapshot for AOT
This adds support for printing the DTD connection information to stdout
when --print-dtd-uri is passed.

This change also fixes an issue where DDS would fail to spawn an isolate
with the DTD snapshot when DDS was running in AOT mode. This means the
SDK must be shipped with both AppJIT and AOT DTD snapshots, at least
until dartdev is moved to run from AOT.

Fixes https://github.com/dart-lang/sdk/issues/55034

TEST=run_test.dart

Change-Id: I788ef9bfe76297a8d594992a2aac440ed9e2ecac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358541
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
2024-03-21 19:50:46 +00:00
Kenzie Schmoll 408918d6f5 [dds] Start DTD from DevTools server if it is not already started.
Fixes https://github.com/dart-lang/sdk/issues/54937.

Tested: pkg/dartdev test for `dart devtools` command, and new `dtd_test.dart` in pkg/dds.
Change-Id: I530ba2fe4d5809082378b61c282ba7856974e21e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354460
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Dan Chevalier <danchevalier@google.com>
2024-03-18 21:50:09 +00:00
Kenzie Schmoll 77ac59ad09 Update package:devtools_shared dep to version 8.0.1
Change-Id: I4f2acded3f990f965ff96813b20a033775f9e87a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358223
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-03-18 18:16:53 +00:00
Danny Tuppeny d931bec5d3 [dds/dap] Fix an issue with DAP Source.name being file paths when package: and dart: URIs are expected
The move to URIs introduced a subtle bug here - we would use the mapped URI (which is almost always `file:`) to decide whether to show a file path, instead of doing it only if the unmapped URI was a `file` (eg. it could have been `package:` or `dart:`.

This wasn't caught by any tests here, but was caught in the Flutter roll (https://github.com/flutter/flutter/pull/145235). This fixes it and adds a new test that we verify the Source names for local files, packages, and dart: URIs.

Change-Id: I282bf935b9fa4016abeafd556dfd368950ee9611
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357325
Commit-Queue: Helin Shiah <helinx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
2024-03-18 15:53:49 +00:00
Elliott Brooks 72b414306d [DAP] Do not kill negative pids on disconnection.
This was causing a bug in Cider where if the VM didn't have a pid set, it defaulted to -1, and killing -1 causes Linux to kill everything that it can.

Bug: https://github.com/dart-lang/sdk/issues/55209
Change-Id: I2dae8cf8ecf718a209df9db33f81cecf6ee48d39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357501
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Elliott Brooks <elliottbrooks@google.com>
2024-03-16 00:51:10 +00:00
Danny Tuppeny 038a07b383 [dds][dap] Add support for macro file-like URIs in the debug adapter
The VM service may now give us `dart-macro+package:` URIs in addition to normal `package:` URIs. These can be mapped to `dart-macro+file:` URIs in the same way that we map `package:` to `file:`.

If the client editor has advertised that they support our custom Dart URIs, we can send these through to the client and let them use the analyzer-provided local sources. Otherwise, we'll treat them like other unknown sources and download them from the VM.

Change-Id: If67523a615c66c469db7b1f52d281c63241eb859
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/357143
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-03-13 15:05:47 +00:00
Ben Konyi 9d043ce763 Fix flaky tests that require an isolate to be runnable
These tests became flaky after 3786c5e5ee
landed as DDS initialization became faster, making it more likely that
an isolate used in the test was not yet runnable.

Partly fixes https://github.com/dart-lang/sdk/issues/55133

Change-Id: Ic919cfa6c8bf2b8274efecfa2a78bc056f7e181e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356340
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
2024-03-07 19:32:34 +00:00
Ben Konyi 3786c5e5ee [ DDS ] Don't await getIsolate calls in DDS initialization
Fix an issue where DDS would fail to initialize when an isolate in the target process was unable to handle service requests (e.g., when executing FFI code or blocked on a system call).

Fixes b/323386606

Change-Id: I659ebaf750e2c800e9819809d1104e024cb059da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354681
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-03-06 21:15:36 +00:00
Danny Tuppeny 7f63f01bbe [dds/dap] Add support for communicating with a DAP client using URIs instead of file paths
Change-Id: I90a623f924dfbeb2e82f090a6d223f080baa7e93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352280
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Commit-Queue: Helin Shiah <helinx@google.com>
2024-02-27 19:10:17 +00:00
eliasyishak 247c3e147a Reland "Add parameter for analytics instance"
This is a reland of commit 0e5542211c

Original change's description:
> Add parameter for analytics instance
>
> R=sstrickl@google.com
>
> Change-Id: I8ef2fe2c757a7625c2e3aa7eba48513e4c2f4e88
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352561
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
> Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>

Change-Id: Ia4b84fe72e235138c81ca58c32a78859804fafae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353320
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
Auto-Submit: Elias Yishak <eliasyishak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-02-21 22:38:50 +00:00
Danny Tuppeny 30b9238561 [dds/dap] Increase number of toStrings() per evaluation from 11 to 100
This was an apparently error when moving to the SDK DAPs. The original DAPs performed 100 toStrings() (and 100 is the batch size for VS Code, so the user wouldn't usually see the limit) but we'd done 10 (actually 11) here.

Fixes https://github.com/Dart-Code/Dart-Code/issues/4995

Change-Id: Ie3ca74c9189a725adb971646db2defaf1ffa9627
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353104
Reviewed-by: Helin Shiah <helinx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-02-20 19:24:12 +00:00
Elias Yishak 53cbcc8c81 Revert "Add parameter for analytics instance"
This reverts commit 0e5542211c.

Reason for revert: breaking google3 tests

Original change's description:
> Add parameter for analytics instance
>
> R=sstrickl@google.com
>
> Change-Id: I8ef2fe2c757a7625c2e3aa7eba48513e4c2f4e88
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352561
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
> Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>

Change-Id: Iec1f2eb0224e8ff8b0375736a96f3986c42cacaa
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353040
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Auto-Submit: Elias Yishak <eliasyishak@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2024-02-19 08:58:28 +00:00
eliasyishak 0e5542211c Add parameter for analytics instance
R=sstrickl@google.com

Change-Id: I8ef2fe2c757a7625c2e3aa7eba48513e4c2f4e88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352561
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
2024-02-17 00:09:29 +00:00
Dan Chevalier 03f797a85a Solidify dtd lifecycle
- devtools server can now take the dtd uri as a parameter on startup
   - dtdUri is passed to the server handler so that devtools can request it.
- FileService is implemented inside the Dart Tooling Daemon (dtd_impl)
    - Added FileService.setProjectRoots
    - Added unit tests and rpc exceptions
- on startup dtd now prints { uri, secret } so that the caller has the secret that allows them to call FileService.setProjectRoots

Fixes: https://github.com/dart-lang/sdk/issues/54790

Change-Id: I7a66aca2f8f06f6a611a46c727a9d5c2485fbe3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346922
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Dan Chevalier <danchevalier@google.com>
2024-02-13 16:17:18 +00:00
Danny Tuppeny e10bc067f7 [dds] [dap] Treat "Client is closed" errors the same as "Client closed with pending request" for DAP
These errors can occur normally during shutdown and should not be considered unhandled, otherwise they will trigger crash reports.

Change-Id: I4b0071b8029e10b021af74bf0b5622c02a22eb75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350860
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-02-07 17:56:10 +00:00
Chingjun Lau bb94c1265c Update comment about debugSdkLibraries and debugExternalPackageLibraries.
According to
https://dart.googlesource.com/sdk/+/7512050101f25530824db6200f4770ed8f083251/pkg/dds/lib/src/dap/adapters/dart.dart#2527,
these two fields are `true` by default.

Change-Id: I085649e45bbf4a0837353674e179a376485cf665
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349626
Auto-Submit: Chingjun Lau <chingjun@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
2024-02-05 21:10:49 +00:00
Danny Tuppeny 0390b7d0e0 [dds/dap] Remove unwanted non-null assertion + add some TODOs
This non-null assertion is an error. If any URIs are returned from the VM that are not `file://` URIs and also return `false` from `isResolvableUri` then this would fail, even though the return values allow `null`s and should be used.

I can't currently write a test for this because in theory there aren't any cases where would actually happen, but I triggered it due to another bug (https://github.com/dart-lang/sdk/issues/54824) and think it's better removed.

Also added some TODOs about some behaviour that may need to change as macro support progresses (it's not far enough for me to make these changes yet).

Change-Id: I4108963b6b88bbbff4bb47f69909391900b5d3ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350300
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-02-05 17:51:30 +00:00
Chingjun Lau 0024349fb3 Avoid unnecessary calls to isExternalPackageLibrary and resolveUrisToPackageLibPaths.
Only try to resolve the uri when `debugExternalPackageLibraries` is
false, which is when it is actually needed.

Change-Id: I5aade6214657eccbdb5e294a8bfb5e2968aa6b3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349631
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Auto-Submit: Chingjun Lau <chingjun@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-02-02 20:40:59 +00:00
Oleh Prypin 0da8f7a7b4 Remove unnecessary imports of 'package:collection' IterableExtension
* Replace `.whereNotNull()` with `.nonNulls` which is now in Dart core.
* `.firstOrNull`, `.lastOrNull`, `.singleOrNull` and `.elementAtOrNull(i)` are also in Dart core and even under the same name, so simply drop the import of 'package:collection' whenever possible.

Bug: b/322159291
Change-Id: I81eb93426680dc78a608bbcc714eb26c0eca5c62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348260
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Oleh Prypin <oprypin@google.com>
2024-01-25 11:07:28 +00:00
Danny Tuppeny a95b584101 [dds][dap] Fix global evaluation inside package: files
The initial global evaluation support only worked when the open script was loaded into the VM as a `file:///` URI (eg. things in a `bin/` folder, and not a `lib/` folder). This is because we short-cut resolving file paths to `package:` URIs for most VM functionality (for example setting breakpoints) because it's unnecessary (the VM supports setting breakpoints with file:/// URIs even for `lib/`).

This change forces us to resolve paths to their resolved URIs (eg. `package:` where applicable) in the case where we're looking up a script for global evaluation.

We could enable this lookup for all cases (to remove the additional `force` flag here), but since it's called much more from the other path (breakpoints) we should add caching (which was more than I wanted to change for this fix).

Fixes https://github.com/Dart-Code/Dart-Code/issues/4932

Change-Id: I57a99ec3b7c726d9d120e6cda7d0b938fec397bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346400
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-01-23 16:38:32 +00:00
Danny Tuppeny 0a2c58e51c [dds/dap] Add missing awaits when resuming
These were lost in 35b560e289 and could result in an unhandled error when there's a race during shutdown if a request had been trying to resume an isolate.

Fixes https://github.com/flutter/flutter/issues/139181

Change-Id: Ie683f5afa801e8d05e15d93a0e2008cd0f74fe5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344521
Reviewed-by: Helin Shiah <helinx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-01-03 20:48:29 +00:00
Danny Tuppeny cd7bf37c1b [dds/dap] Don't throw errors for StackTrace requests on exited Isolates
I noticed a race while running from source today.. If you run a Dart CLI app we add --pause-isolates-on-exit to allow sending async output events before exiting, then we resume.

The stopped event is still propagated to the client (since there can be a delay between the stop and the resume while we wait for output events) and the client may ask for a StackTrace. If this arrives just after we resume the isolate, we would generate an error that could be shown to the user.

This adds a check that the thread ID is really invalid before throwing an error, and if it's valid (eg. it belongs to an earlier isolate) we just return an empty stack trace instead of an error.

Fixes https://github.com/Dart-Code/Dart-Code/issues/4907

Change-Id: I0a3241ffd634acea49b4d1dc7b3cd6b6b1c8d2d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342585
Reviewed-by: Helin Shiah <helinx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-01-03 20:48:29 +00:00
Danny Tuppeny 793755f2c1 [dds/dap] Don't show stack traces in error messages from DAP
We accidentally started showing the stack traces in all errors rendered in VS Code. This changes the format of the message to not include the stack - although it keeps it in the payload to aid debugging when capturing logs.

It also slightly tweaks the error message for global eval to be less cryptic for VS Code.

Fixes https://github.com/Dart-Code/Dart-Code/issues/4899

Change-Id: Id4a0c4e6ef26065059e3becec62bab5d873e7be3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342621
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
2024-01-03 20:48:29 +00:00
Elliott Brooks af8d70367d [DAP] Catch any errors for getObject when requesting getters for a class
Bug: https://github.com/dart-lang/webdev/issues/2297
Change-Id: Id7234e7dd758e16ea05fb4b4ccab1593f3ca5ea8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342704
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Elliott Brooks <elliottbrooks@google.com>
2024-01-03 19:43:42 +00:00
Danny Tuppeny 821bdb6535 [dds/dap] Improve the error message when lookupResolvedPackageUris returns an invalid response
+ add a failing test for https://github.com/dart-lang/sdk/issues/52632 / https://github.com/flutter/flutter/issues/137163

This does not resolve the issue, it only makes it clearer from the error message what the problem is. Unfortunately there is no good workaround when we hit this bug because we can't tell which items in the response are valid/invalid. If we treat them all as invalid (eg. complete all of the completes with null), many things that involve mappings of URIs<->files won't work correctly (breakpoints, opening the right file when we break, etc.).

A workaround is for users not to have commas in their filenames, although it's not clear if there may be other characters triggering this right now.

Change-Id: I6ac7cbd82b726fac76c27d1e00a06f2a07d4757f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342800
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-01-02 21:09:23 +00:00
Kenzie Schmoll c680feedaf Improve error handling for serving static DevTools assets.
Change-Id: I2b62461a64ef6aa8b544b4ace894d7b5ded0912e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343000
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
2023-12-20 21:07:39 +00:00
Chingjun Lau 846b23f3ca Use the provided UriConverter to resolve uri in DAP isolate manager.
Change-Id: I1a708417bdb923823a581a9cdc158b0c35b02cd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342484
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Helin Shiah <helinx@google.com>
Auto-Submit: Chingjun Lau <chingjun@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
2023-12-20 16:32:38 +00:00
Dan Chevalier e58efcb049 Connecting DTD and DTD_impl together.
This change adds the happy path for DTD_impl and DTD being able to:
- register streams
- register serviceMethods
- postEvents to streams
- call serviceMethods

Change-Id: I73865071745ef19a4493f86714e0855930243dd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341700
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
Commit-Queue: Dan Chevalier <danchevalier@google.com>
2023-12-19 15:36:22 +00:00
Chingjun Lau b08ab6541a Always specify showUser: true when responding an error message in DAP.
The DAP spec[1] does not specify what should happen when showUser is not
specified, and VSCode chooses to default it to true[2][3].

This is inconsistent with some other tools which uses false as the
default value[4].

Always pass `showTrue: true` to make it consistent in different systems
that use DAP, and be compatible with VSCode.

[1]: https://microsoft.github.io/debug-adapter-protocol/specification#message
[2]: https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/debug/browser/debugService.ts#L631
[3]: https://github.com/microsoft/vscode/issues/128484
[4]: https://github.com/google/go-dap/issues/87

Change-Id: I8e0147044060dfdbb23c69029ca9708d578844bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339741
Commit-Queue: Helin Shiah <helinx@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-12-07 05:19:39 +00:00
Danny Tuppeny 5fde2e1534 [dds/devtools_server] Add support for finding VS Code extensions defined in packages
See https://github.com/Dart-Code/Dart-Code/issues/4705

Change-Id: I724c039cd6940dd5939330a6f91f38567db9a179
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337781
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
2023-12-06 20:56:11 +00:00
Danny Tuppeny c74ea634cb [dds/devtools] Prevent DevTools server reusing clients that aren't fully initialized
It's only valid to reuse a client that is not showing an embedded page, however we only get the embedded flag when a client sends a "currentPage" event.

There is a period between a client connecting and sending this event where we would consider it reusable when it's not. This fixes that by keeping a flag to indicate if a client has completed initializing (that is, it has sent its initial page).

See https://github.com/Dart-Code/Dart-Code/issues/4832

Change-Id: I9f2d43d1537ee97e4e231a844831e7548cf07beb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336041
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-11-14 20:47:43 +00:00
Danny Tuppeny 8a5e6d135f [dds/dap] Always expect uppercase drive letters from DAP
Some of these tests failed if `Directory.systemTemp` had a lowercase drive letter because DAP always normalises outbound paths to uppercase and we were comparing them directly.

This updates offending tests to compare with uppercase drive letters as is expected, regardless of the original temp directory (used for "cwd" and "program").

Fixes https://github.com/dart-lang/sdk/issues/53949

Change-Id: Ibaa6b6ecfe3d77aeff5b806174167c9452167db6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334160
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-11-06 17:59:48 +00:00
Danny Tuppeny 5e255e0110 [dds/dap] Switch to using isGetter isntead of checking _kind
Both VM and DWDS populate isGetter now so we don't need to check this internal field.

There are existing tests verifying this behaviour.

Change-Id: Ia0f0d74167c718ec66a692523c1f255d63eed654
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330784
Reviewed-by: Helin Shiah <helinx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-10-24 17:39:36 +00:00
Danny Tuppeny c5f60241a8 [dds/dap] Don't provide DAP sourceReferences for non-existing scripts
This adds a check that scripts exist before we create a sourceReference to assume we can download them.

I don't have a good way to test this (in the Dart SDK) because this never happens for Dart - we can always download the scripts. However this code is triggered in Flutter because of https://github.com/flutter/flutter/issues/128880 - we can't find the source so we will try to set it up for downloading.

Fixing that would avoid the need for this change (and make the behaviour more consistent with Dart), but in the meantime I think it's better that we don't produce sourceReferences for sources that don't exist.

Change-Id: I4de3f6e87fe3ff867a1ff7e6d3a5d79f7bf9fa1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330780
Reviewed-by: Helin Shiah <helinx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-10-24 17:35:42 +00:00
Kenzie Schmoll 549c1eea11 Roll DevTools into SDK and bump to devtools_shared 5.0.0
Change-Id: I9c38d6be70816de14bb6b9818e6aa550b11c1a34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331748
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
2023-10-24 17:09:20 +00:00
Ben Konyi 08b4f49249 Split package:vm_service into package:vm_service and package:vm_service_interface
To reduce the headache associated with adding parameters to VM service
APIs, VmServiceInterface has been removed from package:vm_service and
pulled into its own dedicated package:vm_service_interface. This will
help reduce the need for major version bumps of package:vm_service,
which requires manual version bumps through >8 packages in order to make
the latest version available to flutter_tools and DevTools.

This separation of the VmService client from the interface will reduce
the frequency of major version bumps to `package:vm_service` as adding
optional parameters to existing APIs would cause implementers of the
interface to break.

package:vm_service continues to expose a copy of the contents of package:vm_service_interface to avoid breaking google3 rolls until package:dwds can migrate to package:vm_service_interface. package:vm_service will not be published until this copy is removed.

This change also includes:
 - some code cleanup and modernization to both the code generator and
   generated code
 - >=3.0.0 SDK version requirement to allow for new language features

Change-Id: Ib1859c1b4e153fef7ee1f91e67e881bbf42652c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330500
Reviewed-by: Derek Xu <derekx@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-10-23 17:00:10 +00:00
Danny Tuppeny 59294606cf [dds/dap] Expand truncated strings and suppress quotes when copying to clipboard + using repl
Normally in the debugger we return truncated values, but there are some cases where the user expects the full value. The legacy DAP handled these, but the new DAP did not.

With this change:

- "Copy Value" (context: clipboard) actions will always copy the full string (and without quotes)
- the REPL/Debug Console will include the full untruncated string

Fixes https://github.com/Dart-Code/Dart-Code/issues/4730

Change-Id: I6e43f8e21ca606d4ea1e9f1c30a111d7a4d82f20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326642
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-10-18 17:34:59 +00:00
Danny Tuppeny b706bfcd1f [dds/dap] Don't require a VM Service connection to map file:// URIs in stack traces
We only need a VM Service / thread to map dart/package URIs. We should always map file:// URIs.

Fixes https://github.com/Dart-Code/Dart-Code/issues/4768

Change-Id: I19c1fdeae9c9ef66e276121bba22504e8bc9d094
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330140
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-10-12 17:45:26 +00:00
Danny Tuppeny a949bbf145 [dds/dap] Fix evaluation of lists containing nulls
The `elements` field of a list can contain `null`s if the list contains nulls (not a Response that represents a null) so this needs to be handled.

Fixes https://github.com/Dart-Code/Dart-Code/issues/4790

Change-Id: I3f135b802919da610827b2a80236c8d4830c4228
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330280
Reviewed-by: Helin Shiah <helinx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2023-10-12 16:50:50 +00:00
Jens Johansen 73466729f3 [vm] Pass offset and script uri for expression compilation
This CL passes the offset and uri of the file (here called a script uri
as opposed to a library uri, the two will be different if we're in a
part) when doing expression compilation.

This CL only passes the data, but doesn't actually use it.
Future CL(s) will use this data to calculate the static type of
available variables which is needed for an upcomming feature.

TEST=Existing tests.
CoreLibraryReviewExempt: Not changing SDK APIs.
Change-Id: I67ead461ab4bb9341424e693946f3e4afe35ce92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329322
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-10-12 10:22:38 +00:00
Danny Tuppeny 35b560e289 [dds/dap] Add support for "restart frame"
Fixes https://github.com/Dart-Code/Dart-Code/issues/4359

Change-Id: I92d5a13313b97c6bb911d2ef68cf396730272091
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324281
Reviewed-by: Helin Shiah <helinx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-10-02 15:45:07 +00:00
Devon Carew 3b0b1bd863 Bump package:lints to the latest; address instances of new lints.
Changes:
```
> git log --format="%C(auto) %h %s" 8d5f750..b044aca
 https://dart.googlesource.com/lints.git/+/b044aca add several rules to core and recommended (150)
 https://dart.googlesource.com/lints.git/+/81100a2 fix a dangling table link (146)
```

Diff: https://dart.googlesource.com/lints.git/+/8d5f7500024320654adb1e799e49fc10c5304ae7..b044acab9f6669b3d8e781923a8ff86877801177/
Change-Id: I031333ade99af700a7009b14a36d3aadba12fc94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327321
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-09-25 21:15:15 +00:00
Danny Tuppeny a780653606 [dds/dap] Use function locations if frame has no location itself
Some functions when debugging tests have tokenPos=-1 which results in the debugger jumping to the top of the file. If the function has a location, this seems to be more appropriate to use.

Fixes https://github.com/Dart-Code/Dart-Code/issues/4692

Change-Id: I7a800de4f9ce94deb5d35919cab658dee881d439
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324522
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
2023-09-22 21:33:39 +00:00
Kenzie Schmoll 83b27b8bcf Add a retry to the DevTools handler for static files
Change-Id: Iced8093f894afd5574e3ae898e07f237e02002bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325323
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-09-12 18:52:01 +00:00
Kenzie Schmoll 2ed87ffb02 Update DevTools rev to adfb08c95c626248b28cc60df3b085c12ad8758e
Change-Id: Ieda1de59dec0ba68b01ec0893c43c6c4015fe58e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324770
Reviewed-by: Derek Xu <derekx@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
2023-09-08 18:32:51 +00:00
Kenzie Schmoll caedf8214d Bump DevTools to 2.26.2 and devtools_shared to 3.0.0 in DDS
Change-Id: I8601b54fffa34d2c3dba678b3bc6d86f68223ec7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321620
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
2023-08-21 19:43:52 +00:00
Danny Tuppeny 45d06f2302 [dds/dap] Include Isolate IDs in Threads when used over DDS
See https://github.com/dart-lang/sdk/issues/53086

Change-Id: I380744f9e0d604168f026684b31fe689bb8947c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317701
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-08-21 14:17:40 +00:00
Danny Tuppeny eda6963e4d [dds/dap] Revert using Isolate numbers for DAP threadIds
This reverts 95e6f1e110 (minus the changelog/version, which have been updated accordingly).

Fixes https://github.com/dart-lang/sdk/issues/53086 although a replacement for mapping threads/isolates needs to be implemented.

Change-Id: I5e4d71f3b4683a04cabec6bda9e6d23caa7901d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317700
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-08-21 14:17:26 +00:00
pq 42db97d721 bump linter
This is the candidate for the HEAD of the linter SDK sub-tree.

Change-Id: If81b785cb53eed154d1376ebd42b3f0459800361
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320704
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-08-14 23:59:48 +00:00