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