Commit Graph

596 Commits

Author SHA1 Message Date
Ben Konyi 0e535e710b [vm_service] Fix socket exhaustion in resume_shutdown_race_test
The resumer in `resume_shutdown_race_test.dart` was running in a tight
`do-while` loop, hammering the VM server with `getVM` and `getIsolate`
requests to check if all isolates are paused at exit. During VM
shutdown, this rapid sequence of requests could cause socket exhaustion,
especially on Windows, or trigger transient connection errors.

This is fixed by adding a 10ms delay using `Future.delayed` at the end
of each iteration, and wrapping the loop's HTTP request block in a
`try-catch` block to gracefully log and ignore transient connection or
request errors during VM shutdown.

Change-Id: I1bfcad7505254a1feb59dfb654421547efc02d46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/508720
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2026-06-02 13:22:38 -07:00
Ben Konyi 3c0e8ac2fb [vm_service] Fix http_auth_get_isolate_rpc_test not actually testing with authentication codes
When `useAuthToken` is true, the VM Service URI includes the
authentication token as a path segment (e.g.,
`ws://127.0.0.1:8181/auth_token/ws`). Previously,
`http_get_isolate_rpc_common.dart` converted `service.wsUri` to an HTTP
`serverUri` by only copying the host and authority, stripping out the
auth token path segments. This caused all subsequent HTTP request
helpers to fail with a missing or invalid authentication code error.

This is resolved by:
1. Enabling `useAuthToken: true` in `http_auth_get_isolate_rpc_test.dart`.
2. Updating
`http_get_isolate_rpc_common.dart` to extract and preserve the path
   segments from `service.wsUri` (excluding the trailing `'ws'` segment) and
   ensuring a trailing empty segment so that `buildRequestUri` correctly
   formats the final HTTP request path.

Change-Id: I773d402af05c451d2ed776a9660c0bc04f4c672c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/508381
Commit-Queue: Mark Zhou <markzipan@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2026-06-02 12:51:23 -07:00
Ben Konyi 2b4ba49f0d [vm_service] Fix socket leak in makeHttpServiceRequest
In `http_request_helpers.dart`, `makeHttpServiceRequest` was not closing
the created `HttpClient` instance if an exception was thrown during the
HTTP request, response parsing, or JSON decoding. This could cause
socket leaks in tests that invoke this helper.

This is resolved by wrapping the HTTP request, response, and parsing
logic inside a `try-finally` block, ensuring that `httpClient.close()`
is always executed.

Change-Id: I40d5fb8d2c2cd9c16d83418e71a7dc0d67ef2cdc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/508740
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2026-06-02 12:23:10 -07:00
Jake Macdonald 82a952f14a Fix casting of List<String> parameters in VM service generator.
Also updates special cased handling of the `scope` parameter to instead work for any Map typed parameter.

Simplified things in general here by casting values to the correct collection type and then relying on `.cast()` to fill in the proper generic types instead of explicitly filling them in.

Change-Id: I7fef91105ca73ee9726780abd76e92817a9e46c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504780
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2026-05-20 08:28:31 -07:00
Ryan Macnak d36adbacaf [vm] Remove the VM isolate.
The former contents of the VM isolate are now included into each isolate group. This makes each isolate group's heap independent, and in particular allows each heap to be allocated to a separate pointer cage (not done in this CL).

The duplicated stubs that allowed PC relative calls are removed, since the originals can now be the target of PC relative calls.

The bootstrapping needing to load an AppJIT or AppAOT snapshot is reduced to allocating the oddballs. The code is entirely dropped in the AOT runtime, but the JIT runtime still has it to allow for flags to affect the compilation of the stub code. Further refactoring might be able to remove this for the JIT runtime too, with only gen_snapshot knowing how to bootstrap.

Class serialization no longer distinguishes predefined classes.

The page containing null is marked as never-evacuate. null, false and true must not move because the compiler relies on their low bits having certain patterns for some optimizations. (Previously, the entire VM isolate heap never moved.)

Compaction is disabled for IA32. Due to register pressure, some stub calls must not use a scratch register and embed the address of Code.

