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 #define PERFETTO_TP_ARG_TABLE_DEF(NAME, PARENT, C) \ 39 NAME(ArgTable, "args") \ 40 PERFETTO_TP_ROOT_TABLE(PARENT, C) \ 41 C(uint32_t, arg_set_id, Column::Flag::kSorted) \ 42 C(StringPool::Id, flat_key) \ 43 C(StringPool::Id, key) \ 44 C(base::Optional<int64_t>, int_value) \ 45 C(base::Optional<StringPool::Id>, string_value) \ 46 C(base::Optional<double>, real_value) \ 47 C(StringPool::Id, value_type) 48 49 PERFETTO_TP_TABLE(PERFETTO_TP_ARG_TABLE_DEF); 50 51 #define PERFETTO_TP_METADATA_TABLE_DEF(NAME, PARENT, C) \ 52 NAME(MetadataTable, "metadata") \ 53 PERFETTO_TP_ROOT_TABLE(PARENT, C) \ 54 C(StringPool::Id, name) \ 55 C(StringPool::Id, key_type) \ 56 C(base::Optional<int64_t>, int_value) \ 57 C(base::Optional<StringPool::Id>, str_value) 58 59 PERFETTO_TP_TABLE(PERFETTO_TP_METADATA_TABLE_DEF); 60 61 // @name thread 62 // @param utid {uint32_t} Unique thread id. This is != the OS tid. This is a 63 // monotonic number associated to each thread. The OS thread id (tid) 64 // cannot be used as primary key because tids and pids are recycled 65 // by most kernels. 66 // @param upid {@joinable process.upid} 67 #define PERFETTO_TP_THREAD_TABLE_DEF(NAME, PARENT, C) \ 68 NAME(ThreadTable, "internal_thread") \ 69 PERFETTO_TP_ROOT_TABLE(PARENT, C) \ 70 C(uint32_t, tid) \ 71 C(StringPool::Id, name) \ 72 C(base::Optional<int64_t>, start_ts) \ 73 C(base::Optional<int64_t>, end_ts) \ 74 C(base::Optional<uint32_t>, upid) \ 75 C(base::Optional<uint32_t>, is_main_thread) 76 77 PERFETTO_TP_TABLE(PERFETTO_TP_THREAD_TABLE_DEF); 78 79 // @name process 80 // @param upid {uint32_t} Unique process id. This is != the OS pid. This is a 81 // monotonic number associated to each process. The OS process id (pid) 82 // cannot be used as primary key because tids and pids are recycled by 83 // most kernels. 84 // @param uid The Unix user id of the process {@joinable package_list.uid}. 85 #define PERFETTO_TP_PROCESS_TABLE_DEF(NAME, PARENT, C) \ 86 NAME(ProcessTable, "internal_process") \ 87 PERFETTO_TP_ROOT_TABLE(PARENT, C) \ 88 C(uint32_t, pid) \ 89 C(StringPool::Id, name) \ 90 C(base::Optional<int64_t>, start_ts) \ 91 C(base::Optional<int64_t>, end_ts) \ 92 C(base::Optional<uint32_t>, parent_upid) \ 93 C(base::Optional<uint32_t>, uid) \ 94 C(base::Optional<uint32_t>, android_appid) \ 95 C(base::Optional<StringPool::Id>, cmdline) \ 96 C(uint32_t, arg_set_id) 97 98 PERFETTO_TP_TABLE(PERFETTO_TP_PROCESS_TABLE_DEF); 99 100 #define PERFETTO_TP_CPU_TABLE_DEF(NAME, PARENT, C) \ 101 NAME(CpuTable, "cpu") \ 102 PERFETTO_TP_ROOT_TABLE(PARENT, C) \ 103 C(uint32_t, time_in_state_cpu_id) \ 104 C(StringPool::Id, processor) 105 106 PERFETTO_TP_TABLE(PERFETTO_TP_CPU_TABLE_DEF); 107 108 #define PERFETTO_TP_CPU_FREQ_TABLE_DEF(NAME, PARENT, C) \ 109 NAME(CpuFreqTable, "cpu_freq") \ 110 PERFETTO_TP_ROOT_TABLE(PARENT, C) \ 111 C(CpuTable::Id, cpu_id) \ 112 C(uint32_t, freq) 113 114 PERFETTO_TP_TABLE(PERFETTO_TP_CPU_FREQ_TABLE_DEF); 115 116 // Contains all the mapping between clock snapshots and trace time. 117 // 118 // NOTE: this table is not sorted by timestamp; this is why we omit the 119 // sorted flag on the ts column. 120 // 121 // @param ts timestamp of the snapshot in trace time. 122 // @param clock_id id of the clock (corresponds to the id in the trace). 123 // @param clock_name the name of the clock for builtin clocks or null 124 // otherwise. 125 // @param clock_value timestamp of the snapshot in clock time. 126 // @param snapshot_id the index of this snapshot (only useful for debugging) 127 #define PERFETTO_TP_CLOCK_SNAPSHOT_TABLE_DEF(NAME, PARENT, C) \ 128 NAME(ClockSnapshotTable, "clock_snapshot") \ 129 PERFETTO_TP_ROOT_TABLE(PARENT, C) \ 130 C(int64_t, ts) \ 131 C(int64_t, clock_id) \ 132 C(base::Optional<StringPool::Id>, clock_name) \ 133 C(int64_t, clock_value) \ 134 C(uint32_t, snapshot_id) 135 136 PERFETTO_TP_TABLE(PERFETTO_TP_CLOCK_SNAPSHOT_TABLE_DEF); 137 138 } // namespace tables 139 } // namespace trace_processor 140 } // namespace perfetto 141 142 #endif // SRC_TRACE_PROCESSOR_TABLES_METADATA_TABLES_H_ 143