• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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 
17 #ifndef SRC_TRACE_PROCESSOR_STORAGE_STATS_H_
18 #define SRC_TRACE_PROCESSOR_STORAGE_STATS_H_
19 
20 #include <cstddef>
21 
22 namespace perfetto::trace_processor::stats {
23 
24 // Compile time list of parsing and processing stats.
25 // clang-format off
26 #define PERFETTO_TP_STATS(F)                                                   \
27   F(android_br_parse_errors,              kSingle,  kError,    kTrace,    ""), \
28   F(android_log_num_failed,               kSingle,  kError,    kTrace,    ""), \
29   F(android_log_format_invalid,           kSingle,  kError,    kTrace,    ""), \
30   F(android_log_num_skipped,              kSingle,  kInfo,     kTrace,    ""), \
31   F(android_log_num_total,                kSingle,  kInfo,     kTrace,    ""), \
32   F(deobfuscate_location_parse_error,     kSingle,  kError,    kTrace,    ""), \
33   F(energy_breakdown_missing_values,      kSingle,  kError,    kAnalysis, ""), \
34   F(energy_descriptor_invalid,            kSingle,  kError,    kAnalysis, ""), \
35   F(entity_state_descriptor_invalid,      kSingle,  kError,    kAnalysis, ""), \
36   F(entity_state_residency_invalid,       kSingle,  kError,    kAnalysis, ""), \
37   F(entity_state_residency_lookup_failed, kSingle,  kError,    kAnalysis, ""), \
38   F(energy_uid_breakdown_missing_values,  kSingle,  kError,    kAnalysis, ""), \
39   F(frame_timeline_event_parser_errors,   kSingle,  kInfo,     kAnalysis, ""), \
40   F(frame_timeline_unpaired_end_event,    kSingle,  kInfo,     kAnalysis, ""), \
41   F(ftrace_bundle_tokenizer_errors,       kSingle,  kError,    kAnalysis, ""), \
42   F(ftrace_cpu_bytes_begin,               kIndexed, kInfo,     kTrace,    ""), \
43   F(ftrace_cpu_bytes_end,                 kIndexed, kInfo,     kTrace,    ""), \
44   F(ftrace_cpu_bytes_delta,               kIndexed, kInfo,     kTrace,    ""), \
45   F(ftrace_cpu_commit_overrun_begin,      kIndexed, kInfo,     kTrace,    ""), \
46   F(ftrace_cpu_commit_overrun_end,        kIndexed, kInfo,     kTrace,    ""), \
47   F(ftrace_cpu_commit_overrun_delta,      kIndexed, kError,    kTrace,    ""), \
48   F(ftrace_cpu_dropped_events_begin,      kIndexed, kInfo,     kTrace,    ""), \
49   F(ftrace_cpu_dropped_events_end,        kIndexed, kInfo,     kTrace,    ""), \
50   F(ftrace_cpu_dropped_events_delta,      kIndexed, kError,    kTrace,    ""), \
51   F(ftrace_cpu_entries_begin,             kIndexed, kInfo,     kTrace,    ""), \
52   F(ftrace_cpu_entries_end,               kIndexed, kInfo,     kTrace,    ""), \
53   F(ftrace_cpu_entries_delta,             kIndexed, kInfo,     kTrace,    ""), \
54   F(ftrace_cpu_now_ts_begin,              kIndexed, kInfo,     kTrace,    ""), \
55   F(ftrace_cpu_now_ts_end,                kIndexed, kInfo,     kTrace,    ""), \
56   F(ftrace_cpu_oldest_event_ts_begin,     kIndexed, kInfo,     kTrace,    ""), \
57   F(ftrace_cpu_oldest_event_ts_end,       kIndexed, kInfo,     kTrace,    ""), \
58   F(ftrace_cpu_overrun_begin,             kIndexed, kInfo,     kTrace,    ""), \
59   F(ftrace_cpu_overrun_end,               kIndexed, kInfo,     kTrace,    ""), \
60   F(ftrace_cpu_overrun_delta,             kIndexed, kInfo,     kTrace,    ""), \
61   F(ftrace_cpu_read_events_begin,         kIndexed, kInfo,     kTrace,    ""), \
62   F(ftrace_cpu_read_events_end,           kIndexed, kInfo,     kTrace,    ""), \
63   F(ftrace_cpu_read_events_delta,         kIndexed, kInfo,     kTrace,    ""), \
64   F(ftrace_cpu_has_data_loss,             kIndexed, kDataLoss, kTrace,         \
65        "Ftrace data for the given cpu has data losses and is therefore "       \
66        "unreliable. The kernel buffer overwrote events between our reads "     \
67        "in userspace. Try re-recording the trace with a bigger buffer "        \
68        "(ftrace_config.buffer_size_kb), or with fewer enabled ftrace events."),\
69   F(ftrace_kprobe_hits_begin,             kSingle,  kInfo,     kTrace,         \
70        "The number of kretprobe hits at the beginning of the trace."),         \
71   F(ftrace_kprobe_hits_end,               kSingle,  kInfo,     kTrace,         \
72        "The number of kretprobe hits at the end of the trace."),               \
73   F(ftrace_kprobe_hits_delta,             kSingle,  kInfo,     kTrace,         \
74        "The number of kprobe hits encountered during the collection of the"    \
75        "trace."),                                                              \
76   F(ftrace_kprobe_misses_begin,           kSingle,  kInfo,     kTrace,         \
77        "The number of kretprobe missed events at the beginning of the trace."),\
78   F(ftrace_kprobe_misses_end,             kSingle,  kInfo,     kTrace,         \
79        "The number of kretprobe missed events at the end of the trace."),      \
80   F(ftrace_kprobe_misses_delta,           kSingle,  kDataLoss, kTrace,         \
81        "The number of kretprobe missed events encountered during the "         \
82        "collection of the trace. A value greater than zero is due to the "     \
83        "maxactive parameter for the kretprobe being too small"),               \
84   F(ftrace_setup_errors,                  kSingle,  kInfo,     kTrace,         \
85        "One or more atrace/ftrace categories were not found or failed to "     \
86        "enable. See ftrace_setup_errors in the metadata table for details."),  \
87   F(ftrace_abi_errors_skipped_zero_data_length,                                \
88                                           kSingle,  kInfo,     kAnalysis, ""), \
89   F(ftrace_thermal_exynos_acpm_unknown_tz_id,                                  \
90                                           kSingle,  kError,    kAnalysis, ""), \
91   F(fuchsia_non_numeric_counters,         kSingle,  kError,    kAnalysis, ""), \
92   F(fuchsia_timestamp_overflow,           kSingle,  kError,    kAnalysis, ""), \
93   F(fuchsia_record_read_error,            kSingle,  kError,    kAnalysis, ""), \
94   F(fuchsia_invalid_event,                kSingle,  kError,    kAnalysis, ""), \
95   F(fuchsia_invalid_event_arg_type,       kSingle,  kError,    kAnalysis, ""), \
96   F(fuchsia_invalid_event_arg_name,       kSingle,  kError,    kAnalysis, ""), \
97   F(fuchsia_unknown_event_arg,            kSingle,  kError,    kAnalysis, ""), \
98   F(fuchsia_invalid_string_ref,           kSingle,  kError,    kAnalysis, ""), \
99   F(gpu_counters_invalid_spec,            kSingle,  kError,    kAnalysis, ""), \
100   F(gpu_counters_missing_spec,            kSingle,  kError,    kAnalysis, ""), \
101   F(gpu_render_stage_parser_errors,       kSingle,  kError,    kAnalysis, ""), \
102   F(graphics_frame_event_parser_errors,   kSingle,  kInfo,     kAnalysis, ""), \
103   F(guess_trace_type_duration_ns,         kSingle,  kInfo,     kAnalysis, ""), \
104   F(interned_data_tokenizer_errors,       kSingle,  kInfo,     kAnalysis, ""), \
105   F(invalid_clock_snapshots,              kSingle,  kError,    kAnalysis, ""), \
106   F(invalid_cpu_times,                    kSingle,  kError,    kAnalysis, ""), \
107   F(kernel_wakelock_reused_id,            kSingle,  kError,    kAnalysis,      \
108        "Duplicated interning ID seen. Should never happen."),                  \
109   F(kernel_wakelock_unknown_id,           kSingle,  kError,    kAnalysis,      \
110        "Interning ID not found. Should never happen."),                        \
111   F(meminfo_unknown_keys,                 kSingle,  kError,    kAnalysis, ""), \
112   F(mismatched_sched_switch_tids,         kSingle,  kError,    kAnalysis, ""), \
113   F(mm_unknown_type,                      kSingle,  kError,    kAnalysis, ""), \
114   F(parse_trace_duration_ns,              kSingle,  kInfo,     kAnalysis, ""), \
115   F(power_rail_unknown_index,             kSingle,  kError,    kTrace,    ""), \
116   F(proc_stat_unknown_counters,           kSingle,  kError,    kAnalysis, ""), \
117   F(rss_stat_unknown_keys,                kSingle,  kError,    kAnalysis, ""), \
118   F(rss_stat_negative_size,               kSingle,  kInfo,     kAnalysis, ""), \
119   F(rss_stat_unknown_thread_for_mm_id,    kSingle,  kInfo,     kAnalysis, ""), \
120   F(filter_input_bytes,                   kSingle,  kInfo,     kTrace,         \
121        "Number of bytes pre-TraceFilter. The trace file would have been this " \
122        "many bytes big if the TraceConfig didn't specify any TraceFilter. "    \
123        "This affects the actual buffer usage, as filtering happens only "      \
124        "when writing into the trace file (or over IPC)."),                     \
125   F(filter_input_packets,                 kSingle,  kInfo,     kTrace,         \
126        "Number of packets pre-TraceFilter. The trace file would have had so "  \
127        "many packets if the TraceConfig didn't specify any TraceFilter."),     \
128   F(filter_output_bytes,                  kSingle,  kInfo,     kTrace,         \
129        "Number of bytes that made it through the TraceFilter, before the "     \
130        "(optional) Zlib compression stage."),                                  \
131   F(filter_time_taken_ns,                 kSingle,  kInfo,     kTrace,         \
132        "Time cumulatively spent running the TraceFilter throughout the "       \
133        "tracing session by MaybeFilterPackets()."),                            \
134   F(filter_errors,                        kSingle,  kError,    kTrace,    ""), \
135   F(flow_duplicate_id,                    kSingle,  kError,    kTrace,    ""), \
136   F(flow_no_enclosing_slice,              kSingle,  kError,    kTrace,    ""), \
137   F(flow_step_without_start,              kSingle,  kInfo,     kTrace,    ""), \
138   F(flow_end_without_start,               kSingle,  kInfo,     kTrace,    ""), \
139   F(flow_invalid_id,                      kSingle,  kError,    kTrace,    ""), \
140   F(flow_without_direction,               kSingle,  kError,    kTrace,    ""), \
141   F(stackprofile_empty_callstack,         kSingle,  kError,    kTrace,         \
142       "Callstack had no frames. Ignored"),                                     \
143   F(stackprofile_invalid_string_id,       kSingle,  kError,    kTrace,    ""), \
144   F(stackprofile_invalid_mapping_id,      kSingle,  kError,    kTrace,    ""), \
145   F(stackprofile_invalid_frame_id,        kSingle,  kError,    kTrace,    ""), \
146   F(stackprofile_invalid_callstack_id,    kSingle,  kError,    kTrace,    ""), \
147   F(stackprofile_parser_error,            kSingle,  kError,    kTrace,    ""), \
148   F(systrace_parse_failure,               kSingle,  kError,    kAnalysis, ""), \
149   F(task_state_invalid,                   kSingle,  kError,    kAnalysis, ""), \
150   F(traced_buf_abi_violations,            kIndexed, kDataLoss, kTrace,    ""), \
151   F(traced_buf_buffer_size,               kIndexed, kInfo,     kTrace,    ""), \
152   F(traced_buf_bytes_overwritten,         kIndexed, kInfo,     kTrace,    ""), \
153   F(traced_buf_bytes_read,                kIndexed, kInfo,     kTrace,    ""), \
154   F(traced_buf_bytes_filtered_out,        kIndexed, kInfo,     kTrace,         \
155        "Number of bytes discarded (input - output) by the TraceFilter for "    \
156        "each buffer. It is a subset of, but does not add up perfectly to, "    \
157        "(filter_input_bytes - filter_output_bytes) because of the synthetic "  \
158        "metadata and stats packets generated by the tracing service itself."), \
159   F(traced_buf_bytes_written,             kIndexed, kInfo,     kTrace,    ""), \
160   F(traced_buf_clone_done_timestamp_ns,   kIndexed, kInfo,     kTrace,         \
161     "The timestamp when the clone snapshot operation for this buffer "         \
162     "finished"),                                                               \
163   F(traced_buf_chunks_discarded,          kIndexed, kInfo,     kTrace,    ""), \
164   F(traced_buf_chunks_overwritten,        kIndexed, kInfo,     kTrace,    ""), \
165   F(traced_buf_chunks_read,               kIndexed, kInfo,     kTrace,    ""), \
166   F(traced_buf_chunks_rewritten,          kIndexed, kInfo,     kTrace,    ""), \
167   F(traced_buf_chunks_written,            kIndexed, kInfo,     kTrace,    ""), \
168   F(traced_buf_chunks_committed_out_of_order,                                  \
169                                           kIndexed, kInfo,     kTrace,    ""), \
170   F(traced_buf_padding_bytes_cleared,     kIndexed, kInfo,     kTrace,    ""), \
171   F(traced_buf_padding_bytes_written,     kIndexed, kInfo,     kTrace,    ""), \
172   F(traced_buf_patches_failed,            kIndexed, kDataLoss, kTrace,         \
173       "The tracing service potentially lost data from one of the data sources "\
174       "writing into the given target_buffer. This entry can be ignored "       \
175       "if you're using DISCARD buffers and traced_buf_chunks_discarded is "    \
176       "nonzero, meaning that the buffer was filled."),                         \
177   F(traced_buf_patches_succeeded,         kIndexed, kInfo,     kTrace,    ""), \
178   F(traced_buf_readaheads_failed,         kIndexed, kInfo,     kTrace,    ""), \
179   F(traced_buf_readaheads_succeeded,      kIndexed, kInfo,     kTrace,    ""), \
180   F(traced_buf_trace_writer_packet_loss,  kIndexed, kDataLoss, kTrace,         \
181       "The tracing service observed packet loss for this buffer during this "  \
182       "tracing session. This also counts packet loss that happened before "    \
183       "the RING_BUFFER start or after the DISCARD buffer end."),               \
184   F(traced_buf_sequence_packet_loss,      kIndexed, kDataLoss, kAnalysis,      \
185       "The number of groups of consecutive packets lost in each sequence for " \
186       "this buffer"),                                                          \
187   F(traced_buf_incremental_sequences_dropped, kIndexed, kDataLoss, kAnalysis,  \
188       "For a given buffer, indicates the number of sequences where all the "   \
189       "packets on that sequence were dropped due to lack of a valid "          \
190       "incremental state (i.e. interned data). This is usually a strong sign " \
191       "that either: "                                                          \
192       "1) incremental state invalidation is disabled. "                        \
193       "2) the incremental state invalidation interval is too low. "            \
194       "In either case, see "                                                   \
195       "https://perfetto.dev/docs/concepts/buffers"                             \
196       "#incremental-state-in-trace-packets"),                                  \
197   F(traced_buf_write_wrap_count,          kIndexed, kInfo,     kTrace,    ""), \
198   F(traced_clone_started_timestamp_ns,    kSingle,  kInfo,     kTrace,         \
199     "The timestamp when the clone snapshot operation for this trace started"), \
200   F(traced_chunks_discarded,              kSingle,  kInfo,     kTrace,    ""), \
201   F(traced_data_sources_registered,       kSingle,  kInfo,     kTrace,    ""), \
202   F(traced_data_sources_seen,             kSingle,  kInfo,     kTrace,    ""), \
203   F(traced_final_flush_failed,            kSingle,  kDataLoss, kTrace,    ""), \
204   F(traced_final_flush_succeeded,         kSingle,  kInfo,     kTrace,    ""), \
205   F(traced_flushes_failed,                kSingle,  kDataLoss, kTrace,    ""), \
206   F(traced_flushes_requested,             kSingle,  kInfo,     kTrace,    ""), \
207   F(traced_flushes_succeeded,             kSingle,  kInfo,     kTrace,    ""), \
208   F(traced_patches_discarded,             kSingle,  kInfo,     kTrace,    ""), \
209   F(traced_producers_connected,           kSingle,  kInfo,     kTrace,    ""), \
210   F(traced_producers_seen,                kSingle,  kInfo,     kTrace,    ""), \
211   F(traced_total_buffers,                 kSingle,  kInfo,     kTrace,    ""), \
212   F(traced_tracing_sessions,              kSingle,  kInfo,     kTrace,    ""), \
213   F(track_event_parser_errors,            kSingle,  kInfo,     kAnalysis, ""), \
214   F(track_event_dropped_packets_outside_of_range_of_interest,                  \
215                                           kSingle,  kInfo,     kAnalysis,      \
216       "The number of TrackEvent packets dropped by trace processor due to "    \
217       "being outside of the range of interest. This happens if a trace has a " \
218       "TrackEventRangeOfInterest packet, and track event dropping is "         \
219       "enabled."),                                                             \
220   F(track_event_tokenizer_errors,         kSingle,  kInfo,     kAnalysis, ""), \
221   F(track_event_thread_invalid_end,       kSingle,  kError,    kTrace,         \
222       "The end event for a thread track does not match a track event "         \
223       "begin event. This can happen on mixed atrace/track_event traces "       \
224       "and is usually caused by data loss or bugs when the events are "        \
225       "emitted. The outcome of this is that slices can appear to be closed "   \
226       "before they were closed in reality"),                                   \
227   F(tokenizer_skipped_packets,            kSingle,  kInfo,     kAnalysis, ""), \
228   F(vmstat_unknown_keys,                  kSingle,  kError,    kAnalysis, ""), \
229   F(psi_unknown_resource,                 kSingle,  kError,    kAnalysis, ""), \
230   F(vulkan_allocations_invalid_string_id,                                      \
231                                           kSingle,  kError,    kTrace,    ""), \
232   F(clock_sync_failure,                   kSingle,  kError,    kAnalysis, ""), \
233   F(clock_sync_cache_miss,                kSingle,  kInfo,     kAnalysis, ""), \
234   F(process_tracker_errors,               kSingle,  kError,    kAnalysis, ""), \
235   F(json_tokenizer_failure,               kSingle,  kError,    kTrace,    ""), \
236   F(json_parser_failure,                  kSingle,  kError,    kTrace,    ""), \
237   F(json_display_time_unit,               kSingle,  kInfo,     kTrace,         \
238       "The displayTimeUnit key was set in the JSON trace. In some prior "      \
239       "versions of trace processor this key could effect how the trace "       \
240       "processor parsed timestamps and durations. In this version the key is " \
241       "ignored which more closely matches the bavahiour of catapult."),        \
242   F(heap_graph_invalid_string_id,         kIndexed, kError,    kTrace,    ""), \
243   F(heap_graph_non_finalized_graph,       kSingle,  kError,    kTrace,    ""), \
244   F(heap_graph_malformed_packet,          kIndexed, kError,    kTrace,    ""), \
245   F(heap_graph_missing_packet,            kIndexed, kError,    kTrace,    ""), \
246   F(heapprofd_buffer_corrupted,           kIndexed, kError,    kTrace,         \
247       "Shared memory buffer corrupted. This is a bug or memory corruption "    \
248       "in the target. Indexed by target upid."),                               \
249   F(heapprofd_hit_guardrail,              kIndexed, kError,    kTrace,         \
250       "HeapprofdConfig specified a CPU or Memory Guardrail that was hit. "     \
251       "Indexed by target upid."),                                              \
252   F(heapprofd_buffer_overran,             kIndexed, kDataLoss, kTrace,         \
253       "The shared memory buffer between the target and heapprofd overran. "    \
254       "The profile was truncated early. Indexed by target upid."),             \
255   F(heapprofd_client_error,               kIndexed, kError,    kTrace,         \
256       "The heapprofd client ran into a problem and disconnected. "             \
257       "See profile_packet.proto  for error codes."),                           \
258   F(heapprofd_client_disconnected,        kIndexed, kInfo,     kTrace,    ""), \
259   F(heapprofd_malformed_packet,           kIndexed, kError,    kTrace,    ""), \
260   F(heapprofd_missing_packet,             kSingle,  kError,    kTrace,    ""), \
261   F(heapprofd_rejected_concurrent,        kIndexed, kError,    kTrace,         \
262       "The target was already profiled by another tracing session, so the "    \
263       "profile was not taken. Indexed by target upid."),                       \
264   F(heapprofd_non_finalized_profile,      kSingle,  kError,    kTrace,    ""), \
265   F(heapprofd_sampling_interval_adjusted,                                      \
266     kIndexed, kInfo,    kTrace,                                                \
267       "By how many byes the interval for PID was increased "                   \
268       "by adaptive sampling."),                                                \
269   F(heapprofd_unwind_time_us,             kIndexed, kInfo,     kTrace,         \
270       "Time spent unwinding callstacks."),                                     \
271   F(heapprofd_unwind_samples,             kIndexed, kInfo,     kTrace,         \
272       "Number of samples unwound."),                                           \
273   F(heapprofd_client_spinlock_blocked,    kIndexed, kInfo,     kTrace,         \
274        "Time (us) the heapprofd client was blocked on the spinlock."),         \
275   F(heapprofd_last_profile_timestamp,     kIndexed, kInfo,     kTrace,         \
276        "The timestamp (in trace time) for the last dump for a process"),       \
277   F(symbolization_tmp_build_id_not_found,     kSingle,  kError,    kAnalysis,  \
278        "Number of file mappings in /data/local/tmp without a build id. "       \
279        "Symbolization doesn't work for executables in /data/local/tmp "        \
280        "because of SELinux. Please use /data/local/tests"),                    \
281   F(metatrace_overruns,                   kSingle,  kError,    kTrace,    ""), \
282   F(packages_list_has_parse_errors,       kSingle,  kError,    kTrace,    ""), \
283   F(packages_list_has_read_errors,        kSingle,  kError,    kTrace,    ""), \
284   F(game_intervention_has_parse_errors,   kSingle,  kError,    kTrace,         \
285        "One or more parsing errors occurred. This could result from "          \
286        "unknown game more or intervention added to the file to be parsed."),   \
287   F(game_intervention_has_read_errors,    kSingle,  kError,    kTrace,         \
288        "The file to be parsed can't be opened. This can happend when "         \
289        "the file name is not found or no permission to access the file"),      \
290   F(compact_sched_has_parse_errors,       kSingle,  kError,    kTrace,    ""), \
291   F(misplaced_end_event,                  kSingle,  kDataLoss, kAnalysis, ""), \
292   F(truncated_sys_write_duration,         kSingle,  kInfo,     kAnalysis,      \
293       "Count of sys_write slices that have a truncated duration to resolve "   \
294       "nesting incompatibilities with atrace slices. Real durations "          \
295       "can be recovered via the |raw| table."),                                \
296   F(compact_sched_switch_skipped,         kSingle,  kInfo,     kAnalysis, ""), \
297   F(compact_sched_waking_skipped,         kSingle,  kInfo,     kAnalysis, ""), \
298   F(empty_chrome_metadata,                kSingle,  kError,    kTrace,    ""), \
299   F(ninja_parse_errors,                   kSingle,  kError,    kTrace,    ""), \
300   F(perf_cpu_lost_records,                kIndexed, kDataLoss, kTrace,         \
301       "Count of perf samples lost due to kernel buffer overruns. The trace "   \
302       "is missing information, but it's not known which processes are "        \
303       "affected. Consider lowering the sampling frequency or raising "         \
304       "the ring_buffer_pages config option."),                                 \
305   F(perf_process_shard_count,             kIndexed, kInfo,     kTrace,    ""), \
306   F(perf_chosen_process_shard,            kIndexed, kInfo,     kTrace,    ""), \
307   F(perf_guardrail_stop_ts,               kIndexed, kDataLoss, kTrace,    ""), \
308   F(perf_unknown_record_type,             kIndexed, kInfo,     kAnalysis, ""), \
309   F(perf_record_skipped,                  kIndexed, kError,    kAnalysis, ""), \
310   F(perf_samples_skipped,                 kSingle,  kError,    kAnalysis,      \
311       "Count of skipped perf samples that otherwise matched the tracing "      \
312       "config. This will cause a process to be completely absent from the "    \
313       "trace, but does *not* imply data loss for processes that do have "      \
314       "samples in this trace."),                                               \
315   F(perf_counter_skipped_because_no_cpu,  kSingle,  kError,    kAnalysis, ""), \
316   F(perf_features_skipped,                kIndexed, kInfo,     kAnalysis, ""), \
317   F(perf_samples_cpu_mode_unknown,        kSingle,  kError,    kAnalysis, ""), \
318   F(perf_samples_skipped_dataloss,        kSingle,  kDataLoss, kTrace,         \
319       "Count of perf samples lost within the profiler (traced_perf), likely "  \
320       "due to load shedding. This may impact any traced processes. The trace " \
321       "protobuf needs to be inspected manually to confirm which processes "    \
322       "are affected."),                                                        \
323   F(perf_dummy_mapping_used,              kSingle,  kInfo,     kAnalysis, ""), \
324   F(perf_aux_missing,                     kSingle,  kDataLoss, kTrace,         \
325       "Number of bytes missing in AUX data streams due to missing "            \
326       "PREF_RECORD_AUX messages."),                                            \
327   F(perf_aux_ignored,                     kSingle,  kInfo,     kTrace,         \
328        "AUX data was ignored because the proper parser is not implemented."), \
329   F(perf_aux_lost,                        kSingle,  kDataLoss, kTrace,         \
330       "Gaps in the AUX data stream pased to the tokenizer."), \
331   F(perf_aux_truncated,                   kSingle,  kDataLoss, kTrace,         \
332       "Data was truncated when being written to the AUX stream at the "        \
333       "source."),\
334   F(perf_aux_partial,                     kSingle,  kDataLoss, kTrace,         \
335       "The PERF_RECORD_AUX contained partial data."), \
336   F(perf_aux_collision,                   kSingle,  kDataLoss, kTrace,         \
337       "The collection of a sample colliden with another. You should reduce "   \
338       "the rate at which samples are collected."),                             \
339   F(perf_auxtrace_missing,                kSingle,  kDataLoss, kTrace,         \
340       "Number of bytes missing in AUX data streams due to missing "            \
341       "PREF_RECORD_AUXTRACE messages."),                                       \
342   F(perf_unknown_aux_data,                kIndexed, kDataLoss, kTrace,         \
343       "AUX data type encountered for which there is no known parser."),        \
344   F(perf_no_tsc_data,                     kSingle,  kInfo,     kTrace,         \
345       "TSC data unavailable. Will be unable to translate HW clocks."),         \
346   F(spe_no_timestamp,                     kSingle,  kInfo,     kTrace,         \
347       "SPE record with no timestamp. Will try our best to assign a "           \
348       "timestamp."),                                                           \
349   F(spe_record_dropped,                   kSingle,  kDataLoss, kTrace,         \
350       "SPE record dropped. E.g. Unable to assign it a timestamp."),            \
351   F(etm_no_importer,                      kSingle,  kError,    kAnalysis,      \
352       "Unable to parse ETM data because TraceProcessor was not compiled to  "  \
353       " support it. Make sure you enable the `enable_perfetto_etm_importer` "  \
354       " GN flag."),                                                            \
355   F(memory_snapshot_parser_failure,       kSingle,  kError,    kAnalysis, ""), \
356   F(thread_time_in_state_unknown_cpu_freq,                                     \
357                                           kSingle,  kError,    kAnalysis, ""), \
358   F(ftrace_packet_before_tracing_start,   kSingle,  kInfo,     kAnalysis,      \
359       "An ftrace packet was seen before the tracing start timestamp from "     \
360       "the tracing service. This happens if the ftrace buffers were not "      \
361       "cleared properly. These packets are silently dropped by trace "         \
362       "processor."),                                                           \
363   F(sorter_push_event_out_of_order,       kSingle, kError,     kTrace,         \
364       "Trace events are out of order event after sorting. This can happen "    \
365       "due to many factors including clock sync drift, producers emitting "    \
366       "events out of order or a bug in trace processor's logic of sorting."),  \
367   F(unknown_extension_fields,             kSingle,  kError,    kTrace,         \
368       "TraceEvent had unknown extension fields, which might result in "        \
369       "missing some arguments. You may need a newer version of trace "         \
370       "processor to parse them."),                                             \
371   F(network_trace_intern_errors,          kSingle,  kInfo,     kAnalysis, ""), \
372   F(network_trace_parse_errors,           kSingle,  kInfo,     kAnalysis, ""), \
373   F(atom_timestamp_missing,               kSingle,  kError,    kTrace,         \
374       "The corresponding timestamp_nanos entry for a StatsdAtom was "          \
375       "missing. Defaulted to inaccurate packet timestamp."),                   \
376   F(atom_unknown,                         kSingle,  kInfo,     kAnalysis,      \
377       "Unknown statsd atom. Atom descriptor may need to be updated"),          \
378   F(v8_intern_errors,                                                          \
379                                           kSingle,  kDataLoss, kAnalysis,      \
380       "Failed to resolve V8 interned data."),                                  \
381   F(v8_isolate_has_no_code_range,                                              \
382                                           kSingle,  kError,    kAnalysis,      \
383       "V8 isolate had no code range. THis is currently no supported and means" \
384       "we will be unable to parse JS code events for this isolate."),          \
385   F(v8_no_defaults,                                                            \
386                                           kSingle,  kDataLoss, kAnalysis,      \
387       "Failed to resolve V8 default data."),                                   \
388   F(v8_no_code_range,                                                          \
389                                           kSingle,  kError,    kAnalysis,      \
390       "V8 isolate had no code range."),                                        \
391   F(v8_unknown_code_type,                 kSingle,  kError,    kAnalysis, ""), \
392   F(v8_code_load_missing_code_range,      kSingle,  kError,    kAnalysis,      \
393       "V8 load had no code range or an empty one. Event ignored."),            \
394   F(winscope_inputmethod_clients_parse_errors,                                 \
395                                           kSingle,  kInfo,     kAnalysis,      \
396       "InputMethod clients packet has unknown fields, which results in "       \
397       "some arguments missing. You may need a newer version of trace "         \
398       "processor to parse them."),                                             \
399   F(winscope_inputmethod_manager_service_parse_errors,                         \
400                                           kSingle,  kInfo,     kAnalysis,      \
401       "InputMethod manager service packet has unknown fields, which results "  \
402       "in some arguments missing. You may need a newer version of trace "      \
403       "processor to parse them."),                                             \
404   F(winscope_inputmethod_service_parse_errors,                                 \
405                                           kSingle,  kInfo,     kAnalysis,      \
406       "InputMethod service packet has unknown fields, which results in "       \
407       "some arguments missing. You may need a newer version of trace "         \
408       "processor to parse them."),                                             \
409   F(winscope_sf_layers_parse_errors,      kSingle,  kInfo,     kAnalysis,      \
410       "SurfaceFlinger layers snapshot has unknown fields, which results in "   \
411       "some arguments missing. You may need a newer version of trace "         \
412       "processor to parse them."),                                             \
413   F(winscope_sf_transactions_parse_errors,                                     \
414                                           kSingle,  kInfo,     kAnalysis,      \
415       "SurfaceFlinger transactions packet has unknown fields, which results "  \
416       "in some arguments missing. You may need a newer version of trace "      \
417       "processor to parse them."),                                             \
418   F(winscope_shell_transitions_parse_errors,                                   \
419                                           kSingle,  kInfo,     kAnalysis,      \
420       "Shell transition packet has unknown fields, which results "             \
421       "in some arguments missing. You may need a newer version of trace "      \
422       "processor to parse them."),                                             \
423   F(winscope_protolog_invalid_interpolation_parse_errors,                      \
424                                           kSingle,  kInfo,     kAnalysis,      \
425       "ProtoLog message string has invalid interplation parameter."),          \
426   F(winscope_protolog_missing_interned_arg_parse_errors,                       \
427                                           kSingle,  kInfo,     kAnalysis,      \
428       "Failed to find interned ProtoLog argument."),                           \
429   F(winscope_protolog_missing_interned_stacktrace_parse_errors,                \
430                                           kSingle,  kInfo,     kAnalysis,      \
431       "Failed to find interned ProtoLog stacktrace."),                         \
432   F(winscope_protolog_message_decoding_failed,                                 \
433                                           kSingle,  kInfo,     kAnalysis,      \
434       "Failed to decode ProtoLog message."),                                   \
435   F(winscope_protolog_view_config_collision,                                   \
436                                           kSingle,  kInfo,     kAnalysis,      \
437       "Got a viewer config collision!"),                                       \
438   F(winscope_viewcapture_parse_errors,                                         \
439                                           kSingle,  kInfo,     kAnalysis,      \
440       "ViewCapture packet has unknown fields, which results in some "          \
441       "arguments missing. You may need a newer version of trace processor "    \
442       "to parse them."),                                                       \
443   F(winscope_viewcapture_missing_interned_string_parse_errors,                 \
444                                           kSingle,  kInfo,     kAnalysis,      \
445       "Failed to find interned ViewCapture string."),                          \
446   F(winscope_windowmanager_parse_errors, kSingle,  kInfo,     kAnalysis,       \
447       "WindowManager state packet has unknown fields, which results "          \
448       "in some arguments missing. You may need a newer version of trace "      \
449       "processor to parse them."),                                             \
450   F(jit_unknown_frame,                    kSingle,  kDataLoss, kTrace,         \
451       "Indicates that we were unable to determine the function for a frame in "\
452       "a jitted memory region"),                                               \
453   F(ftrace_missing_event_id,              kSingle,  kInfo,    kAnalysis,       \
454       "Indicates that the ftrace event was dropped because the event id was "  \
455       "missing. This is an 'info' stat rather than an error stat because "     \
456       "this can be legitimately missing due to proto filtering."),             \
457   F(android_input_event_parse_errors,     kSingle,  kInfo,     kAnalysis,      \
458       "Android input event packet has unknown fields, which results "          \
459       "in some arguments missing. You may need a newer version of trace "      \
460       "processor to parse them."),                                             \
461   F(mali_unknown_mcu_state_id,            kSingle,  kError,   kAnalysis,       \
462       "An invalid Mali GPU MCU state ID was detected."),                       \
463   F(pixel_modem_negative_timestamp,       kSingle,  kError,   kAnalysis,       \
464       "A negative timestamp was received from a Pixel modem event."),          \
465   F(legacy_v8_cpu_profile_invalid_callsite, kSingle,  kInfo,  kAnalysis,       \
466       "Indicates a callsite in legacy v8 CPU profiling is invalid."),          \
467   F(legacy_v8_cpu_profile_invalid_sample, kSingle,  kError,  kAnalysis,        \
468       "Indicates a sample in legacy v8 CPU profile is invalid. This will "     \
469       "cause CPU samples to be missing in the UI."),                           \
470   F(config_write_into_file_no_flush,      kSingle,  kError,  kTrace,           \
471       "The trace was collected with the `write_into_file` option set but "     \
472       "*without* `flush_period_ms` being set. This will cause the trace to "   \
473       "be fully loaded into memory and use significantly more memory than "    \
474       "necessary."),                                                           \
475   F(config_write_into_file_discard,        kIndexed,  kDataLoss,  kTrace,      \
476       "The trace was collected with the `write_into_file` option set but "     \
477       "uses a `DISCARD` buffer. This configuration is strongly discouraged "   \
478       "and can cause mysterious data loss in the trace. Please use "           \
479       "`RING_BUFFER` buffers instead.")
480 // clang-format on
481 
482 enum Type {
483   kSingle,  // Single-value property, one value per key.
484   kIndexed  // Indexed property, multiple value per key (e.g. cpu_stats[1]).
485 };
486 
487 enum Severity {
488   kInfo,      // Diagnostic counters
489   kDataLoss,  // Correct operation that still resulted in data loss
490   kError      // If any kError counter is > 0 trace_processor_shell will
491               // raise an error. This is also surfaced in the web UI.
492 };
493 
494 enum Source {
495   // The counter is collected when recording the trace on-device and is just
496   // being reflected in the stats table.
497   kTrace,
498 
499   // The counter is generated when importing / processing the trace in the trace
500   // processor.
501   kAnalysis
502 };
503 
504 #if defined(__GNUC__) || defined(__clang__)
505 #if defined(__clang__)
506 #pragma clang diagnostic push
507 // Fix 'error: #pragma system_header ignored in main file' for clang in Google3.
508 #pragma clang diagnostic ignored "-Wpragma-system-header-outside-header"
509 #endif
510 
511 // Ignore GCC warning about a missing argument for a variadic macro parameter.
512 #pragma GCC system_header
513 
514 #if defined(__clang__)
515 #pragma clang diagnostic pop
516 #endif
517 #endif
518 
519 // Declares an enum of literals (one for each stat). The enum values of each
520 // literal corresponds to the string index in the arrays below.
521 #define PERFETTO_TP_STATS_ENUM(name, ...) name
522 enum KeyIDs : size_t { PERFETTO_TP_STATS(PERFETTO_TP_STATS_ENUM), kNumKeys };
523 
524 // The code below declares an array for each property (name, type, ...).
525 
526 #define PERFETTO_TP_STATS_NAME(name, ...) #name
527 constexpr char const* kNames[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_NAME)};
528 
529 #define PERFETTO_TP_STATS_TYPE(_, type, ...) type
530 constexpr Type kTypes[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_TYPE)};
531 
532 #define PERFETTO_TP_STATS_SEVERITY(_, __, severity, ...) severity
533 constexpr Severity kSeverities[] = {
534     PERFETTO_TP_STATS(PERFETTO_TP_STATS_SEVERITY)};
535 
536 #define PERFETTO_TP_STATS_SOURCE(_, __, ___, source, ...) source
537 constexpr Source kSources[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_SOURCE)};
538 
539 #define PERFETTO_TP_STATS_DESCRIPTION(_, __, ___, ____, descr, ...) descr
540 constexpr char const* kDescriptions[] = {
541     PERFETTO_TP_STATS(PERFETTO_TP_STATS_DESCRIPTION)};
542 
543 }  // namespace perfetto::trace_processor::stats
544 
545 #endif  // SRC_TRACE_PROCESSOR_STORAGE_STATS_H_
546