• 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_JSON_JSON_TRACE_PARSER_H_
18 #define SRC_TRACE_PROCESSOR_IMPORTERS_JSON_JSON_TRACE_PARSER_H_
19 
20 #include <stdint.h>
21 
22 #include <memory>
23 #include <tuple>
24 #include <unordered_map>
25 
26 #include "src/trace_processor/importers/common/trace_parser.h"
27 #include "src/trace_processor/importers/json/json_tracker.h"
28 #include "src/trace_processor/importers/systrace/systrace_line_parser.h"
29 #include "src/trace_processor/timestamped_trace_piece.h"
30 
31 namespace Json {
32 class Value;
33 }
34 
35 namespace perfetto {
36 namespace trace_processor {
37 
38 class TraceProcessorContext;
39 
40 // Parses legacy chrome JSON traces. The support for now is extremely rough
41 // and supports only explicit TRACE_EVENT_BEGIN/END events.
42 class JsonTraceParser : public TraceParser {
43  public:
44   explicit JsonTraceParser(TraceProcessorContext*);
45   ~JsonTraceParser() override;
46 
47   // TraceParser implementation.
48   void ParseTracePacket(int64_t timestamp, TimestampedTracePiece) override;
49   void ParseFtracePacket(uint32_t, int64_t, TimestampedTracePiece) override;
50 
51  private:
52   TraceProcessorContext* const context_;
53   SystraceLineParser systrace_line_parser_;
54 
55   void MaybeAddFlow(TrackId track_id, const Json::Value& event);
56 };
57 
58 }  // namespace trace_processor
59 }  // namespace perfetto
60 
61 #endif  // SRC_TRACE_PROCESSOR_IMPORTERS_JSON_JSON_TRACE_PARSER_H_
62