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 SRC_TRACE_BASE_TS_COMMON_H 17 #define SRC_TRACE_BASE_TS_COMMON_H 18 19 #include <limits> 20 #include <map> 21 #include <cstdint> 22 #include <string> 23 24 const uint64_t INVALID_UTID = std::numeric_limits<uint32_t>::max(); 25 const uint64_t INVALID_UINT64 = std::numeric_limits<uint64_t>::max(); 26 const uint64_t MAX_UINT32 = std::numeric_limits<uint32_t>::max(); 27 const uint64_t MAX_UINT64 = std::numeric_limits<uint64_t>::max(); 28 const uint32_t INVALID_UINT16 = std::numeric_limits<uint16_t>::max(); 29 const uint32_t INVALID_UINT32 = std::numeric_limits<uint32_t>::max(); 30 const uint32_t INVALID_INT32 = std::numeric_limits<int32_t>::max(); 31 const int64_t INVALID_INT64 = std::numeric_limits<int64_t>::max(); 32 const uint64_t INVALID_DATAINDEX = std::numeric_limits<uint64_t>::max(); 33 const size_t MAX_SIZE_T = std::numeric_limits<size_t>::max(); 34 const uint32_t INVALID_ID = std::numeric_limits<uint32_t>::max(); 35 const uint64_t SEC_TO_NS = 1000 * 1000 * 1000; 36 const int STR_DEFAULT_LEN = -1; 37 const auto INVALID_CPU = INVALID_UINT32; 38 const auto INVALID_TIME = INVALID_UINT64; 39 enum BuiltinClocks { 40 TS_CLOCK_UNKNOW = 0, 41 TS_CLOCK_BOOTTIME = 1, 42 TS_CLOCK_REALTIME = 2, 43 TS_CLOCK_REALTIME_COARSE = 3, 44 TS_MONOTONIC = 4, 45 TS_MONOTONIC_COARSE = 5, 46 TS_MONOTONIC_RAW = 6, 47 }; 48 49 enum RefType { 50 K_REF_NO_REF = 0, 51 K_REF_ITID = 1, 52 K_REF_CPUID = 2, 53 K_REF_IRQ = 3, 54 K_REF_SOFT_IRQ = 4, 55 K_REF_IPID = 5, 56 K_REF_ITID_LOOKUP_IPID = 6, 57 K_REF_MAX 58 }; 59 60 enum EndState { 61 // (R) ready state or running state, the process is ready to run, but not necessarily occupying the CPU 62 TASK_RUNNABLE = 0, 63 // (S) Indicates that the process is in light sleep, waiting for the resource state, and can respond to the signal. 64 // Generally, the process actively sleeps into 'S' state. 65 TASK_INTERRUPTIBLE = 1, 66 // (D) Indicates that the process is in deep sleep, waiting for resources, and does not respond to signals. 67 // Typical scenario: process acquisition semaphore blocking. 68 TASK_UNINTERRUPTIBLE = 2, 69 // (Running) Indicates that the thread is running 70 TASK_RUNNING = 3, 71 // (I) Thread in interrupt state 72 TASK_INTERRUPTED = 4, 73 // (T) Task being traced 74 TASK_TRACED = 8, 75 // (X) Exit status, the process is about to be destroyed. 76 TASK_EXIT_DEAD = 16, 77 // (Z) Zombie state 78 TASK_ZOMBIE = 32, 79 // (I) clone thread 80 TASK_CLONE = 64, 81 // (K) Process killed 82 TASK_KILLED = 128, 83 // (DK) 84 TASK_DK = 130, 85 // the process is being debug now 86 TASK_TRACED_KILL = 136, 87 // (W) The process is in a deep sleep state and will be killed directly after waking up 88 TASK_WAKEKILL = 256, 89 // (R+) Process groups in the foreground 90 TASK_FOREGROUND = 2048, 91 TASK_MAX = 4096, 92 TASK_INVALID = 9999 93 }; 94 enum TSLogLevel { 95 TS_DEBUG = 68, // Debug 96 TS_ERROR = 69, // Error 97 TS_INFO = 73, // Info 98 TS_VERBOSE = 86, // Verbose 99 TS_WARN = 87 // Warn 100 }; 101 enum SchedWakeType { 102 SCHED_WAKING = 0, // sched_waking 103 SCHED_WAKEUP = 1, // sched_wakeup 104 }; 105 enum DataSourceType { 106 DATA_SOURCE_TYPE_TRACE, 107 DATA_SOURCE_TYPE_MEM, 108 DATA_SOURCE_TYPE_HILOG, 109 DATA_SOURCE_TYPE_ALLOCATION, 110 DATA_SOURCE_TYPE_FPS, 111 DATA_SOURCE_TYPE_NETWORK, 112 DATA_SOURCE_TYPE_DISKIO, 113 DATA_SOURCE_TYPE_CPU, 114 DATA_SOURCE_TYPE_PROCESS, 115 DATA_SOURCE_TYPE_HISYSEVENT, 116 }; 117 using DataIndex = uint64_t; 118 using TableRowId = int32_t; 119 using InternalPid = uint32_t; 120 using InternalTid = uint32_t; 121 using InternalTime = uint64_t; 122 using FilterId = uint32_t; 123 using InternalCpu = uint32_t; // how many cpus? could change to int8_t? 124 125 enum BaseDataType { 126 BASE_DATA_TYPE_INT, 127 BASE_DATA_TYPE_STRING, 128 BASE_DATA_TYPE_DOUBLE, 129 BASE_DATA_TYPE_BOOLEAN 130 }; 131 namespace SysTuning { 132 namespace TraceStreamer { 133 struct ArgsData { 134 BaseDataType type; 135 int64_t value; 136 }; 137 } // namespace TraceStreamer 138 } // namespace SysTuning 139 #endif 140