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 contains process dump write log to file module. */ 17 18 #ifndef DFX_DUMP_REQUEST_H 19 #define DFX_DUMP_REQUEST_H 20 21 #include <csignal> 22 #include <cstdint> 23 #include "dfx_define.h" 24 #include "iosfwd" 25 26 namespace OHOS { 27 namespace HiviewDFX { 28 enum ProcessDumpType : int32_t { 29 DUMP_TYPE_PROCESS, 30 DUMP_TYPE_THREAD, 31 }; 32 33 class ProcessDumpRequest { 34 public: 35 ProcessDumpRequest(); 36 ~ProcessDumpRequest() = default; 37 38 ProcessDumpType GetType() const; 39 void SetType(ProcessDumpType type); 40 41 int32_t GetTid() const; 42 void SetTid(int32_t tid); 43 44 int32_t GetRecycleTid() const; 45 void SetRecycleTid(int32_t tid); 46 47 int32_t GetPid() const; 48 void SetPid(int32_t pid); 49 50 int32_t GetVmPid() const; 51 void SetVmPid(int32_t pid); 52 53 uint32_t GetUid() const; 54 void SetUid(uint32_t uid); 55 56 uint64_t GetReserved() const; 57 void SetReserved(uint64_t reserved); 58 59 uint64_t GetTimeStamp() const; 60 void SetTimeStamp(uint64_t timeStamp); 61 62 siginfo_t GetSiginfo() const; 63 void SetSiginfo(const siginfo_t &siginfo); 64 65 ucontext_t GetContext() const; 66 void SetContext(ucontext_t const &context); 67 68 std::string GetThreadNameString() const; 69 std::string GetProcessNameString() const; 70 std::string GetLastFatalMessage() const; 71 TraceInfo GetTraceInfo() const; 72 73 private: 74 ProcessDumpType type_; 75 int32_t tid_ = 0; 76 int32_t recycleTid_; 77 int32_t pid_ = 0; 78 int32_t vmPid_ = 0; 79 uint32_t uid_ = 0; 80 uint64_t reserved_ = 0; 81 uint64_t timeStamp_ = 0; 82 siginfo_t siginfo_; 83 ucontext_t context_; 84 char threadName_[NAME_LEN]; 85 char processName_[NAME_LEN]; 86 char lastFatalMessage_[MAX_FATAL_MSG_SIZE]; 87 TraceInfo traceInfo; 88 }; 89 90 struct LocalDumperRequest { 91 int32_t type; 92 int32_t tid; 93 int32_t pid; 94 uint32_t uid; 95 uint64_t reserved; 96 uint64_t timeStamp; 97 siginfo_t siginfo; 98 ucontext_t context; 99 }; 100 } // namespace HiviewDFX 101 } // namespace OHOS 102 #endif 103