diff --git a/pkg/dartdev/lib/src/commands/run.dart b/pkg/dartdev/lib/src/commands/run.dart index 6bb4d8d445e..21d7de464bb 100644 --- a/pkg/dartdev/lib/src/commands/run.dart +++ b/pkg/dartdev/lib/src/commands/run.dart @@ -133,7 +133,7 @@ class RunCommand extends DartdevCommand { ..addOption('timeline-recorder', help: 'Selects the timeline recorder to use.\n' 'Valid recorders include: none, ring, endless, startup, ' - 'systrace, file, callback.\n' + 'systrace, file, callback, perfettofile.\n' 'Defaults to ring.', valueHelp: 'recorder'); } else { diff --git a/pkg/vm_service/lib/src/vm_service.dart b/pkg/vm_service/lib/src/vm_service.dart index d55af29009f..f82621a89f3 100644 --- a/pkg/vm_service/lib/src/vm_service.dart +++ b/pkg/vm_service/lib/src/vm_service.dart @@ -941,10 +941,10 @@ abstract class VmServiceInterface { /// timeline request`, will be returned as timeline events are handled by the /// OS in these modes. /// - /// If `getVMTimeline` is invoked while the current recorder is File, an - /// [RPCError] with error code `114`, `invalid timeline request`, will be - /// returned as timeline events are written directly to a file, and thus - /// cannot be retrieved through the VM Service, in this mode. + /// If `getVMTimeline` is invoked while the current recorder is File or + /// Perfettofile, an [RPCError] with error code `114`, `invalid timeline + /// request`, will be returned as timeline events are written directly to a + /// file, and thus cannot be retrieved through the VM Service, in these modes. Future getVMTimeline( {int? timeOriginMicros, int? timeExtentMicros}); @@ -4735,7 +4735,7 @@ class Flag { /// The value of this flag as a string. /// - /// If this property is absent, then the value of the flag was NULL. + /// If this property is absent, then the value of the flag was nullptr. @optional String? valueAsString; diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc index 2aaa86f5c27..62718f230c6 100644 --- a/runtime/vm/service.cc +++ b/runtime/vm/service.cc @@ -4186,7 +4186,8 @@ static void GetVMTimeline(Thread* thread, JSONStream* js) { "for this recorder type.", timeline_recorder->name()); return; - } else if (strcmp(name, FILE_RECORDER_NAME) == 0) { + } else if (strcmp(name, FILE_RECORDER_NAME) == 0 || + strcmp(name, PERFETTO_FILE_RECORDER_NAME) == 0) { js->PrintError(kInvalidTimelineRequest, "A recorder of type \"%s\" is currently in use. As a " "result, timeline events are written directly to a file and " diff --git a/runtime/vm/service/service.md b/runtime/vm/service/service.md index 7dec2596f94..48f3322c4e7 100644 --- a/runtime/vm/service/service.md +++ b/runtime/vm/service/service.md @@ -1214,10 +1214,11 @@ Macos or Systrace, an [RPC error](#rpc-error) with error code _114_, `invalid timeline request`, will be returned as timeline events are handled by the OS in these modes. -If _getVMTimeline_ is invoked while the current recorder is File, an -[RPC error](#rpc-error) with error code _114_, `invalid timeline request`, will -be returned as timeline events are written directly to a file, and thus cannot -be retrieved through the VM Service, in this mode. +If _getVMTimeline_ is invoked while the current recorder is File or +Perfettofile, an [RPC error](#rpc-error) with error code _114_, +`invalid timeline request`, will be returned as timeline events are written +directly to a file, and thus cannot be retrieved through the VM Service, in +these modes. ### getVMTimelineFlags diff --git a/runtime/vm/timeline.cc b/runtime/vm/timeline.cc index 2a21623f9d3..2fbd8435572 100644 --- a/runtime/vm/timeline.cc +++ b/runtime/vm/timeline.cc @@ -110,7 +110,7 @@ GetProtoPreamble(const intptr_t size) { #define DEFAULT_TIMELINE_RECORDER "ring" #if defined(SUPPORT_PERFETTO) #define SUPPORTED_TIMELINE_RECORDERS \ - "ring, endless, startup, systrace, file, callback, perfetto" + "ring, endless, startup, systrace, file, callback, perfettofile" #else #define SUPPORTED_TIMELINE_RECORDERS \ "ring, endless, startup, systrace, file, callback" @@ -249,14 +249,13 @@ static TimelineEventRecorder* CreateTimelineRecorder() { // The Perfetto file recorder is disabled in PRODUCT mode to avoid the large // binary size increase that it brings. { - const intptr_t kLengthOfWordPerfetto = 8; - if (Utils::StrStartsWith(flag, "perfetto") && - (flag[kLengthOfWordPerfetto] == '\0' || - flag[kLengthOfWordPerfetto] == ':' || - flag[kLengthOfWordPerfetto] == '=')) { - const char* filename = flag[kLengthOfWordPerfetto] == '\0' + const intptr_t kPrefixLength = 12; + if (Utils::StrStartsWith(flag, "perfettofile") && + (flag[kPrefixLength] == '\0' || flag[kPrefixLength] == ':' || + flag[kPrefixLength] == '=')) { + const char* filename = flag[kPrefixLength] == '\0' ? "dart.perfetto-trace" - : &flag[kLengthOfWordPerfetto + 1]; + : &flag[kPrefixLength + 1]; free(const_cast(FLAG_timeline_dir)); FLAG_timeline_dir = nullptr; return new TimelineEventPerfettoFileRecorder(filename); diff --git a/runtime/vm/timeline.h b/runtime/vm/timeline.h index 173dce287da..2cabab139f4 100644 --- a/runtime/vm/timeline.h +++ b/runtime/vm/timeline.h @@ -69,7 +69,7 @@ class Zone; #define FILE_RECORDER_NAME "File" #define FUCHSIA_RECORDER_NAME "Fuchsia" #define MACOS_RECORDER_NAME "Macos" -#define PERFETTO_RECORDER_NAME "Perfetto" +#define PERFETTO_FILE_RECORDER_NAME "Perfettofile" #define RING_RECORDER_NAME "Ring" #define STARTUP_RECORDER_NAME "Startup" #define SYSTRACE_RECORDER_NAME "Systrace" @@ -1249,7 +1249,7 @@ class TimelineEventPerfettoFileRecorder : public TimelineEventFileRecorderBase { explicit TimelineEventPerfettoFileRecorder(const char* path); virtual ~TimelineEventPerfettoFileRecorder(); - const char* name() const final { return PERFETTO_RECORDER_NAME; } + const char* name() const final { return PERFETTO_FILE_RECORDER_NAME; } private: void WritePacket(