• 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 <stddef.h>
21 
22 namespace perfetto {
23 namespace trace_processor {
24 namespace stats {
25 
26 // Compile time list of parsing and processing stats.
27 // clang-format off
28 #define PERFETTO_TP_STATS(F)                                                   \
29   F(android_br_parse_errors,              kSingle,  kError,    kTrace,    ""), \
30   F(android_log_num_failed,               kSingle,  kError,    kTrace,    ""), \
31   F(android_log_format_invalid,           kSingle,  kError,    kTrace,    ""), \
32   F(android_log_num_skipped,              kSingle,  kInfo,     kTrace,    ""), \
33   F(android_log_num_total,                kSingle,  kInfo,     kTrace,    ""), \
34   F(counter_events_out_of_order,          kSingle,  kError,    kAnalysis, ""), \
35   F(deobfuscate_location_parse_error,     kSingle,  kError,    kTrace,    ""), \
36   F(energy_breakdown_missing_values,      kSingle,  kError,    kAnalysis, ""), \
37   F(energy_descriptor_invalid,            kSingle,  kError,    kAnalysis, ""), \
38   F(entity_state_descriptor_invalid,      kSingle,  kError,    kAnalysis, ""), \
39   F(entity_state_residency_invalid,       kSingle,  kError,    kAnalysis, ""), \
40   F(entity_state_residency_lookup_failed, kSingle,  kError,    kAnalysis, ""), \
41   F(energy_uid_breakdown_missing_values,  kSingle,  kError,    kAnalysis, ""), \
42   F(frame_timeline_event_parser_errors,   kSingle,  kInfo,     kAnalysis, ""), \
43   F(frame_timeline_unpaired_end_event,    kSingle,  kInfo,     kAnalysis, ""), \
44   F(ftrace_bundle_tokenizer_errors,       kSingle,  kError,    kAnalysis, ""), \
45   F(ftrace_cpu_bytes_begin,               kIndexed, kInfo,     kTrace,    ""), \
46   F(ftrace_cpu_bytes_end,                 kIndexed, kInfo,     kTrace,    ""), \
47   F(ftrace_cpu_bytes_delta,               kIndexed, kInfo,     kTrace,    ""), \
48   F(ftrace_cpu_commit_overrun_begin,      kIndexed, kInfo,     kTrace,    ""), \
49   F(ftrace_cpu_commit_overrun_end,        kIndexed, kInfo,     kTrace,    ""), \
50   F(ftrace_cpu_commit_overrun_delta,      kIndexed, kError,    kTrace,    ""), \
51   F(ftrace_cpu_dropped_events_begin,      kIndexed, kInfo,     kTrace,    ""), \
52   F(ftrace_cpu_dropped_events_end,        kIndexed, kInfo,     kTrace,    ""), \
53   F(ftrace_cpu_dropped_events_delta,      kIndexed, kError,    kTrace,    ""), \
54   F(ftrace_cpu_entries_begin,             kIndexed, kInfo,     kTrace,    ""), \
55   F(ftrace_cpu_entries_end,               kIndexed, kInfo,     kTrace,    ""), \
56   F(ftrace_cpu_entries_delta,             kIndexed, kInfo,     kTrace,    ""), \
57   F(ftrace_cpu_now_ts_begin,              kIndexed, kInfo,     kTrace,    ""), \
58   F(ftrace_cpu_now_ts_end,                kIndexed, kInfo,     kTrace,    ""), \
59   F(ftrace_cpu_oldest_event_ts_begin,     kIndexed, kInfo,     kTrace,    ""), \
60   F(ftrace_cpu_oldest_event_ts_end,       kIndexed, kInfo,     kTrace,    ""), \
61   F(ftrace_cpu_overrun_begin,             kIndexed, kInfo,     kTrace,    ""), \
62   F(ftrace_cpu_overrun_end,               kIndexed, kInfo,     kTrace,    ""), \
63   F(ftrace_cpu_overrun_delta,             kIndexed, kInfo,     kTrace,    ""), \
64   F(ftrace_cpu_read_events_begin,         kIndexed, kInfo,     kTrace,    ""), \
65   F(ftrace_cpu_read_events_end,           kIndexed, kInfo,     kTrace,    ""), \
66   F(ftrace_cpu_read_events_delta,         kIndexed, kInfo,     kTrace,    ""), \
67   F(ftrace_cpu_has_data_loss,             kIndexed, kDataLoss, kTrace,         \
68        "Ftrace data for the given cpu has data losses and is therefore "       \
69        "unreliable. The kernel buffer overwrote events between our reads "     \
70        "in userspace. Try re-recording the trace with a bigger buffer "        \
71        "(ftrace_config.buffer_size_kb), or with fewer enabled ftrace events."),\
72   F(ftrace_setup_errors,                  kSingle,  kInfo,     kTrace,         \
73        "One or more atrace/ftrace categories were not found or failed to "     \
74        "enable. See ftrace_setup_errors in the metadata table for details."),  \
75   F(ftrace_abi_errors_skipped_zero_data_length,                                \
76                                           kSingle,  kInfo,     kAnalysis, ""), \
77   F(ftrace_thermal_exynos_acpm_unknown_tz_id,                                  \
78                                           kSingle,  kError,    kAnalysis, ""), \
79   F(fuchsia_non_numeric_counters,         kSingle,  kError,    kAnalysis, ""), \
80   F(fuchsia_timestamp_overflow,           kSingle,  kError,    kAnalysis, ""), \
81   F(fuchsia_invalid_event,                kSingle,  kError,    kAnalysis, ""), \
82   F(gpu_counters_invalid_spec,            kSingle,  kError,    kAnalysis, ""), \
83   F(gpu_counters_missing_spec,            kSingle,  kError,    kAnalysis, ""), \
84   F(gpu_render_stage_parser_errors,       kSingle,  kError,    kAnalysis, ""), \
85   F(graphics_frame_event_parser_errors,   kSingle,  kInfo,     kAnalysis, ""), \
86   F(guess_trace_type_duration_ns,         kSingle,  kInfo,     kAnalysis, ""), \
87   F(interned_data_tokenizer_errors,       kSingle,  kInfo,     kAnalysis, ""), \
88   F(invalid_clock_snapshots,              kSingle,  kError,    kAnalysis, ""), \
89   F(invalid_cpu_times,                    kSingle,  kError,    kAnalysis, ""), \
90   F(meminfo_unknown_keys,                 kSingle,  kError,    kAnalysis, ""), \
91   F(mismatched_sched_switch_tids,         kSingle,  kError,    kAnalysis, ""), \
92   F(mm_unknown_type,                      kSingle,  kError,    kAnalysis, ""), \
93   F(parse_trace_duration_ns,              kSingle,  kInfo,     kAnalysis, ""), \
94   F(power_rail_unknown_index,             kSingle,  kError,    kTrace,    ""), \
95   F(proc_stat_unknown_counters,           kSingle,  kError,    kAnalysis, ""), \
96   F(rss_stat_unknown_keys,                kSingle,  kError,    kAnalysis, ""), \
97   F(rss_stat_negative_size,               kSingle,  kInfo,     kAnalysis, ""), \
98   F(rss_stat_unknown_thread_for_mm_id,    kSingle,  kInfo,     kAnalysis, ""), \
99   F(sched_switch_out_of_order,            kSingle,  kError,    kAnalysis, ""), \
100   F(slice_out_of_order,                   kSingle,  kError,    kAnalysis, ""), \
101   F(filter_input_bytes,                   kSingle,  kInfo,     kTrace,         \
102        "Number of bytes pre-TraceFilter. The trace file would have been this " \
103        "many bytes big if the TraceConfig didn't specify any TraceFilter. "    \
104        "This affects the actual buffer usage, as filtering happens only "      \
105        "when writing into the trace file (or over IPC)."),                     \
106   F(filter_input_packets,                 kSingle,  kInfo,     kTrace,         \
107        "Number of packets pre-TraceFilter. The trace file would have had so "  \
108        "many packets if the TraceConfig didn't specify any TraceFilter."),     \
109   F(filter_output_bytes,                  kSingle,  kInfo,     kTrace,         \
110        "Number of bytes that made it through the TraceFilter, before the "     \
111        "(optional) Zlib compression stage."),                                  \
112   F(filter_time_taken_ns,                 kSingle,  kInfo,     kTrace,         \
113        "Time cumulatively spent running the TraceFilter throughout the "       \
114        "tracing session by MaybeFilterPackets()."),                            \
115   F(filter_errors,                        kSingle,  kError,    kTrace,    ""), \
116   F(flow_duplicate_id,                    kSingle,  kError,    kTrace,    ""), \
117   F(flow_no_enclosing_slice,              kSingle,  kError,    kTrace,    ""), \
118   F(flow_step_without_start,              kSingle,  kInfo,     kTrace,    ""), \
119   F(flow_end_without_start,               kSingle,  kInfo,     kTrace,    ""), \
120   F(flow_invalid_id,                      kSingle,  kError,    kTrace,    ""), \
121   F(flow_without_direction,               kSingle,  kError,    kTrace,    ""), \
122   F(stackprofile_empty_callstack,         kSingle,  kError,    kTrace,         \
123       "Callstack had no frames. Ignored"),                                     \
124   F(stackprofile_invalid_string_id,       kSingle,  kError,    kTrace,    ""), \
125   F(stackprofile_invalid_mapping_id,      kSingle,  kError,    kTrace,    ""), \
126   F(stackprofile_invalid_frame_id,        kSingle,  kError,    kTrace,    ""), \
127   F(stackprofile_invalid_callstack_id,    kSingle,  kError,    kTrace,    ""), \
128   F(stackprofile_parser_error,            kSingle,  kError,    kTrace,    ""), \
129   F(systrace_parse_failure,               kSingle,  kError,    kAnalysis, ""), \
130   F(task_state_invalid,                   kSingle,  kError,    kAnalysis, ""), \
131   F(traced_buf_abi_violations,            kIndexed, kDataLoss, kTrace,    ""), \
132   F(traced_buf_buffer_size,               kIndexed, kInfo,     kTrace,    ""), \
133   F(traced_buf_bytes_overwritten,         kIndexed, kInfo,     kTrace,    ""), \
134   F(traced_buf_bytes_read,                kIndexed, kInfo,     kTrace,    ""), \
135   F(traced_buf_bytes_filtered_out,        kIndexed, kInfo,     kTrace,         \
136        "Number of bytes discarded (input - output) by the TraceFilter for "    \
137        "each buffer. It is a subset of, but does not add up perfectly to, "    \
138        "(filter_input_bytes - filter_output_bytes) because of the synthetic "  \
139        "metadata and stats packets generated by the tracing service itself."), \
140   F(traced_buf_bytes_written,             kIndexed, kInfo,     kTrace,    ""), \
141   F(traced_buf_chunks_discarded,          kIndexed, kInfo,     kTrace,    ""), \
142   F(traced_buf_chunks_overwritten,        kIndexed, kInfo,     kTrace,    ""), \
143   F(traced_buf_chunks_read,               kIndexed, kInfo,     kTrace,    ""), \
144   F(traced_buf_chunks_rewritten,          kIndexed, kInfo,     kTrace,    ""), \
145   F(traced_buf_chunks_written,            kIndexed, kInfo,     kTrace,    ""), \
146   F(traced_buf_chunks_committed_out_of_order,                                  \
147                                           kIndexed, kInfo,     kTrace,    ""), \
148   F(traced_buf_padding_bytes_cleared,     kIndexed, kInfo,     kTrace,    ""), \
149   F(traced_buf_padding_bytes_written,     kIndexed, kInfo,     kTrace,    ""), \
150   F(traced_buf_patches_failed,            kIndexed, kDataLoss, kTrace,         \
151       "The tracing service potentially lost data from one of the data sources "\
152       "writing into the given target_buffer. This entry can be ignored "       \
153       "if you're using DISCARD buffers and traced_buf_chunks_discarded is "    \
154       "nonzero, meaning that the buffer was filled."),                         \
155   F(traced_buf_patches_succeeded,         kIndexed, kInfo,     kTrace,    ""), \
156   F(traced_buf_readaheads_failed,         kIndexed, kInfo,     kTrace,    ""), \
157   F(traced_buf_readaheads_succeeded,      kIndexed, kInfo,     kTrace,    ""), \
158   F(traced_buf_trace_writer_packet_loss,  kIndexed, kDataLoss, kTrace,         \
159       "The tracing service observed packet loss for this buffer during this "  \
160       "tracing session. This also counts packet loss that happened before "    \
161       "the RING_BUFFER start or after the DISCARD buffer end."),               \
162   F(traced_buf_sequence_packet_loss,      kIndexed, kDataLoss, kAnalysis,      \
163       "The number of groups of consecutive packets lost in each sequence for " \
164       "this buffer"), \
165   F(traced_buf_write_wrap_count,          kIndexed, kInfo,     kTrace,    ""), \
166   F(traced_chunks_discarded,              kSingle,  kInfo,     kTrace,    ""), \
167   F(traced_data_sources_registered,       kSingle,  kInfo,     kTrace,    ""), \
168   F(traced_data_sources_seen,             kSingle,  kInfo,     kTrace,    ""), \
169   F(traced_final_flush_failed,            kSingle,  kDataLoss, kTrace,    ""), \
170   F(traced_final_flush_succeeded,         kSingle,  kInfo,     kTrace,    ""), \
171   F(traced_flushes_failed,                kSingle,  kDataLoss, kTrace,    ""), \
172   F(traced_flushes_requested,             kSingle,  kInfo,     kTrace,    ""), \
173   F(traced_flushes_succeeded,             kSingle,  kInfo,     kTrace,    ""), \
174   F(traced_patches_discarded,             kSingle,  kInfo,     kTrace,    ""), \
175   F(traced_producers_connected,           kSingle,  kInfo,     kTrace,    ""), \
176   F(traced_producers_seen,                kSingle,  kInfo,     kTrace,    ""), \
177   F(traced_total_buffers,                 kSingle,  kInfo,     kTrace,    ""), \
178   F(traced_tracing_sessions,              kSingle,  kInfo,     kTrace,    ""), \
179   F(track_event_parser_errors,            kSingle,  kInfo,     kAnalysis, ""), \
180   F(track_event_dropped_packets_outside_of_range_of_interest,                  \
181                                           kSingle,  kInfo,     kAnalysis,      \
182       "The number of TrackEvent packets dropped by trace processor due to "    \
183       "being outside of the range of interest. This happens if a trace has a " \
184       "TrackEventRangeOfInterest packet, and track event dropping is "         \
185       "enabled."),                                                             \
186   F(track_event_tokenizer_errors,         kSingle,  kInfo,     kAnalysis, ""), \
187   F(track_event_thread_invalid_end,       kSingle,  kError,    kTrace,         \
188       "The end event for a thread track does not match a track event "         \
189       "begin event. This can happen on mixed atrace/track_event traces "       \
190       "and is usually caused by data loss or bugs when the events are "        \
191       "emitted. The outcome of this is that slices can appear to be closed "   \
192       "before they were closed in reality"),                                   \
193   F(tokenizer_skipped_packets,            kSingle,  kInfo,     kAnalysis, ""), \
194   F(vmstat_unknown_keys,                  kSingle,  kError,    kAnalysis, ""), \
195   F(psi_unknown_resource,                 kSingle,  kError,    kAnalysis, ""), \
196   F(vulkan_allocations_invalid_string_id,                                      \
197                                           kSingle,  kError,    kTrace,    ""), \
198   F(clock_sync_failure,                   kSingle,  kError,    kAnalysis, ""), \
199   F(clock_sync_cache_miss,                kSingle,  kInfo,     kAnalysis, ""), \
200   F(process_tracker_errors,               kSingle,  kError,    kAnalysis, ""), \
201   F(json_tokenizer_failure,               kSingle,  kError,    kTrace,    ""), \
202   F(json_parser_failure,                  kSingle,  kError,    kTrace,    ""), \
203   F(json_display_time_unit,               kSingle,  kInfo,     kTrace,         \
204       "The displayTimeUnit key was set in the JSON trace. In some prior "      \
205       "versions of trace processor this key could effect how the trace "       \
206       "processor parsed timestamps and durations. In this version the key is " \
207       "ignored which more closely matches the bavahiour of catapult."),        \
208   F(heap_graph_invalid_string_id,         kIndexed, kError,    kTrace,    ""), \
209   F(heap_graph_non_finalized_graph,       kSingle,  kError,    kTrace,    ""), \
210   F(heap_graph_malformed_packet,          kIndexed, kError,    kTrace,    ""), \
211   F(heap_graph_missing_packet,            kIndexed, kError,    kTrace,    ""), \
212   F(heapprofd_buffer_corrupted,           kIndexed, kError,    kTrace,         \
213       "Shared memory buffer corrupted. This is a bug or memory corruption "    \
214       "in the target. Indexed by target upid."),                               \
215   F(heapprofd_hit_guardrail,              kIndexed, kError,    kTrace,         \
216       "HeapprofdConfig specified a CPU or Memory Guardrail that was hit. "     \
217       "Indexed by target upid."),                                              \
218   F(heapprofd_buffer_overran,             kIndexed, kDataLoss, kTrace,         \
219       "The shared memory buffer between the target and heapprofd overran. "    \
220       "The profile was truncated early. Indexed by target upid."),             \
221   F(heapprofd_client_error,               kIndexed, kError,    kTrace,         \
222       "The heapprofd client ran into a problem and disconnected. "             \
223       "See profile_packet.proto  for error codes."),                           \
224   F(heapprofd_client_disconnected,        kIndexed, kInfo,     kTrace,    ""), \
225   F(heapprofd_malformed_packet,           kIndexed, kError,    kTrace,    ""), \
226   F(heapprofd_missing_packet,             kSingle,  kError,    kTrace,    ""), \
227   F(heapprofd_rejected_concurrent,        kIndexed, kError,    kTrace,         \
228       "The target was already profiled by another tracing session, so the "    \
229       "profile was not taken. Indexed by target upid."),                       \
230   F(heapprofd_non_finalized_profile,      kSingle,  kError,    kTrace,    ""), \
231   F(heapprofd_sampling_interval_adjusted,                                      \
232     kIndexed, kInfo,    kTrace,                                                \
233       "By how many byes the interval for PID was increased "                   \
234       "by adaptive sampling."),                                                \
235   F(heapprofd_unwind_time_us,             kIndexed, kInfo,     kTrace,         \
236       "Time spent unwinding callstacks."),                                     \
237   F(heapprofd_unwind_samples,             kIndexed, kInfo,     kTrace,         \
238       "Number of samples unwound."),                                           \
239   F(heapprofd_client_spinlock_blocked,    kIndexed, kInfo,     kTrace,         \
240        "Time (us) the heapprofd client was blocked on the spinlock."),         \
241   F(heapprofd_last_profile_timestamp,     kIndexed, kInfo,     kTrace,         \
242        "The timestamp (in trace time) for the last dump for a process"),       \
243   F(symbolization_tmp_build_id_not_found,     kSingle,  kError,    kAnalysis,  \
244        "Number of file mappings in /data/local/tmp without a build id. "       \
245        "Symbolization doesn't work for executables in /data/local/tmp "        \
246        "because of SELinux. Please use /data/local/tests"),                    \
247   F(metatrace_overruns,                   kSingle,  kError,    kTrace,    ""), \
248   F(packages_list_has_parse_errors,       kSingle,  kError,    kTrace,    ""), \
249   F(packages_list_has_read_errors,        kSingle,  kError,    kTrace,    ""), \
250   F(game_intervention_has_parse_errors,   kSingle,  kError,    kTrace,         \
251        "One or more parsing errors occurred. This could result from "          \
252        "unknown game more or intervention added to the file to be parsed."),   \
253   F(game_intervention_has_read_errors,    kSingle,  kError,    kTrace,         \
254        "The file to be parsed can't be opened. This can happend when "         \
255        "the file name is not found or no permission to access the file"),      \
256   F(compact_sched_has_parse_errors,       kSingle,  kError,    kTrace,    ""), \
257   F(misplaced_end_event,                  kSingle,  kDataLoss, kAnalysis, ""), \
258   F(truncated_sys_write_duration,         kSingle,  kInfo,     kAnalysis,      \
259       "Count of sys_write slices that have a truncated duration to resolve "   \
260       "nesting incompatibilities with atrace slices. Real durations "          \
261       "can be recovered via the |raw| table."),                                \
262   F(sched_waking_out_of_order,            kSingle,  kError,    kAnalysis, ""), \
263   F(compact_sched_switch_skipped,         kSingle,  kInfo,     kAnalysis, ""), \
264   F(compact_sched_waking_skipped,         kSingle,  kInfo,     kAnalysis, ""), \
265   F(empty_chrome_metadata,                kSingle,  kError,    kTrace,    ""), \
266   F(ninja_parse_errors,                   kSingle,  kError,    kTrace,    ""), \
267   F(perf_cpu_lost_records,                kIndexed, kDataLoss, kTrace,    ""), \
268   F(perf_process_shard_count,             kIndexed, kInfo,     kTrace,    ""), \
269   F(perf_chosen_process_shard,            kIndexed, kInfo,     kTrace,    ""), \
270   F(perf_guardrail_stop_ts,               kIndexed, kDataLoss, kTrace,    ""), \
271   F(perf_unknown_record_type,             kIndexed, kInfo,     kAnalysis, ""), \
272   F(perf_record_skipped,                  kSingle,  kError,    kAnalysis, ""), \
273   F(perf_samples_skipped,                 kSingle,  kError,    kAnalysis, ""), \
274   F(perf_features_skipped,                kIndexed, kInfo,     kAnalysis, ""), \
275   F(perf_samples_skipped_dataloss,        kSingle,  kDataLoss, kTrace,    ""), \
276   F(perf_dummy_mapping_used,              kSingle,  kInfo,     kAnalysis, ""), \
277   F(perf_invalid_event_id,                kSingle,  kError,    kTrace,    ""), \
278   F(memory_snapshot_parser_failure,       kSingle,  kError,    kAnalysis, ""), \
279   F(thread_time_in_state_out_of_order,    kSingle,  kError,    kAnalysis, ""), \
280   F(thread_time_in_state_unknown_cpu_freq,                                     \
281                                           kSingle,  kError,    kAnalysis, ""), \
282   F(ftrace_packet_before_tracing_start,   kSingle,  kInfo,     kAnalysis,      \
283       "An ftrace packet was seen before the tracing start timestamp from "     \
284       "the tracing service. This happens if the ftrace buffers were not "      \
285       "cleared properly. These packets are silently dropped by trace "         \
286       "processor."),                                                           \
287   F(sorter_push_event_out_of_order,       kSingle, kError,     kTrace,         \
288       "Trace events are out of order event after sorting. This can happen "    \
289       "due to many factors including clock sync drift, producers emitting "    \
290       "events out of order or a bug in trace processor's logic of sorting."),  \
291   F(unknown_extension_fields,             kSingle,  kError,    kTrace,         \
292       "TraceEvent had unknown extension fields, which might result in "        \
293       "missing some arguments. You may need a newer version of trace "         \
294       "processor to parse them."),                                             \
295   F(network_trace_intern_errors,          kSingle,  kInfo,     kAnalysis, ""), \
296   F(network_trace_parse_errors,           kSingle,  kInfo,     kAnalysis, ""), \
297   F(atom_timestamp_missing,               kSingle,  kError,    kTrace,         \
298       "The corresponding timestamp_nanos entry for a StatsdAtom was "          \
299       "missing. Defaulted to inaccurate packet timestamp."),                   \
300   F(atom_unknown,                         kSingle,  kInfo,     kAnalysis,      \
301       "Unknown statsd atom. Atom descriptor may need to be updated"),          \
302   F(v8_intern_errors,                                                          \
303                                           kSingle,  kDataLoss, kAnalysis,      \
304       "Failed to resolve V8 interned data."),                                  \
305   F(v8_no_defaults,                                                            \
306                                           kSingle,  kDataLoss, kAnalysis,      \
307       "Failed to resolve V8 default data."),                                   \
308   F(v8_no_code_range,                                                          \
309                                           kSingle,  kError,    kAnalysis,      \
310       "V8 isolate had no code range."),                                        \
311   F(v8_unknown_code_type,                 kSingle,  kError,    kAnalysis, ""), \
312   F(v8_code_load_missing_code_range,      kSingle,  kError,    kAnalysis,      \
313       "V8 load had no code range or an empty one. Event ignored."),            \
314   F(winscope_inputmethod_clients_parse_errors,                                 \
315                                           kSingle,  kInfo,     kAnalysis,      \
316       "InputMethod clients packet has unknown fields, which results in "       \
317       "some arguments missing. You may need a newer version of trace "         \
318       "processor to parse them."),                                             \
319   F(winscope_inputmethod_manager_service_parse_errors,                         \
320                                           kSingle,  kInfo,     kAnalysis,      \
321       "InputMethod manager service packet has unknown fields, which results "  \
322       "in some arguments missing. You may need a newer version of trace "      \
323       "processor to parse them."),                                             \
324   F(winscope_inputmethod_service_parse_errors,                                 \
325                                           kSingle,  kInfo,     kAnalysis,      \
326       "InputMethod service packet has unknown fields, which results in "       \
327       "some arguments missing. You may need a newer version of trace "         \
328       "processor to parse them."),                                             \
329   F(winscope_sf_layers_parse_errors,      kSingle,  kInfo,     kAnalysis,      \
330       "SurfaceFlinger layers snapshot has unknown fields, which results in "   \
331       "some arguments missing. You may need a newer version of trace "         \
332       "processor to parse them."),                                             \
333   F(winscope_sf_transactions_parse_errors,                                     \
334                                           kSingle,  kInfo,     kAnalysis,      \
335       "SurfaceFlinger transactions packet has unknown fields, which results "  \
336       "in some arguments missing. You may need a newer version of trace "      \
337       "processor to parse them."),                                             \
338   F(winscope_shell_transitions_parse_errors,                                   \
339                                           kSingle,  kInfo,     kAnalysis,      \
340       "Shell transition packet has unknown fields, which results "             \
341       "in some arguments missing. You may need a newer version of trace "      \
342       "processor to parse them."),                                             \
343   F(winscope_protolog_invalid_interpolation_parse_errors,                      \
344                                           kSingle,  kInfo,     kAnalysis,      \
345       "ProtoLog message string has invalid interplation parameter."),          \
346   F(winscope_protolog_missing_interned_arg_parse_errors,                       \
347                                           kSingle,  kInfo,     kAnalysis,      \
348       "Failed to find interned ProtoLog argument."),                           \
349   F(winscope_protolog_missing_interned_stacktrace_parse_errors,                \
350                                           kSingle,  kInfo,     kAnalysis,      \
351       "Failed to find interned ProtoLog stacktrace."),                         \
352   F(winscope_viewcapture_parse_errors,                                         \
353                                           kSingle,  kInfo,     kAnalysis,      \
354       "ViewCapture packet has unknown fields, which results in some "          \
355       "arguments missing. You may need a newer version of trace processor "    \
356       "to parse them."),                                                       \
357   F(winscope_viewcapture_missing_interned_string_parse_errors,                 \
358                                           kSingle,  kInfo,     kAnalysis,      \
359       "Failed to find interned ViewCapture string."),                          \
360   F(jit_unknown_frame,                    kSingle,  kDataLoss, kTrace,         \
361       "Indicates that we were unable to determine the function for a frame in "\
362       "a jitted memory region"),                                               \
363   F(ftrace_missing_event_id,              kSingle,  kInfo,    kAnalysis,       \
364       "Indicates that the ftrace event was dropped because the event id was "  \
365       "missing. This is an 'info' stat rather than an error stat because "     \
366       "this can be legitimately missing due to proto filtering."),             \
367   F(android_input_event_parse_errors,     kSingle,  kInfo,     kAnalysis,      \
368       "Android input event packet has unknown fields, which results "          \
369       "in some arguments missing. You may need a newer version of trace "      \
370       "processor to parse them."),                                             \
371   F(mali_unknown_mcu_state_id,            kSingle,  kError,   kAnalysis,       \
372       "An invalid Mali GPU MCU state ID was detected.")
373 // clang-format on
374 
375 enum Type {
376   kSingle,  // Single-value property, one value per key.
377   kIndexed  // Indexed property, multiple value per key (e.g. cpu_stats[1]).
378 };
379 
380 enum Severity {
381   kInfo,      // Diagnostic counters
382   kDataLoss,  // Correct operation that still resulted in data loss
383   kError      // If any kError counter is > 0 trace_processor_shell will
384               // raise an error. This is also surfaced in the web UI.
385 };
386 
387 enum Source {
388   // The counter is collected when recording the trace on-device and is just
389   // being reflected in the stats table.
390   kTrace,
391 
392   // The counter is generated when importing / processing the trace in the trace
393   // processor.
394   kAnalysis
395 };
396 
397 // Ignore GCC warning about a missing argument for a variadic macro parameter.
398 #if defined(__GNUC__) || defined(__clang__)
399 #pragma GCC system_header
400 #endif
401 
402 // Declares an enum of literals (one for each stat). The enum values of each
403 // literal corresponds to the string index in the arrays below.
404 #define PERFETTO_TP_STATS_ENUM(name, ...) name
405 enum KeyIDs : size_t { PERFETTO_TP_STATS(PERFETTO_TP_STATS_ENUM), kNumKeys };
406 
407 // The code below declares an array for each property (name, type, ...).
408 
409 #define PERFETTO_TP_STATS_NAME(name, ...) #name
410 constexpr char const* kNames[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_NAME)};
411 
412 #define PERFETTO_TP_STATS_TYPE(_, type, ...) type
413 constexpr Type kTypes[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_TYPE)};
414 
415 #define PERFETTO_TP_STATS_SEVERITY(_, __, severity, ...) severity
416 constexpr Severity kSeverities[] = {
417     PERFETTO_TP_STATS(PERFETTO_TP_STATS_SEVERITY)};
418 
419 #define PERFETTO_TP_STATS_SOURCE(_, __, ___, source, ...) source
420 constexpr Source kSources[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_SOURCE)};
421 
422 #define PERFETTO_TP_STATS_DESCRIPTION(_, __, ___, ____, descr, ...) descr
423 constexpr char const* kDescriptions[] = {
424     PERFETTO_TP_STATS(PERFETTO_TP_STATS_DESCRIPTION)};
425 
426 }  // namespace stats
427 }  // namespace trace_processor
428 }  // namespace perfetto
429 
430 #endif  // SRC_TRACE_PROCESSOR_STORAGE_STATS_H_
431