The page containing the call-through-safepoint stub is frozen when running with --write-protect-code and the stub is created at runtime (instead of loaded from an AppJIT or AppAOT snapshot). This stub must remain executable even during a safepoint, as a foreign call might during return during a safepoint and only block after the stub directs it to the runtime.

The snapshot symbols are renamed to kDartSnapshotData and kDartSnapshotText. There is no need to distinguish the VM isolate's snapshot, and snaphots are per isolate group not per isolate. Aliases with the old names are added to ease migration.

Some global flags that were automatically set based on the VM isolate's snapshot are now isolate group flags and automatically set by the isolate group's snapshot.

TEST=ci
Change-Id: Iee82016057d609112e9b021d178fc3d4d18b5044
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500621
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-18 11:35:03 -07:00
Sam Rawlins 3f6f8b16bf vm_service: Use super parameters more
Unblocks https://github.com/dart-lang/sdk/issues/59226

We will start reporting super parameter opportunities even when the types don't
match (in these cases, String is assignable to String?).

Change-Id: Ic59456cbc6a6fe312e5b98c5df61b2cdcfedbde8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499220
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2026-05-01 07:40:30 -07:00
Ben Konyi 0b68c62fc5 [Service] Add support for resident frontend server to package:dart_runtime_service_vm
TEST=Existing, ran locally.
Change-Id: Idc1f35eb3d4cf0c7251a64b02b801e8110cc323b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499000
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2026-04-30 17:04:19 -07:00
Jens Johansen 4ee8852d77 [CFE/parser] Update 'end' on endLiteralString; Set offset of StringConcatenation to the start; rename 'token' to 'operatorToken' on endBinaryPatterns
* The 'end' token on endLiteralString is now the last token of the
   string, not the next unrelated token.
 * Set the offset of StringConcatenation to the start of the string,
   not the start of the next unrelated token.
 * The 'end' token on endBinaryPatterns is renamed to 'operatorToken'.

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

Tested: Existing
Change-Id: Iae788464008594c21e759570a626971d89688033
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498601
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-04-30 01:05:23 -07:00
Ben Konyi 9c88b8a976 [ package:vm_service ] Prepare for 15.2.0 release
Change-Id: Ibd8e2237b8a47ccf4a08befc7073f47badf0b443
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498940
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2026-04-28 08:32:29 -07:00
Danny Tuppeny 4d07f9ace4 [vm_service] Use empty lists instead of null for non-optional fields when parsing JSON
Change 64060a8ddf accidentally lost `?? []` for non-optional fields when parsing JSON. This change restores that (in `generate_dart_common.dart`), along with some minor tweaks to get the codegen to work on Windows.

For reasons I don't understand, the generated files were formatted differently to how the formatter formats them on my machine today, which unfortunately makes the diff larger than the intended change.

Change-Id: Ibadaa3ec4c6af4e636c1e5ffd2c7e792bc1e8a14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497600
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-04-24 08:03:51 -07:00
Slava Egorov 53ac68e2dd [vm_service] Deprecate Stack.messages
Make VM always return empty array in the response.

Current implementation for this field comes with a bunch of complexity
because it locks message handler and then invokes Dart code which
makes it difficult to reason about various invariants. This code is 
furthermore demonstrated to cause deadlocks. Given that nobody uses 
it - it is simpler to remove this code altogether.

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

TEST=ci

Change-Id: I497210e0f1542860caa0d765d634f8ec6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496340
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-04-20 10:28:01 -07:00
Ben Konyi 4abe0ecd57 [ package:vm_service ] Bump version to 15.1.0 for release
Change-Id: I8bbebed51ca0a805c6362ef89544bf41af96d3c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495500
Commit-Queue: Jessy Yameogo <yjessy@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Jessy Yameogo <yjessy@google.com>
2026-04-14 13:47:07 -07:00
Danny Tuppeny 17f17178e2 [vm_service] Allow setting a pingInterval on VM Service connections and default to 15s
This acts as a keep-alive to prevent dropped connections by proxies (such as Norton antivirus).

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

Change-Id: I44ee326a426aa73e154f1bf1fa9ef520e3672e58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495401
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Jessy Yameogo <yjessy@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2026-04-14 11:58:25 -07:00
Ben Konyi fc3dbc7ef8 [ dart:io ] Fix bad type casts in network_profiling.dart
In 32e45cf300, types were updated from
Map<String, dynamic> to Map<String, Object> in some situations. These
two aren't compatible and can lead to runtime type cast failures.

