• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2023. 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  * 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 
16 #include "native_memory_profiler_sa_config.h"
17 #include "define_macro.h"
18 #include "logging.h"
19 
20 namespace OHOS::Developtools::NativeDaemon {
Marshalling(Parcel & parcel) const21 bool NativeMemoryProfilerSaConfig::Marshalling(Parcel& parcel) const
22 {
23     WRITEINT32(parcel, pid_);
24     WRITESTRING(parcel, filePath_);
25     WRITEUINT32(parcel, duration_);
26     WRITEINT32(parcel, filterSize_);
27     WRITEUINT32(parcel, shareMemorySize_);
28     WRITESTRING(parcel, processName_);
29     WRITEUINT8(parcel, maxStackDepth_);
30     WRITEBOOL(parcel, mallocDisable_);
31     WRITEBOOL(parcel, mmapDisable_);
32     WRITEBOOL(parcel, freeStackData_);
33     WRITEBOOL(parcel, munmapStackData_);
34     WRITEUINT32(parcel, mallocFreeMatchingInterval_);
35     WRITEUINT32(parcel, mallocFreeMatchingCnt_);
36     WRITEBOOL(parcel, stringCompressed_);
37     WRITEBOOL(parcel, fpUnwind_);
38     WRITEBOOL(parcel, blocked_);
39     WRITEBOOL(parcel, recordAccurately_);
40     WRITEBOOL(parcel, startupMode_);
41     WRITEBOOL(parcel, memtraceEnable_);
42     WRITEBOOL(parcel, offlineSymbolization_);
43     WRITEBOOL(parcel, callframeCompress_);
44     WRITEUINT32(parcel, statisticsInterval_);
45     WRITEINT32(parcel, clockId_);
46     WRITEUINT32(parcel, sampleInterval_);
47     WRITEBOOL(parcel, responseLibraryMode_);
48     WRITEBOOL(parcel, printNmd_);
49     WRITEUINT32(parcel, nmdPid_);
50     WRITEUINT32(parcel, nmdType_);
51     WRITEINT32(parcel, jsStackReport_);
52     WRITEUINT8(parcel, maxJsStackDepth_);
53     WRITESTRING(parcel, filterNapiName_);
54     return true;
55 }
56 
Unmarshalling(Parcel & parcel,std::shared_ptr<NativeMemoryProfilerSaConfig> config)57 bool NativeMemoryProfilerSaConfig::Unmarshalling(Parcel& parcel, std::shared_ptr<NativeMemoryProfilerSaConfig> config)
58 {
59     if (config == nullptr) {
60         return false;
61     }
62     READINT32(parcel, config->pid_);
63     READSTRING(parcel, config->filePath_);
64     READUINT32(parcel, config->duration_);
65     READINT32(parcel, config->filterSize_);
66     READUINT32(parcel, config->shareMemorySize_);
67     READSTRING(parcel, config->processName_);
68     READUINT8(parcel, config->maxStackDepth_);
69     READBOOL(parcel, config->mallocDisable_);
70     READBOOL(parcel, config->mmapDisable_);
71     READBOOL(parcel, config->freeStackData_);
72     READBOOL(parcel, config->munmapStackData_);
73     READUINT32(parcel, config->mallocFreeMatchingInterval_);
74     READUINT32(parcel, config->mallocFreeMatchingCnt_);
75     READBOOL(parcel, config->stringCompressed_);
76     READBOOL(parcel, config->fpUnwind_);
77     READBOOL(parcel, config->blocked_);
78     READBOOL(parcel, config->recordAccurately_);
79     READBOOL(parcel, config->startupMode_);
80     READBOOL(parcel, config->memtraceEnable_);
81     READBOOL(parcel, config->offlineSymbolization_);
82     READBOOL(parcel, config->callframeCompress_);
83     READUINT32(parcel, config->statisticsInterval_);
84     READINT32(parcel, config->clockId_);
85     READUINT32(parcel, config->sampleInterval_);
86     READBOOL(parcel, config->responseLibraryMode_);
87     READBOOL(parcel, config->printNmd_);
88     READUINT32(parcel, config->nmdPid_);
89     READUINT32(parcel, config->nmdType_);
90     READINT32(parcel, config->jsStackReport_);
91     READUINT8(parcel, config->maxJsStackDepth_);
92     READSTRING(parcel, config->filterNapiName_);
93     PrintConfig(config);
94     return true;
95 }
96 
PrintConfig(std::shared_ptr<NativeMemoryProfilerSaConfig> & config)97 void NativeMemoryProfilerSaConfig::PrintConfig(std::shared_ptr<NativeMemoryProfilerSaConfig>& config)
98 {
99     PROFILER_LOG_DEBUG(LOG_CORE,
100         "pid: %d, filePath: %s, duration: %d, filterSize: %d, shareMemorySize: %d, processName: %s",
101         config->pid_, config->filePath_.c_str(), config->duration_, config->filterSize_, config->shareMemorySize_,
102         config->processName_.c_str());
103     PROFILER_LOG_DEBUG(LOG_CORE, "maxStackDepth: %d, mallocDisable: %d, mmapDisable: %d, freeStackData: %d," \
104         "munmapStackData: %d",
105         config->maxStackDepth_, config->mallocDisable_, config->mmapDisable_, config->freeStackData_,
106         config->munmapStackData_);
107     PROFILER_LOG_DEBUG(LOG_CORE, "mallocFreeMatchingInterval: %d, mallocFreeMatchingCnt: %d, stringCompressed: %d," \
108         "fpUnwind: %d, blocked: %d, recordAccurately: %d",
109         config->mallocFreeMatchingInterval_, config->mallocFreeMatchingCnt_, config->stringCompressed_,
110         config->fpUnwind_, config->blocked_, config->recordAccurately_);
111     PROFILER_LOG_DEBUG(LOG_CORE,
112         "startupMode: %d, memtraceEnable: %d, offlineSymbolization: %d, callframeCompress: %d," \
113         "statisticsInterval: %d, clockId: %d",
114         config->startupMode_, config->memtraceEnable_, config->offlineSymbolization_, config->callframeCompress_,
115         config->statisticsInterval_, config->clockId_);
116     PROFILER_LOG_DEBUG(LOG_CORE,
117         "jsStackReport: %d, maxJsStackDepth_: %d, filterNapiName_: %s",
118         config->jsStackReport_, config->maxJsStackDepth_, config->filterNapiName_.c_str());
119 }
120 } // namespace OHOS::Developtools::NativeDaemon