• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <unistd.h>
21 #include "dfx_ark.h"
22 #include "dfx_extractor_utils.h"
23 
24 namespace OHOS {
25 namespace HiviewDFX {
26 class DfxMap;
27 
28 class DfxHap {
29 public:
30     DfxHap() = default;
31     ~DfxHap();
32 
33     bool ParseHapInfo(pid_t pid, uint64_t pc, std::shared_ptr<DfxMap> map, JsFunction *jsFunction);
34 
35 private:
36     bool ParseHapFileInfo(uint64_t pc, std::shared_ptr<DfxMap> map, JsFunction *jsFunction);
37     bool ParseHapMemInfo(pid_t pid, uint64_t pc, 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