SoW-2020-0002: Trace Hit Counters: trigger error reporting integration
[lttng-tools.git] / src / common / lttng-kernel.h
1 /*
2 * Copyright (C) 2011 Julien Desfossez <julien.desfossez@polymtl.ca>
3 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
5 *
6 * SPDX-License-Identifier: GPL-2.0-only
7 *
8 */
9
10 #ifndef _LTTNG_KERNEL_H
11 #define _LTTNG_KERNEL_H
12
13 #include <stdint.h>
14 #include <common/macros.h>
15 #include <lttng/constant.h>
16 #include <lttng/event.h>
17
18 #define LTTNG_KERNEL_SYM_NAME_LEN 256
19 #define LTTNG_KERNEL_MAX_UPROBE_NUM 32
20 #define LTTNG_KERNEL_SESSION_NAME_LEN 256
21 #define LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN 26
22
23 /*
24 * LTTng DebugFS ABI structures.
25 *
26 * This is the kernel ABI copied from lttng-modules tree.
27 */
28
29 enum lttng_kernel_instrumentation {
30 LTTNG_KERNEL_ALL = -1, /* Used within lttng-tools */
31 LTTNG_KERNEL_TRACEPOINT = 0,
32 LTTNG_KERNEL_KPROBE = 1,
33 LTTNG_KERNEL_FUNCTION = 2,
34 LTTNG_KERNEL_KRETPROBE = 3,
35 LTTNG_KERNEL_NOOP = 4, /* not hooked */
36 LTTNG_KERNEL_SYSCALL = 5,
37 LTTNG_KERNEL_UPROBE = 6,
38 };
39
40 enum lttng_kernel_context_type {
41 LTTNG_KERNEL_CONTEXT_PID = 0,
42 LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER = 1,
43 LTTNG_KERNEL_CONTEXT_PROCNAME = 2,
44 LTTNG_KERNEL_CONTEXT_PRIO = 3,
45 LTTNG_KERNEL_CONTEXT_NICE = 4,
46 LTTNG_KERNEL_CONTEXT_VPID = 5,
47 LTTNG_KERNEL_CONTEXT_TID = 6,
48 LTTNG_KERNEL_CONTEXT_VTID = 7,
49 LTTNG_KERNEL_CONTEXT_PPID = 8,
50 LTTNG_KERNEL_CONTEXT_VPPID = 9,
51 LTTNG_KERNEL_CONTEXT_HOSTNAME = 10,
52 LTTNG_KERNEL_CONTEXT_CPU_ID = 11,
53 LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE = 12,
54 LTTNG_KERNEL_CONTEXT_PREEMPTIBLE = 13,
55 LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE = 14,
56 LTTNG_KERNEL_CONTEXT_MIGRATABLE = 15,
57 LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL = 16,
58 LTTNG_KERNEL_CONTEXT_CALLSTACK_USER = 17,
59 LTTNG_KERNEL_CONTEXT_CGROUP_NS = 18,
60 LTTNG_KERNEL_CONTEXT_IPC_NS = 19,
61 LTTNG_KERNEL_CONTEXT_MNT_NS = 20,
62 LTTNG_KERNEL_CONTEXT_NET_NS = 21,
63 LTTNG_KERNEL_CONTEXT_PID_NS = 22,
64 LTTNG_KERNEL_CONTEXT_USER_NS = 23,
65 LTTNG_KERNEL_CONTEXT_UTS_NS = 24,
66 LTTNG_KERNEL_CONTEXT_UID = 25,
67 LTTNG_KERNEL_CONTEXT_EUID = 26,
68 LTTNG_KERNEL_CONTEXT_SUID = 27,
69 LTTNG_KERNEL_CONTEXT_GID = 28,
70 LTTNG_KERNEL_CONTEXT_EGID = 29,
71 LTTNG_KERNEL_CONTEXT_SGID = 30,
72 LTTNG_KERNEL_CONTEXT_VUID = 31,
73 LTTNG_KERNEL_CONTEXT_VEUID = 32,
74 LTTNG_KERNEL_CONTEXT_VSUID = 33,
75 LTTNG_KERNEL_CONTEXT_VGID = 34,
76 LTTNG_KERNEL_CONTEXT_VEGID = 35,
77 LTTNG_KERNEL_CONTEXT_VSGID = 36,
78 LTTNG_KERNEL_CONTEXT_TIME_NS = 37,
79 };
80
81 /* Perf counter attributes */
82 struct lttng_kernel_perf_counter_ctx {
83 uint32_t type;
84 uint64_t config;
85 char name[LTTNG_KERNEL_SYM_NAME_LEN];
86 } LTTNG_PACKED;
87
88 /* Event/Channel context */
89 #define LTTNG_KERNEL_CONTEXT_PADDING1 16
90 #define LTTNG_KERNEL_CONTEXT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32
91 struct lttng_kernel_context {
92 enum lttng_kernel_context_type ctx;
93 char padding[LTTNG_KERNEL_CONTEXT_PADDING1];
94
95 union {
96 struct lttng_kernel_perf_counter_ctx perf_counter;
97 char padding[LTTNG_KERNEL_CONTEXT_PADDING2];
98 } u;
99 } LTTNG_PACKED;
100
101 struct lttng_kernel_kretprobe {
102 uint64_t addr;
103
104 uint64_t offset;
105 char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
106 } LTTNG_PACKED;
107
108 /*
109 * Either addr is used, or symbol_name and offset.
110 */
111 struct lttng_kernel_kprobe {
112 uint64_t addr;
113
114 uint64_t offset;
115 char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
116 } LTTNG_PACKED;
117
118 struct lttng_kernel_uprobe {
119 int fd;
120 } LTTNG_PACKED;
121
122 struct lttng_kernel_event_callsite_uprobe {
123 uint64_t offset;
124 } LTTNG_PACKED;
125
126 struct lttng_kernel_event_callsite {
127 union {
128 struct lttng_kernel_event_callsite_uprobe uprobe;
129 } u;
130 } LTTNG_PACKED;
131
132 /* Function tracer */
133 struct lttng_kernel_function {
134 char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
135 } LTTNG_PACKED;
136
137 #define LTTNG_KERNEL_EVENT_PADDING1 16
138 #define LTTNG_KERNEL_EVENT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32
139 struct lttng_kernel_event {
140 char name[LTTNG_KERNEL_SYM_NAME_LEN];
141 enum lttng_kernel_instrumentation instrumentation;
142 char padding[LTTNG_KERNEL_EVENT_PADDING1];
143
144 /* Per instrumentation type configuration */
145 union {
146 struct lttng_kernel_kretprobe kretprobe;
147 struct lttng_kernel_kprobe kprobe;
148 struct lttng_kernel_uprobe uprobe;
149 struct lttng_kernel_function ftrace;
150 char padding[LTTNG_KERNEL_EVENT_PADDING2];
151 } u;
152 } LTTNG_PACKED;
153
154 #define LTTNG_KERNEL_TRIGGER_PADDING1 16
155 #define LTTNG_KERNEL_TRIGGER_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32
156 struct lttng_kernel_trigger {
157 uint64_t id;
158 uint64_t error_counter_idx;
159 char name[LTTNG_KERNEL_SYM_NAME_LEN]; /* event name */
160 enum lttng_kernel_instrumentation instrumentation;
161 char padding[LTTNG_KERNEL_TRIGGER_PADDING1];
162
163 /* Per instrumentation type configuration */
164 union {
165 struct lttng_kernel_kretprobe kretprobe;
166 struct lttng_kernel_kprobe kprobe;
167 struct lttng_kernel_uprobe uprobe;
168 struct lttng_kernel_function ftrace;
169 char padding[LTTNG_KERNEL_TRIGGER_PADDING2];
170 } u;
171 } LTTNG_PACKED;
172
173 enum lttng_kernel_counter_arithmetic {
174 LTTNG_KERNEL_COUNTER_ARITHMETIC_MODULAR = 1,
175 };
176
177 enum lttng_kernel_counter_bitness {
178 LTTNG_KERNEL_COUNTER_BITNESS_32BITS = 1,
179 LTTNG_KERNEL_COUNTER_BITNESS_64BITS = 2,
180 };
181
182 struct lttng_kernel_counter_dimension {
183 uint64_t size;
184 uint64_t underflow_index;
185 uint64_t overflow_index;
186 uint8_t has_underflow;
187 uint8_t has_overflow;
188 } LTTNG_PACKED;
189
190 #define LTTNG_KERNEL_COUNTER_DIMENSION_MAX 8
191 struct lttng_kernel_counter_conf {
192 uint32_t arithmetic; /* enum lttng_kernel_counter_arithmetic */
193 uint32_t bitness; /* enum lttng_kernel_counter_bitness */
194 uint32_t number_dimensions;
195 int64_t global_sum_step;
196 struct lttng_kernel_counter_dimension dimensions[LTTNG_KERNEL_COUNTER_DIMENSION_MAX];
197 } LTTNG_PACKED;
198
199 struct lttng_kernel_counter_value {
200 uint32_t number_dimensions;
201 uint64_t dimension_indexes[LTTNG_KERNEL_COUNTER_DIMENSION_MAX];
202 int64_t value;
203 } LTTNG_PACKED;
204
205 #define LTTNG_KERNEL_TRIGGER_NOTIFICATION_PADDING 32
206 struct lttng_kernel_trigger_notification {
207 uint64_t id;
208 uint16_t capture_buf_size;
209 char padding[LTTNG_KERNEL_TRIGGER_NOTIFICATION_PADDING];
210 } LTTNG_PACKED;
211
212 #define LTTNG_KERNEL_CAPTURE_BYTECODE_MAX_LEN 65536
213 struct lttng_kernel_capture_bytecode {
214 uint32_t len;
215 uint32_t reloc_offset;
216 uint64_t seqnum;
217 char data[0];
218 } LTTNG_PACKED;
219
220 struct lttng_kernel_tracer_version {
221 uint32_t major;
222 uint32_t minor;
223 uint32_t patchlevel;
224 } LTTNG_PACKED;
225
226 struct lttng_kernel_tracer_abi_version {
227 uint32_t major;
228 uint32_t minor;
229 } LTTNG_PACKED;
230
231 struct lttng_kernel_syscall_mask {
232 uint32_t len; /* in bits */
233 char mask[];
234 } LTTNG_PACKED;
235
236 /*
237 * kernel channel
238 */
239 #define LTTNG_KERNEL_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32
240 struct lttng_kernel_channel {
241 uint64_t subbuf_size; /* bytes */
242 uint64_t num_subbuf; /* power of 2 */
243 unsigned int switch_timer_interval; /* usec */
244 unsigned int read_timer_interval; /* usec */
245 enum lttng_event_output output; /* splice, mmap */
246
247 int overwrite; /* 1: overwrite, 0: discard */
248 char padding[LTTNG_KERNEL_CHANNEL_PADDING1];
249 } LTTNG_PACKED;
250
251 #define KERNEL_FILTER_BYTECODE_MAX_LEN 65536
252 struct lttng_kernel_filter_bytecode {
253 uint32_t len;
254 uint32_t reloc_offset;
255 uint64_t seqnum;
256 char data[0];
257 } LTTNG_PACKED;
258
259 /*
260 * kernel session name
261 */
262 struct lttng_kernel_session_name {
263 char name[LTTNG_KERNEL_SESSION_NAME_LEN];
264 } LTTNG_PACKED;
265
266 /*
267 * kernel session creation datetime
268 */
269 struct lttng_kernel_session_creation_time {
270 char iso8601[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN];
271 } LTTNG_PACKED;
272
273 enum lttng_kernel_tracker_type {
274 LTTNG_KERNEL_TRACKER_UNKNOWN = -1,
275
276 LTTNG_KERNEL_TRACKER_PID = 0,
277 LTTNG_KERNEL_TRACKER_VPID = 1,
278 LTTNG_KERNEL_TRACKER_UID = 2,
279 LTTNG_KERNEL_TRACKER_VUID = 3,
280 LTTNG_KERNEL_TRACKER_GID = 4,
281 LTTNG_KERNEL_TRACKER_VGID = 5,
282 };
283
284 struct lttng_kernel_tracker_args {
285 enum lttng_kernel_tracker_type type;
286 int32_t id;
287 };
288
289 #endif /* _LTTNG_KERNEL_H */
This page took 0.060118 seconds and 5 git commands to generate.