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 "perfetto/trace_processor/trace_blob_view.h" 29 #include "src/trace_processor/importers/common/trace_parser.h" 30 #include "src/trace_processor/storage/trace_storage.h" 31 #include "src/trace_processor/timestamped_trace_piece.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 PacketSequenceState; 44 class TraceProcessorContext; 45 46 class ProtoTraceParser : public TraceParser { 47 public: 48 using ConstBytes = protozero::ConstBytes; 49 explicit ProtoTraceParser(TraceProcessorContext*); 50 ~ProtoTraceParser() override; 51 52 // TraceParser implementation. 53 void ParseTracePacket(int64_t timestamp, TimestampedTracePiece) override; 54 void ParseFtracePacket(uint32_t cpu, 55 int64_t timestamp, 56 TimestampedTracePiece) override; 57 58 void ParseTracePacketImpl(int64_t ts, 59 const TimestampedTracePiece&, 60 PacketSequenceStateGeneration*, 61 const protos::pbzero::TracePacket_Decoder&); 62 63 void ParseTraceStats(ConstBytes); 64 void ParseChromeEvents(int64_t ts, ConstBytes); 65 void ParseMetatraceEvent(int64_t ts, ConstBytes); 66 void ParseTraceConfig(ConstBytes); 67 68 private: 69 TraceProcessorContext* context_; 70 71 const StringId metatrace_id_; 72 const StringId data_name_id_; 73 const StringId raw_chrome_metadata_event_id_; 74 const StringId raw_chrome_legacy_system_trace_event_id_; 75 const StringId raw_chrome_legacy_user_trace_event_id_; 76 }; 77 78 } // namespace trace_processor 79 } // namespace perfetto 80 81 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_PROTO_TRACE_PARSER_H_ 82