• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17syntax = "proto2";
18option optimize_for = LITE_RUNTIME;
19
20import "perfetto/common/trace_stats.proto";
21import "perfetto/config/trace_config.proto";
22import "perfetto/trace/android/android_log.proto";
23import "perfetto/trace/android/packages_list.proto";
24import "perfetto/trace/chrome/chrome_trace_event.proto";
25import "perfetto/trace/clock_snapshot.proto";
26import "perfetto/trace/filesystem/inode_file_map.proto";
27import "perfetto/trace/ftrace/ftrace_event_bundle.proto";
28import "perfetto/trace/ftrace/ftrace_stats.proto";
29import "perfetto/trace/interned_data/interned_data.proto";
30import "perfetto/trace/power/battery_counters.proto";
31import "perfetto/trace/power/power_rails.proto";
32import "perfetto/trace/profiling/profile_packet.proto";
33import "perfetto/trace/ps/process_stats.proto";
34import "perfetto/trace/ps/process_tree.proto";
35import "perfetto/trace/sys_stats/sys_stats.proto";
36import "perfetto/trace/system_info.proto";
37import "perfetto/trace/track_event/process_descriptor.proto";
38import "perfetto/trace/track_event/thread_descriptor.proto";
39import "perfetto/trace/track_event/track_event.proto";
40import "perfetto/trace/trigger.proto";
41import "perfetto/trace/test_event.proto";
42
43package perfetto.protos;
44
45// The root object emitted by Perfetto. A perfetto trace is just a stream of
46// TracePacket(s).
47//
48// Next reserved id: 13 (up to 15).
49// Next id: 51.
50message TracePacket {
51  // TODO(primiano): in future we should add a timestamp_clock_domain field to
52  // allow mixing timestamps from different clock domains.
53  optional uint64 timestamp = 8;  // Timestamp [ns].
54
55  oneof data {
56    FtraceEventBundle ftrace_events = 1;
57    ProcessTree process_tree = 2;
58    ProcessStats process_stats = 9;
59    InodeFileMap inode_file_map = 4;
60    ChromeEventBundle chrome_events = 5;
61    ClockSnapshot clock_snapshot = 6;
62    SysStats sys_stats = 7;
63    TrackEvent track_event = 11;
64
65    // IDs up to 15 are reserved. They take only one byte to encode their
66    // preamble so should be used for freqeuent events.
67
68    TraceConfig trace_config = 33;
69    FtraceStats ftrace_stats = 34;
70    TraceStats trace_stats = 35;
71    ProfilePacket profile_packet = 37;
72    BatteryCounters battery = 38;
73    PowerRails power_rails = 40;
74    AndroidLogPacket android_log = 39;
75    SystemInfo system_info = 45;
76    Trigger trigger = 46;
77    PackagesList packages_list = 47;
78
79    // Only used by TrackEvent.
80    ProcessDescriptor process_descriptor = 43;
81    ThreadDescriptor thread_descriptor = 44;
82
83    // This field is emitted at periodic intervals (~10s) and
84    // contains always the binary representation of the UUID
85    // {82477a76-b28d-42ba-81dc-33326d57a079}. This is used to be able to
86    // efficiently partition long traces without having to fully parse them.
87    bytes synchronization_marker = 36;
88
89    // Zero or more proto encoded trace packets compressed using deflate.
90    // Each compressed_packets TracePacket (including the two field ids and
91    // sizes) should be less than 512KB.
92    bytes compressed_packets = 50;
93
94    // This field is only used for testing.
95    // In previous versions of this proto this field had the id 268435455
96    // This caused many problems:
97    // - protozero decoder does not handle field ids larger than 999.
98    // - old versions of protoc produce Java bindings with syntax errors when
99    //   the field id is large enough.
100    TestEvent for_testing = 900;
101  }
102
103  // Trusted user id of the producer which generated this packet. Keep in sync
104  // with TrustedPacket.trusted_uid.
105  //
106  // TODO(eseckler): Emit this field in a PacketSequenceDescriptor message
107  // instead.
108  oneof optional_trusted_uid { int32 trusted_uid = 3; };
109
110  // Service-assigned identifier of the packet sequence this packet belongs to.
111  // Uniquely identifies a producer + writer pair within the tracing session. A
112  // value of zero denotes an invalid ID. Keep in sync with
113  // TrustedPacket.trusted_packet_sequence_id.
114  oneof optional_trusted_packet_sequence_id {
115    uint32 trusted_packet_sequence_id = 10;
116  }
117
118  // Incrementally emitted interned data, valid only on the packet's sequence
119  // (packets with the same |trusted_packet_sequence_id|). The writer will
120  // usually emit new interned data in the same TracePacket that first refers to
121  // it (since the last reset of interning state). It may also be emitted
122  // proactively in advance of referring to them in later packets.
123  optional InternedData interned_data = 12;
124
125  // Set to true by the writer to indicate that it will re-emit any incremental
126  // data for the packet's sequence before referring to it again. This includes
127  // interned data as well as periodically emitted data like
128  // Process/ThreadDescriptors. This flag only affects the current packet
129  // sequence (see |trusted_packet_sequence_id|).
130  //
131  // When set to true, this TracePacket and subsequent TracePackets on the same
132  // sequence will not refer to any incremental data emitted before this
133  // TracePacket. For example, previously emitted interned data will be
134  // re-emitted if it is referred to again.
135  //
136  // When the reader detects packet loss (|previous_packet_dropped|), it needs
137  // to skip packets in the sequence until the next one with this flag set, to
138  // ensure intact incremental data.
139  optional bool incremental_state_cleared = 41;
140
141  // Flag set by the service if, for the current packet sequence (see
142  // |trusted_packet_sequence_id|), either:
143  // * this is the first packet, or
144  // * one or multiple packets were dropped since the last packet that the
145  //   consumer read from the sequence. This can happen if chunks in the trace
146  //   buffer are overridden before the consumer could read them when the trace
147  //   is configured in ring buffer mode.
148  //
149  // When packet loss occurs, incrementally emitted data (including interned
150  // data) on the sequence should be considered invalid up until the next packet
151  // with |incremental_state_cleared| set.
152  optional bool previous_packet_dropped = 42;
153}
154