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_TOKENIZER_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_TRACK_EVENT_TOKENIZER_H_ 19 20 #include <stdint.h> 21 22 #include "perfetto/protozero/proto_decoder.h" 23 #include "src/trace_processor/importers/proto/proto_importer_module.h" 24 #include "src/trace_processor/storage/trace_storage.h" 25 26 namespace perfetto { 27 28 namespace protos { 29 namespace pbzero { 30 class ChromeThreadDescriptor_Decoder; 31 class ProcessDescriptor_Decoder; 32 class ThreadDescriptor_Decoder; 33 class TracePacket_Decoder; 34 } // namespace pbzero 35 } // namespace protos 36 37 namespace trace_processor { 38 39 class PacketSequenceState; 40 class TraceProcessorContext; 41 class TraceBlobView; 42 class TrackEventTracker; 43 struct TrackEventData; 44 45 class TrackEventTokenizer { 46 public: 47 explicit TrackEventTokenizer(TraceProcessorContext*, TrackEventTracker*); 48 49 ModuleResult TokenizeRangeOfInterestPacket( 50 PacketSequenceState* state, 51 const protos::pbzero::TracePacket_Decoder&, 52 int64_t packet_timestamp); 53 ModuleResult TokenizeTrackDescriptorPacket( 54 PacketSequenceState* state, 55 const protos::pbzero::TracePacket_Decoder&, 56 int64_t packet_timestamp); 57 ModuleResult TokenizeThreadDescriptorPacket( 58 PacketSequenceState* state, 59 const protos::pbzero::TracePacket_Decoder&); 60 void TokenizeTrackEventPacket(PacketSequenceState* state, 61 const protos::pbzero::TracePacket_Decoder&, 62 TraceBlobView* packet, 63 int64_t packet_timestamp); 64 65 private: 66 void TokenizeThreadDescriptor( 67 PacketSequenceState* state, 68 const protos::pbzero::ThreadDescriptor_Decoder&); 69 template <typename T> 70 base::Status AddExtraCounterValues( 71 TrackEventData& data, 72 size_t& index, 73 uint32_t trusted_packet_sequence_id, 74 protozero::RepeatedFieldIterator<T> value_it, 75 protozero::RepeatedFieldIterator<uint64_t> packet_track_uuid_it, 76 protozero::RepeatedFieldIterator<uint64_t> default_track_uuid_it); 77 78 TraceProcessorContext* context_; 79 TrackEventTracker* track_event_tracker_; 80 81 const StringId counter_name_thread_time_id_; 82 const StringId counter_name_thread_instruction_count_id_; 83 }; 84 85 } // namespace trace_processor 86 } // namespace perfetto 87 88 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_TRACK_EVENT_TOKENIZER_H_ 89