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