• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2022. 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  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  */
14 
15 #ifndef EBPF_COVERTER_H
16 #define EBPF_COVERTER_H
17 
18 #include <sstream>
19 #include <map>
20 #include <vector>
21 
22 #include "ebpf_std_type.h"
23 
24 namespace OHOS {
25 namespace EBPF_TOOLS {
26 class EbpfConverter {
27 public:
28     EbpfConverter(const std::string& inputPath, const std::string& outPath);
29     virtual ~EbpfConverter() = default;
30     void StartParsing();
31 
32 private:
33     bool Read(void* buffer, size_t size);
34     void EventFsParsing();
35     void EventMapsParsing();
36     void SymbolInfoParsing();
37     void EventMemParsing();
38     void EventStrParsing();
39     void EventBIOParsing();
40     std::pair<std::string, std::vector<std::string>> GetSymbolInfo(uint64_t pid, uint64_t ip);
41 
42 private:
43     std::stringstream outData_;
44     std::string inputPath_;
45     std::string outputPath_;
46     int32_t fileSize_ { 0 };
47     int32_t fd_ { -1 };
48     std::vector<EventStr> str_;
49     std::map<std::string, Record> record_;
50     std::map<std::string, SymbolInfo> symbolInfo_;
51     std::map<uint32_t, std::vector<EventMaps>> maps_;
52     std::map<uint64_t, uint64_t> vAddr_;
53 };
54 } // EBPF_TOOLS
55 } // OHOS
56 
57 #endif // EBPF_COVERTER_H