1 /* 2 * Copyright (c) 2024 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 DFX_HAP_H 16 #define DFX_HAP_H 17 18 #include <cstdint> 19 #include <memory> 20 #include "dfx_ark.h" 21 #include "dfx_extractor_utils.h" 22 23 namespace OHOS { 24 namespace HiviewDFX { 25 class DfxMap; 26 27 class DfxHap { 28 public: 29 DfxHap() = default; 30 ~DfxHap(); 31 32 bool ParseHapInfo(pid_t pid, uint64_t pc, uintptr_t methodid, std::shared_ptr<DfxMap> map, 33 JsFunction *jsFunction); 34 35 private: 36 bool ParseHapFileInfo(uint64_t pc, uintptr_t methodid, std::shared_ptr<DfxMap> map, JsFunction *jsFunction); 37 bool ParseHapMemInfo(pid_t pid, uint64_t pc, uintptr_t methodid, std::shared_ptr<DfxMap> map, 38 JsFunction *jsFunction); 39 40 bool ParseHapFileData(const std::string& name); 41 bool ParseHapMemData(const pid_t pid, std::shared_ptr<DfxMap> map); 42 43 private: 44 MAYBE_UNUSED uintptr_t arkSymbolExtractorPtr_ = 0; 45 MAYBE_UNUSED std::unique_ptr<uint8_t[]> abcDataPtr_ = nullptr; 46 MAYBE_UNUSED size_t abcDataSize_ = 0; 47 MAYBE_UNUSED uintptr_t abcLoadOffset_ = 0; 48 MAYBE_UNUSED std::unique_ptr<uint8_t[]> srcMapDataPtr_ = nullptr; 49 MAYBE_UNUSED size_t srcMapDataSize_ = 0; 50 MAYBE_UNUSED uintptr_t srcMapLoadOffset_ = 0; 51 MAYBE_UNUSED std::unique_ptr<DfxExtractor> extractor_ = nullptr; 52 }; 53 } // namespace HiviewDFX 54 } // namespace OHOS 55 #endif