• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef RAWTRACE_PARSER_H
17 #define RAWTRACE_PARSER_H
18 #include "common_types.h"
19 #include "cpu_detail_parser.h"
20 #include "parser_base.h"
21 #include "ftrace_processor.h"
22 #include "kernel_symbols_processor.h"
23 #include "trace_data_cache.h"
24 
25 namespace SysTuning {
26 namespace TraceStreamer {
27 class RawTraceParser : public ParserBase {
28 public:
29     RawTraceParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters);
30     ~RawTraceParser();
31     void ParseTraceDataSegment(std::unique_ptr<uint8_t[]> bufferStr, size_t size, bool isFinish = false) override;
32     void WaitForParserEnd();
33 
34 private:
35     bool ParseDataRecursively(std::deque<uint8_t>::iterator& packagesCurIter);
36     void ParseTraceDataItem(const std::string& buffer) override;
37     bool ParseCpuRawData(uint32_t cpuId, const std::string& buffer);
38     bool HmParseCpuRawData(const std::string& buffer);
39     bool ParseLastCommData(uint8_t type, const std::string& buffer);
40     bool InitRawTraceFileHeader(std::deque<uint8_t>::iterator& packagesCurIter);
41     bool InitEventFormats(const std::string& buffer);
42     bool UpdateCpuCoreMax(uint32_t cpuId);
43     void UpdateTraceMinRange();
44 
45 private:
46     std::unique_ptr<FtraceCpuDetailMsg> cpuDetail_ = nullptr;
47     std::unique_ptr<CpuDetailParser> cpuDetailParser_ = nullptr;
48     std::unique_ptr<FtraceProcessor> ftraceProcessor_ = nullptr;
49     std::unique_ptr<KernelSymbolsProcessor> ksymsProcessor_ = nullptr;
50     TraceDataCache* traceDataCache_;
51     bool hasGotHeader_ = false;
52     uint8_t fileType_ = 0;
53     uint8_t restCommDataCnt_ = 0;
54     uint32_t cpuCoreMax_ = 0;
55     const std::string eventEndCmd_ = "print fmt:";
56 };
57 } // namespace TraceStreamer
58 } // namespace SysTuning
59 
60 #endif // RAWTRACE_PARSER_H_
61