[VM/Timeline] Update CLI options to make it clearer that the Perfetto file recorder records to a file

TEST=Manually verified that the modified CLI options worked as expected, CI

Change-Id: Ibaa308e5c9c3b96c939e2007ee2eaaca30eae280
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288063
Reviewed-by: Ben Konyi <bkonyi@google.com>
This commit is contained in:
Derek Xu 2023-04-20 16:42:23 +00:00 committed by Commit Queue
parent 6785f8ece7
commit 4b2f4c6977
6 changed files with 22 additions and 21 deletions

View file

@ -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 {

View file

@ -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<Timeline> 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;

View file

@ -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 "

View file

@ -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

View file

@ -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<char*>(FLAG_timeline_dir));
FLAG_timeline_dir = nullptr;
return new TimelineEventPerfettoFileRecorder(filename);

View file

@ -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(