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_IMPL_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_PROTO_TRACE_PARSER_IMPL_H_ 19 20 #include <stdint.h> 21 22 #include <array> 23 #include <memory> 24 25 #include "perfetto/protozero/field.h" 26 #include "src/trace_processor/importers/common/parser_types.h" 27 #include "src/trace_processor/importers/common/trace_parser.h" 28 #include "src/trace_processor/storage/trace_storage.h" 29 30 namespace perfetto { 31 32 namespace protos { 33 namespace pbzero { 34 class TracePacket_Decoder; 35 } // namespace pbzero 36 } // namespace protos 37 38 namespace trace_processor { 39 40 class PacketSequenceState; 41 class TraceProcessorContext; 42 43 class ProtoTraceParserImpl : public ProtoTraceParser { 44 public: 45 using ConstBytes = protozero::ConstBytes; 46 explicit ProtoTraceParserImpl(TraceProcessorContext*); 47 ~ProtoTraceParserImpl() override; 48 49 void ParseTrackEvent(int64_t ts, TrackEventData data) override; 50 void ParseTracePacket(int64_t ts, TracePacketData data) override; 51 52 void ParseEtwEvent(uint32_t cpu, 53 int64_t /*ts*/, 54 TracePacketData data) override; 55 56 void ParseFtraceEvent(uint32_t cpu, 57 int64_t /*ts*/, 58 TracePacketData data) override; 59 60 void ParseInlineSchedSwitch(uint32_t cpu, 61 int64_t /*ts*/, 62 InlineSchedSwitch data) override; 63 64 void ParseInlineSchedWaking(uint32_t cpu, 65 int64_t /*ts*/, 66 InlineSchedWaking data) override; 67 68 void ParseChromeEvents(int64_t ts, ConstBytes); 69 void ParseMetatraceEvent(int64_t ts, ConstBytes); 70 71 private: 72 StringId GetMetatraceInternedString(uint64_t iid); 73 74 TraceProcessorContext* context_; 75 76 const StringId metatrace_id_; 77 const StringId data_name_id_; 78 const StringId raw_chrome_metadata_event_id_; 79 const StringId raw_chrome_legacy_system_trace_event_id_; 80 const StringId raw_chrome_legacy_user_trace_event_id_; 81 const StringId missing_metatrace_interned_string_id_; 82 83 base::FlatHashMap<uint64_t, StringId> metatrace_interned_strings_; 84 }; 85 86 } // namespace trace_processor 87 } // namespace perfetto 88 89 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_PROTO_TRACE_PARSER_IMPL_H_ 90