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/importers/common/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 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 const TimestampedTracePiece&, 61 PacketSequenceStateGeneration*, 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 ParseDeobfuscationMapping(int64_t ts, 70 PacketSequenceStateGeneration*, 71 uint32_t seq_id, 72 ConstBytes); 73 void ParseChromeEvents(int64_t ts, ConstBytes); 74 void ParseMetatraceEvent(int64_t ts, ConstBytes); 75 void ParseTraceConfig(ConstBytes); 76 void ParseModuleSymbols(ConstBytes); 77 void ParseSmapsPacket(int64_t ts, ConstBytes); 78 79 private: 80 TraceProcessorContext* context_; 81 82 const StringId metatrace_id_; 83 const StringId data_name_id_; 84 const StringId raw_chrome_metadata_event_id_; 85 const StringId raw_chrome_legacy_system_trace_event_id_; 86 const StringId raw_chrome_legacy_user_trace_event_id_; 87 }; 88 89 } // namespace trace_processor 90 } // namespace perfetto 91 92 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_PROTO_TRACE_PARSER_H_ 93