• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 
16 #include "watch_point.h"
17 
18 #include <iostream>
19 
20 namespace OHOS {
21 namespace HiviewDFX {
WatchPoint()22 WatchPoint::WatchPoint()
23     : seq_(0), timestamp_(0), pid_(0), uid_(0), tid_(0), domain_(""), stringId_(""), msg_("")
24 {
25 }
26 
WatchPoint(const WatchPoint::Builder & builder)27 WatchPoint::WatchPoint(const WatchPoint::Builder& builder)
28     : seq_(builder.seq_),
29     timestamp_(builder.timestamp_),
30     pid_(builder.pid_),
31     uid_(builder.uid_),
32     tid_(builder.tid_),
33     domain_(builder.domain_),
34     stringId_(builder.stringId_),
35     msg_(builder.msg_),
36     packageName_(builder.packageName_),
37     processName_(builder.processName_),
38     logPath_(builder.logPath_),
39     hitraceTime_(builder.hitraceTime_),
40     sysrqTime_(builder.sysrqTime_)
41 {
42 }
43 
Builder()44 WatchPoint::Builder::Builder()
45     : seq_(0), timestamp_(0), pid_(0), uid_(0), tid_(0), domain_(""), stringId_(""), msg_("")
46 {
47 }
48 
~Builder()49 WatchPoint::Builder::~Builder() {}
50 
InitSeq(long seq)51 WatchPoint::Builder& WatchPoint::Builder::InitSeq(long seq)
52 {
53     seq_ = seq;
54     return *this;
55 }
56 
InitTimestamp(unsigned long long timestamp)57 WatchPoint::Builder& WatchPoint::Builder::InitTimestamp(unsigned long long timestamp)
58 {
59     timestamp_ = timestamp;
60     return *this;
61 }
62 
InitPid(long pid)63 WatchPoint::Builder& WatchPoint::Builder::InitPid(long pid)
64 {
65     pid_ = pid;
66     return *this;
67 }
68 
InitUid(long uid)69 WatchPoint::Builder& WatchPoint::Builder::InitUid(long uid)
70 {
71     uid_ = uid;
72     return *this;
73 }
74 
InitTid(long tid)75 WatchPoint::Builder& WatchPoint::Builder::InitTid(long tid)
76 {
77     tid_ = tid;
78     return *this;
79 }
80 
InitDomain(const std::string & domain)81 WatchPoint::Builder& WatchPoint::Builder::InitDomain(const std::string& domain)
82 {
83     domain_ = domain;
84     return *this;
85 }
86 
InitStringId(const std::string & stringId)87 WatchPoint::Builder& WatchPoint::Builder::InitStringId(const std::string& stringId)
88 {
89     stringId_ = stringId;
90     return *this;
91 }
92 
InitMsg(const std::string & msg)93 WatchPoint::Builder& WatchPoint::Builder::InitMsg(const std::string& msg)
94 {
95     msg_ = msg;
96     return *this;
97 }
98 
InitProcessName(const std::string & processName)99 WatchPoint::Builder& WatchPoint::Builder::InitProcessName(const std::string& processName)
100 {
101     processName_ = processName;
102     return *this;
103 }
104 
InitPackageName(const std::string & packageName)105 WatchPoint::Builder& WatchPoint::Builder::InitPackageName(const std::string& packageName)
106 {
107     packageName_ = packageName;
108     return *this;
109 }
110 
InitLogPath(const std::string & logPath)111 WatchPoint::Builder& WatchPoint::Builder::InitLogPath(const std::string& logPath)
112 {
113     logPath_ = logPath;
114     return *this;
115 }
116 
InitHitraceTime(const std::string & hitraceTime)117 WatchPoint::Builder& WatchPoint::Builder::InitHitraceTime(const std::string& hitraceTime)
118 {
119     hitraceTime_ = hitraceTime;
120     return *this;
121 }
122 
InitSysrqTime(const std::string & sysrqTime)123 WatchPoint::Builder& WatchPoint::Builder::InitSysrqTime(const std::string& sysrqTime)
124 {
125     sysrqTime_ = sysrqTime;
126     return *this;
127 }
128 
Build() const129 WatchPoint WatchPoint::Builder::Build() const
130 {
131     WatchPoint watchPoint = WatchPoint(*this);
132     return watchPoint;
133 }
134 
GetSeq() const135 long WatchPoint::GetSeq() const
136 {
137     return seq_;
138 }
139 
GetTimestamp() const140 unsigned long long WatchPoint::GetTimestamp() const
141 {
142     return timestamp_;
143 }
144 
GetPid() const145 long WatchPoint::GetPid() const
146 {
147     return pid_;
148 }
149 
GetUid() const150 long WatchPoint::GetUid() const
151 {
152     return uid_;
153 }
154 
GetTid() const155 long WatchPoint::GetTid() const
156 {
157     return tid_;
158 }
159 
GetDomain() const160 std::string WatchPoint::GetDomain() const
161 {
162     return domain_;
163 }
164 
GetStringId() const165 std::string WatchPoint::GetStringId() const
166 {
167     return stringId_;
168 }
169 
GetMsg() const170 std::string WatchPoint::GetMsg() const
171 {
172     return msg_;
173 }
174 
GetPackageName() const175 std::string WatchPoint::GetPackageName() const
176 {
177     return packageName_;
178 }
179 
GetProcessName() const180 std::string WatchPoint::GetProcessName() const
181 {
182     return processName_;
183 }
184 
GetLogPath() const185 std::string WatchPoint::GetLogPath() const
186 {
187     return logPath_;
188 }
189 
GetHitraceTime() const190 std::string WatchPoint::GetHitraceTime() const
191 {
192     return hitraceTime_;
193 }
194 
GetSysrqTime() const195 std::string WatchPoint::GetSysrqTime() const
196 {
197     return sysrqTime_;
198 }
199 
SetLogPath(const std::string & logPath)200 void WatchPoint::SetLogPath(const std::string& logPath)
201 {
202     logPath_ = logPath;
203 }
204 
SetSeq(long seq)205 void WatchPoint::SetSeq(long seq)
206 {
207     seq_ = seq;
208 }
209 
operator <(const WatchPoint & node) const210 bool WatchPoint::operator<(const WatchPoint& node) const
211 {
212     if (timestamp_ == node.timestamp_) {
213         return stringId_.compare(node.GetStringId());
214     }
215     return timestamp_ < node.timestamp_;
216 }
217 
operator ==(const WatchPoint & node) const218 bool WatchPoint::operator==(const WatchPoint& node) const
219 {
220     return timestamp_ == node.GetTimestamp() && stringId_.compare(node.GetStringId());
221 }
222 } // namespace HiviewDFX
223 } // namespace OHOS
224