Commit | Line | Data |
---|---|---|
b7cdc182 | 1 | /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
9f36eaed | 2 | * |
2df37e95 | 3 | * lttng/events.h |
4e3c1b9b | 4 | * |
4e3c1b9b | 5 | * Holds LTTng per-session event registry. |
17baffe2 | 6 | * |
886d51a3 | 7 | * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
4e3c1b9b MD |
8 | */ |
9 | ||
9f36eaed MJ |
10 | #ifndef _LTTNG_EVENTS_H |
11 | #define _LTTNG_EVENTS_H | |
12 | ||
5f4c791e | 13 | #include <lttng/kernel-version.h> |
4e3c1b9b | 14 | #include <linux/list.h> |
d6d808f3 | 15 | #include <linux/kprobes.h> |
d83004aa | 16 | #include <linux/kref.h> |
41f229dc | 17 | #include <linux/uuid.h> |
754d534a | 18 | #include <linux/irq_work.h> |
149b9a9d | 19 | #include <wrapper/uprobes.h> |
2df37e95 MD |
20 | #include <lttng/cpuhotplug.h> |
21 | #include <lttng/tracer.h> | |
22 | #include <lttng/abi.h> | |
23 | #include <lttng/abi-old.h> | |
24 | #include <lttng/endian.h> | |
4e3c1b9b | 25 | |
e97dc605 | 26 | #define lttng_is_signed_type(type) (((type) -1) < (type) 1) |
9e7e4892 | 27 | |
a90917c3 MD |
28 | struct lttng_channel; |
29 | struct lttng_session; | |
d83004aa | 30 | struct lttng_metadata_cache; |
1c25284c | 31 | struct lib_ring_buffer_ctx; |
ba1f5986 | 32 | struct perf_event; |
833ad6a0 | 33 | struct perf_event_attr; |
3b731ab1 | 34 | struct lib_ring_buffer_config; |
4e3c1b9b | 35 | |
c0edae1d MD |
36 | /* Type description */ |
37 | ||
12bb2edb MD |
38 | enum lttng_kernel_type { |
39 | lttng_kernel_type_integer, | |
40 | lttng_kernel_type_string, | |
437d5aa5 MD |
41 | lttng_kernel_type_enum, |
42 | lttng_kernel_type_array, | |
43 | lttng_kernel_type_sequence, | |
44 | lttng_kernel_type_struct, | |
45 | lttng_kernel_type_variant, | |
12bb2edb | 46 | NR_LTTNG_KERNEL_TYPES, |
c0edae1d MD |
47 | }; |
48 | ||
28cbcb59 MD |
49 | enum lttng_kernel_string_encoding { |
50 | lttng_kernel_string_encoding_none = 0, | |
51 | lttng_kernel_string_encoding_UTF8 = 1, | |
52 | lttng_kernel_string_encoding_ASCII = 2, | |
53 | NR_LTTNG_KERNEL_STRING_ENCODING, | |
c0edae1d MD |
54 | }; |
55 | ||
d83004aa JD |
56 | enum channel_type { |
57 | PER_CPU_CHANNEL, | |
58 | METADATA_CHANNEL, | |
59 | }; | |
60 | ||
a28cc520 | 61 | struct lttng_kernel_enum_value { |
141ddf28 MD |
62 | unsigned long long value; |
63 | unsigned int signedness:1; | |
64 | }; | |
65 | ||
a28cc520 MD |
66 | struct lttng_kernel_enum_entry { |
67 | struct lttng_kernel_enum_value start, end; /* start and end are inclusive */ | |
c0edae1d | 68 | const char *string; |
08ad1061 PP |
69 | struct { |
70 | unsigned int is_auto:1; | |
71 | } options; | |
c0edae1d MD |
72 | }; |
73 | ||
437d5aa5 MD |
74 | /* |
75 | * struct lttng_kernel_type_common is fixed-size. Its children inherits | |
76 | * from it by embedding struct lttng_kernel_type_common as its first field. | |
77 | */ | |
78 | struct lttng_kernel_type_common { | |
79 | enum lttng_kernel_type type; | |
80 | }; | |
81 | ||
82 | struct lttng_kernel_type_integer { | |
83 | struct lttng_kernel_type_common parent; | |
c099397a MD |
84 | unsigned int size; /* in bits */ |
85 | unsigned short alignment; /* in bits */ | |
9cccf98a MD |
86 | unsigned int signedness:1, |
87 | reverse_byte_order:1; | |
e0a7a7c4 | 88 | unsigned int base; /* 2, 8, 10, 16, for pretty print */ |
437d5aa5 MD |
89 | }; |
90 | ||
91 | struct lttng_kernel_type_string { | |
92 | struct lttng_kernel_type_common parent; | |
28cbcb59 | 93 | enum lttng_kernel_string_encoding encoding; |
c099397a MD |
94 | }; |
95 | ||
437d5aa5 MD |
96 | struct lttng_kernel_type_enum { |
97 | struct lttng_kernel_type_common parent; | |
98 | const struct lttng_kernel_enum_desc *desc; /* Enumeration mapping */ | |
99 | const struct lttng_kernel_type_common *container_type; | |
100 | }; | |
101 | ||
102 | struct lttng_kernel_type_array { | |
103 | struct lttng_kernel_type_common parent; | |
104 | const struct lttng_kernel_type_common *elem_type; | |
105 | unsigned int length; /* Num. elems. */ | |
106 | unsigned int alignment; | |
107 | enum lttng_kernel_string_encoding encoding; | |
108 | }; | |
109 | ||
110 | struct lttng_kernel_type_sequence { | |
111 | struct lttng_kernel_type_common parent; | |
112 | const char *length_name; /* Length field name. */ | |
113 | const struct lttng_kernel_type_common *elem_type; | |
114 | unsigned int alignment; /* Alignment before elements. */ | |
115 | enum lttng_kernel_string_encoding encoding; | |
116 | }; | |
117 | ||
118 | struct lttng_kernel_type_struct { | |
119 | struct lttng_kernel_type_common parent; | |
120 | unsigned int nr_fields; | |
121 | const struct lttng_kernel_event_field **fields; /* Array of pointers to fields. */ | |
122 | unsigned int alignment; | |
123 | }; | |
124 | ||
125 | struct lttng_kernel_type_variant { | |
126 | struct lttng_kernel_type_common parent; | |
127 | const char *tag_name; | |
128 | const struct lttng_kernel_event_field **choices; /* Array of pointers to fields. */ | |
129 | unsigned int nr_choices; | |
130 | unsigned int alignment; | |
c099397a MD |
131 | }; |
132 | ||
d96a4a7a | 133 | struct lttng_kernel_enum_desc { |
c099397a | 134 | const char *name; |
437d5aa5 | 135 | const struct lttng_kernel_enum_entry **entries; |
141ddf28 | 136 | unsigned int nr_entries; |
c099397a | 137 | }; |
c0edae1d MD |
138 | |
139 | /* Event field description */ | |
140 | ||
437d5aa5 | 141 | struct lttng_kernel_event_field { |
c0edae1d | 142 | const char *name; |
437d5aa5 | 143 | const struct lttng_kernel_type_common *type; |
f127e61e | 144 | unsigned int nowrite:1, /* do not write into trace */ |
ceabb767 MD |
145 | user:1, /* fetch from user-space */ |
146 | nofilter:1; /* do not consider for filter */ | |
c0edae1d MD |
147 | }; |
148 | ||
437d5aa5 MD |
149 | #define lttng_kernel_static_type_integer(_size, _alignment, _signedness, _byte_order, _base) \ |
150 | ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_integer, { \ | |
151 | .parent = { \ | |
152 | .type = lttng_kernel_type_integer, \ | |
153 | }, \ | |
154 | .size = (_size), \ | |
155 | .alignment = (_alignment), \ | |
156 | .signedness = (_signedness), \ | |
157 | .reverse_byte_order = (_byte_order) != __BYTE_ORDER, \ | |
158 | .base = (_base), \ | |
159 | })) | |
160 | ||
161 | #define lttng_kernel_static_type_integer_from_type(_type, _byte_order, _base) \ | |
162 | lttng_kernel_static_type_integer(sizeof(_type) * CHAR_BIT, \ | |
163 | lttng_alignof(_type) * CHAR_BIT, \ | |
164 | lttng_is_signed_type(_type), \ | |
165 | _byte_order, \ | |
166 | _base) | |
167 | ||
168 | #define lttng_kernel_static_type_enum(_desc, _container_type) \ | |
169 | ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_enum, { \ | |
170 | .parent = { \ | |
171 | .type = lttng_kernel_type_enum, \ | |
172 | }, \ | |
173 | .desc = (_desc), \ | |
174 | .container_type = (_container_type), \ | |
175 | })) | |
176 | ||
177 | #define lttng_kernel_static_type_array(_length, _elem_type, _alignment, _encoding) \ | |
178 | ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_array, { \ | |
179 | .parent = { \ | |
180 | .type = lttng_kernel_type_array, \ | |
181 | }, \ | |
182 | .length = (_length), \ | |
183 | .alignment = (_alignment), \ | |
184 | .encoding = lttng_kernel_string_encoding_##_encoding, \ | |
185 | .elem_type = (_elem_type), \ | |
186 | })) | |
187 | ||
188 | #define lttng_kernel_static_type_array_text(_length) \ | |
189 | lttng_kernel_static_type_array(_length, \ | |
190 | lttng_kernel_static_type_integer(sizeof(char) * CHAR_BIT, \ | |
191 | lttng_alignof(char) * CHAR_BIT, lttng_is_signed_type(char), \ | |
192 | __BYTE_ORDER, 10), \ | |
193 | 0, UTF8) | |
194 | ||
195 | #define lttng_kernel_static_type_sequence(_length_name, _elem_type, _alignment, _encoding) \ | |
196 | ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_sequence, { \ | |
197 | .parent = { \ | |
198 | .type = lttng_kernel_type_sequence, \ | |
199 | }, \ | |
200 | .length_name = (_length_name), \ | |
201 | .alignment = (_alignment), \ | |
202 | .encoding = lttng_kernel_string_encoding_##_encoding, \ | |
203 | .elem_type = (_elem_type), \ | |
204 | })) | |
205 | ||
206 | #define lttng_kernel_static_type_string(_encoding) \ | |
207 | ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_string, { \ | |
208 | .parent = { \ | |
209 | .type = lttng_kernel_type_string, \ | |
210 | }, \ | |
211 | .encoding = lttng_kernel_string_encoding_##_encoding, \ | |
212 | })) | |
213 | ||
214 | #define lttng_kernel_static_type_struct(_nr_fields, _fields, _alignment) \ | |
215 | ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_struct, { \ | |
216 | .parent = { \ | |
217 | .type = lttng_kernel_type_struct, \ | |
218 | }, \ | |
219 | .nr_fields = (_nr_fields), \ | |
220 | .fields = _fields, \ | |
221 | .alignment = (_alignment), \ | |
222 | })) | |
223 | ||
224 | #define lttng_kernel_static_type_variant(_nr_choices, _choices, _tag_name, _alignment) \ | |
225 | ((const struct lttng_kernel_type_common *) __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_type_variant, { \ | |
226 | .parent = { \ | |
227 | .type = lttng_kernel_type_variant, \ | |
228 | }, \ | |
229 | .tag_name = (_tag_name), \ | |
230 | .choices = _choices, \ | |
231 | .nr_choices = (_nr_choices), \ | |
232 | .alignment = (_alignment), \ | |
233 | })) | |
234 | ||
235 | #define lttng_kernel_static_event_field(_name, _type, _nowrite, _user, _nofilter) \ | |
236 | __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_event_field, { \ | |
237 | .name = (_name), \ | |
238 | .type = (_type), \ | |
239 | .nowrite = (_nowrite), \ | |
240 | .user = (_user), \ | |
241 | .nofilter = (_nofilter), \ | |
242 | }) | |
243 | ||
244 | #define lttng_kernel_static_event_field_array(_fields...) \ | |
245 | __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_event_field *, \ | |
246 | _fields \ | |
247 | ) | |
248 | ||
249 | #define lttng_kernel_static_ctx_field(_event_field, _get_size, _get_size_arg, _record, _get_value, _destroy, _priv) \ | |
250 | __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_ctx_field, { \ | |
251 | .event_field = (_event_field), \ | |
252 | .get_size = (_get_size), \ | |
253 | .get_size_arg = (_get_size_arg), \ | |
254 | .record = (_record), \ | |
255 | .get_value = (_get_value), \ | |
256 | .destroy = (_destroy), \ | |
257 | .priv = (_priv), \ | |
258 | }) | |
259 | ||
260 | #define lttng_kernel_static_enum_entry_value(_string, _value) \ | |
261 | __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_enum_entry, { \ | |
262 | .start = { \ | |
263 | .signedness = lttng_is_signed_type(__typeof__(_value)), \ | |
264 | .value = lttng_is_signed_type(__typeof__(_value)) ? \ | |
265 | (long long) (_value) : (_value), \ | |
266 | }, \ | |
267 | .end = { \ | |
268 | .signedness = lttng_is_signed_type(__typeof__(_value)), \ | |
269 | .value = lttng_is_signed_type(__typeof__(_value)) ? \ | |
270 | (long long) (_value) : (_value), \ | |
271 | }, \ | |
272 | .string = (_string), \ | |
273 | }), | |
274 | ||
275 | #define lttng_kernel_static_enum_entry_range(_string, _range_start, _range_end) \ | |
276 | __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_enum_entry, { \ | |
277 | .start = { \ | |
278 | .signedness = lttng_is_signed_type(__typeof__(_range_start)), \ | |
279 | .value = lttng_is_signed_type(__typeof__(_range_start)) ? \ | |
280 | (long long) (_range_start) : (_range_start), \ | |
281 | }, \ | |
282 | .end = { \ | |
283 | .signedness = lttng_is_signed_type(__typeof__(_range_end)), \ | |
284 | .value = lttng_is_signed_type(__typeof__(_range_end)) ? \ | |
285 | (long long) (_range_end) : (_range_end), \ | |
286 | }, \ | |
287 | .string = (_string), \ | |
288 | }), | |
289 | ||
290 | #define lttng_kernel_static_enum_entry_auto(_string) \ | |
291 | __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_enum_entry, { \ | |
292 | .start = { \ | |
293 | .signedness = -1, \ | |
294 | .value = -1, \ | |
295 | }, \ | |
296 | .end = { \ | |
297 | .signedness = -1, \ | |
298 | .value = -1, \ | |
299 | }, \ | |
300 | .string = (_string), \ | |
301 | .options = { \ | |
302 | .is_auto = 1, \ | |
303 | } \ | |
304 | }), | |
305 | ||
07dfc1d0 MD |
306 | union lttng_ctx_value { |
307 | int64_t s64; | |
308 | const char *str; | |
309 | double d; | |
310 | }; | |
311 | ||
2001023e MD |
312 | /* |
313 | * We need to keep this perf counter field separately from struct | |
437d5aa5 | 314 | * lttng_kernel_ctx_field because cpu hotplug needs fixed-location addresses. |
2001023e MD |
315 | */ |
316 | struct lttng_perf_counter_field { | |
5f4c791e | 317 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) |
1e367326 MD |
318 | struct lttng_cpuhp_node cpuhp_prepare; |
319 | struct lttng_cpuhp_node cpuhp_online; | |
320 | #else | |
2001023e MD |
321 | struct notifier_block nb; |
322 | int hp_enable; | |
1e367326 | 323 | #endif |
2001023e MD |
324 | struct perf_event_attr *attr; |
325 | struct perf_event **e; /* per-cpu array */ | |
437d5aa5 MD |
326 | char *name; |
327 | struct lttng_kernel_event_field *event_field; | |
2001023e MD |
328 | }; |
329 | ||
79150a49 JD |
330 | struct lttng_probe_ctx { |
331 | struct lttng_event *event; | |
7fad9b39 | 332 | struct lttng_event_notifier *event_notifier; // Not sure if we will ever need it. |
79150a49 JD |
333 | uint8_t interruptible; |
334 | }; | |
335 | ||
437d5aa5 MD |
336 | struct lttng_kernel_ctx_field { |
337 | const struct lttng_kernel_event_field *event_field; | |
f1676205 | 338 | size_t (*get_size)(size_t offset); |
437d5aa5 | 339 | size_t (*get_size_arg)(size_t offset, struct lttng_kernel_ctx_field *field, |
1474c8e2 FG |
340 | struct lib_ring_buffer_ctx *ctx, |
341 | struct lttng_channel *chan); | |
437d5aa5 | 342 | void (*record)(struct lttng_kernel_ctx_field *field, |
f1676205 | 343 | struct lib_ring_buffer_ctx *ctx, |
a90917c3 | 344 | struct lttng_channel *chan); |
437d5aa5 | 345 | void (*get_value)(struct lttng_kernel_ctx_field *field, |
79150a49 | 346 | struct lttng_probe_ctx *lttng_probe_ctx, |
07dfc1d0 | 347 | union lttng_ctx_value *value); |
437d5aa5 | 348 | void (*destroy)(struct lttng_kernel_ctx_field *field); |
3c1a57e8 | 349 | void *priv; |
ba1f5986 MD |
350 | }; |
351 | ||
437d5aa5 MD |
352 | struct lttng_kernel_ctx { |
353 | struct lttng_kernel_ctx_field *fields; | |
0d1a681e | 354 | unsigned int nr_fields; |
ba1f5986 | 355 | unsigned int allocated_fields; |
a9dd15da | 356 | size_t largest_align; /* in bytes */ |
0d1a681e MD |
357 | }; |
358 | ||
437d5aa5 MD |
359 | struct lttng_kernel_event_desc { |
360 | const char *event_name; /* lttng-modules name */ | |
361 | const char *event_kname; /* Linux kernel name (tracepoints) */ | |
362 | const struct lttng_kernel_probe_desc *probe_desc; | |
363 | void (*probe_callback)(void); | |
364 | const struct lttng_kernel_event_field **fields; /* event payload */ | |
c0edae1d | 365 | unsigned int nr_fields; |
dc7f600a | 366 | struct module *owner; |
7fad9b39 | 367 | void *event_notifier_callback; |
c0edae1d MD |
368 | }; |
369 | ||
437d5aa5 MD |
370 | struct lttng_kernel_probe_desc { |
371 | const char *provider_name; | |
372 | const struct lttng_kernel_event_desc **event_desc; | |
85a9ca7f MD |
373 | unsigned int nr_events; |
374 | struct list_head head; /* chain registered probes */ | |
3c997079 MD |
375 | struct list_head lazy_init_head; |
376 | int lazy; /* lazy registration */ | |
85a9ca7f MD |
377 | }; |
378 | ||
7371f44c MD |
379 | struct lttng_krp; /* Kretprobe handling */ |
380 | ||
3c997079 MD |
381 | enum lttng_event_type { |
382 | LTTNG_TYPE_EVENT = 0, | |
383 | LTTNG_TYPE_ENABLER = 1, | |
384 | }; | |
385 | ||
89ec2b91 FD |
386 | enum lttng_bytecode_node_type { |
387 | LTTNG_BYTECODE_NODE_TYPE_FILTER, | |
99d223ad | 388 | LTTNG_BYTECODE_NODE_TYPE_CAPTURE, |
89ec2b91 FD |
389 | }; |
390 | ||
391 | struct lttng_bytecode_node { | |
392 | enum lttng_bytecode_node_type type; | |
07dfc1d0 MD |
393 | struct list_head node; |
394 | struct lttng_enabler *enabler; | |
89ec2b91 FD |
395 | struct { |
396 | uint32_t len; | |
397 | uint32_t reloc_offset; | |
398 | uint64_t seqnum; | |
399 | char data[]; | |
400 | } bc; | |
07dfc1d0 MD |
401 | }; |
402 | ||
403 | /* | |
80c2a69a | 404 | * Bytecode interpreter return value masks. |
07dfc1d0 | 405 | */ |
80c2a69a FD |
406 | enum lttng_bytecode_interpreter_ret { |
407 | LTTNG_INTERPRETER_DISCARD = 0, | |
408 | LTTNG_INTERPRETER_RECORD_FLAG = (1ULL << 0), | |
07dfc1d0 MD |
409 | /* Other bits are kept for future use. */ |
410 | }; | |
411 | ||
99d223ad FD |
412 | struct lttng_interpreter_output; |
413 | ||
07dfc1d0 MD |
414 | struct lttng_bytecode_runtime { |
415 | /* Associated bytecode */ | |
89ec2b91 | 416 | struct lttng_bytecode_node *bc; |
3d650c7b FD |
417 | union { |
418 | uint64_t (*filter)(void *filter_data, | |
419 | struct lttng_probe_ctx *lttng_probe_ctx, | |
420 | const char *filter_stack_data); | |
99d223ad FD |
421 | uint64_t (*capture)(void *filter_data, |
422 | struct lttng_probe_ctx *lttng_probe_ctx, | |
423 | const char *capture_stack_data, | |
424 | struct lttng_interpreter_output *output); | |
3d650c7b | 425 | } interpreter_funcs; |
07dfc1d0 MD |
426 | int link_failed; |
427 | struct list_head node; /* list of bytecode runtime in event */ | |
437d5aa5 | 428 | struct lttng_kernel_ctx *ctx; |
07dfc1d0 MD |
429 | }; |
430 | ||
3c997079 MD |
431 | /* |
432 | * Objects in a linked-list of enablers, owned by an event. | |
433 | */ | |
434 | struct lttng_enabler_ref { | |
435 | struct list_head node; /* enabler ref list */ | |
436 | struct lttng_enabler *ref; /* backward ref */ | |
437 | }; | |
438 | ||
3aed4dca | 439 | struct lttng_uprobe_handler { |
83b802dc FD |
440 | union { |
441 | struct lttng_event *event; | |
9de67196 | 442 | struct lttng_event_notifier *event_notifier; |
83b802dc | 443 | } u; |
3aed4dca FD |
444 | loff_t offset; |
445 | struct uprobe_consumer up_consumer; | |
446 | struct list_head node; | |
447 | }; | |
448 | ||
8bf17deb FD |
449 | struct lttng_kprobe { |
450 | struct kprobe kp; | |
451 | char *symbol_name; | |
452 | }; | |
453 | ||
83b802dc FD |
454 | struct lttng_uprobe { |
455 | struct inode *inode; | |
456 | struct list_head head; | |
457 | }; | |
458 | ||
badfe9f5 MD |
459 | enum lttng_syscall_entryexit { |
460 | LTTNG_SYSCALL_ENTRY, | |
461 | LTTNG_SYSCALL_EXIT, | |
462 | }; | |
463 | ||
464 | enum lttng_syscall_abi { | |
465 | LTTNG_SYSCALL_ABI_NATIVE, | |
466 | LTTNG_SYSCALL_ABI_COMPAT, | |
467 | }; | |
468 | ||
85a9ca7f | 469 | /* |
a90917c3 | 470 | * lttng_event structure is referred to by the tracing fast path. It must be |
85a9ca7f MD |
471 | * kept small. |
472 | */ | |
a90917c3 | 473 | struct lttng_event { |
3c997079 | 474 | enum lttng_event_type evtype; /* First field. */ |
85a9ca7f | 475 | unsigned int id; |
a90917c3 | 476 | struct lttng_channel *chan; |
e64957da | 477 | int enabled; |
437d5aa5 | 478 | const struct lttng_kernel_event_desc *desc; |
85a9ca7f | 479 | void *filter; |
437d5aa5 | 480 | struct lttng_kernel_ctx *ctx; |
38d024ae | 481 | enum lttng_kernel_instrumentation instrumentation; |
d6d808f3 | 482 | union { |
8bf17deb | 483 | struct lttng_kprobe kprobe; |
7371f44c MD |
484 | struct { |
485 | struct lttng_krp *lttng_krp; | |
486 | char *symbol_name; | |
487 | } kretprobe; | |
83b802dc | 488 | struct lttng_uprobe uprobe; |
badfe9f5 | 489 | struct { |
badfe9f5 MD |
490 | enum lttng_syscall_entryexit entryexit; |
491 | enum lttng_syscall_abi abi; | |
3b82c4e1 | 492 | struct hlist_node node; /* chain registered syscall event */ |
badfe9f5 | 493 | } syscall; |
d6d808f3 | 494 | } u; |
3c997079 | 495 | struct list_head list; /* Event list in session */ |
9cccf98a | 496 | unsigned int metadata_dumped:1; |
3c997079 MD |
497 | |
498 | /* Backward references: list of lttng_enabler_ref (ref to enablers) */ | |
499 | struct list_head enablers_ref_head; | |
500 | struct hlist_node hlist; /* session ht of events */ | |
501 | int registered; /* has reg'd tracepoint probe */ | |
07dfc1d0 | 502 | /* list of struct lttng_bytecode_runtime, sorted by seqnum */ |
183e8b3a | 503 | struct list_head filter_bytecode_runtime_head; |
07dfc1d0 | 504 | int has_enablers_without_bytecode; |
3c997079 MD |
505 | }; |
506 | ||
c3eddb2e MD |
507 | struct lttng_kernel_notifier_ctx { |
508 | int eval_capture; | |
509 | }; | |
510 | ||
dffef45d FD |
511 | // FIXME: Really similar to lttng_event above. Could those be merged ? |
512 | struct lttng_event_notifier { | |
513 | enum lttng_event_type evtype; /* First field. */ | |
514 | uint64_t user_token; | |
99f52fcc | 515 | uint64_t error_counter_index; |
dffef45d FD |
516 | int enabled; |
517 | int registered; /* has reg'd tracepoint probe */ | |
437d5aa5 | 518 | const struct lttng_kernel_event_desc *desc; |
dffef45d FD |
519 | void *filter; |
520 | struct list_head list; /* event_notifier list in event_notifier group */ | |
521 | ||
522 | enum lttng_kernel_instrumentation instrumentation; | |
523 | union { | |
2b16f0c9 | 524 | struct lttng_kprobe kprobe; |
9de67196 | 525 | struct lttng_uprobe uprobe; |
8a8ac9a8 FD |
526 | struct { |
527 | enum lttng_syscall_entryexit entryexit; | |
528 | enum lttng_syscall_abi abi; | |
529 | struct hlist_node node; /* chain registered syscall event_notifier */ | |
530 | unsigned int syscall_id; | |
531 | } syscall; | |
532 | ||
dffef45d FD |
533 | } u; |
534 | ||
535 | /* Backward references: list of lttng_enabler_ref (ref to enablers) */ | |
536 | struct list_head enablers_ref_head; | |
537 | struct hlist_node hlist; /* session ht of event_notifiers */ | |
538 | /* list of struct lttng_bytecode_runtime, sorted by seqnum */ | |
183e8b3a | 539 | struct list_head filter_bytecode_runtime_head; |
99d223ad FD |
540 | size_t num_captures; |
541 | struct list_head capture_bytecode_runtime_head; | |
dffef45d | 542 | int has_enablers_without_bytecode; |
c3eddb2e | 543 | int eval_capture; /* Should evaluate capture */ |
dffef45d | 544 | |
99d223ad FD |
545 | void (*send_notification)(struct lttng_event_notifier *event_notifier, |
546 | struct lttng_probe_ctx *lttng_probe_ctx, | |
c3eddb2e MD |
547 | const char *interpreter_stack_data, |
548 | struct lttng_kernel_notifier_ctx *notif_ctx); | |
dffef45d FD |
549 | struct lttng_event_notifier_group *group; /* Weak ref */ |
550 | }; | |
551 | ||
3b861b22 FD |
552 | enum lttng_enabler_format_type { |
553 | LTTNG_ENABLER_FORMAT_STAR_GLOB, | |
554 | LTTNG_ENABLER_FORMAT_NAME, | |
3c997079 MD |
555 | }; |
556 | ||
557 | /* | |
558 | * Enabler field, within whatever object is enabling an event. Target of | |
559 | * backward reference. | |
560 | */ | |
561 | struct lttng_enabler { | |
562 | enum lttng_event_type evtype; /* First field. */ | |
563 | ||
3b861b22 | 564 | enum lttng_enabler_format_type format_type; |
3c997079 | 565 | |
608ab495 | 566 | /* head list of struct lttng_bytecode_node */ |
07dfc1d0 | 567 | struct list_head filter_bytecode_head; |
3c997079 MD |
568 | |
569 | struct lttng_kernel_event event_param; | |
b2bc0bc8 | 570 | unsigned int enabled:1; |
dffef45d FD |
571 | |
572 | uint64_t user_token; /* User-provided token. */ | |
b2bc0bc8 FD |
573 | }; |
574 | ||
575 | struct lttng_event_enabler { | |
576 | struct lttng_enabler base; | |
577 | struct list_head node; /* per-session list of enablers */ | |
3c997079 | 578 | struct lttng_channel *chan; |
2954b37c FD |
579 | /* |
580 | * Unused, but kept around to make it explicit that the tracer can do | |
581 | * it. | |
582 | */ | |
437d5aa5 | 583 | struct lttng_kernel_ctx *ctx; |
85a9ca7f MD |
584 | }; |
585 | ||
dffef45d FD |
586 | struct lttng_event_notifier_enabler { |
587 | struct lttng_enabler base; | |
99f52fcc | 588 | uint64_t error_counter_index; |
dffef45d FD |
589 | struct list_head node; /* List of event_notifier enablers */ |
590 | struct lttng_event_notifier_group *group; | |
99d223ad FD |
591 | |
592 | /* head list of struct lttng_bytecode_node */ | |
593 | struct list_head capture_bytecode_head; | |
594 | uint64_t num_captures; | |
dffef45d FD |
595 | }; |
596 | ||
99d223ad | 597 | |
b2bc0bc8 FD |
598 | static inline |
599 | struct lttng_enabler *lttng_event_enabler_as_enabler( | |
600 | struct lttng_event_enabler *event_enabler) | |
601 | { | |
602 | return &event_enabler->base; | |
603 | } | |
604 | ||
dffef45d FD |
605 | static inline |
606 | struct lttng_enabler *lttng_event_notifier_enabler_as_enabler( | |
607 | struct lttng_event_notifier_enabler *event_notifier_enabler) | |
608 | { | |
609 | return &event_notifier_enabler->base; | |
610 | } | |
b2bc0bc8 | 611 | |
a90917c3 | 612 | struct lttng_channel_ops { |
85a9ca7f | 613 | struct channel *(*channel_create)(const char *name, |
5cf4b87c | 614 | void *priv, |
85a9ca7f MD |
615 | void *buf_addr, |
616 | size_t subbuf_size, size_t num_subbuf, | |
617 | unsigned int switch_timer_interval, | |
618 | unsigned int read_timer_interval); | |
619 | void (*channel_destroy)(struct channel *chan); | |
620 | struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan); | |
f71ecafa | 621 | int (*buffer_has_read_closed_stream)(struct channel *chan); |
85a9ca7f | 622 | void (*buffer_read_close)(struct lib_ring_buffer *buf); |
4e1f08f4 | 623 | int (*event_reserve)(struct lib_ring_buffer_ctx *ctx, |
64c796d8 | 624 | uint32_t event_id); |
85a9ca7f MD |
625 | void (*event_commit)(struct lib_ring_buffer_ctx *ctx); |
626 | void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src, | |
627 | size_t len); | |
4ea00e4f JD |
628 | void (*event_write_from_user)(struct lib_ring_buffer_ctx *ctx, |
629 | const void *src, size_t len); | |
58aa5d24 MD |
630 | void (*event_memset)(struct lib_ring_buffer_ctx *ctx, |
631 | int c, size_t len); | |
16f78f3a MD |
632 | void (*event_strcpy)(struct lib_ring_buffer_ctx *ctx, const char *src, |
633 | size_t len); | |
634 | void (*event_strcpy_from_user)(struct lib_ring_buffer_ctx *ctx, | |
635 | const char __user *src, size_t len); | |
1ec3f75a MD |
636 | /* |
637 | * packet_avail_size returns the available size in the current | |
638 | * packet. Note that the size returned is only a hint, since it | |
639 | * may change due to concurrent writes. | |
640 | */ | |
641 | size_t (*packet_avail_size)(struct channel *chan); | |
71c1d843 | 642 | wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu); |
24cedcfe MD |
643 | wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan); |
644 | int (*is_finalized)(struct channel *chan); | |
254ec7bc | 645 | int (*is_disabled)(struct channel *chan); |
3b731ab1 JD |
646 | int (*timestamp_begin) (const struct lib_ring_buffer_config *config, |
647 | struct lib_ring_buffer *bufb, | |
648 | uint64_t *timestamp_begin); | |
649 | int (*timestamp_end) (const struct lib_ring_buffer_config *config, | |
650 | struct lib_ring_buffer *bufb, | |
651 | uint64_t *timestamp_end); | |
652 | int (*events_discarded) (const struct lib_ring_buffer_config *config, | |
653 | struct lib_ring_buffer *bufb, | |
654 | uint64_t *events_discarded); | |
655 | int (*content_size) (const struct lib_ring_buffer_config *config, | |
656 | struct lib_ring_buffer *bufb, | |
657 | uint64_t *content_size); | |
658 | int (*packet_size) (const struct lib_ring_buffer_config *config, | |
659 | struct lib_ring_buffer *bufb, | |
660 | uint64_t *packet_size); | |
661 | int (*stream_id) (const struct lib_ring_buffer_config *config, | |
662 | struct lib_ring_buffer *bufb, | |
663 | uint64_t *stream_id); | |
2348ca17 JD |
664 | int (*current_timestamp) (const struct lib_ring_buffer_config *config, |
665 | struct lib_ring_buffer *bufb, | |
666 | uint64_t *ts); | |
5b3cf4f9 JD |
667 | int (*sequence_number) (const struct lib_ring_buffer_config *config, |
668 | struct lib_ring_buffer *bufb, | |
669 | uint64_t *seq); | |
5594698f JD |
670 | int (*instance_id) (const struct lib_ring_buffer_config *config, |
671 | struct lib_ring_buffer *bufb, | |
672 | uint64_t *id); | |
85a9ca7f MD |
673 | }; |
674 | ||
a101fa10 MD |
675 | struct lttng_counter_ops { |
676 | struct lib_counter *(*counter_create)(size_t nr_dimensions, | |
677 | const size_t *max_nr_elem, /* for each dimension */ | |
678 | int64_t global_sum_step); | |
679 | void (*counter_destroy)(struct lib_counter *counter); | |
680 | int (*counter_add)(struct lib_counter *counter, const size_t *dimension_indexes, | |
681 | int64_t v); | |
682 | /* | |
683 | * counter_read reads a specific cpu's counter if @cpu >= 0, or | |
684 | * the global aggregation counter if @cpu == -1. | |
685 | */ | |
686 | int (*counter_read)(struct lib_counter *counter, const size_t *dimension_indexes, int cpu, | |
687 | int64_t *value, bool *overflow, bool *underflow); | |
688 | /* | |
689 | * counter_aggregate returns the total sum of all per-cpu counters and | |
690 | * the global aggregation counter. | |
691 | */ | |
692 | int (*counter_aggregate)(struct lib_counter *counter, const size_t *dimension_indexes, | |
693 | int64_t *value, bool *overflow, bool *underflow); | |
694 | int (*counter_clear)(struct lib_counter *counter, const size_t *dimension_indexes); | |
695 | }; | |
696 | ||
a90917c3 | 697 | struct lttng_transport { |
a33c9927 MD |
698 | char *name; |
699 | struct module *owner; | |
700 | struct list_head node; | |
a90917c3 | 701 | struct lttng_channel_ops ops; |
a33c9927 MD |
702 | }; |
703 | ||
a101fa10 MD |
704 | struct lttng_counter_transport { |
705 | char *name; | |
706 | struct module *owner; | |
707 | struct list_head node; | |
708 | struct lttng_counter_ops ops; | |
709 | }; | |
710 | ||
80f87dd2 MD |
711 | struct lttng_syscall_filter; |
712 | ||
3c997079 MD |
713 | #define LTTNG_EVENT_HT_BITS 12 |
714 | #define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS) | |
715 | ||
716 | struct lttng_event_ht { | |
717 | struct hlist_head table[LTTNG_EVENT_HT_SIZE]; | |
718 | }; | |
719 | ||
dffef45d FD |
720 | #define LTTNG_EVENT_NOTIFIER_HT_BITS 12 |
721 | #define LTTNG_EVENT_NOTIFIER_HT_SIZE (1U << LTTNG_EVENT_NOTIFIER_HT_BITS) | |
722 | ||
723 | struct lttng_event_notifier_ht { | |
724 | struct hlist_head table[LTTNG_EVENT_NOTIFIER_HT_SIZE]; | |
725 | }; | |
726 | ||
a90917c3 | 727 | struct lttng_channel { |
c099397a | 728 | unsigned int id; |
85a9ca7f | 729 | struct channel *chan; /* Channel buffers */ |
e64957da | 730 | int enabled; |
437d5aa5 | 731 | struct lttng_kernel_ctx *ctx; |
85a9ca7f | 732 | /* Event ID management */ |
a90917c3 | 733 | struct lttng_session *session; |
85a9ca7f MD |
734 | struct file *file; /* File associated to channel */ |
735 | unsigned int free_event_id; /* Next event ID to allocate */ | |
736 | struct list_head list; /* Channel list */ | |
a90917c3 MD |
737 | struct lttng_channel_ops *ops; |
738 | struct lttng_transport *transport; | |
3b82c4e1 MD |
739 | struct hlist_head *sc_table; /* for syscall tracing */ |
740 | struct hlist_head *compat_sc_table; | |
741 | struct hlist_head *sc_exit_table; /* for syscall exit tracing */ | |
742 | struct hlist_head *compat_sc_exit_table; | |
743 | struct hlist_head sc_unknown; /* for unknown syscalls */ | |
744 | struct hlist_head sc_compat_unknown; | |
745 | struct hlist_head sc_exit_unknown; | |
746 | struct hlist_head compat_sc_exit_unknown; | |
80f87dd2 | 747 | struct lttng_syscall_filter *sc_filter; |
9115fbdc | 748 | int header_type; /* 0: unset, 1: compact, 2: large */ |
d83004aa | 749 | enum channel_type channel_type; |
3b82c4e1 MD |
750 | int syscall_all_entry; |
751 | int syscall_all_exit; | |
80f87dd2 MD |
752 | unsigned int metadata_dumped:1, |
753 | sys_enter_registered:1, | |
754 | sys_exit_registered:1, | |
3c997079 | 755 | tstate:1; /* Transient enable state */ |
85a9ca7f MD |
756 | }; |
757 | ||
d83004aa JD |
758 | struct lttng_metadata_stream { |
759 | void *priv; /* Ring buffer private data */ | |
760 | struct lttng_metadata_cache *metadata_cache; | |
f613e3e6 MD |
761 | unsigned int metadata_in; /* Bytes read from the cache */ |
762 | unsigned int metadata_out; /* Bytes consumed from stream */ | |
d83004aa JD |
763 | int finalized; /* Has channel been finalized */ |
764 | wait_queue_head_t read_wait; /* Reader buffer-level wait queue */ | |
765 | struct list_head list; /* Stream list */ | |
b3b8072b | 766 | struct lttng_transport *transport; |
9616f0bf | 767 | uint64_t version; /* Current version of the metadata cache */ |
8b97fd42 | 768 | bool coherent; /* Stream in a coherent state */ |
d83004aa JD |
769 | }; |
770 | ||
114667d5 MD |
771 | #define LTTNG_DYNAMIC_LEN_STACK_SIZE 128 |
772 | ||
773 | struct lttng_dynamic_len_stack { | |
774 | size_t stack[LTTNG_DYNAMIC_LEN_STACK_SIZE]; | |
775 | size_t offset; | |
776 | }; | |
777 | ||
778 | DECLARE_PER_CPU(struct lttng_dynamic_len_stack, lttng_dynamic_len_stack); | |
e0130fab MD |
779 | |
780 | /* | |
d1f652f8 | 781 | * struct lttng_id_tracker declared in header due to deferencing of *v |
e0130fab MD |
782 | * in RCU_INITIALIZER(v). |
783 | */ | |
d1f652f8 MD |
784 | #define LTTNG_ID_HASH_BITS 6 |
785 | #define LTTNG_ID_TABLE_SIZE (1 << LTTNG_ID_HASH_BITS) | |
e0130fab | 786 | |
d1f652f8 MD |
787 | enum tracker_type { |
788 | TRACKER_PID, | |
789 | TRACKER_VPID, | |
790 | TRACKER_UID, | |
791 | TRACKER_VUID, | |
792 | TRACKER_GID, | |
793 | TRACKER_VGID, | |
794 | ||
795 | TRACKER_UNKNOWN, | |
796 | }; | |
797 | ||
798 | struct lttng_id_tracker_rcu { | |
799 | struct hlist_head id_hash[LTTNG_ID_TABLE_SIZE]; | |
800 | }; | |
801 | ||
802 | struct lttng_id_tracker { | |
803 | struct lttng_session *session; | |
804 | enum tracker_type tracker_type; | |
805 | struct lttng_id_tracker_rcu *p; /* RCU dereferenced. */ | |
e0130fab MD |
806 | }; |
807 | ||
d1f652f8 | 808 | struct lttng_id_hash_node { |
7e6f9ef6 | 809 | struct hlist_node hlist; |
d1f652f8 | 810 | int id; |
7e6f9ef6 MD |
811 | }; |
812 | ||
a90917c3 | 813 | struct lttng_session { |
85a9ca7f | 814 | int active; /* Is trace session active ? */ |
8070f5c0 | 815 | int been_active; /* Has trace session been active ? */ |
85a9ca7f MD |
816 | struct file *file; /* File associated to session */ |
817 | struct list_head chan; /* Channel list head */ | |
818 | struct list_head events; /* Event list head */ | |
819 | struct list_head list; /* Session list */ | |
c099397a | 820 | unsigned int free_chan_id; /* Next chan ID to allocate */ |
d793d5e1 | 821 | uuid_le uuid; /* Trace session unique ID */ |
d83004aa | 822 | struct lttng_metadata_cache *metadata_cache; |
d1f652f8 MD |
823 | struct lttng_id_tracker pid_tracker; |
824 | struct lttng_id_tracker vpid_tracker; | |
825 | struct lttng_id_tracker uid_tracker; | |
826 | struct lttng_id_tracker vuid_tracker; | |
827 | struct lttng_id_tracker gid_tracker; | |
828 | struct lttng_id_tracker vgid_tracker; | |
3c997079 MD |
829 | unsigned int metadata_dumped:1, |
830 | tstate:1; /* Transient enable state */ | |
b2bc0bc8 | 831 | /* List of event enablers */ |
3c997079 MD |
832 | struct list_head enablers_head; |
833 | /* Hash table of events */ | |
834 | struct lttng_event_ht events_ht; | |
7f859fbf | 835 | char name[LTTNG_KERNEL_SESSION_NAME_LEN]; |
1c88f269 | 836 | char creation_time[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN]; |
85a9ca7f MD |
837 | }; |
838 | ||
99f52fcc FD |
839 | struct lttng_counter { |
840 | struct file *file; /* File associated to counter. */ | |
841 | struct file *owner; | |
842 | struct lttng_counter_transport *transport; | |
843 | struct lib_counter *counter; | |
844 | struct lttng_counter_ops *ops; | |
845 | }; | |
846 | ||
750b05f2 FD |
847 | struct lttng_event_notifier_group { |
848 | struct file *file; /* File associated to event notifier group */ | |
21f58fb7 | 849 | struct file *notif_file; /* File used to expose notifications to userspace. */ |
750b05f2 | 850 | struct list_head node; /* event notifier group list */ |
dffef45d FD |
851 | struct list_head enablers_head; /* List of enablers */ |
852 | struct list_head event_notifiers_head; /* List of event notifier */ | |
853 | struct lttng_event_notifier_ht event_notifiers_ht; /* Hash table of event notifiers */ | |
750b05f2 FD |
854 | struct lttng_channel_ops *ops; |
855 | struct lttng_transport *transport; | |
856 | struct channel *chan; /* Ring buffer channel for event notifier group. */ | |
857 | struct lib_ring_buffer *buf; /* Ring buffer for event notifier group. */ | |
21f58fb7 FD |
858 | wait_queue_head_t read_wait; |
859 | struct irq_work wakeup_pending; /* Pending wakeup irq work. */ | |
8a8ac9a8 FD |
860 | struct lttng_event_notifier *sc_unknown; /* for unknown syscalls */ |
861 | struct lttng_event_notifier *sc_compat_unknown; | |
862 | ||
863 | struct lttng_syscall_filter *sc_filter; | |
864 | ||
865 | struct hlist_head *event_notifier_syscall_dispatch; | |
866 | struct hlist_head *event_notifier_compat_syscall_dispatch; | |
867 | struct hlist_head *event_notifier_exit_syscall_dispatch; | |
868 | struct hlist_head *event_notifier_exit_compat_syscall_dispatch; | |
869 | ||
870 | struct hlist_head event_notifier_unknown_syscall_dispatch; | |
871 | struct hlist_head event_notifier_compat_unknown_syscall_dispatch; | |
872 | struct hlist_head event_notifier_exit_unknown_syscall_dispatch; | |
873 | struct hlist_head event_notifier_exit_compat_unknown_syscall_dispatch; | |
874 | ||
875 | int syscall_all_entry; | |
876 | int syscall_all_exit; | |
877 | ||
878 | unsigned int sys_enter_registered:1, sys_exit_registered:1; | |
879 | ||
880 | struct lttng_counter *error_counter; | |
881 | size_t error_counter_len; | |
750b05f2 FD |
882 | }; |
883 | ||
d83004aa JD |
884 | struct lttng_metadata_cache { |
885 | char *data; /* Metadata cache */ | |
886 | unsigned int cache_alloc; /* Metadata allocated size (bytes) */ | |
887 | unsigned int metadata_written; /* Number of bytes written in metadata cache */ | |
3e75e2a7 | 888 | atomic_t producing; /* Metadata being produced (incomplete) */ |
d83004aa JD |
889 | struct kref refcount; /* Metadata cache usage */ |
890 | struct list_head metadata_stream; /* Metadata stream list */ | |
a36580d5 | 891 | uuid_le uuid; /* Trace session unique ID (copy) */ |
9616f0bf JD |
892 | struct mutex lock; /* Produce/consume lock */ |
893 | uint64_t version; /* Current version of the metadata */ | |
d83004aa JD |
894 | }; |
895 | ||
3c997079 MD |
896 | void lttng_lock_sessions(void); |
897 | void lttng_unlock_sessions(void); | |
898 | ||
899 | struct list_head *lttng_get_probe_list_head(void); | |
900 | ||
b2bc0bc8 FD |
901 | struct lttng_event_enabler *lttng_event_enabler_create( |
902 | enum lttng_enabler_format_type format_type, | |
3c997079 MD |
903 | struct lttng_kernel_event *event_param, |
904 | struct lttng_channel *chan); | |
905 | ||
b2bc0bc8 FD |
906 | int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler); |
907 | int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler); | |
dffef45d FD |
908 | struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create( |
909 | struct lttng_event_notifier_group *event_notifier_group, | |
910 | enum lttng_enabler_format_type format_type, | |
911 | struct lttng_kernel_event_notifier *event_notifier_param); | |
912 | ||
913 | int lttng_event_notifier_enabler_enable( | |
914 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
915 | int lttng_event_notifier_enabler_disable( | |
916 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
3c997079 | 917 | int lttng_fix_pending_events(void); |
b01155ba | 918 | int lttng_fix_pending_event_notifiers(void); |
3c997079 | 919 | int lttng_session_active(void); |
b01155ba | 920 | bool lttng_event_notifier_active(void); |
3c997079 | 921 | |
a90917c3 MD |
922 | struct lttng_session *lttng_session_create(void); |
923 | int lttng_session_enable(struct lttng_session *session); | |
924 | int lttng_session_disable(struct lttng_session *session); | |
925 | void lttng_session_destroy(struct lttng_session *session); | |
9616f0bf | 926 | int lttng_session_metadata_regenerate(struct lttng_session *session); |
601252cf | 927 | int lttng_session_statedump(struct lttng_session *session); |
d83004aa | 928 | void metadata_cache_destroy(struct kref *kref); |
4e3c1b9b | 929 | |
99f52fcc FD |
930 | struct lttng_counter *lttng_kernel_counter_create( |
931 | const char *counter_transport_name, size_t number_dimensions, | |
932 | const size_t *dimensions_sizes); | |
933 | int lttng_kernel_counter_read(struct lttng_counter *counter, | |
934 | const size_t *dimension_indexes, int32_t cpu, | |
935 | int64_t *val, bool *overflow, bool *underflow); | |
936 | int lttng_kernel_counter_aggregate(struct lttng_counter *counter, | |
937 | const size_t *dimension_indexes, int64_t *val, | |
938 | bool *overflow, bool *underflow); | |
939 | int lttng_kernel_counter_clear(struct lttng_counter *counter, | |
940 | const size_t *dimension_indexes); | |
941 | ||
942 | ||
750b05f2 | 943 | struct lttng_event_notifier_group *lttng_event_notifier_group_create(void); |
99f52fcc FD |
944 | int lttng_event_notifier_group_create_error_counter( |
945 | struct file *event_notifier_group_file, | |
946 | const struct lttng_kernel_counter_conf *error_counter_conf); | |
750b05f2 FD |
947 | void lttng_event_notifier_group_destroy( |
948 | struct lttng_event_notifier_group *event_notifier_group); | |
949 | ||
a90917c3 | 950 | struct lttng_channel *lttng_channel_create(struct lttng_session *session, |
5dbbdb43 MD |
951 | const char *transport_name, |
952 | void *buf_addr, | |
953 | size_t subbuf_size, size_t num_subbuf, | |
954 | unsigned int switch_timer_interval, | |
d83004aa JD |
955 | unsigned int read_timer_interval, |
956 | enum channel_type channel_type); | |
a90917c3 | 957 | struct lttng_channel *lttng_global_channel_create(struct lttng_session *session, |
4e3c1b9b MD |
958 | int overwrite, void *buf_addr, |
959 | size_t subbuf_size, size_t num_subbuf, | |
960 | unsigned int switch_timer_interval, | |
961 | unsigned int read_timer_interval); | |
4e3c1b9b | 962 | |
d83004aa | 963 | void lttng_metadata_channel_destroy(struct lttng_channel *chan); |
a90917c3 | 964 | struct lttng_event *lttng_event_create(struct lttng_channel *chan, |
3c997079 MD |
965 | struct lttng_kernel_event *event_param, |
966 | void *filter, | |
437d5aa5 | 967 | const struct lttng_kernel_event_desc *event_desc, |
3c997079 | 968 | enum lttng_kernel_instrumentation itype); |
33a39a3c MD |
969 | struct lttng_event *_lttng_event_create(struct lttng_channel *chan, |
970 | struct lttng_kernel_event *event_param, | |
971 | void *filter, | |
437d5aa5 | 972 | const struct lttng_kernel_event_desc *event_desc, |
33a39a3c | 973 | enum lttng_kernel_instrumentation itype); |
6dccd6c1 JD |
974 | struct lttng_event *lttng_event_compat_old_create(struct lttng_channel *chan, |
975 | struct lttng_kernel_old_event *old_event_param, | |
976 | void *filter, | |
437d5aa5 | 977 | const struct lttng_kernel_event_desc *internal_desc); |
c0e31d2e | 978 | |
dffef45d | 979 | struct lttng_event_notifier *lttng_event_notifier_create( |
437d5aa5 | 980 | const struct lttng_kernel_event_desc *event_notifier_desc, |
dffef45d | 981 | uint64_t id, |
99f52fcc | 982 | uint64_t error_counter_idx, |
dffef45d FD |
983 | struct lttng_event_notifier_group *event_notifier_group, |
984 | struct lttng_kernel_event_notifier *event_notifier_param, | |
985 | void *filter, | |
986 | enum lttng_kernel_instrumentation itype); | |
987 | struct lttng_event_notifier *_lttng_event_notifier_create( | |
437d5aa5 | 988 | const struct lttng_kernel_event_desc *event_notifier_desc, |
dffef45d | 989 | uint64_t id, |
99f52fcc | 990 | uint64_t error_counter_idx, |
dffef45d FD |
991 | struct lttng_event_notifier_group *event_notifier_group, |
992 | struct lttng_kernel_event_notifier *event_notifier_param, | |
993 | void *filter, | |
994 | enum lttng_kernel_instrumentation itype); | |
995 | ||
a90917c3 MD |
996 | int lttng_channel_enable(struct lttng_channel *channel); |
997 | int lttng_channel_disable(struct lttng_channel *channel); | |
998 | int lttng_event_enable(struct lttng_event *event); | |
999 | int lttng_event_disable(struct lttng_event *event); | |
e64957da | 1000 | |
2b16f0c9 FD |
1001 | int lttng_event_notifier_enable(struct lttng_event_notifier *event_notifier); |
1002 | int lttng_event_notifier_disable(struct lttng_event_notifier *event_notifier); | |
1003 | ||
a90917c3 MD |
1004 | void lttng_transport_register(struct lttng_transport *transport); |
1005 | void lttng_transport_unregister(struct lttng_transport *transport); | |
11b5a3c2 | 1006 | |
a101fa10 MD |
1007 | void lttng_counter_transport_register(struct lttng_counter_transport *transport); |
1008 | void lttng_counter_transport_unregister(struct lttng_counter_transport *transport); | |
1009 | ||
360f38ea | 1010 | void synchronize_trace(void); |
80996790 | 1011 | int lttng_abi_init(void); |
6dccd6c1 | 1012 | int lttng_abi_compat_old_init(void); |
80996790 | 1013 | void lttng_abi_exit(void); |
6dccd6c1 | 1014 | void lttng_abi_compat_old_exit(void); |
1c25284c | 1015 | |
437d5aa5 MD |
1016 | int lttng_probe_register(struct lttng_kernel_probe_desc *desc); |
1017 | void lttng_probe_unregister(struct lttng_kernel_probe_desc *desc); | |
1018 | const struct lttng_kernel_event_desc *lttng_event_desc_get(const char *name); | |
1019 | void lttng_event_desc_put(const struct lttng_kernel_event_desc *desc); | |
a90917c3 MD |
1020 | int lttng_probes_init(void); |
1021 | void lttng_probes_exit(void); | |
1ec65de1 | 1022 | |
b3b8072b | 1023 | int lttng_metadata_output_channel(struct lttng_metadata_stream *stream, |
8b97fd42 | 1024 | struct channel *chan, bool *coherent); |
d83004aa | 1025 | |
d1f652f8 MD |
1026 | int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node); |
1027 | int lttng_id_tracker_empty_set(struct lttng_id_tracker *lf); | |
1028 | void lttng_id_tracker_destroy(struct lttng_id_tracker *lf, bool rcu); | |
1029 | bool lttng_id_tracker_lookup(struct lttng_id_tracker_rcu *p, int id); | |
1030 | int lttng_id_tracker_add(struct lttng_id_tracker *lf, int id); | |
1031 | int lttng_id_tracker_del(struct lttng_id_tracker *lf, int id); | |
e0130fab | 1032 | |
d1f652f8 MD |
1033 | int lttng_session_track_id(struct lttng_session *session, |
1034 | enum tracker_type tracker_type, int id); | |
1035 | int lttng_session_untrack_id(struct lttng_session *session, | |
1036 | enum tracker_type tracker_type, int id); | |
e0130fab | 1037 | |
d1f652f8 MD |
1038 | int lttng_session_list_tracker_ids(struct lttng_session *session, |
1039 | enum tracker_type tracker_type); | |
7e6f9ef6 | 1040 | |
2754583e MD |
1041 | void lttng_clock_ref(void); |
1042 | void lttng_clock_unref(void); | |
1043 | ||
437d5aa5 | 1044 | int lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc, |
8a8ac9a8 FD |
1045 | struct lttng_enabler *enabler); |
1046 | ||
3a523f5b | 1047 | #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS) |
3b82c4e1 MD |
1048 | int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler, void *filter); |
1049 | int lttng_syscalls_unregister_channel(struct lttng_channel *chan); | |
2d6d88c6 | 1050 | int lttng_syscalls_destroy_event(struct lttng_channel *chan); |
ade8a729 FD |
1051 | int lttng_syscall_filter_enable_event( |
1052 | struct lttng_channel *chan, | |
badfe9f5 | 1053 | struct lttng_event *event); |
ade8a729 FD |
1054 | int lttng_syscall_filter_disable_event( |
1055 | struct lttng_channel *chan, | |
badfe9f5 | 1056 | struct lttng_event *event); |
ade8a729 | 1057 | |
12e579db MD |
1058 | long lttng_channel_syscall_mask(struct lttng_channel *channel, |
1059 | struct lttng_kernel_syscall_mask __user *usyscall_mask); | |
2d6d88c6 | 1060 | |
8a8ac9a8 FD |
1061 | int lttng_syscalls_register_event_notifier( |
1062 | struct lttng_event_notifier_enabler *event_notifier_enabler, | |
1063 | void *filter); | |
1064 | int lttng_syscals_create_matching_event_notifiers( | |
1065 | struct lttng_event_notifier_enabler *event_notifier_enabler, void *filter); | |
3b82c4e1 | 1066 | int lttng_syscalls_unregister_event_notifier_group(struct lttng_event_notifier_group *group); |
8a8ac9a8 FD |
1067 | int lttng_syscall_filter_enable_event_notifier(struct lttng_event_notifier *event_notifier); |
1068 | int lttng_syscall_filter_disable_event_notifier(struct lttng_event_notifier *event_notifier); | |
1ec65de1 | 1069 | #else |
2d6d88c6 | 1070 | static inline int lttng_syscalls_register_event( |
3b82c4e1 | 1071 | struct lttng_event_enabler *event_enabler, void *filter) |
1ec65de1 MD |
1072 | { |
1073 | return -ENOSYS; | |
1074 | } | |
1075 | ||
3b82c4e1 | 1076 | static inline int lttng_syscalls_unregister_channel(struct lttng_channel *chan) |
1ec65de1 MD |
1077 | { |
1078 | return 0; | |
1079 | } | |
80f87dd2 | 1080 | |
badfe9f5 MD |
1081 | static inline int lttng_syscalls_destroy(struct lttng_channel *chan) |
1082 | { | |
1083 | return 0; | |
1084 | } | |
1085 | ||
2d6d88c6 | 1086 | static inline int lttng_syscall_filter_enable_event(struct lttng_channel *chan, |
badfe9f5 | 1087 | struct lttng_event *event); |
80f87dd2 MD |
1088 | { |
1089 | return -ENOSYS; | |
1090 | } | |
1091 | ||
2d6d88c6 | 1092 | static inline int lttng_syscall_filter_disable_event(struct lttng_channel *chan, |
badfe9f5 | 1093 | struct lttng_event *event); |
80f87dd2 MD |
1094 | { |
1095 | return -ENOSYS; | |
1096 | } | |
12e579db | 1097 | |
f127e61e | 1098 | static inline long lttng_channel_syscall_mask(struct lttng_channel *channel, |
12e579db MD |
1099 | struct lttng_kernel_syscall_mask __user *usyscall_mask) |
1100 | { | |
1101 | return -ENOSYS; | |
1102 | } | |
dffef45d | 1103 | |
8a8ac9a8 FD |
1104 | static inline int lttng_syscalls_register_event_notifier( |
1105 | struct lttng_event_notifier_group *group, void *filter) | |
1106 | { | |
1107 | return -ENOSYS; | |
1108 | } | |
1109 | ||
3b82c4e1 | 1110 | static inline int lttng_syscalls_unregister_event_notifier_group( |
8a8ac9a8 FD |
1111 | struct lttng_event_notifier_group *group) |
1112 | { | |
1113 | return 0; | |
1114 | } | |
1115 | ||
1116 | static inline int lttng_syscall_filter_enable_event_notifier( | |
1117 | struct lttng_event_notifier_group *group, | |
1118 | const char *name) | |
1119 | { | |
1120 | return -ENOSYS; | |
1121 | } | |
1122 | ||
1123 | static inline int lttng_syscall_filter_disable_event_notifier( | |
1124 | struct lttng_event_notifier_group *group, | |
1125 | const char *name) | |
1126 | { | |
1127 | return -ENOSYS; | |
1128 | } | |
1129 | ||
1ec65de1 MD |
1130 | #endif |
1131 | ||
183e8b3a | 1132 | int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler *event_enabler, |
07dfc1d0 | 1133 | struct lttng_kernel_filter_bytecode __user *bytecode); |
183e8b3a | 1134 | int lttng_event_notifier_enabler_attach_filter_bytecode( |
dffef45d FD |
1135 | struct lttng_event_notifier_enabler *event_notifier_enabler, |
1136 | struct lttng_kernel_filter_bytecode __user *bytecode); | |
99d223ad FD |
1137 | int lttng_event_notifier_enabler_attach_capture_bytecode( |
1138 | struct lttng_event_notifier_enabler *event_notifier_enabler, | |
1139 | struct lttng_kernel_capture_bytecode __user *bytecode); | |
2dfda770 | 1140 | |
437d5aa5 MD |
1141 | void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_desc, |
1142 | struct lttng_kernel_ctx *ctx, | |
60206944 FD |
1143 | struct list_head *instance_bytecode_runtime_head, |
1144 | struct list_head *enabler_bytecode_runtime_head); | |
966ad253 | 1145 | void lttng_free_event_filter_runtime(struct lttng_event *event); |
3ef5cc03 | 1146 | void lttng_free_event_notifier_filter_runtime(struct lttng_event_notifier *event_notifier); |
07dfc1d0 | 1147 | |
114667d5 MD |
1148 | int lttng_probes_init(void); |
1149 | ||
437d5aa5 | 1150 | extern struct lttng_kernel_ctx *lttng_static_ctx; |
07dfc1d0 MD |
1151 | |
1152 | int lttng_context_init(void); | |
1153 | void lttng_context_exit(void); | |
437d5aa5 MD |
1154 | int lttng_kernel_context_append(struct lttng_kernel_ctx **ctx_p, |
1155 | const struct lttng_kernel_ctx_field *f); | |
1156 | void lttng_kernel_context_remove_last(struct lttng_kernel_ctx **ctx_p); | |
1157 | struct lttng_kernel_ctx_field *lttng_kernel_get_context_field_from_index(struct lttng_kernel_ctx *ctx, | |
c02eb859 | 1158 | size_t index); |
437d5aa5 MD |
1159 | int lttng_kernel_find_context(struct lttng_kernel_ctx *ctx, const char *name); |
1160 | int lttng_kernel_get_context_index(struct lttng_kernel_ctx *ctx, const char *name); | |
1161 | void lttng_kernel_destroy_context(struct lttng_kernel_ctx *ctx); | |
1162 | int lttng_add_pid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1163 | int lttng_add_cpu_id_to_ctx(struct lttng_kernel_ctx **ctx); | |
1164 | int lttng_add_procname_to_ctx(struct lttng_kernel_ctx **ctx); | |
1165 | int lttng_add_prio_to_ctx(struct lttng_kernel_ctx **ctx); | |
1166 | int lttng_add_nice_to_ctx(struct lttng_kernel_ctx **ctx); | |
1167 | int lttng_add_vpid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1168 | int lttng_add_tid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1169 | int lttng_add_vtid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1170 | int lttng_add_ppid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1171 | int lttng_add_vppid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1172 | int lttng_add_hostname_to_ctx(struct lttng_kernel_ctx **ctx); | |
1173 | int lttng_add_interruptible_to_ctx(struct lttng_kernel_ctx **ctx); | |
1174 | int lttng_add_need_reschedule_to_ctx(struct lttng_kernel_ctx **ctx); | |
79150a49 | 1175 | #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT) |
437d5aa5 | 1176 | int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx); |
79150a49 JD |
1177 | #else |
1178 | static inline | |
437d5aa5 | 1179 | int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx) |
79150a49 JD |
1180 | { |
1181 | return -ENOSYS; | |
1182 | } | |
1183 | #endif | |
1184 | #ifdef CONFIG_PREEMPT_RT_FULL | |
437d5aa5 | 1185 | int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx); |
79150a49 JD |
1186 | #else |
1187 | static inline | |
437d5aa5 | 1188 | int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx) |
79150a49 JD |
1189 | { |
1190 | return -ENOSYS; | |
1191 | } | |
1192 | #endif | |
2fa2d39a | 1193 | |
437d5aa5 | 1194 | int lttng_add_callstack_to_ctx(struct lttng_kernel_ctx **ctx, int type); |
2fa2d39a | 1195 | |
a6cf40a4 | 1196 | #if defined(CONFIG_CGROUPS) && \ |
5f4c791e | 1197 | ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) || \ |
a6cf40a4 | 1198 | LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0)) |
437d5aa5 | 1199 | int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx); |
a6cf40a4 MJ |
1200 | #else |
1201 | static inline | |
437d5aa5 | 1202 | int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx) |
a6cf40a4 MJ |
1203 | { |
1204 | return -ENOSYS; | |
1205 | } | |
1206 | #endif | |
1207 | ||
1208 | #if defined(CONFIG_IPC_NS) && \ | |
5f4c791e | 1209 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) |
437d5aa5 | 1210 | int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx); |
a6cf40a4 MJ |
1211 | #else |
1212 | static inline | |
437d5aa5 | 1213 | int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx) |
a6cf40a4 MJ |
1214 | { |
1215 | return -ENOSYS; | |
1216 | } | |
1217 | #endif | |
1218 | ||
1219 | #if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \ | |
5f4c791e | 1220 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) |
437d5aa5 | 1221 | int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx); |
a6cf40a4 MJ |
1222 | #else |
1223 | static inline | |
437d5aa5 | 1224 | int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx) |
a6cf40a4 MJ |
1225 | { |
1226 | return -ENOSYS; | |
1227 | } | |
1228 | #endif | |
1229 | ||
1230 | #if defined(CONFIG_NET_NS) && \ | |
5f4c791e | 1231 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) |
437d5aa5 | 1232 | int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx); |
a6cf40a4 MJ |
1233 | #else |
1234 | static inline | |
437d5aa5 | 1235 | int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx) |
a6cf40a4 MJ |
1236 | { |
1237 | return -ENOSYS; | |
1238 | } | |
1239 | #endif | |
1240 | ||
1241 | #if defined(CONFIG_PID_NS) && \ | |
5f4c791e | 1242 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) |
437d5aa5 | 1243 | int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx); |
a6cf40a4 MJ |
1244 | #else |
1245 | static inline | |
437d5aa5 | 1246 | int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx) |
a6cf40a4 MJ |
1247 | { |
1248 | return -ENOSYS; | |
1249 | } | |
1250 | #endif | |
1251 | ||
1252 | #if defined(CONFIG_USER_NS) && \ | |
5f4c791e | 1253 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) |
437d5aa5 | 1254 | int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx); |
a6cf40a4 MJ |
1255 | #else |
1256 | static inline | |
437d5aa5 | 1257 | int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx) |
a6cf40a4 MJ |
1258 | { |
1259 | return -ENOSYS; | |
1260 | } | |
1261 | #endif | |
1262 | ||
1263 | #if defined(CONFIG_UTS_NS) && \ | |
5f4c791e | 1264 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) |
437d5aa5 | 1265 | int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx); |
a6cf40a4 MJ |
1266 | #else |
1267 | static inline | |
437d5aa5 | 1268 | int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx) |
a6cf40a4 MJ |
1269 | { |
1270 | return -ENOSYS; | |
1271 | } | |
1272 | #endif | |
1273 | ||
876e2e92 | 1274 | #if defined(CONFIG_TIME_NS) && \ |
5f4c791e | 1275 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0)) |
437d5aa5 | 1276 | int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx); |
876e2e92 MJ |
1277 | #else |
1278 | static inline | |
437d5aa5 | 1279 | int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx) |
876e2e92 MJ |
1280 | { |
1281 | return -ENOSYS; | |
1282 | } | |
1283 | #endif | |
1284 | ||
437d5aa5 MD |
1285 | int lttng_add_uid_to_ctx(struct lttng_kernel_ctx **ctx); |
1286 | int lttng_add_euid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1287 | int lttng_add_suid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1288 | int lttng_add_gid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1289 | int lttng_add_egid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1290 | int lttng_add_sgid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1291 | int lttng_add_vuid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1292 | int lttng_add_veuid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1293 | int lttng_add_vsuid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1294 | int lttng_add_vgid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1295 | int lttng_add_vegid_to_ctx(struct lttng_kernel_ctx **ctx); | |
1296 | int lttng_add_vsgid_to_ctx(struct lttng_kernel_ctx **ctx); | |
dc923e75 | 1297 | |
8a3af9ee | 1298 | #if defined(CONFIG_PERF_EVENTS) |
c24a0d71 MD |
1299 | int lttng_add_perf_counter_to_ctx(uint32_t type, |
1300 | uint64_t config, | |
1301 | const char *name, | |
437d5aa5 | 1302 | struct lttng_kernel_ctx **ctx); |
1e367326 MD |
1303 | int lttng_cpuhp_perf_counter_online(unsigned int cpu, |
1304 | struct lttng_cpuhp_node *node); | |
1305 | int lttng_cpuhp_perf_counter_dead(unsigned int cpu, | |
1306 | struct lttng_cpuhp_node *node); | |
1d443b34 MD |
1307 | #else |
1308 | static inline | |
1309 | int lttng_add_perf_counter_to_ctx(uint32_t type, | |
1310 | uint64_t config, | |
1311 | const char *name, | |
437d5aa5 | 1312 | struct lttng_kernel_ctx **ctx) |
1d443b34 MD |
1313 | { |
1314 | return -ENOSYS; | |
1315 | } | |
1e367326 MD |
1316 | static inline |
1317 | int lttng_cpuhp_perf_counter_online(unsigned int cpu, | |
1318 | struct lttng_cpuhp_node *node) | |
1319 | { | |
1320 | return 0; | |
1321 | } | |
1322 | static inline | |
1323 | int lttng_cpuhp_perf_counter_dead(unsigned int cpu, | |
1324 | struct lttng_cpuhp_node *node) | |
1325 | { | |
1326 | return 0; | |
1327 | } | |
1d443b34 | 1328 | #endif |
02119ee5 | 1329 | |
0c956676 MD |
1330 | int lttng_logger_init(void); |
1331 | void lttng_logger_exit(void); | |
1332 | ||
c337ddc2 MD |
1333 | extern int lttng_statedump_start(struct lttng_session *session); |
1334 | ||
acd614cc | 1335 | #ifdef CONFIG_KPROBES |
8bf17deb | 1336 | int lttng_kprobes_register_event(const char *name, |
f17701fb MD |
1337 | const char *symbol_name, |
1338 | uint64_t offset, | |
1339 | uint64_t addr, | |
a90917c3 | 1340 | struct lttng_event *event); |
8bf17deb FD |
1341 | void lttng_kprobes_unregister_event(struct lttng_event *event); |
1342 | void lttng_kprobes_destroy_event_private(struct lttng_event *event); | |
2b16f0c9 FD |
1343 | int lttng_kprobes_register_event_notifier(const char *symbol_name, |
1344 | uint64_t offset, | |
1345 | uint64_t addr, | |
1346 | struct lttng_event_notifier *event_notifier); | |
1347 | void lttng_kprobes_unregister_event_notifier(struct lttng_event_notifier *event_notifier); | |
1348 | void lttng_kprobes_destroy_event_notifier_private(struct lttng_event_notifier *event_notifier); | |
acd614cc MD |
1349 | #else |
1350 | static inline | |
8bf17deb | 1351 | int lttng_kprobes_register_event(const char *name, |
acd614cc MD |
1352 | const char *symbol_name, |
1353 | uint64_t offset, | |
1354 | uint64_t addr, | |
a90917c3 | 1355 | struct lttng_event *event) |
acd614cc MD |
1356 | { |
1357 | return -ENOSYS; | |
1358 | } | |
1359 | ||
25f53c39 | 1360 | static inline |
8bf17deb FD |
1361 | void lttng_kprobes_unregister_event(struct lttng_event *event) |
1362 | { | |
1363 | } | |
1364 | ||
1365 | static inline | |
1366 | void lttng_kprobes_destroy_event_private(struct lttng_event *event) | |
acd614cc MD |
1367 | { |
1368 | } | |
edeb3137 MD |
1369 | |
1370 | static inline | |
2b16f0c9 FD |
1371 | int lttng_kprobes_register_event_notifier(const char *symbol_name, |
1372 | uint64_t offset, | |
1373 | uint64_t addr, | |
1374 | struct lttng_event_notifier *event_notifier) | |
1375 | { | |
1376 | return -ENOSYS; | |
1377 | } | |
1378 | ||
1379 | static inline | |
1380 | void lttng_kprobes_unregister_event_notifier(struct lttng_event_notifier *event_notifier) | |
1381 | { | |
1382 | } | |
1383 | ||
1384 | static inline | |
1385 | void lttng_kprobes_destroy_event_notifier_private(struct lttng_event_notifier *event_notifier) | |
edeb3137 MD |
1386 | { |
1387 | } | |
acd614cc | 1388 | #endif |
d6d808f3 | 1389 | |
3aed4dca FD |
1390 | int lttng_event_add_callsite(struct lttng_event *event, |
1391 | struct lttng_kernel_event_callsite *callsite); | |
e33fc900 | 1392 | |
9de67196 FD |
1393 | int lttng_event_notifier_add_callsite(struct lttng_event_notifier *event_notifier, |
1394 | struct lttng_kernel_event_callsite *callsite); | |
1395 | ||
149b9a9d | 1396 | #ifdef CONFIG_UPROBES |
83b802dc | 1397 | int lttng_uprobes_register_event(const char *name, |
3aed4dca | 1398 | int fd, struct lttng_event *event); |
83b802dc | 1399 | int lttng_uprobes_event_add_callsite(struct lttng_event *event, |
3aed4dca | 1400 | struct lttng_kernel_event_callsite *callsite); |
83b802dc FD |
1401 | void lttng_uprobes_unregister_event(struct lttng_event *event); |
1402 | void lttng_uprobes_destroy_event_private(struct lttng_event *event); | |
9de67196 FD |
1403 | int lttng_uprobes_register_event_notifier(const char *name, |
1404 | int fd, struct lttng_event_notifier *event_notifier); | |
1405 | int lttng_uprobes_event_notifier_add_callsite(struct lttng_event_notifier *event_notifier, | |
1406 | struct lttng_kernel_event_callsite *callsite); | |
1407 | void lttng_uprobes_unregister_event_notifier(struct lttng_event_notifier *event_notifier); | |
1408 | void lttng_uprobes_destroy_event_notifier_private(struct lttng_event_notifier *event_notifier); | |
149b9a9d YB |
1409 | #else |
1410 | static inline | |
83b802dc | 1411 | int lttng_uprobes_register_event(const char *name, |
3aed4dca FD |
1412 | int fd, struct lttng_event *event) |
1413 | { | |
1414 | return -ENOSYS; | |
1415 | } | |
1416 | ||
1417 | static inline | |
83b802dc | 1418 | int lttng_uprobes_event_add_callsite(struct lttng_event *event, |
e33fc900 | 1419 | struct lttng_kernel_event_callsite *callsite) |
149b9a9d YB |
1420 | { |
1421 | return -ENOSYS; | |
1422 | } | |
1423 | ||
1424 | static inline | |
83b802dc | 1425 | void lttng_uprobes_unregister_event(struct lttng_event *event) |
149b9a9d YB |
1426 | { |
1427 | } | |
1428 | ||
1429 | static inline | |
83b802dc | 1430 | void lttng_uprobes_destroy_event_private(struct lttng_event *event) |
149b9a9d YB |
1431 | { |
1432 | } | |
9de67196 FD |
1433 | |
1434 | static inline | |
1435 | int lttng_uprobes_register_event_notifier(const char *name, | |
1436 | int fd, struct lttng_event_notifier *event_notifier) | |
1437 | { | |
1438 | return -ENOSYS; | |
1439 | } | |
1440 | ||
1441 | static inline | |
1442 | int lttng_uprobes_event_notifier_add_callsite(struct lttng_event_notifier *event_notifier, | |
1443 | struct lttng_kernel_event_callsite *callsite) | |
1444 | { | |
1445 | return -ENOSYS; | |
1446 | } | |
1447 | ||
1448 | static inline | |
1449 | void lttng_uprobes_unregister_event_notifier(struct lttng_event_notifier *event_notifier) | |
1450 | { | |
1451 | } | |
1452 | ||
1453 | static inline | |
1454 | void lttng_uprobes_destroy_event_notifier_private(struct lttng_event_notifier *event_notifier) | |
1455 | { | |
1456 | } | |
149b9a9d YB |
1457 | #endif |
1458 | ||
7371f44c MD |
1459 | #ifdef CONFIG_KRETPROBES |
1460 | int lttng_kretprobes_register(const char *name, | |
1461 | const char *symbol_name, | |
1462 | uint64_t offset, | |
1463 | uint64_t addr, | |
a90917c3 MD |
1464 | struct lttng_event *event_entry, |
1465 | struct lttng_event *event_exit); | |
1466 | void lttng_kretprobes_unregister(struct lttng_event *event); | |
1467 | void lttng_kretprobes_destroy_private(struct lttng_event *event); | |
a0493bef MD |
1468 | int lttng_kretprobes_event_enable_state(struct lttng_event *event, |
1469 | int enable); | |
7371f44c MD |
1470 | #else |
1471 | static inline | |
1472 | int lttng_kretprobes_register(const char *name, | |
1473 | const char *symbol_name, | |
1474 | uint64_t offset, | |
1475 | uint64_t addr, | |
a90917c3 MD |
1476 | struct lttng_event *event_entry, |
1477 | struct lttng_event *event_exit) | |
7371f44c MD |
1478 | { |
1479 | return -ENOSYS; | |
1480 | } | |
1481 | ||
1482 | static inline | |
a90917c3 | 1483 | void lttng_kretprobes_unregister(struct lttng_event *event) |
7371f44c MD |
1484 | { |
1485 | } | |
1486 | ||
1487 | static inline | |
a90917c3 | 1488 | void lttng_kretprobes_destroy_private(struct lttng_event *event) |
7371f44c MD |
1489 | { |
1490 | } | |
a0493bef MD |
1491 | |
1492 | static inline | |
1493 | int lttng_kretprobes_event_enable_state(struct lttng_event *event, | |
1494 | int enable) | |
1495 | { | |
1496 | return -ENOSYS; | |
1497 | } | |
7371f44c MD |
1498 | #endif |
1499 | ||
3db41b2c | 1500 | int lttng_calibrate(struct lttng_kernel_calibrate *calibrate); |
57105fc2 | 1501 | |
271b6681 | 1502 | extern const struct file_operations lttng_tracepoint_list_fops; |
2d2464bd | 1503 | extern const struct file_operations lttng_syscall_list_fops; |
271b6681 | 1504 | |
ef200626 | 1505 | #define TRACEPOINT_HAS_DATA_ARG |
ef200626 | 1506 | |
a90917c3 | 1507 | #endif /* _LTTNG_EVENTS_H */ |