blob: 9721879053e9253a5883610ebb674e8157c35abf [file] [log] [blame]
Lalit Magantid54d7522019-05-30 14:36:08 +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 Secklerd8b52082019-10-17 15:58:38 +010017#ifndef SRC_TRACE_PROCESSOR_IMPORTERS_SYSTRACE_SYSTRACE_TRACE_PARSER_H_
18#define SRC_TRACE_PROCESSOR_IMPORTERS_SYSTRACE_SYSTRACE_TRACE_PARSER_H_
Lalit Magantid54d7522019-05-30 14:36:08 +010019
20#include <deque>
21#include <regex>
22
Lalit Maganti1534bb72021-04-23 14:11:26 +010023#include "src/trace_processor/importers/common/chunked_trace_reader.h"
Lalit Maganti2f0b41d2020-02-27 13:35:39 +000024#include "src/trace_processor/importers/systrace/systrace_line_parser.h"
25#include "src/trace_processor/importers/systrace/systrace_line_tokenizer.h"
Lalit Maganti7010b332020-02-07 10:51:15 +000026#include "src/trace_processor/storage/trace_storage.h"
Lalit Maganti0faddc42020-04-10 17:58:24 +010027#include "src/trace_processor/types/trace_processor_context.h"
Lalit Magantid54d7522019-05-30 14:36:08 +010028
29namespace perfetto {
30namespace trace_processor {
31
32class SystraceTraceParser : public ChunkedTraceReader {
33 public:
34 explicit SystraceTraceParser(TraceProcessorContext*);
35 ~SystraceTraceParser() override;
36
37 // ChunkedTraceReader implementation.
Primiano Tucci3264b592021-11-08 18:20:51 +000038 util::Status Parse(TraceBlobView) override;
Primiano Tucci40da82f2020-02-13 18:04:35 +000039 void NotifyEndOfFile() override;
Lalit Magantid54d7522019-05-30 14:36:08 +010040
41 private:
42 enum ParseState {
43 kBeforeParse,
44 kHtmlBeforeSystrace,
Isabelle Taylor8b4740b2019-10-25 10:25:24 +010045 kTraceDataSection,
Lalit Magantid54d7522019-05-30 14:36:08 +010046 kSystrace,
Hector Dearmanb6390cc2020-04-22 12:54:19 +010047 kProcessDumpLong,
48 kProcessDumpShort,
Lalit Maganti86dfcdb2020-08-19 17:25:51 +010049 kCgroupDump,
Lalit Magantid54d7522019-05-30 14:36:08 +010050 kEndOfSystrace,
51 };
52
Lalit Magantid54d7522019-05-30 14:36:08 +010053 ParseState state_ = ParseState::kBeforeParse;
54
55 // Used to glue together trace packets that span across two (or more)
56 // Parse() boundaries.
57 std::deque<uint8_t> partial_buf_;
Lalit Maganti2f0b41d2020-02-27 13:35:39 +000058
59 SystraceLineTokenizer line_tokenizer_;
60 SystraceLineParser line_parser_;
Hector Dearmanb6390cc2020-04-22 12:54:19 +010061 TraceProcessorContext* ctx_;
Lalit Magantid54d7522019-05-30 14:36:08 +010062};
63
64} // namespace trace_processor
65} // namespace perfetto
66
Eric Secklerd8b52082019-10-17 15:58:38 +010067#endif // SRC_TRACE_PROCESSOR_IMPORTERS_SYSTRACE_SYSTRACE_TRACE_PARSER_H_