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