Lalit Maganti | d54d752 | 2019-05-30 14:36:08 +0100 | [diff] [blame] | 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 | |
Eric Seckler | d8b5208 | 2019-10-17 15:58:38 +0100 | [diff] [blame] | 17 | #ifndef SRC_TRACE_PROCESSOR_IMPORTERS_SYSTRACE_SYSTRACE_TRACE_PARSER_H_ |
| 18 | #define SRC_TRACE_PROCESSOR_IMPORTERS_SYSTRACE_SYSTRACE_TRACE_PARSER_H_ |
Lalit Maganti | d54d752 | 2019-05-30 14:36:08 +0100 | [diff] [blame] | 19 | |
| 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 | |
| 27 | namespace perfetto { |
| 28 | namespace trace_processor { |
| 29 | |
| 30 | class 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 Taylor | 8b4740b | 2019-10-25 10:25:24 +0100 | [diff] [blame^] | 42 | kTraceDataSection, |
Lalit Maganti | d54d752 | 2019-05-30 14:36:08 +0100 | [diff] [blame] | 43 | 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 Seckler | d8b5208 | 2019-10-17 15:58:38 +0100 | [diff] [blame] | 63 | #endif // SRC_TRACE_PROCESSOR_IMPORTERS_SYSTRACE_SYSTRACE_TRACE_PARSER_H_ |