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