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 INCLUDE_PERFETTO_EXT_BASE_METATRACE_EVENTS_H_
18 #define INCLUDE_PERFETTO_EXT_BASE_METATRACE_EVENTS_H_
19
20 #include <stdint.h>
21
22 namespace perfetto {
23 namespace metatrace {
24
25 enum Tags : uint32_t {
26 TAG_NONE = 0,
27 TAG_ANY = uint32_t(-1),
28 TAG_FTRACE = 1 << 0,
29 TAG_PROC_POLLERS = 1 << 1,
30 TAG_TRACE_WRITER = 1 << 2,
31 TAG_TRACE_SERVICE = 1 << 3,
32 TAG_PRODUCER = 1 << 4,
33 };
34
35 // The macros below generate matching enums and arrays of string literals.
36 // This is to avoid maintaining string maps manually.
37
38 // clang-format off
39
40 // DO NOT remove or reshuffle items in this list, only append. The ID of these
41 // events are an ABI, the trace processor relies on these to open old traces.
42 #define PERFETTO_METATRACE_EVENTS(F) \
43 F(EVENT_ZERO_UNUSED), \
44 F(FTRACE_CPU_READER_READ), /*unused*/ \
45 F(FTRACE_DRAIN_CPUS), /*unused*/ \
46 F(FTRACE_UNBLOCK_READERS), /*unused*/ \
47 F(FTRACE_CPU_READ_NONBLOCK), /*unused*/ \
48 F(FTRACE_CPU_READ_BLOCK), /*unused*/ \
49 F(FTRACE_CPU_SPLICE_NONBLOCK), /*unused*/ \
50 F(FTRACE_CPU_SPLICE_BLOCK), /*unused*/ \
51 F(FTRACE_CPU_WAIT_CMD), /*unused*/ \
52 F(FTRACE_CPU_RUN_CYCLE), /*unused*/ \
53 F(FTRACE_CPU_FLUSH), \
54 F(FTRACE_CPU_DRAIN), /*unused*/ \
55 F(READ_SYS_STATS), \
56 F(PS_WRITE_ALL_PROCESSES), \
57 F(PS_ON_PIDS), \
58 F(PS_ON_RENAME_PIDS), \
59 F(PS_WRITE_ALL_PROCESS_STATS), \
60 F(TRACE_WRITER_COMMIT_STARTUP_WRITER_BATCH), \
61 F(FTRACE_READ_TICK), \
62 F(FTRACE_CPU_READ_CYCLE), \
63 F(FTRACE_CPU_READ_BATCH), \
64 F(KALLSYMS_PARSE), \
65 F(PROFILER_READ_TICK), \
66 F(PROFILER_READ_CPU), \
67 F(PROFILER_UNWIND_TICK), \
68 F(PROFILER_UNWIND_SAMPLE), \
69 F(PROFILER_UNWIND_INITIAL_ATTEMPT), \
70 F(PROFILER_UNWIND_ATTEMPT), \
71 F(PROFILER_MAPS_PARSE), \
72 F(PROFILER_MAPS_REPARSE), \
73 F(PROFILER_UNWIND_CACHE_CLEAR)
74
75 // Append only, see above.
76 //
77 // Values that aren't used as counters:
78 // * FTRACE_SERVICE_COMMIT_DATA is a bit-packed representation of an event, see
79 // tracing_service_impl.cc for the format.
80 // * PROFILER_UNWIND_CURRENT_PID represents the PID that is being unwound.
81 //
82 #define PERFETTO_METATRACE_COUNTERS(F) \
83 F(COUNTER_ZERO_UNUSED),\
84 F(FTRACE_PAGES_DRAINED), \
85 F(PS_PIDS_SCANNED), \
86 F(TRACE_SERVICE_COMMIT_DATA), \
87 F(PROFILER_UNWIND_QUEUE_SZ), \
88 F(PROFILER_UNWIND_CURRENT_PID)
89
90 // clang-format on
91
92 #define PERFETTO_METATRACE_IDENTITY(name) name
93 #define PERFETTO_METATRACE_TOSTRING(name) #name
94
95 enum Events : uint16_t {
96 PERFETTO_METATRACE_EVENTS(PERFETTO_METATRACE_IDENTITY),
97 EVENTS_MAX
98 };
99 constexpr char const* kEventNames[] = {
100 PERFETTO_METATRACE_EVENTS(PERFETTO_METATRACE_TOSTRING)};
101
102 enum Counters : uint16_t {
103 PERFETTO_METATRACE_COUNTERS(PERFETTO_METATRACE_IDENTITY),
104 COUNTERS_MAX
105 };
106 constexpr char const* kCounterNames[] = {
107 PERFETTO_METATRACE_COUNTERS(PERFETTO_METATRACE_TOSTRING)};
108
SuppressUnusedVarsInAmalgamatedBuild()109 inline void SuppressUnusedVarsInAmalgamatedBuild() {
110 (void)kCounterNames;
111 (void)kEventNames;
112 }
113
114 } // namespace metatrace
115 } // namespace perfetto
116
117 #endif // INCLUDE_PERFETTO_EXT_BASE_METATRACE_EVENTS_H_
118