• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
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 EBPF_DATA_PARSER_H
16 #define EBPF_DATA_PARSER_H
17 #include "bio_latency_data_parser.h"
18 #include "ebpf_data_reader.h"
19 #include "ebpf_splitter.h"
20 #include "ebpf_data_structure.h"
21 #include "file_system_data_parser.h"
22 #include "paged_memory_data_parser.h"
23 #include "trace_data_cache.h"
24 #include "trace_streamer_filters.h"
25 
26 namespace SysTuning {
27 namespace TraceStreamer {
28 class EbpfDataParser : public FileSystemDataParser, public PagedMemoryDataParser, public BioLatencyDataParser {
29 public:
30     EbpfDataParser(TraceDataCache *dataCache, const TraceStreamerFilters *ctx);
31     ~EbpfDataParser();
32     void InitAndParseEbpfData(const std::deque<uint8_t> &dequeBuffer, uint64_t size);
33     void Finish();
SupportImportSymbolTable()34     bool SupportImportSymbolTable()
35     {
36         return ebpfDataReader_ ? true : false;
37     }
RecordEbpfProfilerHeader(uint8_t * buffer,uint32_t len)38     void RecordEbpfProfilerHeader(uint8_t *buffer, uint32_t len)
39     {
40         ebpfSplitter.RecordEbpfProfilerHeader(buffer, len);
41     }
42     void SetEbpfDataOffset(uint64_t offset);
43     void SetSpliteTimeRange(uint64_t splitFileMinTs, uint64_t splitFileMaxTs);
44     bool AddAndSplitEbpfData(std::deque<uint8_t> &dequeBuffer);
GetEbpfSplitResult()45     const auto &GetEbpfSplitResult()
46     {
47         return ebpfSplitter.GetEbpfSplitResult();
48     }
ClearEbpfSplitResult()49     void ClearEbpfSplitResult()
50     {
51         ebpfDataReader_ = nullptr;
52         ebpfSplitter.ClearEbpfSplitResult();
53         ebpfAllEventStartTime_ = std::numeric_limits<uint64_t>::max();
54         ebpfAllEventEndTime_ = 0;
55     }
56 
57 private:
58     bool Init(const std::deque<uint8_t> &dequeBuffer, uint64_t size);
59     std::unique_ptr<EbpfDataReader> ebpfDataReader_;
60     uint64_t ebpfAllEventStartTime_ = std::numeric_limits<uint64_t>::max();
61     uint64_t ebpfAllEventEndTime_ = 0;
62     EbpfSplitter ebpfSplitter;
63 };
64 } // namespace TraceStreamer
65 } // namespace SysTuning
66 #endif // EBPF_DATA_PARSER_H
67