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 #ifndef RELIABILITY_WATCHDOG_INNER_DATA_H 17 #define RELIABILITY_WATCHDOG_INNER_DATA_H 18 19 namespace OHOS { 20 namespace HiviewDFX { 21 constexpr const char* const KEY_SAMPLE_INTERVAL = "sample_interval"; 22 constexpr const char* const KEY_SAMPLE_COUNT = "sample_count"; 23 constexpr const char* const KEY_SAMPLE_REPORT_TIMES = "report_times_per_app"; 24 constexpr const char* const KEY_LOG_TYPE = "log_type"; 25 constexpr const char* const KEY_SET_TIMES_FLAG = "set_report_times_flag"; 26 constexpr const char* const KEY_IGNORE_STARTUP_TIME = "ignore_startup_time"; 27 constexpr const char* const KEY_CHECKER_INTERVAL = "checker_interval"; 28 constexpr const char* const APP_START_CONFIG = "/data/storage/el2/log/xperf_config"; 29 constexpr const char* const EVENT_APP_START_SLOW = "APP_START_SLOW"; 30 constexpr const char* const EVENT_SLIDING_JANK = "SLIDING_JANK"; 31 constexpr const char* const KEY_EVENT_NAME = "event_name"; 32 constexpr const char* const KEY_THRESHOLD = "threshold"; 33 constexpr const char* const KEY_TRIGGER_INTERVAL = "trigger_interval"; 34 constexpr const char* const KEY_COLLECT_TIMES = "collect_times"; 35 constexpr const char* const KEY_REPORT_TIMES = "report_times"; 36 constexpr const char* const KEY_START_TIME = "start_time"; 37 constexpr const char* const KEY_STARTUP_DURATION = "startup_duration"; 38 constexpr const char* const EVENT_APP_START_SCROLL_JANK = "APP_START_SCROLL_JANK"; 39 constexpr const char* const EVENT_APP_START_JANK = "APP_START_JANK"; 40 constexpr const char* const APP_START_SAMPLE = "AppStartSample"; 41 const int SAMPLE_DEFULE_INTERVAL = 150; 42 const int SAMPLE_DEFULE_COUNT = 10; 43 const int SAMPLE_DEFULE_REPORT_TIMES = 1; 44 const int SET_TIMES_FLAG = 1; 45 const int DEFAULT_IGNORE_STARTUP_TIME = 10; // 10s 46 const int ENABLE_TREE_FORMAT = 1; 47 const int APP_START_PARAM_SIZE = 5; 48 const int XCOLLIE_CALLBACK_HISTORY_MAX = 5; 49 const int XCOLLIE_CALLBACK_TIMEWIN_MAX = 60; 50 const unsigned int MAX_WATCH_NUM = 128; // 128: max handler thread 51 constexpr int64_t APP_START_LIMIT = 7 * 24 * 60 * 60 * 1000; // 7 days 52 53 using TimePoint = AppExecFwk::InnerEvent::TimePoint; 54 55 typedef void (*WatchdogInnerBeginFunc)(const char* eventName); 56 typedef void (*WatchdogInnerEndFunc)(const char* eventName); 57 typedef int (*ThreadSamplerInitFunc)(int); 58 typedef int32_t (*ThreadSamplerSampleFunc)(); 59 typedef int (*ThreadSamplerCollectFunc)(char*, char*, size_t, size_t, int); 60 typedef int (*ThreadSamplerDeinitFunc)(); 61 typedef void (*SigActionType)(int, siginfo_t*, void*); 62 63 struct TimeContent { 64 int64_t curBegin; 65 int64_t curEnd; 66 }; 67 68 struct StackContent { 69 bool isStartSampleEnabled {true}; 70 int detectorCount {0}; 71 int collectCount {0}; 72 int reportTimes {SAMPLE_DEFULE_REPORT_TIMES}; 73 int scrollTimes {SAMPLE_DEFULE_REPORT_TIMES}; 74 int64_t reportBegin {0}; 75 int64_t reportEnd {0}; 76 TimePoint lastEndTime; 77 }; 78 79 struct TraceContent { 80 int traceState {0}; 81 int traceCount {0}; 82 int dumpCount {0}; 83 int64_t reportBegin {0}; 84 int64_t reportEnd {0}; 85 TimePoint lastEndTime; 86 }; 87 88 struct AppStartContent { 89 int64_t startTime {0}; 90 int64_t sampleInterval {0}; 91 int64_t startUpDuration {0}; 92 int64_t threshold {0}; 93 std::atomic_int collectCount {0}; 94 int targetCount {0}; 95 int reportTimes {SAMPLE_DEFULE_REPORT_TIMES}; 96 bool isStartSampleEnabled {true}; 97 bool isFinishStartSample {false}; 98 std::atomic_bool enableStartSample {false}; 99 }; 100 } // end of namespace HiviewDFX 101 } // end of namespace OHOS 102 #endif 103