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 #ifndef FREEZE_WATCHPOINT_H 17 #define FREEZE_WATCHPOINT_H 18 19 #include <cstdint> 20 #include <string> 21 22 namespace OHOS { 23 namespace HiviewDFX { 24 class WatchPoint { 25 public: 26 class Builder { 27 public: 28 Builder(); 29 ~Builder(); 30 Builder& InitSeq(long seq); 31 Builder& InitTimestamp(unsigned long long timestamp); 32 Builder& InitPid(long pid); 33 Builder& InitTid(long tid); 34 Builder& InitUid(long uid); 35 Builder& InitTerminalThreadStack(const std::string& terminalThreadStack); 36 Builder& InitDomain(const std::string& domain); 37 Builder& InitStringId(const std::string& stringId); 38 Builder& InitMsg(const std::string& msg); 39 Builder& InitPackageName(const std::string& packageName); 40 Builder& InitProcessName(const std::string& processName); 41 Builder& InitForeGround(const std::string& foreGround); 42 Builder& InitLogPath(const std::string& logPath); 43 Builder& InitHitraceTime(const std::string& hitraceTime); 44 Builder& InitSysrqTime(const std::string& sysrqTime); 45 WatchPoint Build() const; 46 47 private: 48 long seq_; 49 unsigned long long timestamp_; 50 long pid_; 51 long tid_; 52 long uid_; 53 std::string terminalThreadStack_; 54 std::string domain_; 55 std::string stringId_; 56 std::string msg_; 57 std::string packageName_; 58 std::string processName_; 59 std::string foreGround_; 60 std::string logPath_; 61 std::string hitraceTime_; 62 std::string sysrqTime_; 63 friend class WatchPoint; 64 }; 65 66 WatchPoint(); 67 explicit WatchPoint(const WatchPoint::Builder& builder); ~WatchPoint()68 ~WatchPoint() {}; 69 70 long GetSeq() const; 71 unsigned long long GetTimestamp() const; 72 long GetPid() const; 73 long GetTid() const; 74 long GetUid() const; 75 std::string GetTerminalThreadStack() const; 76 std::string GetDomain() const; 77 std::string GetStringId() const; 78 std::string GetMsg() const; 79 std::string GetPackageName() const; 80 std::string GetProcessName() const; 81 std::string GetForeGround() const; 82 std::string GetLogPath() const; 83 std::string GetHitraceTime() const; 84 std::string GetSysrqTime() const; 85 void SetLogPath(const std::string& logPath); 86 void SetTerminalThreadStack(const std::string& terminalThreadStack); 87 void SetSeq(long seq); 88 bool operator<(const WatchPoint& node) const; 89 bool operator==(const WatchPoint& node) const; 90 91 private: 92 long seq_; 93 unsigned long long timestamp_; 94 long pid_; 95 long tid_; 96 long uid_; 97 std::string terminalThreadStack_; 98 std::string domain_; 99 std::string stringId_; 100 std::string msg_; 101 std::string packageName_; 102 std::string processName_; 103 std::string foreGround_; 104 std::string logPath_; 105 std::string hitraceTime_; 106 std::string sysrqTime_; 107 }; 108 } // namespace HiviewDFX 109 } // namespace OHOS 110 #endif 111