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_TABLES_TRACK_TABLES_H_
18 #define SRC_TRACE_PROCESSOR_TABLES_TRACK_TABLES_H_
19 
20 #include "src/trace_processor/tables/macros.h"
21 
22 namespace perfetto {
23 namespace trace_processor {
24 namespace tables {
25 
26 // @tablegroup Tracks
27 // @param source_arg_set_id {@joinable args.arg_set_id}
28 #define PERFETTO_TP_TRACK_TABLE_DEF(NAME, PARENT, C) \
29   NAME(TrackTable, "track")                          \
30   PERFETTO_TP_ROOT_TABLE(PARENT, C)                  \
31   C(StringPool::Id, name)                            \
32   C(base::Optional<uint32_t>, source_arg_set_id)
33 
34 PERFETTO_TP_TABLE(PERFETTO_TP_TRACK_TABLE_DEF);
35 
36 // @tablegroup Tracks
37 #define PERFETTO_TP_PROCESS_TRACK_TABLE_DEF(NAME, PARENT, C) \
38   NAME(ProcessTrackTable, "process_track")                   \
39   PARENT(PERFETTO_TP_TRACK_TABLE_DEF, C)                     \
40   C(uint32_t, upid)
41 
42 PERFETTO_TP_TABLE(PERFETTO_TP_PROCESS_TRACK_TABLE_DEF);
43 
44 // @tablegroup Tracks
45 #define PERFETTO_TP_THREAD_TRACK_TABLE_DEF(NAME, PARENT, C) \
46   NAME(ThreadTrackTable, "thread_track")                    \
47   PARENT(PERFETTO_TP_TRACK_TABLE_DEF, C)                    \
48   C(uint32_t, utid)
49 
50 PERFETTO_TP_TABLE(PERFETTO_TP_THREAD_TRACK_TABLE_DEF);
51 
52 // @tablegroup Tracks
53 #define PERFETTO_TP_GPU_TRACK_DEF(NAME, PARENT, C) \
54   NAME(GpuTrackTable, "gpu_track")                 \
55   PARENT(PERFETTO_TP_TRACK_TABLE_DEF, C)           \
56   C(StringPool::Id, scope)                         \
57   C(StringPool::Id, description)                   \
58   C(base::Optional<int64_t>, context_id)
59 
60 PERFETTO_TP_TABLE(PERFETTO_TP_GPU_TRACK_DEF);
61 
62 // @tablegroup Tracks
63 #define PERFETTO_TP_COUNTER_TRACK_DEF(NAME, PARENT, C) \
64   NAME(CounterTrackTable, "counter_track")             \
65   PARENT(PERFETTO_TP_TRACK_TABLE_DEF, C)               \
66   C(StringPool::Id, unit)                              \
67   C(StringPool::Id, description)
68 
69 PERFETTO_TP_TABLE(PERFETTO_TP_COUNTER_TRACK_DEF);
70 
71 // @tablegroup Tracks
72 #define PERFETTO_TP_THREAD_COUNTER_TRACK_DEF(NAME, PARENT, C) \
73   NAME(ThreadCounterTrackTable, "thread_counter_track")       \
74   PARENT(PERFETTO_TP_COUNTER_TRACK_DEF, C)                    \
75   C(uint32_t, utid)
76 
77 PERFETTO_TP_TABLE(PERFETTO_TP_THREAD_COUNTER_TRACK_DEF);
78 
79 // @tablegroup Tracks
80 #define PERFETTO_TP_PROCESS_COUNTER_TRACK_DEF(NAME, PARENT, C) \
81   NAME(ProcessCounterTrackTable, "process_counter_track")      \
82   PARENT(PERFETTO_TP_COUNTER_TRACK_DEF, C)                     \
83   C(uint32_t, upid)
84 
85 PERFETTO_TP_TABLE(PERFETTO_TP_PROCESS_COUNTER_TRACK_DEF);
86 
87 // @tablegroup Tracks
88 #define PERFETTO_TP_CPU_COUNTER_TRACK_DEF(NAME, PARENT, C) \
89   NAME(CpuCounterTrackTable, "cpu_counter_track")          \
90   PARENT(PERFETTO_TP_COUNTER_TRACK_DEF, C)                 \
91   C(uint32_t, cpu)
92 
93 PERFETTO_TP_TABLE(PERFETTO_TP_CPU_COUNTER_TRACK_DEF);
94 
95 // @tablegroup Tracks
96 #define PERFETTO_TP_IRQ_COUNTER_TRACK_DEF(NAME, PARENT, C) \
97   NAME(IrqCounterTrackTable, "irq_counter_track")          \
98   PARENT(PERFETTO_TP_COUNTER_TRACK_DEF, C)                 \
99   C(int32_t, irq)
100 
101 PERFETTO_TP_TABLE(PERFETTO_TP_IRQ_COUNTER_TRACK_DEF);
102 
103 // @tablegroup Tracks
104 #define PERFETTO_TP_SOFTIRQ_COUNTER_TRACK_DEF(NAME, PARENT, C) \
105   NAME(SoftirqCounterTrackTable, "softirq_counter_track")      \
106   PARENT(PERFETTO_TP_COUNTER_TRACK_DEF, C)                     \
107   C(int32_t, softirq)
108 
109 PERFETTO_TP_TABLE(PERFETTO_TP_SOFTIRQ_COUNTER_TRACK_DEF);
110 
111 // @tablegroup Tracks
112 #define PERFETTO_TP_GPU_COUNTER_TRACK_DEF(NAME, PARENT, C) \
113   NAME(GpuCounterTrackTable, "gpu_counter_track")          \
114   PARENT(PERFETTO_TP_COUNTER_TRACK_DEF, C)                 \
115   C(uint32_t, gpu_id)
116 
117 PERFETTO_TP_TABLE(PERFETTO_TP_GPU_COUNTER_TRACK_DEF);
118 
119 // Sampled counters' values for samples in the perf_sample table.
120 //
121 // @param perf_session_id id of a distict profiling stream.
122 //        {@joinable perf_sample.perf_session_id}
123 // @param cpu the core the sample was taken on.
124 // @is_timebase if true, this counter was the sampling timebase for this
125 //              perf_session_id.
126 // @tablegroup Tracks
127 #define PERFETTO_TP_PERF_COUNTER_TRACK_DEF(NAME, PARENT, C) \
128   NAME(PerfCounterTrackTable, "perf_counter_track")         \
129   PARENT(PERFETTO_TP_COUNTER_TRACK_DEF, C)                  \
130   C(uint32_t, perf_session_id)                              \
131   C(uint32_t, cpu)                                          \
132   C(uint32_t, is_timebase)
133 
134 PERFETTO_TP_TABLE(PERFETTO_TP_PERF_COUNTER_TRACK_DEF);
135 
136 }  // namespace tables
137 }  // namespace trace_processor
138 }  // namespace perfetto
139 
140 #endif  // SRC_TRACE_PROCESSOR_TABLES_TRACK_TABLES_H_
141