diff --git a/pkg/analysis_server/benchmark/perf/memory_tests.dart b/pkg/analysis_server/benchmark/perf/memory_tests.dart index 5f242cd79c6..7d30cec6466 100644 --- a/pkg/analysis_server/benchmark/perf/memory_tests.dart +++ b/pkg/analysis_server/benchmark/perf/memory_tests.dart @@ -98,16 +98,11 @@ class ServiceProtocol { socket.listen(_handleMessage); } - Future call(String method, [Map args = const {}]) { + Future call(String method, [Map args]) { var id = '${++_id}'; var completer = Completer(); _completers[id] = completer; - var m = { - 'jsonrpc': '2.0', - 'id': id, - 'method': method, - 'args': args - }; + var m = {'id': id, 'method': method}; if (args != null) m['params'] = args; var message = jsonEncode(m); socket.add(message); diff --git a/pkg/analysis_server/test/integration/support/integration_tests.dart b/pkg/analysis_server/test/integration/support/integration_tests.dart index e51eacebc92..eeb9a1c88cb 100644 --- a/pkg/analysis_server/test/integration/support/integration_tests.dart +++ b/pkg/analysis_server/test/integration/support/integration_tests.dart @@ -587,9 +587,7 @@ class Server { serverPath = normalize(join(rootDir, 'bin', 'server.dart')); } - var arguments = [ - '--disable-dart-dev', - ]; + var arguments = []; // // Add VM arguments. // diff --git a/pkg/dartdev/lib/src/commands/run.dart b/pkg/dartdev/lib/src/commands/run.dart index 4a558f5a4d7..1abc46af331 100644 --- a/pkg/dartdev/lib/src/commands/run.dart +++ b/pkg/dartdev/lib/src/commands/run.dart @@ -60,7 +60,7 @@ Run a Dart file.'''); // synchronization). if (args.any((element) => (element.startsWith('--observe') || element.startsWith('--enable-vm-service')))) { - return await _DebuggingSession(this, args).start(); + return await _DebuggingSession(args).start(); } // Starting in ProcessStartMode.inheritStdio mode means the child process @@ -73,8 +73,7 @@ Run a Dart file.'''); } class _DebuggingSession { - _DebuggingSession(this._runCommand, List args) - : _args = args.toList() { + _DebuggingSession(List args) : _args = args.toList() { // Process flags that are meant to configure the VM service HTTP server or // dump VM service connection information to a file. Since the VM service // clients won't actually be connecting directly to the service, we'll make @@ -85,32 +84,23 @@ class _DebuggingSession { if (isObserve) { _observe = true; } - if (arg.contains('=') || arg.contains(':')) { - // These flags can be provided by the embedder so we need to check for - // both `=` and `:` separators. - final observatoryBindInfo = - (arg.contains('=') ? arg.split('=') : arg.split(':'))[1] - .split('/'); - _port = int.tryParse(observatoryBindInfo.first) ?? 0; - if (observatoryBindInfo.length > 1) { - try { - _bindAddress = Uri.http(observatoryBindInfo[1], ''); - } on FormatException { - // TODO(bkonyi): log invalid parse? The VM service just ignores bad - // input flags. - // Ignore. - } + // These flags can be provided by the embedder so we need to check for + // both `=` and `:` separators. + final observatoryBindInfo = + (arg.contains('=') ? arg.split('=') : arg.split(':'))[1].split('/'); + _port = int.tryParse(observatoryBindInfo.first) ?? 0; + if (observatoryBindInfo.length > 1) { + try { + _bindAddress = Uri.http(observatoryBindInfo[1], ''); + } on FormatException { + // TODO(bkonyi): log invalid parse? The VM service just ignores bad + // input flags. + // Ignore. } } } else if (arg.startsWith('--write-service-info=')) { try { - final split = arg.split('='); - if (split[1].isNotEmpty) { - _serviceInfoUri = Uri.parse(split[1]); - } else { - _runCommand.usageException( - 'Invalid URI argument to --write-service-info: "${split[1]}"'); - } + _serviceInfoUri = Uri.parse(arg.split('=')[1]); } on FormatException { // TODO(bkonyi): log invalid parse? The VM service just ignores bad // input flags. @@ -139,7 +129,7 @@ class _DebuggingSession { // Start using ProcessStartMode.normal and forward stdio manually as we // need to filter the true VM service URI and replace it with the DDS URI. _process = await Process.start( - sdk.dart, + 'dart', [ '--disable-dart-dev', _observe @@ -162,7 +152,7 @@ class _DebuggingSession { // Shutdown DDS if it was started and wait for the process' stdio streams // to close so we don't truncate program output. await Future.wait([ - if (_dds != null) _dds.shutdown(), + _dds?.shutdown(), _stderrDone, _stdoutDone, ]); @@ -204,8 +194,8 @@ class _DebuggingSession { if (_dds == null) { return msg; } - if (msg.contains('Observatory listening on') || - msg.contains('Connect to Observatory at')) { + if (msg.startsWith('Observatory listening on') || + msg.startsWith('Connect to Observatory at')) { // Search for the VM service URI in the message and replace it. msg = msg.replaceFirst( RegExp(r'https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.' @@ -254,7 +244,7 @@ class _DebuggingSession { Uri _bindAddress = Uri.http('127.0.0.1', ''); DartDevelopmentService _dds; bool _observe = false; - int _port = 0; + int _port; Process _process; Uri _serviceInfoUri; Future _stderrDone; @@ -262,5 +252,4 @@ class _DebuggingSession { final List _args; final Completer _ddsCompleter = Completer(); - final RunCommand _runCommand; } diff --git a/pkg/dds/lib/src/dds_impl.dart b/pkg/dds/lib/src/dds_impl.dart index a0ef676f949..5b6815141c1 100644 --- a/pkg/dds/lib/src/dds_impl.dart +++ b/pkg/dds/lib/src/dds_impl.dart @@ -65,7 +65,7 @@ class _DartDevelopmentService implements DartDevelopmentService { } _shuttingDown = true; // Don't accept anymore HTTP requests. - await _server?.close(); + await _server.close(); // Close connections to clients. await clientManager.shutdown(); diff --git a/pkg/dds/test/smoke_test.dart b/pkg/dds/test/smoke_test.dart index 297d8bbfc57..39468b0fd51 100644 --- a/pkg/dds/test/smoke_test.dart +++ b/pkg/dds/test/smoke_test.dart @@ -18,7 +18,6 @@ Future spawnDartProcess(String script) async { final serviceInfoFile = await File.fromUri(serviceInfoUri).create(); final arguments = [ - '--disable-dart-dev', '--observe=0', '--pause-isolates-on-start', '--write-service-info=$serviceInfoUri', diff --git a/pkg/vm/test/incremental_compiler_test.dart b/pkg/vm/test/incremental_compiler_test.dart index 65cec8a22d1..9ab518294c4 100644 --- a/pkg/vm/test/incremental_compiler_test.dart +++ b/pkg/vm/test/incremental_compiler_test.dart @@ -454,7 +454,7 @@ main() { const kObservatoryListening = 'Observatory listening on '; final RegExp observatoryPortRegExp = - new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)"); + new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)/"); int port; final splitter = new LineSplitter(); Completer portLineCompleter = new Completer(); @@ -580,7 +580,7 @@ main() { const kObservatoryListening = 'Observatory listening on '; final RegExp observatoryPortRegExp = - new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)"); + new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)/"); int port; final splitter = new LineSplitter(); Completer portLineCompleter = new Completer(); @@ -679,7 +679,7 @@ main() { String portLine = await portLineCompleter.future; final RegExp observatoryPortRegExp = - new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)"); + new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)/"); expect(observatoryPortRegExp.hasMatch(portLine), isTrue); final match = observatoryPortRegExp.firstMatch(portLine); final port = int.parse(match.group(1)); @@ -820,7 +820,7 @@ main() { const kObservatoryListening = 'Observatory listening on '; final RegExp observatoryPortRegExp = - new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)"); + new RegExp("Observatory listening on http://127.0.0.1:\([0-9]*\)/"); int port; final splitter = new LineSplitter(); Completer portLineCompleter = new Completer(); @@ -1297,7 +1297,7 @@ class RemoteVm { /// Retrieves the ID of the main isolate using the service protocol. Future _computeMainId() async { - var vm = await rpc.sendRequest('getVM', {}); + var vm = await rpc.sendRequest('getVM'); var isolates = vm['isolates']; for (var isolate in isolates) { if (isolate['name'].contains(r'$main')) { diff --git a/pkg/vm_service/test/common/test_helper.dart b/pkg/vm_service/test/common/test_helper.dart index dd1e71c52ad..28516727b53 100644 --- a/pkg/vm_service/test/common/test_helper.dart +++ b/pkg/vm_service/test/common/test_helper.dart @@ -141,9 +141,7 @@ class _ServiceTesteeLauncher { List extraArgs) { String dartExecutable = Platform.executable; - var fullArgs = [ - '--disable-dart-dev', - ]; + var fullArgs = []; if (pause_on_start) { fullArgs.add('--pause-isolates-on-start'); } diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc index 8742d98c401..06b91091176 100644 --- a/runtime/bin/main.cc +++ b/runtime/bin/main.cc @@ -999,7 +999,7 @@ void main(int argc, char** argv) { char* script_name; const int EXTRA_VM_ARGUMENTS = 10; CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS); - CommandLineOptions dart_options(argc + EXTRA_VM_ARGUMENTS); + CommandLineOptions dart_options(argc); bool print_flags_seen = false; bool verbose_debug_seen = false; diff --git a/runtime/bin/main_options.cc b/runtime/bin/main_options.cc index 7251b82475b..7dd360dca37 100644 --- a/runtime/bin/main_options.cc +++ b/runtime/bin/main_options.cc @@ -35,7 +35,6 @@ static const char* kSnapshotKindNames[] = { }; SnapshotKind Options::gen_snapshot_kind_ = kNone; -bool Options::enable_vm_service_ = false; #define OPTION_FIELD(variable) Options::variable##_ @@ -309,8 +308,7 @@ bool Options::ProcessEnableVmServiceOption(const char* arg, if (value == NULL) { return false; } - if (Options::disable_dart_dev() && - !ExtractPortAndAddress( + if (!ExtractPortAndAddress( value, &vm_service_server_port_, &vm_service_server_ip_, DEFAULT_VM_SERVICE_SERVER_PORT, DEFAULT_VM_SERVICE_SERVER_IP)) { Syslog::PrintErr( @@ -321,7 +319,7 @@ bool Options::ProcessEnableVmServiceOption(const char* arg, #if !defined(DART_PRECOMPILED_RUNTIME) dfe()->set_use_incremental_compiler(true); #endif // !defined(DART_PRECOMPILED_RUNTIME) - enable_vm_service_ = true; + return true; } @@ -331,8 +329,7 @@ bool Options::ProcessObserveOption(const char* arg, if (value == NULL) { return false; } - if (Options::disable_dart_dev() && - !ExtractPortAndAddress( + if (!ExtractPortAndAddress( value, &vm_service_server_port_, &vm_service_server_ip_, DEFAULT_VM_SERVICE_SERVER_PORT, DEFAULT_VM_SERVICE_SERVER_IP)) { Syslog::PrintErr( @@ -349,7 +346,6 @@ bool Options::ProcessObserveOption(const char* arg, #if !defined(DART_PRECOMPILED_RUNTIME) dfe()->set_use_incremental_compiler(true); #endif // !defined(DART_PRECOMPILED_RUNTIME) - enable_vm_service_ = true; return true; } @@ -380,10 +376,6 @@ bool Options::ProcessAbiVersionOption(const char* arg, return true; } -static bool IsOption(const char* actual, const char* expected) { - return (OptionProcessor::ProcessOption(actual, expected) != nullptr); -} - int Options::ParseArguments(int argc, char** argv, bool vm_run_app_snapshot, @@ -405,7 +397,7 @@ int Options::ParseArguments(int argc, // Parse out the vm options. while (i < argc) { - if (OptionProcessor::TryProcess(argv[i], &temp_vm_options)) { + if (OptionProcessor::TryProcess(argv[i], vm_options)) { i++; } else { // Check if this flag is a potentially valid VM flag. @@ -450,21 +442,18 @@ int Options::ParseArguments(int argc, // The arguments to the VM are at positions 1 through i-1 in argv. Platform::SetExecutableArguments(i, argv); - bool implicitly_use_dart_dev = false; - bool run_script = false; + bool is_script = false; int script_or_cmd_index = -1; // Get the script name. if (i < argc) { - // If the script name is a valid file or a URL, we'll run the script - // directly. Otherwise, this might be a DartDev command and we need to try - // to find the DartDev snapshot so we can forward the command and its - // arguments. - bool is_potential_file_path = !DartDevUtils::ShouldParseCommand(argv[i]); + // If the script name is a valid file or a URL, we'll run the script directly. + // Otherwise, this might be a DartDev command and we need to try to + // find the DartDev snapshot so we can forward the command and its arguments. script_or_cmd_index = i; if (Options::disable_dart_dev() || - (is_potential_file_path && !enable_vm_service_)) { + !DartDevUtils::ShouldParseCommand(argv[i])) { *script_name = strdup(argv[i]); - run_script = true; + is_script = true; i++; } else if (!DartDevUtils::TryResolveDartDevSnapshotPath(script_name)) { Syslog::PrintErr( @@ -472,22 +461,6 @@ int Options::ParseArguments(int argc, argv[i]); Platform::Exit(kErrorExitCode); } - // Handle the special case where the user is running a Dart program without - // using a DartDev command and wants to use the VM service. Here we'll run - // the program using DartDev as it's used to spawn a DDS instance - if (!Options::disable_dart_dev() && is_potential_file_path && - enable_vm_service_) { - implicitly_use_dart_dev = true; - dart_options->AddArgument("run"); - for (int j = 1; j < i; ++j) { - if (IsOption(argv[j], "--observe")) { - dart_options->AddArgument(argv[j]); - } - if (IsOption(argv[j], "--enable-vm-service")) { - dart_options->AddArgument(argv[j]); - } - } - } } else if (!Options::disable_dart_dev() && ((Options::help_option() && !Options::verbose_option()) || (argc == 1)) && @@ -499,18 +472,11 @@ int Options::ParseArguments(int argc, return -1; } - const char** vm_argv = temp_vm_options.arguments(); - int vm_argc = temp_vm_options.count(); - - if (Options::disable_dart_dev() || run_script) { - // Only populate the VM options if we're not running with DartDev. + if (Options::disable_dart_dev() || is_script) { + // Only populate the VM options if we're not running with dartdev. + const char** vm_argv = temp_vm_options.arguments(); + int vm_argc = temp_vm_options.count(); vm_options->AddArguments(vm_argv, vm_argc); - } else if (implicitly_use_dart_dev) { - // If we're using DartDev implicitly (e.g., dart --observe foo.dart), we - // want to forward all the VM arguments to the spawned process to ensure - // the program behaves as the user expects even though we're running - // through DartDev without their knowledge. - dart_options->AddArguments(vm_argv, vm_argc); } else if (i > 1) { // If we're running with DartDev, we're going to ignore the VM options for // this VM instance and print a warning. diff --git a/runtime/bin/main_options.h b/runtime/bin/main_options.h index 92478632838..649334924d4 100644 --- a/runtime/bin/main_options.h +++ b/runtime/bin/main_options.h @@ -168,7 +168,6 @@ class Options { // VM Service argument processing. static const char* vm_service_server_ip_; - static bool enable_vm_service_; static int vm_service_server_port_; static bool ExtractPortAndAddress(const char* option_value, int* out_port, diff --git a/runtime/observatory/tests/service/test_helper.dart b/runtime/observatory/tests/service/test_helper.dart index 4c78a05ba56..bbb68b4faab 100644 --- a/runtime/observatory/tests/service/test_helper.dart +++ b/runtime/observatory/tests/service/test_helper.dart @@ -159,9 +159,7 @@ class _ServiceTesteeLauncher { final String dartExecutable = Platform.executable; - final fullArgs = [ - '--disable-dart-dev', - ]; + final fullArgs = []; if (pause_on_start) { fullArgs.add('--pause-isolates-on-start'); } @@ -417,7 +415,7 @@ class _ServiceTesterRunner { () => ignoreLateException( () async { if (useDds) { - await dds?.shutdown(); + await dds.shutdown(); } process.requestExit(); },