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_IMPORTERS_PROTO_TRACK_EVENT_PARSER_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_TRACK_EVENT_PARSER_H_ 19 20 #include "perfetto/base/build_config.h" 21 #include "perfetto/protozero/field.h" 22 #include "src/trace_processor/args_tracker.h" 23 #include "src/trace_processor/importers/proto/args_table_utils.h" 24 #include "src/trace_processor/slice_tracker.h" 25 #include "src/trace_processor/storage/trace_storage.h" 26 #include "src/trace_processor/timestamped_trace_piece.h" 27 28 #include "protos/perfetto/trace/track_event/track_event.pbzero.h" 29 30 namespace Json { 31 class Value; 32 } 33 34 namespace perfetto { 35 36 namespace trace_processor { 37 38 class PacketSequenceStateGeneration; 39 class TraceProcessorContext; 40 41 class TrackEventParser { 42 public: 43 explicit TrackEventParser(TraceProcessorContext* context); 44 45 void ParseTrackDescriptor(protozero::ConstBytes); 46 UniquePid ParseProcessDescriptor(protozero::ConstBytes); 47 UniqueTid ParseThreadDescriptor(protozero::ConstBytes); 48 49 void ParseTrackEvent(int64_t ts, 50 TrackEventData* event_data, 51 protozero::ConstBytes); 52 53 private: 54 class EventImporter; 55 56 void ParseChromeProcessDescriptor(UniquePid, protozero::ConstBytes); 57 void ParseChromeThreadDescriptor(UniqueTid, protozero::ConstBytes); 58 void ParseCounterDescriptor(TrackId, protozero::ConstBytes); 59 60 TraceProcessorContext* context_; 61 ProtoToArgsTable proto_to_args_; 62 63 const StringId counter_name_thread_time_id_; 64 const StringId counter_name_thread_instruction_count_id_; 65 const StringId task_file_name_args_key_id_; 66 const StringId task_function_name_args_key_id_; 67 const StringId task_line_number_args_key_id_; 68 const StringId log_message_body_key_id_; 69 const StringId raw_legacy_event_id_; 70 const StringId legacy_event_passthrough_utid_id_; 71 const StringId legacy_event_category_key_id_; 72 const StringId legacy_event_name_key_id_; 73 const StringId legacy_event_phase_key_id_; 74 const StringId legacy_event_duration_ns_key_id_; 75 const StringId legacy_event_thread_timestamp_ns_key_id_; 76 const StringId legacy_event_thread_duration_ns_key_id_; 77 const StringId legacy_event_thread_instruction_count_key_id_; 78 const StringId legacy_event_thread_instruction_delta_key_id_; 79 const StringId legacy_event_use_async_tts_key_id_; 80 const StringId legacy_event_unscoped_id_key_id_; 81 const StringId legacy_event_global_id_key_id_; 82 const StringId legacy_event_local_id_key_id_; 83 const StringId legacy_event_id_scope_key_id_; 84 const StringId legacy_event_bind_id_key_id_; 85 const StringId legacy_event_bind_to_enclosing_key_id_; 86 const StringId legacy_event_flow_direction_key_id_; 87 const StringId flow_direction_value_in_id_; 88 const StringId flow_direction_value_out_id_; 89 const StringId flow_direction_value_inout_id_; 90 const StringId chrome_user_event_action_args_key_id_; 91 const StringId chrome_user_event_action_hash_args_key_id_; 92 const StringId chrome_legacy_ipc_class_args_key_id_; 93 const StringId chrome_legacy_ipc_line_args_key_id_; 94 const StringId chrome_keyed_service_name_args_key_id_; 95 const StringId chrome_histogram_sample_name_hash_args_key_id_; 96 const StringId chrome_histogram_sample_name_args_key_id_; 97 const StringId chrome_histogram_sample_sample_args_key_id_; 98 const StringId chrome_latency_info_trace_id_key_id_; 99 const StringId chrome_latency_info_step_key_id_; 100 const StringId chrome_latency_info_frame_tree_node_id_key_id_; 101 102 std::array<StringId, 8> chrome_latency_info_step_ids_; 103 std::array<StringId, 38> chrome_legacy_ipc_class_ids_; 104 std::array<StringId, 9> chrome_process_name_ids_; 105 std::array<StringId, 14> chrome_thread_name_ids_; 106 std::array<StringId, 4> counter_unit_ids_; 107 }; 108 109 } // namespace trace_processor 110 } // namespace perfetto 111 112 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_TRACK_EVENT_PARSER_H_ 113