• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 /* This files is writer log to file module on process dump module. */
17 
18 #include "dfx_dump_request.h"
19 
20 #include <securec.h>
21 #include <string>
22 #include "dfx_log.h"
23 
24 namespace OHOS {
25 namespace HiviewDFX {
ProcessDumpRequest()26 ProcessDumpRequest::ProcessDumpRequest()
27 {
28     errno_t err = memset_s(&siginfo_, sizeof(siginfo_), 0, sizeof(siginfo_));
29     if (err != EOK) {
30         DfxLogError("%s :: memset_s siginfo_ failed.", __func__);
31     }
32     err = memset_s(&context_, sizeof(context_), 0, sizeof(context_));
33     if (err != EOK) {
34         DfxLogError("%s :: memset_s context_ failed.", __func__);
35     }
36     err = memset_s(&threadName_, sizeof(threadName_), 0, sizeof(threadName_));
37     if (err != EOK) {
38         DfxLogError("%s :: memset_s threadName_ failed.", __func__);
39     }
40     err = memset_s(&processName_, sizeof(processName_), 0, sizeof(processName_));
41     if (err != EOK) {
42         DfxLogError("%s :: memset_s processName_ failed.", __func__);
43     }
44     err = memset_s(&lastFatalMessage_, sizeof(lastFatalMessage_), 0, sizeof(lastFatalMessage_));
45     if (err != EOK) {
46         DfxLogError("%s :: memset_s lastFatalMessage_ failed.", __func__);
47     }
48     type_ = DUMP_TYPE_PROCESS;
49 }
50 
GetType() const51 ProcessDumpType ProcessDumpRequest::GetType() const
52 {
53     return type_;
54 }
55 
SetType(ProcessDumpType type)56 void ProcessDumpRequest::SetType(ProcessDumpType type)
57 {
58     type_ = type;
59 }
60 
GetTid() const61 int32_t ProcessDumpRequest::GetTid() const
62 {
63     return tid_;
64 }
65 
SetTid(int32_t tid)66 void ProcessDumpRequest::SetTid(int32_t tid)
67 {
68     tid_ = tid;
69 }
70 
GetRecycleTid() const71 int32_t ProcessDumpRequest::GetRecycleTid() const
72 {
73     return recycleTid_;
74 }
75 
SetRecycleTid(int32_t tid)76 void ProcessDumpRequest::SetRecycleTid(int32_t tid)
77 {
78     recycleTid_ = tid;
79 }
80 
GetPid() const81 int32_t ProcessDumpRequest::GetPid() const
82 {
83     return pid_;
84 }
85 
SetPid(int32_t pid)86 void ProcessDumpRequest::SetPid(int32_t pid)
87 {
88     pid_ = pid;
89 }
90 
GetVmPid() const91 int32_t ProcessDumpRequest::GetVmPid() const
92 {
93     return vmPid_;
94 }
95 
SetVmPid(int32_t pid)96 void ProcessDumpRequest::SetVmPid(int32_t pid)
97 {
98     vmPid_ = pid;
99 }
100 
GetUid() const101 uint32_t ProcessDumpRequest::GetUid() const
102 {
103     return uid_;
104 }
105 
SetUid(uint32_t uid)106 void ProcessDumpRequest::SetUid(uint32_t uid)
107 {
108     uid_ = uid;
109 }
110 
GetReserved() const111 uint64_t ProcessDumpRequest::GetReserved() const
112 {
113     return reserved_;
114 }
115 
SetReserved(uint64_t reserved)116 void ProcessDumpRequest::SetReserved(uint64_t reserved)
117 {
118     reserved_ = reserved;
119 }
120 
GetTimeStamp() const121 uint64_t ProcessDumpRequest::GetTimeStamp() const
122 {
123     return timeStamp_;
124 }
125 
SetTimeStamp(uint64_t timeStamp)126 void ProcessDumpRequest::SetTimeStamp(uint64_t timeStamp)
127 {
128     timeStamp_ = timeStamp;
129 }
130 
GetSiginfo() const131 siginfo_t ProcessDumpRequest::GetSiginfo() const
132 {
133     return siginfo_;
134 }
135 
SetSiginfo(const siginfo_t & siginfo)136 void ProcessDumpRequest::SetSiginfo(const siginfo_t &siginfo)
137 {
138     siginfo_ = siginfo;
139 }
140 
GetContext() const141 ucontext_t ProcessDumpRequest::GetContext() const
142 {
143     return context_;
144 }
145 
GetThreadNameString() const146 std::string ProcessDumpRequest::GetThreadNameString() const
147 {
148     std::string threadName(threadName_, sizeof(threadName_) - 1);
149     return threadName;
150 }
151 
GetProcessNameString() const152 std::string ProcessDumpRequest::GetProcessNameString() const
153 {
154     std::string processName(processName_, sizeof(processName_) - 1);
155     return processName;
156 }
157 
GetLastFatalMessage() const158 std::string ProcessDumpRequest::GetLastFatalMessage() const
159 {
160     std::string lastMsg(lastFatalMessage_);
161     return lastMsg;
162 }
163 
SetContext(ucontext_t const & context)164 void ProcessDumpRequest::SetContext(ucontext_t const &context)
165 {
166     context_ = context;
167 }
168 
GetTraceInfo() const169 TraceInfo ProcessDumpRequest::GetTraceInfo() const
170 {
171     return traceInfo;
172 }
173 } // namespace HiviewDFX
174 } // namespace OHOS
175