This change fixes these cast failures and adds a regression test.

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

CoreLibraryReviewExempt: Only internal dart:io details.
Change-Id: I6684d447fc2fe98f9d54fb5bebc3e67f225fe5c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494680
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2026-04-13 10:17:53 -07:00
Lasse R.H. Nielsen 711e50389f Remove var and final from parameters in pkg/.
Doesn't change anything in `front_end/*testcases/primary_constructors/`.
(Would have skipped any other file with `test` in its path and
an explicit language version marker, but there weren't any outside
of those `front_end` directories).

Almost no files used as test input were affected, and none testing the actual syntax changed.
The `.../nnbd/required_2.dart` test case was split into a legacy version retaining the `var`/`final` with a language marker, and a new version without the `var`/`final` cases.

The `pkg/analyzer/` tests, and any other tests that have source code
in strings, are not migrated by this CL.

Tested: No change to behavior. One test split into legacy and new.
Change-Id: I7f5aa4cc98001a9adecacd106c0b3be14f96be1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480542
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2026-04-10 09:09:39 -07:00
Nourhan Hasan 596e0b0849 [vm/service]: expose Pointer<T> address in VM Service Protocol
Pointer<T> instances were previously serialized as PlainInstance
with no address, making them opaque to all debugger clients.

TEST=pkg/vm_service/test/get_object_rpc_test.dart

Fixes: https://github.com/dart-lang/sdk/issues/62853
Change-Id: Ia44eb0fa0851332409680d8d593141fe25505114
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486460
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Nourhan Hasan <nourhan.m.hasan@gmail.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2026-03-24 10:23:38 -07:00
Ben Konyi 086cb1a441 [ Service ] Add HTTP and DevFS support to package:dart_runtime_service
This change adds support for invoking RPCs via HTTP requests, allowing
for interacting with the service without needing to establish a web
socket connection.

This change also adds support for the development file system, otherwise
known as DevFS. DevFS is a (currently) undocumented feature provided by
the VM service that gives clients limited file system access within a
directory contained in the system's temp directory. This is currently
used by Flutter to push kernel files to the device when performing a hot
reload.

The DevFS implementation for package:dart_runtime_service_vm removes
the long deprecated support for `path` parameters, leaving `uri`s as
the only supported format for specifying file system types. Existing
DevFS tests have been updated to replace `path` with `uri` in
preparation for dart_runtime_service_vm becoming the new default VM
service.

This change brings the package:vm_service test suite pass rate to ~95%.

Change-Id: Ib7d95db5788c37408d3dec79926ca7206660a43f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488280
Reviewed-by: Jessy Yameogo <yjessy@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2026-03-20 15:23:38 -07:00
Lasse R.H. Nielsen 56505e0575 Stop using Match.group.
The `Match.operator[]` does the same thing and is
generally recommended (and shorter).
(I want to deprecate `group` and `groups`)

Tested: Refactoring.
CoreLibraryReviewExempt: Calling equivalent function.
Change-Id: I4c758968ae622fe16b7322be1b29b05b91e7fcd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489021
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2026-03-20 09:09:46 -07:00
Ben Konyi e3ca6d824b [ Service ] Add expression evaluation support to dart_runtime_service_vm
Brings pass rate of package:vm_service tests to ~85%

TEST=Manual
Change-Id: I2335d98358362110add93c2acfe51c3fc1385237
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487560
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2026-03-16 11:14:52 -07:00
Ryan Macnak eae5349c23 [test] Remove asserts that currentRss <= maxRss.
The underlying syscalls and proc reads that produce these values may produce inaccurate values.

Bug: https://github.com/dart-lang/sdk/issues/62715
Change-Id: I508db7722a4ab2536848742155ef5631533b58dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481580
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-02-18 14:26:51 -08:00
Tess Strickland 0eae14f76a [vm] Change how the debugger skips the same position after breakpoints.
Previously, the debugger used a boolean "skip next step" field that was
set when a breakpoint was hit. In compiled code, not skipping the next
step would cause a redundant pause to be emitted after a breakpoint, and
so that field caused the next run of PauseStepping to reset it to false
and then continue single stepping without the redundant pause.

