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_METADATA_H_ 18 #define SRC_TRACE_PROCESSOR_STORAGE_METADATA_H_ 19 20 #include <stddef.h> 21 22 #include "src/trace_processor/types/variadic.h" 23 24 namespace perfetto { 25 namespace trace_processor { 26 namespace metadata { 27 28 // Compile time list of metadata items. 29 // clang-format off 30 #define PERFETTO_TP_METADATA(F) \ 31 F(all_data_source_flushed_ns, KeyType::kMulti, Variadic::kInt), \ 32 F(all_data_source_started_ns, KeyType::kSingle, Variadic::kInt), \ 33 F(android_build_fingerprint, KeyType::kSingle, Variadic::kString), \ 34 F(android_sdk_version, KeyType::kSingle, Variadic::kInt), \ 35 F(android_soc_model, KeyType::kSingle, Variadic::kString), \ 36 F(benchmark_description, KeyType::kSingle, Variadic::kString), \ 37 F(benchmark_had_failures, KeyType::kSingle, Variadic::kInt), \ 38 F(benchmark_label, KeyType::kSingle, Variadic::kString), \ 39 F(benchmark_name, KeyType::kSingle, Variadic::kString), \ 40 F(benchmark_start_time_us, KeyType::kSingle, Variadic::kInt), \ 41 F(benchmark_story_name, KeyType::kSingle, Variadic::kString), \ 42 F(benchmark_story_run_index, KeyType::kSingle, Variadic::kInt), \ 43 F(benchmark_story_run_time_us, KeyType::kSingle, Variadic::kInt), \ 44 F(benchmark_story_tags, KeyType::kMulti, Variadic::kString), \ 45 F(ftrace_setup_errors, KeyType::kMulti, Variadic::kString), \ 46 F(ftrace_latest_data_start_ns, KeyType::kSingle, Variadic::kInt), \ 47 F(range_of_interest_start_us, KeyType::kSingle, Variadic::kInt), \ 48 F(statsd_triggering_subscription_id, KeyType::kSingle, Variadic::kInt), \ 49 F(system_machine, KeyType::kSingle, Variadic::kString), \ 50 F(system_name, KeyType::kSingle, Variadic::kString), \ 51 F(system_release, KeyType::kSingle, Variadic::kString), \ 52 F(system_version, KeyType::kSingle, Variadic::kString), \ 53 F(timezone_off_mins, KeyType::kSingle, Variadic::kInt), \ 54 F(trace_config_pbtxt, KeyType::kSingle, Variadic::kString), \ 55 F(trace_size_bytes, KeyType::kSingle, Variadic::kInt), \ 56 F(trace_time_clock_id, KeyType::kSingle, Variadic::kInt), \ 57 F(trace_type, KeyType::kSingle, Variadic::kString), \ 58 F(trace_uuid, KeyType::kSingle, Variadic::kString), \ 59 F(tracing_disabled_ns, KeyType::kSingle, Variadic::kInt), \ 60 F(tracing_started_ns, KeyType::kSingle, Variadic::kInt), \ 61 F(ui_state, KeyType::kSingle, Variadic::kString), \ 62 F(unique_session_name, KeyType::kSingle, Variadic::kString) 63 // clang-format on 64 65 // Compile time list of metadata items. 66 // clang-format off 67 #define PERFETTO_TP_METADATA_KEY_TYPES(F) \ 68 F(kSingle, "single"), \ 69 F(kMulti, "multi") 70 // clang-format 71 72 // Ignore GCC warning about a missing argument for a variadic macro parameter. 73 #if defined(__GNUC__) || defined(__clang__) 74 #pragma GCC system_header 75 #endif 76 77 #define PERFETTO_TP_META_TYPE_ENUM(varname, ...) varname 78 enum class KeyType : size_t { 79 PERFETTO_TP_METADATA_KEY_TYPES(PERFETTO_TP_META_TYPE_ENUM), 80 kNumKeyTypes, 81 }; 82 83 #define PERFETTO_TP_META_TYPE_NAME(_, name, ...) name 84 constexpr char const* kKeyTypeNames[] = { 85 PERFETTO_TP_METADATA_KEY_TYPES(PERFETTO_TP_META_TYPE_NAME) 86 }; 87 88 // Declares an enum of literals (one for each item). The enum values of each 89 // literal corresponds to the string index in the arrays below. 90 #define PERFETTO_TP_META_ENUM(name, ...) name 91 enum KeyId : size_t { 92 PERFETTO_TP_METADATA(PERFETTO_TP_META_ENUM), 93 kNumKeys 94 }; 95 96 // The code below declares an array for each property: 97 // name, key type, value type. 98 99 #define PERFETTO_TP_META_NAME(name, ...) #name 100 constexpr char const* kNames[] = { 101 PERFETTO_TP_METADATA(PERFETTO_TP_META_NAME)}; 102 103 #define PERFETTO_TP_META_KEYTYPE(_, type, ...) type 104 constexpr KeyType kKeyTypes[] = { 105 PERFETTO_TP_METADATA(PERFETTO_TP_META_KEYTYPE)}; 106 107 #define PERFETTO_TP_META_VALUETYPE(_, __, type, ...) type 108 constexpr Variadic::Type kValueTypes[] = { 109 PERFETTO_TP_METADATA(PERFETTO_TP_META_VALUETYPE)}; 110 111 } // namespace metadata 112 } // namespace trace_processor 113 } // namespace perfetto 114 115 #endif // SRC_TRACE_PROCESSOR_STORAGE_METADATA_H_ 116