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_UINT32 = std::numeric_limits<uint32_t>::max(); 29 const uint32_t INVALID_INT32 = std::numeric_limits<int32_t>::max(); 30 const uint64_t INVALID_DATAINDEX = std::numeric_limits<uint64_t>::max(); 31 const size_t MAX_SIZE_T = std::numeric_limits<size_t>::max(); 32 const uint32_t INVALID_ID = std::numeric_limits<uint32_t>::max(); 33 const uint64_t SEC_TO_NS = 1000 * 1000 * 1000; 34 enum BuiltinClocks { 35 TS_CLOCK_UNKNOW = 0, 36 TS_CLOCK_BOOTTIME = 1, 37 TS_CLOCK_REALTIME = 2, 38 TS_CLOCK_REALTIME_COARSE = 3, 39 TS_MONOTONIC = 4, 40 TS_MONOTONIC_COARSE = 5, 41 TS_MONOTONIC_RAW = 6, 42 }; 43 44 enum RefType { 45 K_REF_NO_REF = 0, 46 K_REF_ITID = 1, 47 K_REF_CPUID = 2, 48 K_REF_IRQ = 3, 49 K_REF_SOFT_IRQ = 4, 50 K_REF_IPID = 5, 51 K_REF_ITID_LOOKUP_IPID = 6, 52 K_REF_MAX 53 }; 54 55 enum EndState { 56 // (R) ready state or running state, the process is ready to run, but not necessarily occupying the CPU 57 TASK_RUNNABLE = 0, 58 // (S) Indicates that the process is in light sleep, waiting for the resource state, and can respond to the signal. 59 // Generally, the process actively sleeps into 'S' state. 60 TASK_INTERRUPTIBLE = 1, 61 // (D) Indicates that the process is in deep sleep, waiting for resources, and does not respond to signals. 62 // Typical scenario: process acquisition semaphore blocking. 63 TASK_UNINTERRUPTIBLE = 2, 64 // (Running) Indicates that the thread is running 65 TASK_RUNNING = 3, 66 // (I) Thread in interrupt state 67 TASK_INTERRUPTED = 4, 68 // (X) Exit status, the process is about to be destroyed. 69 TASK_EXIT_DEAD = 16, 70 // (Z) Zombie state 71 TASK_ZOMBIE = 32, 72 // (I) clone thread 73 TASK_CLONE = 64, 74 // (K) Process killed 75 TASK_KILLED = 128, 76 // (DK) 77 TASK_DK = 130, 78 // the process is being debug now 79 TASK_TRACED_KILL = 136, 80 // (W) The process is in a deep sleep state and will be killed directly after waking up 81 TASK_WAKEKILL = 256, 82 // (R+) Process groups in the foreground 83 TASK_FOREGROUND = 2048, 84 TASK_MAX = 4096, 85 TASK_INVALID = 9999 86 }; 87 enum LogLevel { 88 DEBUG = 68, // Debug 89 ERROR = 69, // Error 90 INFO = 73, // Info 91 VERBOSE = 86, // Verbose 92 WARN = 87 // Warn 93 }; 94 enum SchedWakeType { 95 SCHED_WAKING = 0, // sched_waking 96 SCHED_WAKEUP = 1, // sched_wakeup 97 }; 98 using DataIndex = uint64_t; 99 using TableRowId = uint64_t; 100 using InternalPid = uint32_t; 101 using InternalTid = uint32_t; 102 using InternalTime = uint64_t; 103 using FilterId = uint32_t; 104 105 enum BaseDataType { 106 BASE_DATA_TYPE_INT, 107 BASE_DATA_TYPE_STRING, 108 BASE_DATA_TYPE_DOUBLE, 109 BASE_DATA_TYPE_BOOLEAN 110 }; 111 namespace SysTuning { 112 namespace TraceStreamer { 113 struct ArgsData { 114 BaseDataType type; 115 int64_t value; 116 }; 117 } // namespace TraceStreamer 118 } // namespace SysTuning 119 #endif 120