1 /* 2 * Copyright (C) 2018 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_PROTO_TRACE_PARSER_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_PROTO_TRACE_PARSER_H_ 19 20 #include <stdint.h> 21 22 #include <array> 23 #include <memory> 24 25 #include "perfetto/ext/base/optional.h" 26 #include "perfetto/ext/base/string_view.h" 27 #include "perfetto/protozero/field.h" 28 #include "src/trace_processor/storage/trace_storage.h" 29 #include "src/trace_processor/timestamped_trace_piece.h" 30 #include "src/trace_processor/trace_blob_view.h" 31 #include "src/trace_processor/trace_parser.h" 32 33 namespace perfetto { 34 35 namespace protos { 36 namespace pbzero { 37 class TracePacket_Decoder; 38 } // namespace pbzero 39 } // namespace protos 40 41 namespace trace_processor { 42 43 class ArgsTracker; 44 class PacketSequenceState; 45 class TraceProcessorContext; 46 47 class ProtoTraceParser : public TraceParser { 48 public: 49 using ConstBytes = protozero::ConstBytes; 50 explicit ProtoTraceParser(TraceProcessorContext*); 51 ~ProtoTraceParser() override; 52 53 // TraceParser implementation. 54 void ParseTracePacket(int64_t timestamp, TimestampedTracePiece) override; 55 void ParseFtracePacket(uint32_t cpu, 56 int64_t timestamp, 57 TimestampedTracePiece) override; 58 59 void ParseTracePacketImpl(int64_t ts, 60 TimestampedTracePiece, 61 const TracePacketData*, 62 const protos::pbzero::TracePacket_Decoder&); 63 64 void ParseTraceStats(ConstBytes); 65 void ParseProfilePacket(int64_t ts, 66 PacketSequenceStateGeneration*, 67 uint32_t seq_id, 68 ConstBytes); 69 void ParsePerfSample(int64_t ts, PacketSequenceStateGeneration*, ConstBytes); 70 void ParseChromeBenchmarkMetadata(ConstBytes); 71 void ParseChromeEvents(int64_t ts, ConstBytes); 72 void ParseMetatraceEvent(int64_t ts, ConstBytes); 73 void ParseTraceConfig(ConstBytes); 74 void ParseModuleSymbols(ConstBytes); 75 void ParseTrigger(int64_t ts, ConstBytes); 76 77 private: 78 TraceProcessorContext* context_; 79 80 const StringId metatrace_id_; 81 const StringId data_name_id_; 82 const StringId raw_chrome_metadata_event_id_; 83 const StringId raw_chrome_legacy_system_trace_event_id_; 84 const StringId raw_chrome_legacy_user_trace_event_id_; 85 }; 86 87 } // namespace trace_processor 88 } // namespace perfetto 89 90 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_PROTO_TRACE_PARSER_H_ 91