1 /* 2 * Copyright (C) 2023 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 GET_DMA_INFO_H 16 #define GET_DMA_INFO_H 17 #include <map> 18 #include <memory> 19 #include <string> 20 #include <vector> 21 22 #include "executor/memory/parse/meminfo_data.h" 23 24 namespace OHOS { 25 namespace HiviewDFX { 26 class DmaInfo { 27 public: 28 DmaInfo(); 29 ~DmaInfo(); 30 31 using ValueMap = std::map<uint32_t, uint64_t>; 32 using DmaInfoMap = std::map<uint64_t, MemInfoData::DmaInfo>; 33 34 bool ParseDmaInfo(); 35 uint64_t GetDmaByPid(const int32_t &pid) const; 36 uint64_t GetTotalDma(); 37 38 private: 39 void CreateDmaInfo(const std::string &line); 40 41 DmaInfoMap dmaInfos_; 42 ValueMap dmaMap_; 43 bool initialized_ = false; 44 }; 45 } // namespace HiviewDFX 46 } // namespace OHOS 47 48 #endif // GET_DMA_INFO_H