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 #include "native_leak_info.h"
16 
17 #include <string>
18 
19 namespace OHOS {
20 namespace HiviewDFX {
21 using std::string;
22 using std::vector;
23 using std::to_string;
24 
~NativeLeakInfo()25 NativeLeakInfo::~NativeLeakInfo() {}
26 
GetPidStartTime() const27 time_t NativeLeakInfo::GetPidStartTime() const
28 {
29     return pidStartTime_;
30 }
31 
SetPidStartTime(time_t startTime)32 void NativeLeakInfo::SetPidStartTime(time_t startTime)
33 {
34     pidStartTime_ = startTime;
35 }
36 
GetActualRssThreshold() const37 uint64_t NativeLeakInfo::GetActualRssThreshold() const
38 {
39     return actualRssThreshold_;
40 }
41 
SetActualRssThreshold(uint64_t value)42 void NativeLeakInfo::SetActualRssThreshold(uint64_t value)
43 {
44     actualRssThreshold_ = value;
45 }
46 
GetDebugStartTime() const47 time_t NativeLeakInfo::GetDebugStartTime() const
48 {
49     return debugStartTime_;
50 }
51 
SetDebugStartTime(time_t value)52 void NativeLeakInfo::SetDebugStartTime(time_t value)
53 {
54     debugStartTime_ = value;
55 }
56 
GetLeakGrade() const57 string NativeLeakInfo::GetLeakGrade() const
58 {
59     return leakGrade_;
60 }
61 
SetLeakGrade(const string & grade)62 void NativeLeakInfo::SetLeakGrade(const string &grade)
63 {
64     leakGrade_ = grade;
65 }
66 
GetJavaState() const67 bool NativeLeakInfo::GetJavaState() const
68 {
69     return javaState_;
70 }
71 
SetJavaState(bool flag)72 void NativeLeakInfo::SetJavaState(bool flag)
73 {
74     javaState_ = flag;
75 }
76 
GetInThresholdList() const77 bool NativeLeakInfo::GetInThresholdList() const
78 {
79     return isInThresholdList_;
80 }
81 
SetInThresholdList(bool flag)82 void NativeLeakInfo::SetInThresholdList(bool flag)
83 {
84     isInThresholdList_ = flag;
85 }
86 
GetIsProcessDied() const87 bool NativeLeakInfo::GetIsProcessDied() const
88 {
89     return isProcessDied_;
90 }
91 
SetIsProcessDied(bool flag)92 void NativeLeakInfo::SetIsProcessDied(bool flag)
93 {
94     isProcessDied_ = flag;
95 }
96 
GetIsAppendSmapsFile() const97 bool NativeLeakInfo::GetIsAppendSmapsFile() const
98 {
99     return isAppendSmapsFile_;
100 }
101 
SetIsAppendSmapsFile(bool flag)102 void NativeLeakInfo::SetIsAppendSmapsFile(bool flag)
103 {
104     isAppendSmapsFile_ = flag;
105 }
106 
GetIsDumpHiprofilerDrop() const107 bool NativeLeakInfo::GetIsDumpHiprofilerDrop() const
108 {
109     return isDumpHiprofilerDrop_;
110 }
111 
SetIsDumpHiprofilerDrop(bool flag)112 void NativeLeakInfo::SetIsDumpHiprofilerDrop(bool flag)
113 {
114     isDumpHiprofilerDrop_ = flag;
115 }
116 
GetSampleFilePath()117 string NativeLeakInfo::GetSampleFilePath()
118 {
119     string path = MEMORY_LEAK_PATH + "/memleak-native-" + processName_ + "-" + to_string(pid_) + "-sample.txt";
120     return path;
121 }
122 
GetLogFilePath()123 string NativeLeakInfo::GetLogFilePath()
124 {
125     string path = MEMORY_LEAK_PATH + "/memleak-temp-" + processName_ + "-" + to_string(pid_) + "-" +
126         leakedTime_ + ".txt";
127     return path;
128 }
129 
GetRsMemPath()130 string NativeLeakInfo::GetRsMemPath()
131 {
132     string path = MEMORY_LEAK_PATH + "/memleak-temp-" + processName_ + "-" + to_string(pid_) + "-rsMem.txt";
133     return path;
134 }
135 
GetRsGpuPath()136 string NativeLeakInfo::GetRsGpuPath()
137 {
138     string path = MEMORY_LEAK_PATH + "/memleak-temp-" + processName_ + "-" + to_string(pid_) + "-rsGpu.txt";
139     return path;
140 }
141 
GetSmapsPath()142 string NativeLeakInfo::GetSmapsPath()
143 {
144     string path = MEMORY_LEAK_PATH + "/memleak-native-" + processName_ + "-" + to_string(pid_) + "-smaps.txt";
145     return path;
146 }
147 
148 } // namespace HiviewDFX
149 } // namespace OHOS
150