• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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_METADATA_TABLES_H_
18 #define SRC_TRACE_PROCESSOR_TABLES_METADATA_TABLES_H_
19 
20 #include "src/trace_processor/tables/macros.h"
21 
22 namespace perfetto {
23 namespace trace_processor {
24 namespace tables {
25 
26 // @param arg_set_id {@joinable args.arg_set_id}
27 #define PERFETTO_TP_RAW_TABLE_DEF(NAME, PARENT, C) \
28   NAME(RawTable, "raw")                            \
29   PERFETTO_TP_ROOT_TABLE(PARENT, C)                \
30   C(int64_t, ts, Column::Flag::kSorted)            \
31   C(StringPool::Id, name)                          \
32   C(uint32_t, cpu)                                 \
33   C(uint32_t, utid)                                \
34   C(uint32_t, arg_set_id)
35 
36 PERFETTO_TP_TABLE(PERFETTO_TP_RAW_TABLE_DEF);
37 
38 // @name args
39 #define PERFETTO_TP_ARG_TABLE_DEF(NAME, PARENT, C) \
40   NAME(ArgTable, "internal_args")                  \
41   PERFETTO_TP_ROOT_TABLE(PARENT, C)                \
42   C(uint32_t, arg_set_id, Column::Flag::kSorted)   \
43   C(StringPool::Id, flat_key)                      \
44   C(StringPool::Id, key)                           \
45   C(base::Optional<int64_t>, int_value)            \
46   C(base::Optional<StringPool::Id>, string_value)  \
47   C(base::Optional<double>, real_value)            \
48   C(StringPool::Id, value_type)
49 
50 PERFETTO_TP_TABLE(PERFETTO_TP_ARG_TABLE_DEF);
51 
52 #define PERFETTO_TP_METADATA_TABLE_DEF(NAME, PARENT, C) \
53   NAME(MetadataTable, "metadata")                       \
54   PERFETTO_TP_ROOT_TABLE(PARENT, C)                     \
55   C(StringPool::Id, name)                               \
56   C(StringPool::Id, key_type)                           \
57   C(base::Optional<int64_t>, int_value)                 \
58   C(base::Optional<StringPool::Id>, str_value)
59 
60 PERFETTO_TP_TABLE(PERFETTO_TP_METADATA_TABLE_DEF);
61 
62 // Contains information of threads seen during the trace
63 //
64 // @name thread
65 // @param utid             {uint32_t} Unique thread id. This is != the OS tid.
66 //                         This is a monotonic number associated to each thread.
67 //                         The OS thread id (tid) cannot be used as primary key
68 //                         because tids and pids are recycled by most kernels.
69 // @param tid              The OS id for this thread. Note: this is *not*
70 //                         unique over the lifetime of the trace so cannot be
71 //                         used as a primary key. Use |utid| instead.
72 // @param name             The name of the thread. Can be populated from many
73 //                         sources (e.g. ftrace, /proc scraping, track event
74 //                         etc).
75 // @param start_ts         The start timestamp of this thread (if known). Is
76 //                         null in most cases unless a thread creation event is
77 //                         enabled (e.g. task_newtask ftrace event on
78 //                         Linux/Android).
79 // @param end_ts           The end timestamp of this thread (if known). Is
80 //                         null in most cases unless a thread destruction event
81 //                         is enabled (e.g. sched_process_free ftrace event on
82 //                         Linux/Android).
83 // @param upid             {@joinable process.upid} The process hosting this
84 //                         thread.
85 // @param is_main_thread   Boolean indicating if this thread is the main thread
86 //                         in the process.
87 #define PERFETTO_TP_THREAD_TABLE_DEF(NAME, PARENT, C) \
88   NAME(ThreadTable, "internal_thread")                \
89   PERFETTO_TP_ROOT_TABLE(PARENT, C)                   \
90   C(uint32_t, tid)                                    \
91   C(base::Optional<StringPool::Id>, name)             \
92   C(base::Optional<int64_t>, start_ts)                \
93   C(base::Optional<int64_t>, end_ts)                  \
94   C(base::Optional<uint32_t>, upid)                   \
95   C(base::Optional<uint32_t>, is_main_thread)
96 
97 PERFETTO_TP_TABLE(PERFETTO_TP_THREAD_TABLE_DEF);
98 
99 // Contains information of processes seen during the trace
100 //
101 // @name process
102 // @param upid            {uint32_t} Unique process id. This is != the OS pid.
103 //                        This is a monotonic number associated to each process.
104 //                        The OS process id (pid) cannot be used as primary key
105 //                        because tids and pids are recycled by most kernels.
106 // @param pid             The OS id for this process. Note: this is *not*
107 //                        unique over the lifetime of the trace so cannot be
108 //                        used as a primary key. Use |upid| instead.
109 // @param name            The name of the process. Can be populated from many
110 //                        sources (e.g. ftrace, /proc scraping, track event
111 //                        etc).
112 // @param start_ts        The start timestamp of this process (if known). Is
113 //                        null in most cases unless a process creation event is
114 //                        enabled (e.g. task_newtask ftrace event on
115 //                        Linux/Android).
116 // @param end_ts          The end timestamp of this process (if known). Is
117 //                        null in most cases unless a process destruction event
118 //                        is enabled (e.g. sched_process_free ftrace event on
119 //                        Linux/Android).
120 // @param parent_upid     {@joinable process.upid} The upid of the process which
121 //                        caused this process to be spawned.
122 // @param uid             {@joinable package_list.uid} The Unix user id of the
123 //                        process.
124 // @param android_appid   Android appid of this process.
125 // @param cmdline         /proc/cmdline for this process.
126 // @param arg_set_id      {@joinable args.arg_set_id} Extra args for this
127 //                        process.
128 #define PERFETTO_TP_PROCESS_TABLE_DEF(NAME, PARENT, C) \
129   NAME(ProcessTable, "internal_process")               \
130   PERFETTO_TP_ROOT_TABLE(PARENT, C)                    \
131   C(uint32_t, pid)                                     \
132   C(base::Optional<StringPool::Id>, name)              \
133   C(base::Optional<int64_t>, start_ts)                 \
134   C(base::Optional<int64_t>, end_ts)                   \
135   C(base::Optional<uint32_t>, parent_upid)             \
136   C(base::Optional<uint32_t>, uid)                     \
137   C(base::Optional<uint32_t>, android_appid)           \
138   C(base::Optional<StringPool::Id>, cmdline)           \
139   C(uint32_t, arg_set_id)
140 
141 PERFETTO_TP_TABLE(PERFETTO_TP_PROCESS_TABLE_DEF);
142 
143 #define PERFETTO_TP_CPU_TABLE_DEF(NAME, PARENT, C) \
144   NAME(CpuTable, "cpu")                            \
145   PERFETTO_TP_ROOT_TABLE(PARENT, C)                \
146   C(uint32_t, time_in_state_cpu_id)                \
147   C(StringPool::Id, processor)
148 
149 PERFETTO_TP_TABLE(PERFETTO_TP_CPU_TABLE_DEF);
150 
151 #define PERFETTO_TP_CPU_FREQ_TABLE_DEF(NAME, PARENT, C) \
152   NAME(CpuFreqTable, "cpu_freq")                        \
153   PERFETTO_TP_ROOT_TABLE(PARENT, C)                     \
154   C(CpuTable::Id, cpu_id)                               \
155   C(uint32_t, freq)
156 
157 PERFETTO_TP_TABLE(PERFETTO_TP_CPU_FREQ_TABLE_DEF);
158 
159 // Contains all the mapping between clock snapshots and trace time.
160 //
161 // NOTE: this table is not sorted by timestamp; this is why we omit the
162 // sorted flag on the ts column.
163 //
164 // @param ts            timestamp of the snapshot in trace time.
165 // @param clock_id      id of the clock (corresponds to the id in the trace).
166 // @param clock_name    the name of the clock for builtin clocks or null
167 //                      otherwise.
168 // @param clock_value   timestamp of the snapshot in clock time.
169 // @param snapshot_id   the index of this snapshot (only useful for debugging)
170 #define PERFETTO_TP_CLOCK_SNAPSHOT_TABLE_DEF(NAME, PARENT, C) \
171   NAME(ClockSnapshotTable, "clock_snapshot")                  \
172   PERFETTO_TP_ROOT_TABLE(PARENT, C)                           \
173   C(int64_t, ts)                                              \
174   C(int64_t, clock_id)                                        \
175   C(base::Optional<StringPool::Id>, clock_name)               \
176   C(int64_t, clock_value)                                     \
177   C(uint32_t, snapshot_id)
178 
179 PERFETTO_TP_TABLE(PERFETTO_TP_CLOCK_SNAPSHOT_TABLE_DEF);
180 
181 }  // namespace tables
182 }  // namespace trace_processor
183 }  // namespace perfetto
184 
185 #endif  // SRC_TRACE_PROCESSOR_TABLES_METADATA_TABLES_H_
186