• 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 #ifndef SRC_PRINT_EVENT_PARSER_H
16 #define SRC_PRINT_EVENT_PARSER_H
17 #include <regex>
18 #include <string_view>
19 #include "common_types.h"
20 #include "event_parser_base.h"
21 #include "filter/measure_filter.h"
22 #include "filter/process_filter.h"
23 #include "filter/slice_filter.h"
24 #include "string_to_numerical.h"
25 #include "trace_streamer_config.h"
26 namespace SysTuning {
27 namespace TraceStreamer {
28 class PrintEventParser : private EventParserBase {
29 public:
30     PrintEventParser(TraceDataCache* dataCache, const TraceStreamerFilters* filter);
31     bool ParsePrintEvent(const std::string& comm, uint64_t ts, uint32_t pid, std::string_view event);
32 private:
33     ParseResult GetTracePoint(std::string_view pointStr, TracePoint& outPoint) const;
34     ParseResult CheckTracePoint(std::string_view pointStr) const;
35     uint32_t GetThreadGroupId(std::string_view pointStr, size_t& length) const;
36     std::string_view GetPointNameForBegin(std::string_view pointStr, size_t tGidlength) const;
37     ParseResult HandlerB(std::string_view pointStr, TracePoint& outPoint, size_t tGidlength) const;
38     static ParseResult HandlerE(void);
39     ParseResult HandlerCSF(std::string_view pointStr, TracePoint& outPoint, size_t tGidlength) const;
40     static size_t GetNameLength(std::string_view pointStr, size_t nameIndex);
41     size_t GetValueLength(std::string_view pointStr, size_t valueIndex) const;
42 private:
43     const uint32_t pointLength_;
44     const uint32_t maxPointLength_;
45     TraceStreamerConfig config_{};
46 };
47 } // namespace TraceStreamer
48 } // namespace SysTuning
49 
50 #endif // SRC_PRINT_EVENT_PARSER_H
51