blob: cbc6ccb1c246eb1d7845ba0e9759f109b13a6b08 [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
23#include "src/trace_processor/chunked_trace_reader.h"
24#include "src/trace_processor/trace_processor_context.h"
25#include "src/trace_processor/trace_storage.h"
26
27namespace perfetto {
28namespace trace_processor {
29
30class SystraceTraceParser : public ChunkedTraceReader {
31 public:
32 explicit SystraceTraceParser(TraceProcessorContext*);
33 ~SystraceTraceParser() override;
34
35 // ChunkedTraceReader implementation.
36 util::Status Parse(std::unique_ptr<uint8_t[]>, size_t size) override;
37
38 private:
39 enum ParseState {
40 kBeforeParse,
41 kHtmlBeforeSystrace,
Isabelle Taylor8b4740b2019-10-25 10:25:24 +010042 kTraceDataSection,
Lalit Magantid54d7522019-05-30 14:36:08 +010043 kSystrace,
44 kEndOfSystrace,
45 };
46
47 util::Status ParseSingleSystraceEvent(const std::string& buffer);
48
49 TraceProcessorContext* const context_;
50 const StringId sched_wakeup_name_id_ = 0;
51 const StringId cpu_idle_name_id_ = 0;
52
53 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_;
58};
59
60} // namespace trace_processor
61} // namespace perfetto
62
Eric Secklerd8b52082019-10-17 15:58:38 +010063#endif // SRC_TRACE_PROCESSOR_IMPORTERS_SYSTRACE_SYSTRACE_TRACE_PARSER_H_