• 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     return true;
49 }
50 
Unmarshalling(Parcel & parcel,std::shared_ptr<NativeMemoryProfilerSaConfig> config)51 bool NativeMemoryProfilerSaConfig::Unmarshalling(Parcel& parcel, std::shared_ptr<NativeMemoryProfilerSaConfig> config)
52 {
53     if (config == nullptr) {
54         return false;
55     }
56     READINT32(parcel, config->pid_);
57     READSTRING(parcel, config->filePath_);
58     READUINT32(parcel, config->duration_);
59     READINT32(parcel, config->filterSize_);
60     READUINT32(parcel, config->shareMemorySize_);
61     READSTRING(parcel, config->processName_);
62     READUINT8(parcel, config->maxStackDepth_);
63     READBOOL(parcel, config->mallocDisable_);
64     READBOOL(parcel, config->mmapDisable_);
65     READBOOL(parcel, config->freeStackData_);
66     READBOOL(parcel, config->munmapStackData_);
67     READUINT32(parcel, config->mallocFreeMatchingInterval_);
68     READUINT32(parcel, config->mallocFreeMatchingCnt_);
69     READBOOL(parcel, config->stringCompressed_);
70     READBOOL(parcel, config->fpUnwind_);
71     READBOOL(parcel, config->blocked_);
72     READBOOL(parcel, config->recordAccurately_);
73     READBOOL(parcel, config->startupMode_);
74     READBOOL(parcel, config->memtraceEnable_);
75     READBOOL(parcel, config->offlineSymbolization_);
76     READBOOL(parcel, config->callframeCompress_);
77     READUINT32(parcel, config->statisticsInterval_);
78     READINT32(parcel, config->clockId_);
79     READUINT32(parcel, config->sampleInterval_);
80     READBOOL(parcel, config->responseLibraryMode_);
81     PrintConfig(config);
82     return true;
83 }
84 
PrintConfig(std::shared_ptr<NativeMemoryProfilerSaConfig> & config)85 void NativeMemoryProfilerSaConfig::PrintConfig(std::shared_ptr<NativeMemoryProfilerSaConfig>& config)
86 {
87     PROFILER_LOG_DEBUG(LOG_CORE,
88         "pid: %d, filePath: %s, duration: %d, filterSize: %d, shareMemorySize: %d, processName: %s",
89         config->pid_, config->filePath_.c_str(), config->duration_, config->filterSize_, config->shareMemorySize_,
90         config->processName_.c_str());
91     PROFILER_LOG_DEBUG(LOG_CORE, "maxStackDepth: %d, mallocDisable: %d, mmapDisable: %d, freeStackData: %d," \
92         "munmapStackData: %d",
93         config->maxStackDepth_, config->mallocDisable_, config->mmapDisable_, config->freeStackData_,
94         config->munmapStackData_);
95     PROFILER_LOG_DEBUG(LOG_CORE, "mallocFreeMatchingInterval: %d, mallocFreeMatchingCnt: %d, stringCompressed: %d," \
96         "fpUnwind: %d, blocked: %d, recordAccurately: %d",
97         config->mallocFreeMatchingInterval_, config->mallocFreeMatchingCnt_, config->stringCompressed_,
98         config->fpUnwind_, config->blocked_, config->recordAccurately_);
99     PROFILER_LOG_DEBUG(LOG_CORE,
100         "startupMode: %d, memtraceEnable: %d, offlineSymbolization: %d, callframeCompress: %d," \
101         "statisticsInterval: %d, clockId: %d",
102         config->startupMode_, config->memtraceEnable_, config->offlineSymbolization_, config->callframeCompress_,
103         config->statisticsInterval_, config->clockId_);
104 }
105 } // namespace OHOS::Developtools::NativeDaemon