blob: f33bc5fc30c4caa238b0341eb80724a03fe7ef38 [file] [log] [blame]
Primiano Tucci0d72a312018-08-07 14:42:45 +01001/*
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
Eric Seckler137a4672019-10-24 08:51:14 +010017#ifndef SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_PROTO_TRACE_PARSER_H_
18#define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_PROTO_TRACE_PARSER_H_
Primiano Tucci0d72a312018-08-07 14:42:45 +010019
20#include <stdint.h>
Primiano Tuccic9d4a8b2018-10-30 20:19:01 -070021
22#include <array>
Primiano Tucci7e330292018-08-24 19:10:52 +020023#include <memory>
Primiano Tucci7e330292018-08-24 19:10:52 +020024
Eric Secklerb32cacf2019-09-27 16:51:19 +010025#include "perfetto/ext/base/optional.h"
Primiano Tucci2c5488f2019-06-01 03:27:28 +010026#include "perfetto/ext/base/string_view.h"
Primiano Tuccie5f11682019-03-22 07:21:49 +000027#include "perfetto/protozero/field.h"
Lalit Magantid1a7b032021-04-23 14:46:57 +010028#include "src/trace_processor/importers/common/trace_parser.h"
Lalit Maganti7010b332020-02-07 10:51:15 +000029#include "src/trace_processor/storage/trace_storage.h"
Eric Seckler1a2ea132019-10-16 11:35:31 +010030#include "src/trace_processor/timestamped_trace_piece.h"
Alexander Timin97d87852021-05-17 18:01:33 +000031#include "src/trace_processor/util/trace_blob_view.h"
Primiano Tucci0d72a312018-08-07 14:42:45 +010032
33namespace perfetto {
Eric Secklerd2af9892019-11-01 10:10:53 +000034
35namespace protos {
36namespace pbzero {
37class TracePacket_Decoder;
38} // namespace pbzero
39} // namespace protos
40
Primiano Tucci0d72a312018-08-07 14:42:45 +010041namespace trace_processor {
42
Eric Secklerc93823e2019-06-03 16:49:19 +010043class ArgsTracker;
Eric Seckler771960c2019-10-22 15:37:12 +010044class PacketSequenceState;
Primiano Tucci0d72a312018-08-07 14:42:45 +010045class TraceProcessorContext;
46
Deepanjan Roy01994ca2019-04-02 11:05:34 -070047class ProtoTraceParser : public TraceParser {
Primiano Tucci0d72a312018-08-07 14:42:45 +010048 public:
Primiano Tuccie5f11682019-03-22 07:21:49 +000049 using ConstBytes = protozero::ConstBytes;
Primiano Tucci7e330292018-08-24 19:10:52 +020050 explicit ProtoTraceParser(TraceProcessorContext*);
Eric Seckler684a4f72019-04-26 14:34:07 +010051 ~ProtoTraceParser() override;
Primiano Tucci0d72a312018-08-07 14:42:45 +010052
Deepanjan Roy01994ca2019-04-02 11:05:34 -070053 // TraceParser implementation.
Eric Seckler1a2ea132019-10-16 11:35:31 +010054 void ParseTracePacket(int64_t timestamp, TimestampedTracePiece) override;
Eric Seckler684a4f72019-04-26 14:34:07 +010055 void ParseFtracePacket(uint32_t cpu,
56 int64_t timestamp,
Eric Seckler1a2ea132019-10-16 11:35:31 +010057 TimestampedTracePiece) override;
Eric Seckler684a4f72019-04-26 14:34:07 +010058
Eric Secklerde589952019-10-17 12:46:07 +010059 void ParseTracePacketImpl(int64_t ts,
Lalit Maganti9a843112020-11-10 13:39:05 +000060 const TimestampedTracePiece&,
61 PacketSequenceStateGeneration*,
Eric Secklerd2af9892019-11-01 10:10:53 +000062 const protos::pbzero::TracePacket_Decoder&);
Eric Seckler87ede882019-10-18 10:48:36 +010063
Primiano Tuccie5f11682019-03-22 07:21:49 +000064 void ParseTraceStats(ConstBytes);
Florian Mayer5716fc12019-06-24 11:50:51 -070065 void ParseProfilePacket(int64_t ts,
Eric Seckler7e9dc312020-01-02 15:17:28 +000066 PacketSequenceStateGeneration*,
Florian Mayerf2701882019-12-11 17:32:48 +000067 uint32_t seq_id,
Florian Mayer5716fc12019-06-24 11:50:51 -070068 ConstBytes);
Florian Mayer64c1d8f2020-08-14 14:08:57 +010069 void ParseDeobfuscationMapping(int64_t ts,
70 PacketSequenceStateGeneration*,
71 uint32_t seq_id,
72 ConstBytes);
Eric Seckler0441e972019-09-14 02:27:55 +010073 void ParseChromeEvents(int64_t ts, ConstBytes);
Primiano Tuccib02d8dc2019-06-04 11:46:43 +010074 void ParseMetatraceEvent(int64_t ts, ConstBytes);
Ioannis Ilkosf4389a62019-10-07 10:00:52 +010075 void ParseTraceConfig(ConstBytes);
Florian Mayera480cd62019-09-24 10:36:56 +010076 void ParseModuleSymbols(ConstBytes);
Florian Mayer5a992d92020-04-09 13:53:24 +020077 void ParseSmapsPacket(int64_t ts, ConstBytes);
Primiano Tucci0d72a312018-08-07 14:42:45 +010078
79 private:
Primiano Tucci0d72a312018-08-07 14:42:45 +010080 TraceProcessorContext* context_;
Mikael Pessa7160ccc2019-07-25 11:19:26 -070081
Primiano Tuccib02d8dc2019-06-04 11:46:43 +010082 const StringId metatrace_id_;
Mikhail Khokhlovfd746552019-08-15 14:54:29 +010083 const StringId data_name_id_;
Mikhail Khokhlovca34df22019-08-07 16:50:01 +010084 const StringId raw_chrome_metadata_event_id_;
Mikhail Khokhlovfd746552019-08-15 14:54:29 +010085 const StringId raw_chrome_legacy_system_trace_event_id_;
86 const StringId raw_chrome_legacy_user_trace_event_id_;
Primiano Tucci0d72a312018-08-07 14:42:45 +010087};
88
89} // namespace trace_processor
90} // namespace perfetto
91
Eric Seckler137a4672019-10-24 08:51:14 +010092#endif // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_PROTO_TRACE_PARSER_H_