Commit graph

90 commits

Author SHA1 Message Date
Ben Konyi e83e78431f [ CLI ] Improved consistency of -D and --define across tools and
commands

- Added support for --define to the VM and dart2js
- Added support for -D and --define for `dart run` and `dart compile js`

Remaining improvements:
- Add support for providing multiple comma separated values for `dart
  run`, `dart`, and `dart2js`

Related issue: https://github.com/dart-lang/sdk/issues/44562

TEST=Updated CLI tests and added new dart2js tests.

Change-Id: I9379c7aee1eab377adb3438393d9ad79c4938cc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178262
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-01-13 23:33:17 +00:00
Sigurd Meldgaard f3fe9dc3b3 Reland "Improve handling of disable-dartdev-analytics"
This is a reland of 58860f4814

Original change's description:
> Improve handling of disable-dartdev-analytics
>
> This is second try of https://dart-review.googlesource.com/c/sdk/+/171284
> that was reverted to to faulty logic in main_options.
>
> Some other refactorings are piggy-backed along.
>
> TestProject.runSync no longer takes a 'command' argument. It was anyway
> often not an argument.
>
> Also stop the messy handling of pub arguments. It is no longer needed.
>
> BUG: https://github.com/dart-lang/sdk/issues/44135
> Change-Id: I49abf5810d9ea262409ba9d93f0471037cb8a753
> TEST=The VM change is tested via all the pkg/dartdev/test/command/* tests that invoke dart with the --no-analytics flag.
> TEST=Furthermore manual test that the --no-analytics flag is passed to dartdev.
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174261
> Reviewed-by: Jonas Jensen <jonasfj@google.com>
> Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>

Change-Id: I725662f578d061f87171ceffe9aff3de83688f58
TEST=Furthermore run the vm-kernel-precomp-obfuscate-linux-release-x64-try trybot
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174473
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
2020-12-04 14:22:10 +00:00
Sigurd Meldgaard 97baa6efd1 Revert "Improve handling of disable-dartdev-analytics"
This reverts commit 58860f4814.

Reason for revert: Broke bots. Will investigate.

Original change's description:
> Improve handling of disable-dartdev-analytics
>
> This is second try of https://dart-review.googlesource.com/c/sdk/+/171284
> that was reverted to to faulty logic in main_options.
>
> Some other refactorings are piggy-backed along.
>
> TestProject.runSync no longer takes a 'command' argument. It was anyway
> often not an argument.
>
> Also stop the messy handling of pub arguments. It is no longer needed.
>
> BUG: https://github.com/dart-lang/sdk/issues/44135
> Change-Id: I49abf5810d9ea262409ba9d93f0471037cb8a753
> TEST=The VM change is tested via all the pkg/dartdev/test/command/* tests that invoke dart with the --no-analytics flag.
> TEST=Furthermore manual test that the --no-analytics flag is passed to dartdev.
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174261
> Reviewed-by: Jonas Jensen <jonasfj@google.com>
> Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>

TBR=bkonyi@google.com,sigurdm@google.com,jonasfj@google.com

Change-Id: I754bcebdcfc595158b04d431662b65bf25f5b89d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174466
Reviewed-by: Sigurd Meldgaard <sigurdm@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
2020-12-01 13:11:16 +00:00
Sigurd Meldgaard 58860f4814 Improve handling of disable-dartdev-analytics
This is second try of https://dart-review.googlesource.com/c/sdk/+/171284
that was reverted to to faulty logic in main_options.

Some other refactorings are piggy-backed along.

TestProject.runSync no longer takes a 'command' argument. It was anyway
often not an argument.

Also stop the messy handling of pub arguments. It is no longer needed.

BUG: https://github.com/dart-lang/sdk/issues/44135
Change-Id: I49abf5810d9ea262409ba9d93f0471037cb8a753
TEST=The VM change is tested via all the pkg/dartdev/test/command/* tests that invoke dart with the --no-analytics flag.
TEST=Furthermore manual test that the --no-analytics flag is passed to dartdev.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174261
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
2020-12-01 10:25:55 +00:00
Ben Konyi b0ccaf75a3 [ VM / CLI ] Fix issue where trying to snapshot a non-existent script would cause an assertion failure
Passing --snapshot should result in the CLI being bypassed (`dart compile`
should be used otherwise). Check to see if this option is provided when
attempting to parse the script name and always populate script_name in
that case.

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

TEST=Added regression test to the CLI package to exercise this path.

Fixed: 43785
Change-Id: Ifb67a5880f6b83c54e6deb6b0785b61fdcfc0ada
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172820
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-11-18 20:01:04 +00:00
Sigurd Meldgaard 5cbb25f753 Revert "Improve handling of disable-dartdev-analytics"
This reverts commit cda994ffc8.

Reason for revert: This stopped all sending of analytics from dartdev.

The added flag in dartdev had an implicit default value of 'false' -> no analytics would be sent.

Also the main_options.cc change was broken and did not pass the argument on to dartdev.

This failed to be caught by tests because all test are run with analytics off, and that happened implicitly.

Original change's description:
> Improve handling of disable-dartdev-analytics
>
> Some other refactorings are piggy-backed along.
>
> TestProject.runSync no longer takes a 'command' argument. It was anyway
> often not an argument.
>
> Also stop the messy handling of pub arguments. It is no longer needed.
>
> BUG: https://github.com/dart-lang/sdk/issues/44135
> TEST=The VM change is tested via all the pkg/dartdev/test/command/* tests that invoke dart with the --no-analytics flag.
>
> Change-Id: Ib5a1a29841a5fdb28663b7f60c5d6fc31ba252d0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171284
> Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Jonas Jensen <jonasfj@google.com>

TBR=kustermann@google.com,bkonyi@google.com,sigurdm@google.com,jonasfj@google.com

Change-Id: I92ef65b16cdb75fb2475faf9f522fda62e181bab
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171941
Reviewed-by: Sigurd Meldgaard <sigurdm@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
2020-11-13 14:30:46 +00:00
Sigurd Meldgaard cda994ffc8 Improve handling of disable-dartdev-analytics
Some other refactorings are piggy-backed along.

TestProject.runSync no longer takes a 'command' argument. It was anyway
often not an argument.

Also stop the messy handling of pub arguments. It is no longer needed.

BUG: https://github.com/dart-lang/sdk/issues/44135
TEST=The VM change is tested via all the pkg/dartdev/test/command/* tests that invoke dart with the --no-analytics flag.

Change-Id: Ib5a1a29841a5fdb28663b7f60c5d6fc31ba252d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171284
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
2020-11-13 08:40:06 +00:00
Ben Konyi 267db1871c [ VM ] Fix memory leak in main_options.cc
Caused by changes in ffc36db613 which
removed memory cleanup.

TEST=Existing tests surface the problem with ASAN enabled.

Change-Id: I4880a459e5421c754574778ad097984f2e47d885
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170440
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-11-04 22:33:27 +00:00
Ben Konyi ffc36db613 [ CLI / VM ] Add --enable-experiment support for 'dart compile', change
where --enable experiment is accepted

Adds --enable-experiment support for:
  - dart compile aot-snapshot
  - dart compile jit-snapshot
  - dart compile js
  - dart compile exe
  - dart compile kernel

Also changes --enable-experiment from a top level CLI flag to a
per-command flag. --enable-experiment flags will now only be
interpreted by the VM if:

1) They are provided before a CLI command (e.g., dart
--enable-experiment=non-nullable analyze) or

2) They are provided with an explicit or implicit run command (e.g.,
dart --enable-experiment=non-nullable foo.dart or dart
--enable-experiment=non-nullable run foo.dart or dart run
--enable-experiment=non-nullable foo.dart)

This should make it more generally clear where --enable-experiment is
accepted and what subcommands can accept the flag. Prior to this change,
providing --enable-experiment anywhere, even for commands without
experiment support, would not raise an error.

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

Change-Id: I5ec48b2dd2bb6db5526185dae2edbca95ef24d9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169902
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
2020-11-04 00:34:26 +00:00
Ben Konyi 7f723f4166 [ VM / CLI ] Fix issue where VM flags would be parsed from the option
list for a script.

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

Change-Id: I6f0860e0a43055aaab775a28baa660d60fb1c47e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169782
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-10-30 23:25:22 +00:00
Alexander Aprelev 340f78eab3 [vm/io] Add a test for nonblocking ssl certification evaluation.
This is follow-up to a6dafabb88.

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

Change-Id: I4da732ab08235a1f549d45c7fa5fb87db672e2aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166701
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-10-12 15:06:52 +00:00
Ryan Macnak 30897929fc [vm] Fix warnings in GCC 9.3.0 and XCode 12.0.
Bug: https://github.com/flutter/flutter/issues/66203
Change-Id: Ifff0c211e2ecdcb56d62c273a471fc05bbae9c37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161602
Reviewed-by: Chinmay Garde <chinmaygarde@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-09-21 22:02:32 +00:00
Ben Konyi fe85812e27 [ VM / DartDev ] Fix --disable-service-auth-codes not being recognized by DDS
The VM and dartdev were not forwarding --disable-service-auth-codes to
the DDS instance, resulting in auth codes always being enabled.

Change-Id: Ib23bfeb7c64a51fb1229f049a4b61cb1ce5018de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163261
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-09-18 17:23:31 +00:00
Ben Konyi f0d88cc96d Reland "[ Service / DDS ] Advertise DDS as the VM service, bump version to 4.0"
This reverts commit ed120c3c80.

Change-Id: I445f4bb2dafaad3ce2daa3ae42efe1723f9b1abe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160660
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-09-03 15:20:14 +00:00
Ben Konyi ed120c3c80 Revert "[ Service / DDS ] Advertise DDS as the VM service, bump version to 4.0"
This reverts commit 0ea18ffb36.

Reason for revert: Tree is on fire

Original change's description:
> [ Service / DDS ] Advertise DDS as the VM service, bump version to 4.0
> 
> This change does the following:
>   - The DDS URI will be reported by the VM as the VM service URI. If DDS
>     disconnects, the VM service URI will be reported instead. This only
>     impacts the standalone VM.
>   - Updated the service protocol to 4.0 and removed the following
>     deprecated functionality:
>       - Client synchronization RPCs (these now live in DDS)
>       - getWebSocketTarget (no longer needed as the VM service no longer
>         tries to redirect web socket clients to DDS)
>   - Regenerates package:vm_service based on the new spec, prepare for
>     5.0 release
> 
> Change-Id: I8a2b401062342eb99b81ef10ef6926baa88f946e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160141
> Reviewed-by: Siva Annamalai <asiva@google.com>

TBR=bkonyi@google.com,rmacnak@google.com,asiva@google.com

Change-Id: I6a16e9fa7ceb18555d6424a169cfa811d3833419
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160340
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-08-26 16:08:27 +00:00
Ben Konyi 0ea18ffb36 [ Service / DDS ] Advertise DDS as the VM service, bump version to 4.0
This change does the following:
  - The DDS URI will be reported by the VM as the VM service URI. If DDS
    disconnects, the VM service URI will be reported instead. This only
    impacts the standalone VM.
  - Updated the service protocol to 4.0 and removed the following
    deprecated functionality:
      - Client synchronization RPCs (these now live in DDS)
      - getWebSocketTarget (no longer needed as the VM service no longer
        tries to redirect web socket clients to DDS)
  - Regenerates package:vm_service based on the new spec, prepare for
    5.0 release

Change-Id: I8a2b401062342eb99b81ef10ef6926baa88f946e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160141
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-08-26 14:55:15 +00:00
Liam Appelbe 79cec0e864 [vm] Delete ABI infrastructure
Change-Id: I26d455d96c87010293a6dcb9f6c0eecfcaf3c816
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157102
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2020-08-06 19:55:12 +00:00
Ben Konyi 501c807266 [ VM / DartDev ] Update argument handling for 'run' command
Previously the help messages for 'dart run' were output by a secondary
VM spawned solely to print the VM's help message. However, this help
message was not consistent with those found for other DartDev commands.

With this change, the 'run' command:

- Uses package:args to create a help message consistent with other
 DartDev commands.

- No longer accepts arbitrary options and is instead restricted to a
 subset of common flags. Passing a VM flag which is not included in
 this subset of commands will result in an argument error if passed
 *after* the 'run' command. Other VM flags can be passed immediately
 following 'dart' and before the DartDev command.

- No longer outputs the VM verbose options when invoked with '--help
 --verbose'. VM verbose options and the original VM help message can
 be viewed by running 'dart --help --verbose'. This makes uncommon
 VM flags used for development less visible to regular users.

- Now properly forwards the subset of VM options accepted by 'run' to
 the VM (e.g., 'dart run --observe --no-pause-isolates-on-exit foo.dart'
 would have ignored '--no-pause-isolates-on-exit').

Change-Id: Ie56b767cc21e6af3630c742458a6c3e9f7418250
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155841
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-07-31 21:41:10 +00:00
Ben Konyi 157ebfe50f Reland "[ VM / DartDev ] Launch DartDev in an isolate within a single main Dart process"
This reverts commit 7e373831ce.

Change-Id: Ib94d793a5753ec6352cd9a65e35f726a63336368
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154830
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-07-21 16:23:18 +00:00
Ben Konyi 95d55e2bbb Revert "[ VM / DartDev ] Disable DartDev by default, allow for enabling via --enable-dart-dev"
This reverts commit f6a82443e4.

Change-Id: Icd2050126f6e7442ac3e99219548c93196933861
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154829
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-07-20 18:17:28 +00:00
Ben Konyi f6a82443e4 [ VM / DartDev ] Disable DartDev by default, allow for enabling via
--enable-dart-dev

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

Change-Id: I107ff86a65c20317d8813769bdf78b92bb6cb145
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154822
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-07-17 20:21:59 +00:00
Alexander Aprelev 7e373831ce Revert "Reland "[ VM / DartDev ] Launch DartDev in an isolate within a single main Dart process""
This reverts commit bc4cb123a8.

Reason for revert: breaks crossword simarm tests https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-precomp-linux-debug-simarm_x64/2619

Original change's description:
> Reland "[ VM / DartDev ] Launch DartDev in an isolate within a single main Dart process"
> 
> This CL changes how DartDev is run and how the run command handles executing a Dart program (will port additional commands in a separate CL). Rather than using DartDev to spawn a child process to run user code, the VM will instead launch a DartDev isolate after doing some VM options processing. DartDev will communicate information like exit codes and script/arg pairs with the VM via isolate ports. Once DartDev runs to completion and notifies the VM that a script should be run, the VM will move on to spawning another isolate with user code and continue executing in the same VM process.
> 
> By moving DartDev into an isolate within the same process that user code will eventually run in we're able to resolve the following issues that arose due to signal handling and IPC issues:
> 
> VM hangs when --enable-vm-service is supplied and there are compile time errors (https://github.com/dart-lang/sdk/issues/42630)
> Dart daemon spinning in exit code handler / zombie Dart processes (https://github.com/dart-lang/sdk/issues/41978)
> Signal handling in children of 'dartdev run' is problematic (https://github.com/dart-lang/sdk/issues/42092)
> 
> This reverts commit 3849b5061c.
> 
> Change-Id: I4fd3ba33840771a9f284d733c4a25fac6cde64ca
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154706
> Reviewed-by: Siva Annamalai <asiva@google.com>

TBR=bkonyi@google.com,asiva@google.com

Change-Id: I649d94c668417f2edbfd7039fa5c876e10dc32fe
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154800
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-07-17 04:37:48 +00:00
Ben Konyi bc4cb123a8 Reland "[ VM / DartDev ] Launch DartDev in an isolate within a single main Dart process"
This CL changes how DartDev is run and how the run command handles executing a Dart program (will port additional commands in a separate CL). Rather than using DartDev to spawn a child process to run user code, the VM will instead launch a DartDev isolate after doing some VM options processing. DartDev will communicate information like exit codes and script/arg pairs with the VM via isolate ports. Once DartDev runs to completion and notifies the VM that a script should be run, the VM will move on to spawning another isolate with user code and continue executing in the same VM process.

By moving DartDev into an isolate within the same process that user code will eventually run in we're able to resolve the following issues that arose due to signal handling and IPC issues:

VM hangs when --enable-vm-service is supplied and there are compile time errors (https://github.com/dart-lang/sdk/issues/42630)
Dart daemon spinning in exit code handler / zombie Dart processes (https://github.com/dart-lang/sdk/issues/41978)
Signal handling in children of 'dartdev run' is problematic (https://github.com/dart-lang/sdk/issues/42092)

This reverts commit 3849b5061c.

Change-Id: I4fd3ba33840771a9f284d733c4a25fac6cde64ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154706
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-07-17 00:54:11 +00:00
Ben Konyi 3849b5061c Revert "[ VM / DartDev ] Launch DartDev in an isolate within a single main Dart process"
This reverts commit ffe258d2d4.

Reason for revert: Failures on bots

Original change's description:
> [ VM / DartDev ] Launch DartDev in an isolate within a single main Dart process
> 
> This CL changes how DartDev is run and how the run command handles executing a Dart program (will port additional commands in a separate CL). Rather than using DartDev to spawn a child process to run user code, the VM will instead launch a DartDev isolate after doing some VM options processing. DartDev will communicate information like exit codes and script/arg pairs with the VM via isolate ports. Once DartDev runs to completion and notifies the VM that a script should be run, the VM will move on to spawning another isolate with user code and continue executing in the same VM process.
> 
> By moving DartDev into an isolate within the same process that user code will eventually run in we're able to resolve the following issues that arose due to signal handling and IPC issues:
> 
> VM hangs when --enable-vm-service is supplied and there are compile time errors (https://github.com/dart-lang/sdk/issues/42630)
> Dart daemon spinning in exit code handler / zombie Dart processes (https://github.com/dart-lang/sdk/issues/41978)
> Signal handling in children of 'dartdev run' is problematic (https://github.com/dart-lang/sdk/issues/41978)
> 
> Change-Id: I1c6b1425831b691ad20284716aa80f817dbaf607
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152588
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

TBR=bkonyi@google.com,rmacnak@google.com,asiva@google.com

Change-Id: Idb1d24a4524bdc3ccfb199a82710f3c0d9db539a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154702
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-07-16 19:50:57 +00:00
Ben Konyi ffe258d2d4 [ VM / DartDev ] Launch DartDev in an isolate within a single main Dart process
This CL changes how DartDev is run and how the run command handles executing a Dart program (will port additional commands in a separate CL). Rather than using DartDev to spawn a child process to run user code, the VM will instead launch a DartDev isolate after doing some VM options processing. DartDev will communicate information like exit codes and script/arg pairs with the VM via isolate ports. Once DartDev runs to completion and notifies the VM that a script should be run, the VM will move on to spawning another isolate with user code and continue executing in the same VM process.

By moving DartDev into an isolate within the same process that user code will eventually run in we're able to resolve the following issues that arose due to signal handling and IPC issues:

VM hangs when --enable-vm-service is supplied and there are compile time errors (https://github.com/dart-lang/sdk/issues/42630)
Dart daemon spinning in exit code handler / zombie Dart processes (https://github.com/dart-lang/sdk/issues/41978)
Signal handling in children of 'dartdev run' is problematic (https://github.com/dart-lang/sdk/issues/41978)

Change-Id: I1c6b1425831b691ad20284716aa80f817dbaf607
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152588
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-07-16 19:03:24 +00:00
Ben Konyi 68612120df [ VM ] Remove options from standard dart --help output that are covered
by DartDev commands

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

Change-Id: I7ca88907c2588e6085f83a613ee41d99cb661c5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153902
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-07-10 17:40:04 +00:00
Ben Konyi e24733ebd1 [ VM ] Change version output message to reference SDK instead of VM
Fixes https://github.com/dart-lang/sdk/issues/42486

Change-Id: I99a2c6e01065098991e2952aa45f42c5e5636189
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152682
Reviewed-by: Jaime Wren <jwren@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-06-26 19:09:45 +00:00
Alexander Aprelev d33e51df3c [build] Support --clang when building dart sdk on Windows.
It relies on flutter copy of clang distribution, same one that is used to build flutter/engine.

It addressed several deprecated warnings from clang compiler for functions like strdup, unlink, etc.

It allows few warnings still since they are triggered in third_party sources.

Change-Id: Ieb13792c011438d46dbbc0fa030e1b5e4ea14315
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142704
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-06-25 03:36:41 +00:00
Martin Kustermann 39577ea564 [vm] Remove (unused & deprecated) --package-root parameter from VM binaries and from tests (Platform.packageRoot always returns null)
Closes https://github.com/dart-lang/sdk/issues/41245

Change-Id: Idd7526199b4c2479297c58b05bc13efcb79d01e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152321
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-06-24 18:17:53 +00:00
Ben Konyi 82de6e0854 [ VM / DartDev ] Forward --enable-experiment=... to DartDev
VM portion of https://github.com/dart-lang/sdk/issues/42339

Change-Id: I97fa7ec0847aa4ed75fc5aaab2d75c1ca514aa66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151890
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Jaime Wren <jwren@google.com>
2020-06-23 17:49:02 +00:00
Ben Konyi bac15a80ce [ VM / DartDev ] Add special flags '--enable-analytics' and '--disable-analytics' which are treated as VM options but always forwarded to DartDev
Change-Id: Ief9d03f49176c9eacbf5fc953be9bc99e53aa21b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149662
Reviewed-by: Jaime Wren <jwren@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-06-01 23:10:18 +00:00
Ben Konyi 499ae5c363 [ VM / DartDev ] Fix issue where --disable-dart-dev and --observe argument order mattered
Prior to this change, if the VM was run with:

`dart --observe=8282 --disable-dart-dev foo.dart`

The custom VM service port would be ignored whereas with:

`dart --disable-dart-dev --observe=8282 foo.dart`

The custom VM service port would be used. This was due to
the value of `--disable-dart-dev` being used during argument parsing
even though the value may not have been parsed yet.

Change-Id: I221fb4c0ad6fdc0ae1855bd60b58c115de00e34b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148153
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-05-14 19:56:35 +00:00
Ben Konyi 2063ce7437 [ package:dds ] Added authentication code support
Also fixed issue where not all VM flags were being forwarded to the child
of an implicit DartDev instance.

Change-Id: I4c7bacb1b93ae336b6ed1f80eb621fbeabd8ced9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148021
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-05-14 01:32:26 +00:00
Ben Konyi 444490d640 Reland "[ VM / DartDev ] Run all debugging sessions via 'dart run'"
This is a reland of 604a366065

Original change's description:
> [ VM / DartDev ] Run all debugging sessions via 'dart run'
> 
> Prior to this change, running `dart --observe foo.dart` would result in
> the DartDev flow being bypassed. While `dart foo.dart` will continue to
> bypass DartDev and be run directly, running either `dart --observe
> <vm-flags> foo.dart` or `dart --enable-vm-service <vm-flags> foo.dart`
> will result in the command being implicitly converted to `dart run
> --observe <vm-flags> foo.dart`. This is required for all standalone VM
> instances to run against DDS instead of the VM service directly.
> 
> As usual, the DartDev flow can always be bypassed by providing the
> --disable-dart-dev flag.
> 
> Change-Id: I211cd1ec4b1ec0e75ae0a568a66f1a0fc7b3852f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147342
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>

Change-Id: I917d3056322d74766bdf376a3e28871ad5b66cfa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147980
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-05-13 19:58:56 +00:00
David Morgan 964f966c0c Revert "[ VM / DartDev ] Run all debugging sessions via 'dart run'"
This reverts commit 604a366065.

Reason for revert: Breaks google3, see b/156414355

Original change's description:
> [ VM / DartDev ] Run all debugging sessions via 'dart run'
> 
> Prior to this change, running `dart --observe foo.dart` would result in
> the DartDev flow being bypassed. While `dart foo.dart` will continue to
> bypass DartDev and be run directly, running either `dart --observe
> <vm-flags> foo.dart` or `dart --enable-vm-service <vm-flags> foo.dart`
> will result in the command being implicitly converted to `dart run
> --observe <vm-flags> foo.dart`. This is required for all standalone VM
> instances to run against DDS instead of the VM service directly.
> 
> As usual, the DartDev flow can always be bypassed by providing the
> --disable-dart-dev flag.
> 
> Change-Id: I211cd1ec4b1ec0e75ae0a568a66f1a0fc7b3852f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147342
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>

TBR=bkonyi@google.com,rmacnak@google.com,asiva@google.com

Change-Id: I688a3779e7ccaf85a28dc4d6f5ccf23596109519
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147900
Reviewed-by: David Morgan <davidmorgan@google.com>
Commit-Queue: David Morgan <davidmorgan@google.com>
2020-05-13 07:13:35 +00:00
Ben Konyi 604a366065 [ VM / DartDev ] Run all debugging sessions via 'dart run'
Prior to this change, running `dart --observe foo.dart` would result in
the DartDev flow being bypassed. While `dart foo.dart` will continue to
bypass DartDev and be run directly, running either `dart --observe
<vm-flags> foo.dart` or `dart --enable-vm-service <vm-flags> foo.dart`
will result in the command being implicitly converted to `dart run
--observe <vm-flags> foo.dart`. This is required for all standalone VM
instances to run against DDS instead of the VM service directly.

As usual, the DartDev flow can always be bypassed by providing the
--disable-dart-dev flag.

Change-Id: I211cd1ec4b1ec0e75ae0a568a66f1a0fc7b3852f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147342
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-05-12 19:53:11 +00:00
Ben Konyi 5ccbe533ab [ VM / dartdev ] Ignore VM flags in dartdev VM instance
In order to reduce confusion, if a VM instance detects that it will be
running a dartdev snapshot it will ignore all VM flags and print a
warning message to stderr informing users that the flags are being
ignored and that they should be passed immediately after the 'dart run'
command. This will prevent the dartdev snapshot from being run with
incompatible flags in addition to preventing users from accidentally
setting flags for the dartdev VM when they meant to set those flags for
the target process.

As usual, passing --disable-dart-dev will allow for the user to bypass
this behavior and run their dart program directly.

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

Change-Id: I7d5dc3d4ddae8be99994620b5b2c2e4cc492ae5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146984
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-05-08 19:22:56 +00:00
Ben Konyi c800b26816 [ VM / DartDev ] Make DartDev help message the default when running dart --help
Running the standalone VM in the following ways will result in the
DartDev help message being shown:

- `dart`
- `dart --help`

The following will output the VM help message:

- `dart run`
- `dart help run`
- `dart --help --verbose` (includes verbose VM flags)
- `dart help run --verbose` (includes verbose VM flags)
- `dart run --verbose` (includes verbose VM flags)

The original standalone VM behavior can be restored by providing the --disable_dart_dev flag.

Change-Id: I67cf015d62366efdfd8bf9b215d4319fd5af3f46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144497
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Jaime Wren <jwren@google.com>
2020-04-27 22:39:06 +00:00
Ben Konyi 20eaa47ac2 [ VM ] Updated help message for --write-service-info to --write-service-info=file_uri to reduce ambiguity with Windows' paths
Fixes https://github.com/dart-lang/sdk/issues/41109

Change-Id: I26f5c6ba262ca2e0cb8c63fa4b892f014825177f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143308
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-04-13 20:39:58 +00:00
Ben Konyi 31fdba6cec [ VM ] Fix issue where DartDev snapshot would not be found when Dart is installed with Brew
Brew uses symlinks to symlinks, and code to determine the directory of
the current Dart executable was assuming that only one level of
symlinking could occur. This change results in symlink evaluation being
performed until we find the absolute path of the executable.

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

Change-Id: Id7326f09e01383150a41754e71174400cc6ec6b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139781
Reviewed-by: Jaime Wren <jwren@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-03-17 20:16:25 +00:00
Ben Konyi a212b75ba7 Reland "[ VM / DartDev ] Load and run dartdev snapshot if first argument to dart is not a valid file path"
Should fix issues with Windows path resolution and a potential invalid free.

This reverts commit 6053084920.

Change-Id: I683abdbf2c10644e6cadd9643ea880cee9338f72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138014
Reviewed-by: Jaime Wren <jwren@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-03-02 22:55:46 +00:00
Ben Konyi 6053084920 Revert "[ VM / DartDev ] Load and run dartdev snapshot if first argument to dart is not a valid file path"
This reverts commit 9ca77d42be.

Reason for revert: Windows bots going red.

Original change's description:
> [ VM / DartDev ] Load and run dartdev snapshot if first argument to dart is not a valid file path
> 
> Change-Id: I754ff3cd44af95364ce8095255a67621f256dbd3
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137249
> Reviewed-by: Jaime Wren <jwren@google.com>
> Commit-Queue: Ben Konyi <bkonyi@google.com>

TBR=jwren@google.com,bkonyi@google.com,asiva@google.com

Change-Id: Iff3a9e5457b95bfafea16915ae1311e978f5fc1a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137824
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-02-28 22:00:45 +00:00
Ben Konyi 9ca77d42be [ VM / DartDev ] Load and run dartdev snapshot if first argument to dart is not a valid file path
Change-Id: I754ff3cd44af95364ce8095255a67621f256dbd3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137249
Reviewed-by: Jaime Wren <jwren@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-02-28 20:40:10 +00:00
Ben Konyi 6548694a82 Reland "[ VM / DartDev ] Added support for format and pub commands via standalone VM"
Fixes a malloc/delete[] mismatch.

This reverts commit b3396cbdca.

Change-Id: I18fe142bc60bedd8af4c588ba4039742e1d34606
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134570
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-02-06 00:04:09 +00:00
Ben Konyi b3396cbdca Revert "[ VM / DartDev ] Added support for format and pub commands via standalone VM"
This reverts commit 1b959d6127.

Reason for revert: ASAN failures

Original change's description:
> [ VM / DartDev ] Added support for `format` and `pub` commands via standalone VM
> 
> Initial work to allow for Dart snapshots to be executed based on a verb
> provided to the VM. Examples:
> 
> - `dart format` === `dartfmt`
> - `dart pub run test` === `pub run test`
> 
> Change-Id: I22c9c2ab6790b485395f1148419c517641f693ac
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133663
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>

TBR=bkonyi@google.com,asiva@google.com

Change-Id: I35d9ff260e5f35f4e36b1e22ecf8b9dc1d2e3ed2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134564
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-02-05 20:56:19 +00:00
Ben Konyi 1b959d6127 [ VM / DartDev ] Added support for format and pub commands via standalone VM
Initial work to allow for Dart snapshots to be executed based on a verb
provided to the VM. Examples:

- `dart format` === `dartfmt`
- `dart pub run test` === `pub run test`

Change-Id: I22c9c2ab6790b485395f1148419c517641f693ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133663
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-02-05 19:37:14 +00:00
jonahwilliams 96ff3276f4 [vmservice] allow fallback on port bind failure
Work towards https://github.com/flutter/flutter/issues/46724

Background:

on the latest versions of iOS today, we have to use mdns to discover the observatory port and authentication code. For a variety of reasons this can fail, leaving us with no way to connect.

An alternative approach is to specify the observatory port and disable the authentication code. If binding to this port fails, however, we would still like to attempt connecting with mdns.

Overview:

This adds a new flag to the dart SDK, --enable-service-port-fallback. This amends the behavior of the vmservice with a specified port. After failing to bind 3 times to a non-zero port, update the port selection to 0.

Results:

Tested locally two dart VMs with the same specified port:

```
jonahwilliams@jonahwilliams0:~/Documents/engine/src/out/host_debug_unopt$ ./dart --enable-service-port-fallback --observe=8080 example.dart
Observatory server failed to start after 1 tries
Falling back to automatic port selection

vm-service: isolate(2785434094928835)  'main' has no debugger attached and is paused at exit.  Connect to Observatory to debug.
Observatory listening on http://127.0.0.1:45663/62A5IHjmv9E=/
```
Change-Id: I582ab402a457330928e5b490f9718fcd52b56720
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133434
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Jonah Williams <jonahwilliams@google.com>
2020-01-28 23:36:14 +00:00
Jonah Williams cdeb9a7a8c Revert "[vmservice] allow fallback on port bind failure"
This reverts commit 6ff7e9ebad.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> [vmservice] allow fallback on port bind failure
> 
> Work towards https://github.com/flutter/flutter/issues/46724
> 
> Background:
> 
> on the latest versions of iOS today, we have to use mdns to discover the observatory port and authentication code. For a variety of reasons this can fail, leaving us with no way to connect.
> 
> An alternative approach is to specify the observatory port and disable the authentication code. If binding to this port fails, however, we would still like to attempt connecting with mdns.
> 
> Overview:
> 
> This adds a new flag to the dart SDK, --enable-service-port-fallback. This amends the behavior of the vmservice with a specified port. After failing to bind once to a non-zero port, update the port selection to 0.
> 
> Results:
> 
> Tested locally two dart VMs with the same specified port:
> 
> ```
> jonahwilliams@jonahwilliams0:~/Documents/engine/src/out/host_debug_unopt$ ./dart --enable-service-port-fallback --observe=8080 example.dart
> Observatory server failed to start after 1 tries
> Falling back to automatic port selection
> vm-service: isolate(2785434094928835)  'main' has no debugger attached and is paused at exit.  Connect to Observatory to debug.
> Observatory listening on http://127.0.0.1:45663/62A5IHjmv9E=/
> ```
> 
> Change-Id: I371583edcb603325428f1cb760992e39b9f3b6dc
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130441
> Commit-Queue: Jonah Williams <jonahwilliams@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>

TBR=bkonyi@google.com,jonahwilliams@google.com

Change-Id: I337b2d549e33ef9c616c276a48ce894a14b1c317
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133327
Reviewed-by: Jonah Williams <jonahwilliams@google.com>
Commit-Queue: Jonah Williams <jonahwilliams@google.com>
2020-01-24 21:47:34 +00:00
jonahwilliams 6ff7e9ebad [vmservice] allow fallback on port bind failure
Work towards https://github.com/flutter/flutter/issues/46724

Background:

on the latest versions of iOS today, we have to use mdns to discover the observatory port and authentication code. For a variety of reasons this can fail, leaving us with no way to connect.

An alternative approach is to specify the observatory port and disable the authentication code. If binding to this port fails, however, we would still like to attempt connecting with mdns.

Overview:

This adds a new flag to the dart SDK, --enable-service-port-fallback. This amends the behavior of the vmservice with a specified port. After failing to bind once to a non-zero port, update the port selection to 0.

Results:

Tested locally two dart VMs with the same specified port:

```
jonahwilliams@jonahwilliams0:~/Documents/engine/src/out/host_debug_unopt$ ./dart --enable-service-port-fallback --observe=8080 example.dart
Observatory server failed to start after 1 tries
Falling back to automatic port selection
vm-service: isolate(2785434094928835)  'main' has no debugger attached and is paused at exit.  Connect to Observatory to debug.
Observatory listening on http://127.0.0.1:45663/62A5IHjmv9E=/
```

Change-Id: I371583edcb603325428f1cb760992e39b9f3b6dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130441
Commit-Queue: Jonah Williams <jonahwilliams@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-01-24 20:28:15 +00:00
Samir Jindel a846098c18 [vm] Enable ELF loader to read snapshots from memory without any backing file.
Also build Dart_LoadELF_Fd on Linux as well to get minimal coverage for Fuchsia.

Change-Id: I4be3eeae3e4559e95413fd60a26b9e6d2edabb32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127644
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-10 12:26:05 +00:00