• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/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 ProtoTraceParser : public TraceParser {
44  public:
45   using ConstBytes = protozero::ConstBytes;
46   explicit ProtoTraceParser(TraceProcessorContext*);
47   ~ProtoTraceParser() override;
48 
49   void ParseTrackEvent(int64_t ts, TrackEventData data) override;
50   void ParseTracePacket(int64_t ts, TracePacketData data) override;
51 
52   void ParseFtraceEvent(uint32_t cpu,
53                         int64_t /*ts*/,
54                         TracePacketData data) override;
55 
56   void ParseInlineSchedSwitch(uint32_t cpu,
57                               int64_t /*ts*/,
58                               InlineSchedSwitch data) override;
59 
60   void ParseInlineSchedWaking(uint32_t cpu,
61                               int64_t /*ts*/,
62                               InlineSchedWaking data) override;
63 
64   void ParseTraceStats(ConstBytes);
65   void ParseChromeEvents(int64_t ts, ConstBytes);
66   void ParseMetatraceEvent(int64_t ts, ConstBytes);
67 
68  private:
69   StringId GetMetatraceInternedString(uint64_t iid);
70 
71   TraceProcessorContext* context_;
72 
73   const StringId metatrace_id_;
74   const StringId data_name_id_;
75   const StringId raw_chrome_metadata_event_id_;
76   const StringId raw_chrome_legacy_system_trace_event_id_;
77   const StringId raw_chrome_legacy_user_trace_event_id_;
78   const StringId missing_metatrace_interned_string_id_;
79 
80   base::FlatHashMap<uint64_t, StringId> metatrace_interned_strings_;
81 };
82 
83 }  // namespace trace_processor
84 }  // namespace perfetto
85 
86 #endif  // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_PROTO_TRACE_PARSER_H_
87