106f6ba60Sopenharmony_ci/* 206f6ba60Sopenharmony_ci * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. 306f6ba60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 406f6ba60Sopenharmony_ci * you may not use this file except in compliance with the License. 506f6ba60Sopenharmony_ci * You may obtain a copy of the License at 606f6ba60Sopenharmony_ci * 706f6ba60Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 806f6ba60Sopenharmony_ci * 906f6ba60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1006f6ba60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1106f6ba60Sopenharmony_ci * See the License for the specific language governing permissions and 1206f6ba60Sopenharmony_ci * limitations under the License. 1306f6ba60Sopenharmony_ci */ 1406f6ba60Sopenharmony_ci 1506f6ba60Sopenharmony_ci#ifndef EBPF_COVERTER_H 1606f6ba60Sopenharmony_ci#define EBPF_COVERTER_H 1706f6ba60Sopenharmony_ci 1806f6ba60Sopenharmony_ci#include <sstream> 1906f6ba60Sopenharmony_ci#include <map> 2006f6ba60Sopenharmony_ci#include <vector> 2106f6ba60Sopenharmony_ci 2206f6ba60Sopenharmony_ci#include "ebpf_std_type.h" 2306f6ba60Sopenharmony_ci 2406f6ba60Sopenharmony_cinamespace OHOS { 2506f6ba60Sopenharmony_cinamespace EBPF_TOOLS { 2606f6ba60Sopenharmony_ciclass EbpfConverter { 2706f6ba60Sopenharmony_cipublic: 2806f6ba60Sopenharmony_ci EbpfConverter(const std::string& inputPath, const std::string& outPath); 2906f6ba60Sopenharmony_ci virtual ~EbpfConverter(); 3006f6ba60Sopenharmony_ci void StartParsing(); 3106f6ba60Sopenharmony_ci 3206f6ba60Sopenharmony_ciprivate: 3306f6ba60Sopenharmony_ci bool Read(void* buffer, size_t size); 3406f6ba60Sopenharmony_ci void EventFsParsing(); 3506f6ba60Sopenharmony_ci void EventMapsParsing(); 3606f6ba60Sopenharmony_ci void SymbolInfoParsing(); 3706f6ba60Sopenharmony_ci void EventMemParsing(); 3806f6ba60Sopenharmony_ci void EventStrParsing(); 3906f6ba60Sopenharmony_ci void EventBIOParsing(); 4006f6ba60Sopenharmony_ci std::pair<std::string, std::vector<std::string>> GetSymbolInfo(uint64_t pid, uint64_t ip); 4106f6ba60Sopenharmony_cipublic: 4206f6ba60Sopenharmony_ci static std::pair<bool, std::string> CheckNotExistsFilePath(const std::string& filePath); 4306f6ba60Sopenharmony_ci 4406f6ba60Sopenharmony_ciprivate: 4506f6ba60Sopenharmony_ci std::stringstream outData_; 4606f6ba60Sopenharmony_ci std::string inputPath_; 4706f6ba60Sopenharmony_ci std::string outputPath_; 4806f6ba60Sopenharmony_ci int32_t fileSize_ { 0 }; 4906f6ba60Sopenharmony_ci int32_t fd_ { -1 }; 5006f6ba60Sopenharmony_ci std::vector<EventStr> str_; 5106f6ba60Sopenharmony_ci std::map<std::string, Record> record_; 5206f6ba60Sopenharmony_ci std::map<std::string, SymbolInfo> symbolInfo_; 5306f6ba60Sopenharmony_ci std::map<uint32_t, std::vector<EventMaps>> maps_; 5406f6ba60Sopenharmony_ci std::map<uint64_t, uint64_t> vAddr_; 5506f6ba60Sopenharmony_ci}; 5606f6ba60Sopenharmony_ci} // EBPF_TOOLS 5706f6ba60Sopenharmony_ci} // OHOS 5806f6ba60Sopenharmony_ci 5906f6ba60Sopenharmony_ci#endif // EBPF_COVERTER_H