From eff8c305d9c8e77b31e877a06d91e814c4ed9436 Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Mon, 15 Aug 2022 21:02:36 +0000 Subject: [PATCH] [ Service / Timeline ] Enable Compiler, Dart, and GC timeline streams when --observe is provided TEST=pkg/vm_service/test_timeline_default_streams_test.dart Fixes https://github.com/flutter/devtools/issues/3444 Change-Id: I3f772a54a512eb836e3e7279ee8d4d3437473393 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255181 Commit-Queue: Ben Konyi Reviewed-by: Ryan Macnak --- pkg/dartdev/lib/src/commands/run.dart | 8 +++++ .../test/timeline_default_streams_test.dart | 32 +++++++++++++++++++ runtime/bin/main_options.cc | 3 ++ 3 files changed, 43 insertions(+) create mode 100644 pkg/vm_service/test/timeline_default_streams_test.dart diff --git a/pkg/dartdev/lib/src/commands/run.dart b/pkg/dartdev/lib/src/commands/run.dart index 48c42912060..f029757fb0a 100644 --- a/pkg/dartdev/lib/src/commands/run.dart +++ b/pkg/dartdev/lib/src/commands/run.dart @@ -92,6 +92,14 @@ class RunCommand extends DartdevCommand { 'Print a warning when an isolate pauses with no attached debugger' ' when running with --enable-vm-service.', ) + ..addOption( + 'timeline-streams', + help: 'Enables recording for specific timeline streams.\n' + 'Valid streams include: all, API, Compiler, CompilerVerbose, Dart, ' + 'Debugger, Embedder, GC, Isolate, VM.\n' + 'Defaults to "Compiler, Dart, GC" when --observe is provided.', + valueHelp: 'str1, str2, ...', + ) ..addSeparator( 'Other debugging options:', ) diff --git a/pkg/vm_service/test/timeline_default_streams_test.dart b/pkg/vm_service/test/timeline_default_streams_test.dart new file mode 100644 index 00000000000..cbed7b77e96 --- /dev/null +++ b/pkg/vm_service/test/timeline_default_streams_test.dart @@ -0,0 +1,32 @@ +// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// VMOptions=--observe --no-pause-isolates-on-exit + +import 'dart:developer'; + +import 'package:test/test.dart'; +import 'package:vm_service/vm_service.dart'; +import 'package:vm_service/vm_service_io.dart'; + +main() { + late VmService service; + setUp(() async { + ServiceProtocolInfo serviceInfo = await Service.getInfo(); + // Wait for VM service to publish its connection info. + while (serviceInfo.serverUri == null) { + await Future.delayed(Duration(milliseconds: 10)); + serviceInfo = await Service.getInfo(); + } + service = + await vmServiceConnectUri(serviceInfo.serverWebSocketUri!.toString()); + }); + + tearDown(() => service.dispose()); + + test('Check default timeline streams set by --observe', () async { + final flags = await service.getVMTimelineFlags(); + expect(flags.recordedStreams, containsAll(['Compiler', 'Dart', 'GC'])); + }); +} diff --git a/runtime/bin/main_options.cc b/runtime/bin/main_options.cc index fa8401a7b2f..f561942c8f6 100644 --- a/runtime/bin/main_options.cc +++ b/runtime/bin/main_options.cc @@ -163,6 +163,7 @@ void Options::PrintUsage() { " --pause-isolates-on-exit\n" " --pause-isolates-on-unhandled-exceptions\n" " --warn-on-pause-with-no-debugger\n" +" --timeline-streams=\"Compiler, Dart, GC\"\n" " This set is subject to change.\n" " Please see these options (--help --verbose) for further documentation.\n" "--write-service-info=\n" @@ -204,6 +205,7 @@ void Options::PrintUsage() { " --pause-isolates-on-exit\n" " --pause-isolates-on-unhandled-exceptions\n" " --warn-on-pause-with-no-debugger\n" +" --timeline-streams=\"Compiler, Dart, GC\"\n" " This set is subject to change.\n" " Please see these options for further documentation.\n" #endif // !defined(PRODUCT) @@ -377,6 +379,7 @@ bool Options::ProcessObserveOption(const char* arg, vm_options->AddArgument("--pause-isolates-on-unhandled-exceptions"); vm_options->AddArgument("--profiler"); vm_options->AddArgument("--warn-on-pause-with-no-debugger"); + vm_options->AddArgument("--timeline-streams=\"Compiler,Dart,GC\""); #if !defined(DART_PRECOMPILED_RUNTIME) dfe()->set_use_incremental_compiler(true); #endif // !defined(DART_PRECOMPILED_RUNTIME)