However, skipping only the next call to PauseStepping isn't enough
when debugging bytecode. For bytecode, single stepping is performed on
each bytecode instruction and so there may be multiple instructions after a breakpoint until a new token position is reached.

Instead, remove the field and generalize the case being avoided by
recording the token position that should be ignored and single
stepping until the token position changes. This is done by recording
a real last_stepping_pos_ with a last_stepping_fp_ of 0, which now
means to skip any possible pauses until the token position changes.

Doing this means that in each case where there are possible skips to
be performed (skipping the same fp/pos after a pause, skipping the
pos after a breakpoint, skipping the await fp/pos after a resumption),
all such skips are handled via a single unified mechanism.

This CL also reworks the kStepOut behavior so that it steps into
the awaiter closest to the highest debuggable frame on the stack if
there is one, not just the first awaiter even if there are no
debuggable frames between that awaiter and the next.

TEST=pkg/vm_service/test/vm_timeline_flags

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: Ic897d7bea382589751777f4db39aa58bf9525604
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474340
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2026-01-21 09:48:23 -08:00
Ryan Macnak e53115a98c [vm] Fix crash on GC after service id zone deletion.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62154
Change-Id: Ib1ca89aa7344614de1ffc2fae6e6f93850e4a1b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466880
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-12-08 13:17:40 -08:00
Tess Strickland 57ea885496 [pkg/vm_service] Handle lack of optimized out variables in interpreter.
Test the evaluation of the variable as normal when interpreted, and
expect the appropriate RPCError when not interpreted.

TEST=pkg/vm_service/test/evaluate_optimized_out_variable_test

Cq-Include-Trybots: luci.dart.try:vm-linux-release-x64-try,vm-dyn-linux-debug-x64-try,vm-dyn-mac-debug-arm64-try
Change-Id: I964b75fcfbd789aa7ee5b02c325d028a1a9394f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464441
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2025-12-02 06:52:59 -08:00
Jens Johansen c9ebb0e311 [CFE] Expression compilation overwrites types to static types if from "dart:"
When the VM has an `int` it often represents it as a `_Smi` (which
extends `_IntegerImplementation` which implements `int`), but the
interface member for e.g. `+` on `_Smi` is `_IntegerImplementation.+`
and `_IntegerImplementation` is not special-cased in
`isSpecialCasedBinaryOperator` (but `int` and `num` is, so using `int`
having the interface member `num.+` makes `isSpecialCasedBinaryOperator`
return true if the type is `int` but false if the type is `_Smi`).

Not knowing which specialized types the VM could send for more general
types that are then specialized in the compiler this CL fixes the issue
(linked below) by using the static types of definitions from `dart:`.

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

Change-Id: I66cb2d44d5762719b14b51cb139fa0df6b00468f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459420
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-11-09 23:33:10 -08:00
Jessy Yameogo bb0ae6c3df The _routeRequest method in vm_service.dart has a bug where it catches and re-encodes RPCError exceptions as kServerError, losing the original error code and information.
This PR applies the following changes to the _routeRequest method:

- Preserves RPCError exceptions: When an RPCError is caught, it returns the error as-is using e.toMap(), maintaining the original error code and information.

- Wraps other exceptions: Only non-RPCError exceptions are wrapped as kServerError, which is the appropriate behavior for unexpected errors.

This ensures that when service callbacks throw specific RPCError instances (like kIsolateCannotReload), those error codes are properly propagated to the client instead of being incorrectly replaced with kServerError.

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

Change-Id: Ib67c78035215372d1cc2c73d8c819e2825aad5bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458040
Auto-Submit: Jessy Yameogo <yjessy@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2025-10-29 09:09:57 -07:00
Tess Strickland 26b3a60b49 [pkg/vm_service] Standardize stop printing in checkRecordedStops.
If debugPrintFile and debugPrintLine are provided, provide the stop
lines to the failure expect in the same format as the recorded stops are
printed when debugPrint is true.

Add additional debug output that lists which stops were matched and
which recorded stops were skipped, and add a reason to the failure
expect that includes the expected and recorded stop indices.

TEST=ci

Change-Id: If6974a23de72a1922d64937303816c96f646199c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457380
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-10-24 07:43:29 -07:00
Tess Strickland 74f753f32d [vm,dyn_modules] More work on bytecode debugger support.
Detects yield points in Debugger::IsAtAsyncJump for bytecode by seeing
if the currently executing instruction is a direct call to an await
or yield compiled stub.

Adds a ResumptionBreakpointHandler runtime entry that is called
during Interpreter::Resume() if the current isolate has resumption
breakpoints.

Similarly, all the places where a DebugCheck could be emitted if
debugging stops are requested now include an explicit source position
emission when source positions are requested but debugger stops are not,
to ensure the debugger has appropriate information.

Fixes CompareTopDartFrameTo returning kSelf for non-top frames when
the top frame was interpreted but the stepping frame was not or
vice versa.

TEST=pkg/vm_service/test

Change-Id: I88cdc37cf745f30e8dfb6b14c19fc9b2c4cbaf2d
Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try,vm-dyn-mac-debug-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446300
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-09-12 04:19:40 -07:00
Jens Johansen 1f845d1eb7 [CFE] Expression evaluation: Use dynamic get etc and fixup names to access private stuff when possible
For expression evaluation we want to be "more than dart" in that if for
instance we can see (in the debugger) that a List contains `B`s (even
if it's typed as containing `A`s) we'd like to be able to access things
on `B` (without manually having to cast to either `B` or `dynamic`).

Furthermore - when we in the debugger can see that it's a `B`, and that
`B` has, say, a field `_privateField` or a method `_privateMethod` we'd
like to be able to access that even if `B` is in another library.

This CL - for expression evaluation - makes dynamic accesses and calls
where we would normally issue a "missing getter" (etc) error, and tries
to create a `Name` so private access is possible.

Change-Id: I887318a50413e9a5f11ec685b27719edd312dca0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446260
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-08-26 00:27:19 -07:00
Jens Johansen 080af85987 [CFE] Specific error message when using unavailable variables in expression evaluation
So instead of either being told that a variable doesn't exist, or
using a field or something instead of a local, you'll now get a message
saying "<variable> is unavailable in this expression evaluation".

Bug: https://github.com/dart-lang/sdk/issues/53996
Bug: https://github.com/dart-lang/sdk/issues/53087
Bug: https://github.com/dart-lang/sdk/issues/45913 (sort of?)
Bug: https://github.com/dart-lang/sdk/issues/53688
Change-Id: I6726209584e414ddc40f3e7ff6bffa9e7283e9d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445701
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-08-20 23:13:11 -07:00
Jens Johansen 3175e427d8 [CFE] Keep const locals by default; expression evaluation can evaluate const locals
Note: Const locals are still off for VM aot and dart2js for the entry
points I've found in an attempt to retain the old behaviour there.
It might be better if those targets could remove such locals in a
whole-world analysis instead.

 * Keep const locals by default (except as noted above). Update the
   verifier to accept that. For the platforms this has increased the
   size by at most 6584 bytes. With this the VM will pass in any const
   locals as it does normal locals, but as the variable is never
   captured it will never pass a const local defined in a method when
   inside a local function in that method.
 * Change the dart scope calculation(s) to return the found variables
   instead of just the types of the found variables.
 * When the incremental compilers expression compilation - via the dart
   scope calculation - finds a const local that it wasn't told about, it
   will pass it on as an extra variable that it knows about, allowing
   for evaluating const locals in the case not covered by the first
   bullet.

With luck this can in future CLs be extended to know about other
variables that we're not told about, allowing to give a message saying
something like
"yes, we know what 'foo' is, but you can't currently use it" as wanted
in for instance https://github.com/dart-lang/sdk/issues/60316 and
https://github.com/dart-lang/sdk/issues/53996.

Tested: Existing tests for existing functionality; new tests for the new
Change-Id: I1ec24350273e6f81574bb2888f6bf46e3b8b1b47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445461
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2025-08-19 04:30:41 -07:00
Derek Xu 966500e03f [VM/Service] Deprecate streamCpuSamplesWithUserTag
TEST=pkg/vm_service/test/stream_cpu_samples_with_user_tag_rpc_test,
other pkg/vm_service tests

CoreLibraryReviewExempt: This CL only includes some implementation
changes to `dart:vmservice`, it does not touch any other core libraries.
Issue: https://github.com/dart-lang/sdk/issues/61267
Change-Id: I68be75b642acc4a9b8475c56aa993693ff42fbdd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444101
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-08-12 09:21:21 -07:00
Derek Xu 3bf3383a49 [VM/Service] Tweak profile_startup_cli_flag_test to make it less flaky
This is a followup to
https://github.com/dart-lang/sdk/commit/1ddbc4428829f126a7963ca11763bec90187fe5f
that follows the same rationale described in that commit’s message. This
followup is being made because the original change did not successfully
resolve the flakiness on Windows configurations. If the flakiness is
still present after this change lands, we probably have to replace this
`package:vm_service` integration test with a C++ test that interacts
directly with a `SampleBlockBuffer`.

Issue: https://github.com/dart-lang/sdk/issues/61191
Change-Id: Ifc3029dbd23b3bcfaac947d3b3f6bd54b973eb05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444443
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-08-11 13:33:45 -07:00
Derek Xu 1ddbc44288 [VM/Service] Tweak profile_startup_cli_flag_test to make it less flaky
The `--profile-period` argument is used when calculating a sample buffer
size that satisfies the `--sample-buffer-duration` argument, so this CL
changes the `--profile-period` argument we pass from 100 to 500, because
the profiler is more likely to actually hit that rate of sampling.

This CL also changes `testeeMain` to spin for 10 seconds instead of 5
seconds, to make it more likely to fill up the sample buffer.

Issue: https://github.com/dart-lang/sdk/issues/61191
Change-Id: Ic18b47f86bd2495b7df1af4d7f886fb11aa42812
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442242
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-07-25 12:32:51 -07:00
Derek Xu 9b89266f43 [VM] Introduce --profile-startup CLI flag
TEST=pkg/vm_service/test/profile_startup_cli_flag_test

Change-Id: I39bf67bf3157fe5700f1a62822f1dc3159c9bc96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/438980
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-07-24 12:04:17 -07:00
Ivan Inozemtsev e694eb261a [release] Bump version on main to 3.10
Change-Id: I502950fa3cf72958628512634ad0d62ca54f61cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434804
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2025-07-14 22:47:12 -07:00
Jessy Yameogo 119e128847 Added debug info to http_get_isolate_rpc_test
The test was failing on Windows with generic `Expect.isTrue(false) fails` errors, making it difficult to diagnose which assertion was failing.

Added debug messages to `Expect.isTrue()` calls to show actual values when assertions fail.

This will help identify the root cause of test failures.

Change-Id: I61b7d944aacb5f22be861809f33896d162fca770
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/438960
Reviewed-by: Ben Konyi <bkonyi@google.com>
Auto-Submit: Jessy Yameogo <yjessy@google.com>
Commit-Queue: Jessy Yameogo <yjessy@google.com>
2025-07-08 11:09:25 -07:00
Jessy Yameogo 7d1998d510 catch error when connection is disposed
Change-Id: I7a6512091786701621ce5d1197f975eb3fb098c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/438760
Reviewed-by: Ben Konyi <bkonyi@google.com>
Auto-Submit: Jessy Yameogo <yjessy@google.com>
Commit-Queue: Jessy Yameogo <yjessy@google.com>
2025-07-03 14:46:24 -07:00
Sam Rawlins a8414a4962 vm_service: Use less dynamic, both explicit and implicit
Change-Id: Idde221b094fd23ded8e6d77d47f8ce73ab2549c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437022
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-26 12:07:31 -07:00
Sam Rawlins 64060a8ddf vm_service: Assign fields in field initializers
This is achieved with just a bit of delicacy around commas, braces,
semicolons, and possible super-initializers.

There is exactly one case of a statement that needs to remain in the
constructor body: `_parseTokenPosTable()`.

Additionally I add one helper, `_createServiceObjectListOrNull`, which takes care of some casting and nullability quirks. This also includes one small perf improvement: when `createServiceObject` returns null,
we immediately return an empty list, without wrapping it in `List.from`.


vm_service: helper for list fields
Change-Id: Ic5e36bbfa451bea06edf0d9e684705d392f1ad39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436540
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-06-25 08:57:13 -07:00
Sam Rawlins c27ad09258 vm_service: Remove unused categoryName parameter
Change-Id: I2ea111c576a550e2d473e8b55b51b6ac41e687c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436481
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-06-23 13:04:40 -07:00
Sam Rawlins 2be548666d vm_service: Tidy nullability and finality in generator
While exploring this code, I saw some easy wins:

* A number of local variables of the form `String? x = a.b.c;` can be
  made non-nullable as `.c` now returns  `String`; no tooling will warn
  the developer of this.
* A number of methods of the form `String? m() {...}` can be made non-
  nullable, as they only return non-null values; no tooling will warn
  the developer of this.
* A number of methods of the form `m(String? p) {...}` can instead
  accept non-nullable Strings, as all of the call sites pass non-null
  Strings.
* `_coerceRefType` accepted a `String?` parameter but immediately null-
  checked it's value. We can use the type system to enforce that this
  function requires non-null values.
* StreamCategory's `_name` and `_events` fields can be made non-nullable
  by using a little factory constructor; this enhancement reveals that
  the fields can be made final (analyzer reports this). Then we have
  unnecessary public getters that expose these final fields; the fields
  can instead be made public, and the getters removed.
* `Api.types` can be made a `List<Type>`.
* Some fields can be made final: `MemberType.types`, `TypeRef.name`,
  `TypeRef.nullable`, `MethodArg.type`, and `MethodArg.name`.
* Some fields can be made non-nullable: `TypeRef.name`,
  `MethodArg.name`, and `EnumValue.name`.

Change-Id: Ia36c1edc4686c6a14d76fd053d70da60b7b4aac6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436420
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-06-23 11:29:41 -07:00
Sam Rawlins 66ba0cf14f vm_service: Make SocketProfile.sockets non-late.
We only need to adjust a private constructor to make it non-late
[1] [2].

[1]: https://dart.dev/effective-dart/usage#dont-use-late-when-a-constructor-initializer-list-will-do
[2]: https://dart.dev/effective-dart/design#avoid-public-late-final-fields-without-initializers

Change-Id: Ia063718104027a1cec147ca94d7ce34a661f5efd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435000
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-23 09:58:20 -07:00
Derek Xu b3c579d3ee Revert "Reland "[VM/Service] Shut down the VM immediately after the VM Service fails to start during VM initialization""
This reverts commit c2095cb347.

Reason for revert: These changes are blocking the Dart SDK -> Flutter roll because they cause some Fuchsia tests to fail.

Original change's description:
> Reland "[VM/Service] Shut down the VM immediately after the VM Service fails to start during VM initialization"
>
> This reverts commit d510876d9e.
>
> Reason for revert: g3 and Golem have been made compatible with this CL.
> See b/409535026 and
> https://chrome-internal-review.googlesource.com/c/golem/+/8345341.
>
> TEST=pkg/vm_service/test/failure_to_start_vm_service_after_vm_is_initialized_test,
> pkg/vm_service/test/failure_to_start_vm_service_during_vm_initialization_test
>
> Original change's description:
> > Revert "[VM/Service] Shut down the VM immediately after the VM Service fails to start during VM initialization"
> >
> > This reverts commit 56ccf437e6.
> >
> > Reason for revert: b/409535026
> >
> > TEST=ci
> >
> > Original change's description:
> > > [VM/Service] Shut down the VM immediately after the VM Service fails to start during VM initialization
> > >
> > > TEST=pkg/vm_service/test/failure_to_start_vm_service_after_vm_is_initialized_test,
> > > pkg/vm_service/test/failure_to_start_vm_service_during_vm_initialization_test
> > >
> > > Fixes: https://github.com/dart-lang/sdk/issues/60256
> > > Change-Id: I0543ab26e5721a4048136f27e8f4429bef04920f
> > > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416300
> > > Commit-Queue: Derek Xu <derekx@google.com>
> > > Reviewed-by: Ben Konyi <bkonyi@google.com>
> >
> > Change-Id: I61eb42f0f00ad97e95e3ebf19990fe75d2d416aa
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421622
> > Reviewed-by: Derek Xu <derekx@google.com>
> > Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
> > Reviewed-by: Ben Konyi <bkonyi@google.com>
>
> Change-Id: Ieba880b7b298e491055c3f6049bab6772b1f8aa3
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434960
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I03b2371728de91e4e20008a879280c1ccab4d07c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435540
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-06-18 08:21:15 -07:00
Derek Xu c2095cb347 Reland "[VM/Service] Shut down the VM immediately after the VM Service fails to start during VM initialization"
This reverts commit d510876d9e.

Reason for revert: g3 and Golem have been made compatible with this CL.
See b/409535026 and
https://chrome-internal-review.googlesource.com/c/golem/+/8345341.

TEST=pkg/vm_service/test/failure_to_start_vm_service_after_vm_is_initialized_test,
pkg/vm_service/test/failure_to_start_vm_service_during_vm_initialization_test

Original change's description:
> Revert "[VM/Service] Shut down the VM immediately after the VM Service fails to start during VM initialization"
>
> This reverts commit 56ccf437e6.
>
> Reason for revert: b/409535026
>
> TEST=ci
>
> Original change's description:
> > [VM/Service] Shut down the VM immediately after the VM Service fails to start during VM initialization
> >
> > TEST=pkg/vm_service/test/failure_to_start_vm_service_after_vm_is_initialized_test,
> > pkg/vm_service/test/failure_to_start_vm_service_during_vm_initialization_test
> >
> > Fixes: https://github.com/dart-lang/sdk/issues/60256
> > Change-Id: I0543ab26e5721a4048136f27e8f4429bef04920f
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416300
> > Commit-Queue: Derek Xu <derekx@google.com>
> > Reviewed-by: Ben Konyi <bkonyi@google.com>
>
> Change-Id: I61eb42f0f00ad97e95e3ebf19990fe75d2d416aa
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421622
> Reviewed-by: Derek Xu <derekx@google.com>
> Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

Change-Id: Ieba880b7b298e491055c3f6049bab6772b1f8aa3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434960
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-06-17 11:31:00 -07:00
Johnni Winther b8b072ed3b [cfe] Update message for undefined access
This updates the message text for undefined access. Instead of saying
that the member is not defined on the "class", it now says on the "type".

Closes #60290

Change-Id: I9387f892e99ba109b9b1d99af25714ab83b5350c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433941
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2025-06-17 04:03:26 -07:00
Derek Xu c9c8929099 [package:vm_service] Add kTimerSignificantlyOverdue field to EventKind
I overlooked making this additon earlier. This CL also prepares
`package:vm_service 15.0.2` to be published.

TEST=CI

Change-Id: I4d28d87c027d27c4e532e5608f57b62eaa290e44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433082
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-06-05 07:34:51 -07:00
Ryan Macnak 03301c9bfb [vm] Support assembly output for Windows.
The resulting DLL lacks debugging information / PDB.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/60812
Bug: https://github.com/dart-lang/sdk/issues/60813
Cq-Include-Trybots: luci.dart.try:vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-release-arm64-try,vm-aot-win-release-x64-try
Change-Id: I305bad0081ec24f27249ad9b75ff8d32fa9c4893
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428200
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-02 12:12:04 -07:00
Derek Xu fe46d2089f [package:vm_service] Add dot_shorthands_test
Fixes: https://github.com/dart-lang/sdk/issues/59875
Change-Id: I2653a6473a00cbf89b26872c7e50a34e6d486a22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431120
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
2025-05-26 10:43:59 -07:00
Derek Xu 12bb30af89 [package:vm_service] Prepare to publish version 15.0.1
Change-Id: I3e9ccc809bc031c1015eaacd266e41ac8475b1fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430140
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-05-21 11:09:40 -07:00
Derek Xu 3dc9d8dcf9 [VM/Service] Add getQueuedMicrotasks RPC
TEST=pkg/vm_service/test/get_queued_microtasks_rpc_test

CoreLibraryReviewExempt: This CL does not include any core library API
changes, only VM Service implementation changes within
sdk/lib/vmservice/.
Change-Id: Ie5488f498e4d0f3d201e3f31423fd5029b74a726
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425160
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-05-13 14:29:37 -07:00