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; | |
f0039724 | 112 | const char *length_name; /* Length field name. If NULL, use previous field. */ |
437d5aa5 MD |
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; | |
f0039724 | 127 | const char *tag_name; /* Tag field name. If NULL, use previous field. */ |
437d5aa5 MD |
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 | ||
437d5aa5 MD |
249 | #define lttng_kernel_static_enum_entry_value(_string, _value) \ |
250 | __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_enum_entry, { \ | |
251 | .start = { \ | |
252 | .signedness = lttng_is_signed_type(__typeof__(_value)), \ | |
253 | .value = lttng_is_signed_type(__typeof__(_value)) ? \ | |
254 | (long long) (_value) : (_value), \ | |
255 | }, \ | |
256 | .end = { \ | |
257 | .signedness = lttng_is_signed_type(__typeof__(_value)), \ | |
258 | .value = lttng_is_signed_type(__typeof__(_value)) ? \ | |
259 | (long long) (_value) : (_value), \ | |
260 | }, \ | |
261 | .string = (_string), \ | |
262 | }), | |
263 | ||
264 | #define lttng_kernel_static_enum_entry_range(_string, _range_start, _range_end) \ | |
265 | __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_enum_entry, { \ | |
266 | .start = { \ | |
267 | .signedness = lttng_is_signed_type(__typeof__(_range_start)), \ | |
268 | .value = lttng_is_signed_type(__typeof__(_range_start)) ? \ | |
269 | (long long) (_range_start) : (_range_start), \ | |
270 | }, \ | |
271 | .end = { \ | |
272 | .signedness = lttng_is_signed_type(__typeof__(_range_end)), \ | |
273 | .value = lttng_is_signed_type(__typeof__(_range_end)) ? \ | |
274 | (long long) (_range_end) : (_range_end), \ | |
275 | }, \ | |
276 | .string = (_string), \ | |
277 | }), | |
278 | ||
279 | #define lttng_kernel_static_enum_entry_auto(_string) \ | |
280 | __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_enum_entry, { \ | |
281 | .start = { \ | |
282 | .signedness = -1, \ | |
283 | .value = -1, \ | |
284 | }, \ | |
285 | .end = { \ | |
286 | .signedness = -1, \ | |
287 | .value = -1, \ | |
288 | }, \ | |
289 | .string = (_string), \ | |
290 | .options = { \ | |
291 | .is_auto = 1, \ | |
292 | } \ | |
293 | }), | |
294 | ||
79150a49 | 295 | struct lttng_probe_ctx { |
e2d5dbc7 | 296 | struct lttng_kernel_event_common *event; |
79150a49 JD |
297 | uint8_t interruptible; |
298 | }; | |
299 | ||
437d5aa5 MD |
300 | struct lttng_kernel_event_desc { |
301 | const char *event_name; /* lttng-modules name */ | |
302 | const char *event_kname; /* Linux kernel name (tracepoints) */ | |
303 | const struct lttng_kernel_probe_desc *probe_desc; | |
304 | void (*probe_callback)(void); | |
305 | const struct lttng_kernel_event_field **fields; /* event payload */ | |
c0edae1d | 306 | unsigned int nr_fields; |
dc7f600a | 307 | struct module *owner; |
c0edae1d MD |
308 | }; |
309 | ||
437d5aa5 MD |
310 | struct lttng_kernel_probe_desc { |
311 | const char *provider_name; | |
312 | const struct lttng_kernel_event_desc **event_desc; | |
85a9ca7f MD |
313 | unsigned int nr_events; |
314 | struct list_head head; /* chain registered probes */ | |
3c997079 MD |
315 | struct list_head lazy_init_head; |
316 | int lazy; /* lazy registration */ | |
85a9ca7f MD |
317 | }; |
318 | ||
7371f44c MD |
319 | struct lttng_krp; /* Kretprobe handling */ |
320 | ||
8a445457 MD |
321 | enum lttng_kernel_bytecode_type { |
322 | LTTNG_KERNEL_BYTECODE_TYPE_FILTER, | |
323 | LTTNG_KERNEL_BYTECODE_TYPE_CAPTURE, | |
89ec2b91 FD |
324 | }; |
325 | ||
326 | struct lttng_bytecode_node { | |
8a445457 | 327 | enum lttng_kernel_bytecode_type type; |
07dfc1d0 MD |
328 | struct list_head node; |
329 | struct lttng_enabler *enabler; | |
89ec2b91 FD |
330 | struct { |
331 | uint32_t len; | |
332 | uint32_t reloc_offset; | |
333 | uint64_t seqnum; | |
334 | char data[]; | |
335 | } bc; | |
07dfc1d0 MD |
336 | }; |
337 | ||
99d223ad FD |
338 | struct lttng_interpreter_output; |
339 | ||
07dfc1d0 MD |
340 | struct lttng_bytecode_runtime { |
341 | /* Associated bytecode */ | |
8a445457 | 342 | enum lttng_kernel_bytecode_type type; |
89ec2b91 | 343 | struct lttng_bytecode_node *bc; |
8a445457 MD |
344 | int (*interpreter_func)(struct lttng_bytecode_runtime *kernel_bytecode, |
345 | const char *interpreter_stack_data, | |
a775608d | 346 | struct lttng_probe_ctx *lttng_probe_ctx, |
8a445457 | 347 | void *caller_ctx); |
07dfc1d0 MD |
348 | int link_failed; |
349 | struct list_head node; /* list of bytecode runtime in event */ | |
437d5aa5 | 350 | struct lttng_kernel_ctx *ctx; |
07dfc1d0 MD |
351 | }; |
352 | ||
3c997079 MD |
353 | /* |
354 | * Objects in a linked-list of enablers, owned by an event. | |
355 | */ | |
356 | struct lttng_enabler_ref { | |
357 | struct list_head node; /* enabler ref list */ | |
358 | struct lttng_enabler *ref; /* backward ref */ | |
359 | }; | |
360 | ||
3aed4dca | 361 | struct lttng_uprobe_handler { |
e2d5dbc7 | 362 | struct lttng_kernel_event_common *event; |
3aed4dca FD |
363 | loff_t offset; |
364 | struct uprobe_consumer up_consumer; | |
365 | struct list_head node; | |
366 | }; | |
367 | ||
8bf17deb FD |
368 | struct lttng_kprobe { |
369 | struct kprobe kp; | |
370 | char *symbol_name; | |
371 | }; | |
372 | ||
83b802dc FD |
373 | struct lttng_uprobe { |
374 | struct inode *inode; | |
375 | struct list_head head; | |
376 | }; | |
377 | ||
badfe9f5 MD |
378 | enum lttng_syscall_entryexit { |
379 | LTTNG_SYSCALL_ENTRY, | |
380 | LTTNG_SYSCALL_EXIT, | |
381 | }; | |
382 | ||
383 | enum lttng_syscall_abi { | |
384 | LTTNG_SYSCALL_ABI_NATIVE, | |
385 | LTTNG_SYSCALL_ABI_COMPAT, | |
386 | }; | |
387 | ||
8a445457 MD |
388 | /* |
389 | * Result of the run_filter() callback. | |
390 | */ | |
391 | enum lttng_kernel_event_filter_result { | |
392 | LTTNG_KERNEL_EVENT_FILTER_ACCEPT = 0, | |
393 | LTTNG_KERNEL_EVENT_FILTER_REJECT = 1, | |
394 | }; | |
395 | ||
a67ba386 MD |
396 | struct lttng_kernel_event_common_private; |
397 | ||
398 | enum lttng_kernel_event_type { | |
399 | LTTNG_KERNEL_EVENT_TYPE_RECORDER = 0, | |
400 | LTTNG_KERNEL_EVENT_TYPE_NOTIFIER = 1, | |
401 | }; | |
402 | ||
403 | struct lttng_kernel_event_common { | |
404 | struct lttng_kernel_event_common_private *priv; /* Private event interface */ | |
405 | ||
406 | enum lttng_kernel_event_type type; | |
407 | /* Get child with container_of(). */ | |
408 | ||
e64957da | 409 | int enabled; |
a67ba386 | 410 | int eval_filter; /* Need to evaluate filters */ |
8a445457 | 411 | int (*run_filter)(const struct lttng_kernel_event_common *event, |
a67ba386 | 412 | const char *stack_data, |
8a445457 | 413 | struct lttng_probe_ctx *probe_ctx, |
a67ba386 | 414 | void *filter_ctx); |
3c997079 MD |
415 | }; |
416 | ||
a67ba386 MD |
417 | struct lttng_kernel_event_recorder_private; |
418 | ||
419 | struct lttng_kernel_event_recorder { | |
420 | struct lttng_kernel_event_common parent; | |
421 | struct lttng_kernel_event_recorder_private *priv; /* Private event record interface */ | |
422 | ||
423 | struct lttng_channel *chan; | |
c3eddb2e MD |
424 | }; |
425 | ||
a67ba386 MD |
426 | struct lttng_kernel_notification_ctx { |
427 | int eval_capture; /* Capture evaluation available. */ | |
428 | }; | |
dffef45d | 429 | |
a67ba386 | 430 | struct lttng_kernel_event_notifier_private; |
8a8ac9a8 | 431 | |
a67ba386 MD |
432 | struct lttng_kernel_event_notifier { |
433 | struct lttng_kernel_event_common parent; | |
434 | struct lttng_kernel_event_notifier_private *priv; /* Private event notifier interface */ | |
dffef45d | 435 | |
a67ba386 MD |
436 | int eval_capture; /* Need to evaluate capture */ |
437 | void (*notification_send)(struct lttng_kernel_event_notifier *event_notifier, | |
a67ba386 | 438 | const char *stack_data, |
a775608d | 439 | struct lttng_probe_ctx *probe_ctx, |
a67ba386 | 440 | struct lttng_kernel_notification_ctx *notif_ctx); |
dffef45d FD |
441 | }; |
442 | ||
3b861b22 FD |
443 | enum lttng_enabler_format_type { |
444 | LTTNG_ENABLER_FORMAT_STAR_GLOB, | |
445 | LTTNG_ENABLER_FORMAT_NAME, | |
3c997079 MD |
446 | }; |
447 | ||
a90917c3 | 448 | struct lttng_channel_ops { |
85a9ca7f | 449 | struct channel *(*channel_create)(const char *name, |
5cf4b87c | 450 | void *priv, |
85a9ca7f MD |
451 | void *buf_addr, |
452 | size_t subbuf_size, size_t num_subbuf, | |
453 | unsigned int switch_timer_interval, | |
454 | unsigned int read_timer_interval); | |
455 | void (*channel_destroy)(struct channel *chan); | |
456 | struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan); | |
f71ecafa | 457 | int (*buffer_has_read_closed_stream)(struct channel *chan); |
85a9ca7f | 458 | void (*buffer_read_close)(struct lib_ring_buffer *buf); |
cefd899f | 459 | int (*event_reserve)(struct lib_ring_buffer_ctx *ctx); |
85a9ca7f MD |
460 | void (*event_commit)(struct lib_ring_buffer_ctx *ctx); |
461 | void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src, | |
462 | size_t len); | |
4ea00e4f JD |
463 | void (*event_write_from_user)(struct lib_ring_buffer_ctx *ctx, |
464 | const void *src, size_t len); | |
58aa5d24 MD |
465 | void (*event_memset)(struct lib_ring_buffer_ctx *ctx, |
466 | int c, size_t len); | |
16f78f3a MD |
467 | void (*event_strcpy)(struct lib_ring_buffer_ctx *ctx, const char *src, |
468 | size_t len); | |
469 | void (*event_strcpy_from_user)(struct lib_ring_buffer_ctx *ctx, | |
470 | const char __user *src, size_t len); | |
1ec3f75a MD |
471 | /* |
472 | * packet_avail_size returns the available size in the current | |
473 | * packet. Note that the size returned is only a hint, since it | |
474 | * may change due to concurrent writes. | |
475 | */ | |
476 | size_t (*packet_avail_size)(struct channel *chan); | |
71c1d843 | 477 | wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu); |
24cedcfe MD |
478 | wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan); |
479 | int (*is_finalized)(struct channel *chan); | |
254ec7bc | 480 | int (*is_disabled)(struct channel *chan); |
3b731ab1 JD |
481 | int (*timestamp_begin) (const struct lib_ring_buffer_config *config, |
482 | struct lib_ring_buffer *bufb, | |
483 | uint64_t *timestamp_begin); | |
484 | int (*timestamp_end) (const struct lib_ring_buffer_config *config, | |
485 | struct lib_ring_buffer *bufb, | |
486 | uint64_t *timestamp_end); | |
487 | int (*events_discarded) (const struct lib_ring_buffer_config *config, | |
488 | struct lib_ring_buffer *bufb, | |
489 | uint64_t *events_discarded); | |
490 | int (*content_size) (const struct lib_ring_buffer_config *config, | |
491 | struct lib_ring_buffer *bufb, | |
492 | uint64_t *content_size); | |
493 | int (*packet_size) (const struct lib_ring_buffer_config *config, | |
494 | struct lib_ring_buffer *bufb, | |
495 | uint64_t *packet_size); | |
496 | int (*stream_id) (const struct lib_ring_buffer_config *config, | |
497 | struct lib_ring_buffer *bufb, | |
498 | uint64_t *stream_id); | |
2348ca17 JD |
499 | int (*current_timestamp) (const struct lib_ring_buffer_config *config, |
500 | struct lib_ring_buffer *bufb, | |
501 | uint64_t *ts); | |
5b3cf4f9 JD |
502 | int (*sequence_number) (const struct lib_ring_buffer_config *config, |
503 | struct lib_ring_buffer *bufb, | |
504 | uint64_t *seq); | |
5594698f JD |
505 | int (*instance_id) (const struct lib_ring_buffer_config *config, |
506 | struct lib_ring_buffer *bufb, | |
507 | uint64_t *id); | |
85a9ca7f MD |
508 | }; |
509 | ||
a101fa10 MD |
510 | struct lttng_counter_ops { |
511 | struct lib_counter *(*counter_create)(size_t nr_dimensions, | |
512 | const size_t *max_nr_elem, /* for each dimension */ | |
513 | int64_t global_sum_step); | |
514 | void (*counter_destroy)(struct lib_counter *counter); | |
515 | int (*counter_add)(struct lib_counter *counter, const size_t *dimension_indexes, | |
516 | int64_t v); | |
517 | /* | |
518 | * counter_read reads a specific cpu's counter if @cpu >= 0, or | |
519 | * the global aggregation counter if @cpu == -1. | |
520 | */ | |
521 | int (*counter_read)(struct lib_counter *counter, const size_t *dimension_indexes, int cpu, | |
522 | int64_t *value, bool *overflow, bool *underflow); | |
523 | /* | |
524 | * counter_aggregate returns the total sum of all per-cpu counters and | |
525 | * the global aggregation counter. | |
526 | */ | |
527 | int (*counter_aggregate)(struct lib_counter *counter, const size_t *dimension_indexes, | |
528 | int64_t *value, bool *overflow, bool *underflow); | |
529 | int (*counter_clear)(struct lib_counter *counter, const size_t *dimension_indexes); | |
530 | }; | |
531 | ||
a90917c3 | 532 | struct lttng_transport { |
a33c9927 MD |
533 | char *name; |
534 | struct module *owner; | |
535 | struct list_head node; | |
a90917c3 | 536 | struct lttng_channel_ops ops; |
a33c9927 MD |
537 | }; |
538 | ||
a101fa10 MD |
539 | struct lttng_counter_transport { |
540 | char *name; | |
541 | struct module *owner; | |
542 | struct list_head node; | |
543 | struct lttng_counter_ops ops; | |
544 | }; | |
545 | ||
80f87dd2 MD |
546 | struct lttng_syscall_filter; |
547 | ||
3c997079 MD |
548 | #define LTTNG_EVENT_HT_BITS 12 |
549 | #define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS) | |
550 | ||
551 | struct lttng_event_ht { | |
552 | struct hlist_head table[LTTNG_EVENT_HT_SIZE]; | |
553 | }; | |
554 | ||
dffef45d FD |
555 | #define LTTNG_EVENT_NOTIFIER_HT_BITS 12 |
556 | #define LTTNG_EVENT_NOTIFIER_HT_SIZE (1U << LTTNG_EVENT_NOTIFIER_HT_BITS) | |
557 | ||
558 | struct lttng_event_notifier_ht { | |
559 | struct hlist_head table[LTTNG_EVENT_NOTIFIER_HT_SIZE]; | |
560 | }; | |
561 | ||
a90917c3 | 562 | struct lttng_channel { |
c099397a | 563 | unsigned int id; |
85a9ca7f | 564 | struct channel *chan; /* Channel buffers */ |
e64957da | 565 | int enabled; |
437d5aa5 | 566 | struct lttng_kernel_ctx *ctx; |
85a9ca7f | 567 | /* Event ID management */ |
a90917c3 | 568 | struct lttng_session *session; |
85a9ca7f MD |
569 | struct file *file; /* File associated to channel */ |
570 | unsigned int free_event_id; /* Next event ID to allocate */ | |
571 | struct list_head list; /* Channel list */ | |
a90917c3 MD |
572 | struct lttng_channel_ops *ops; |
573 | struct lttng_transport *transport; | |
3b82c4e1 MD |
574 | struct hlist_head *sc_table; /* for syscall tracing */ |
575 | struct hlist_head *compat_sc_table; | |
576 | struct hlist_head *sc_exit_table; /* for syscall exit tracing */ | |
577 | struct hlist_head *compat_sc_exit_table; | |
578 | struct hlist_head sc_unknown; /* for unknown syscalls */ | |
579 | struct hlist_head sc_compat_unknown; | |
580 | struct hlist_head sc_exit_unknown; | |
581 | struct hlist_head compat_sc_exit_unknown; | |
80f87dd2 | 582 | struct lttng_syscall_filter *sc_filter; |
9115fbdc | 583 | int header_type; /* 0: unset, 1: compact, 2: large */ |
d83004aa | 584 | enum channel_type channel_type; |
3b82c4e1 MD |
585 | int syscall_all_entry; |
586 | int syscall_all_exit; | |
80f87dd2 MD |
587 | unsigned int metadata_dumped:1, |
588 | sys_enter_registered:1, | |
589 | sys_exit_registered:1, | |
3c997079 | 590 | tstate:1; /* Transient enable state */ |
85a9ca7f MD |
591 | }; |
592 | ||
d83004aa JD |
593 | struct lttng_metadata_stream { |
594 | void *priv; /* Ring buffer private data */ | |
595 | struct lttng_metadata_cache *metadata_cache; | |
f613e3e6 MD |
596 | unsigned int metadata_in; /* Bytes read from the cache */ |
597 | unsigned int metadata_out; /* Bytes consumed from stream */ | |
d83004aa JD |
598 | int finalized; /* Has channel been finalized */ |
599 | wait_queue_head_t read_wait; /* Reader buffer-level wait queue */ | |
600 | struct list_head list; /* Stream list */ | |
b3b8072b | 601 | struct lttng_transport *transport; |
9616f0bf | 602 | uint64_t version; /* Current version of the metadata cache */ |
8b97fd42 | 603 | bool coherent; /* Stream in a coherent state */ |
d83004aa JD |
604 | }; |
605 | ||
114667d5 MD |
606 | #define LTTNG_DYNAMIC_LEN_STACK_SIZE 128 |
607 | ||
608 | struct lttng_dynamic_len_stack { | |
609 | size_t stack[LTTNG_DYNAMIC_LEN_STACK_SIZE]; | |
610 | size_t offset; | |
611 | }; | |
612 | ||
613 | DECLARE_PER_CPU(struct lttng_dynamic_len_stack, lttng_dynamic_len_stack); | |
e0130fab MD |
614 | |
615 | /* | |
d1f652f8 | 616 | * struct lttng_id_tracker declared in header due to deferencing of *v |
e0130fab MD |
617 | * in RCU_INITIALIZER(v). |
618 | */ | |
d1f652f8 MD |
619 | #define LTTNG_ID_HASH_BITS 6 |
620 | #define LTTNG_ID_TABLE_SIZE (1 << LTTNG_ID_HASH_BITS) | |
e0130fab | 621 | |
d1f652f8 MD |
622 | enum tracker_type { |
623 | TRACKER_PID, | |
624 | TRACKER_VPID, | |
625 | TRACKER_UID, | |
626 | TRACKER_VUID, | |
627 | TRACKER_GID, | |
628 | TRACKER_VGID, | |
629 | ||
630 | TRACKER_UNKNOWN, | |
631 | }; | |
632 | ||
633 | struct lttng_id_tracker_rcu { | |
634 | struct hlist_head id_hash[LTTNG_ID_TABLE_SIZE]; | |
635 | }; | |
636 | ||
637 | struct lttng_id_tracker { | |
638 | struct lttng_session *session; | |
639 | enum tracker_type tracker_type; | |
640 | struct lttng_id_tracker_rcu *p; /* RCU dereferenced. */ | |
e0130fab MD |
641 | }; |
642 | ||
d1f652f8 | 643 | struct lttng_id_hash_node { |
7e6f9ef6 | 644 | struct hlist_node hlist; |
d1f652f8 | 645 | int id; |
7e6f9ef6 MD |
646 | }; |
647 | ||
a90917c3 | 648 | struct lttng_session { |
85a9ca7f | 649 | int active; /* Is trace session active ? */ |
8070f5c0 | 650 | int been_active; /* Has trace session been active ? */ |
85a9ca7f MD |
651 | struct file *file; /* File associated to session */ |
652 | struct list_head chan; /* Channel list head */ | |
653 | struct list_head events; /* Event list head */ | |
654 | struct list_head list; /* Session list */ | |
c099397a | 655 | unsigned int free_chan_id; /* Next chan ID to allocate */ |
d793d5e1 | 656 | uuid_le uuid; /* Trace session unique ID */ |
d83004aa | 657 | struct lttng_metadata_cache *metadata_cache; |
d1f652f8 MD |
658 | struct lttng_id_tracker pid_tracker; |
659 | struct lttng_id_tracker vpid_tracker; | |
660 | struct lttng_id_tracker uid_tracker; | |
661 | struct lttng_id_tracker vuid_tracker; | |
662 | struct lttng_id_tracker gid_tracker; | |
663 | struct lttng_id_tracker vgid_tracker; | |
3c997079 MD |
664 | unsigned int metadata_dumped:1, |
665 | tstate:1; /* Transient enable state */ | |
b2bc0bc8 | 666 | /* List of event enablers */ |
3c997079 MD |
667 | struct list_head enablers_head; |
668 | /* Hash table of events */ | |
669 | struct lttng_event_ht events_ht; | |
606828e4 MD |
670 | char name[LTTNG_KERNEL_ABI_SESSION_NAME_LEN]; |
671 | char creation_time[LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN]; | |
85a9ca7f MD |
672 | }; |
673 | ||
99f52fcc FD |
674 | struct lttng_counter { |
675 | struct file *file; /* File associated to counter. */ | |
676 | struct file *owner; | |
677 | struct lttng_counter_transport *transport; | |
678 | struct lib_counter *counter; | |
679 | struct lttng_counter_ops *ops; | |
680 | }; | |
681 | ||
750b05f2 FD |
682 | struct lttng_event_notifier_group { |
683 | struct file *file; /* File associated to event notifier group */ | |
21f58fb7 | 684 | struct file *notif_file; /* File used to expose notifications to userspace. */ |
750b05f2 | 685 | struct list_head node; /* event notifier group list */ |
dffef45d FD |
686 | struct list_head enablers_head; /* List of enablers */ |
687 | struct list_head event_notifiers_head; /* List of event notifier */ | |
688 | struct lttng_event_notifier_ht event_notifiers_ht; /* Hash table of event notifiers */ | |
750b05f2 FD |
689 | struct lttng_channel_ops *ops; |
690 | struct lttng_transport *transport; | |
691 | struct channel *chan; /* Ring buffer channel for event notifier group. */ | |
692 | struct lib_ring_buffer *buf; /* Ring buffer for event notifier group. */ | |
21f58fb7 FD |
693 | wait_queue_head_t read_wait; |
694 | struct irq_work wakeup_pending; /* Pending wakeup irq work. */ | |
a67ba386 MD |
695 | struct lttng_kernel_event_notifier *sc_unknown; /* for unknown syscalls */ |
696 | struct lttng_kernel_event_notifier *sc_compat_unknown; | |
8a8ac9a8 FD |
697 | |
698 | struct lttng_syscall_filter *sc_filter; | |
699 | ||
700 | struct hlist_head *event_notifier_syscall_dispatch; | |
701 | struct hlist_head *event_notifier_compat_syscall_dispatch; | |
702 | struct hlist_head *event_notifier_exit_syscall_dispatch; | |
703 | struct hlist_head *event_notifier_exit_compat_syscall_dispatch; | |
704 | ||
705 | struct hlist_head event_notifier_unknown_syscall_dispatch; | |
706 | struct hlist_head event_notifier_compat_unknown_syscall_dispatch; | |
707 | struct hlist_head event_notifier_exit_unknown_syscall_dispatch; | |
708 | struct hlist_head event_notifier_exit_compat_unknown_syscall_dispatch; | |
709 | ||
710 | int syscall_all_entry; | |
711 | int syscall_all_exit; | |
712 | ||
713 | unsigned int sys_enter_registered:1, sys_exit_registered:1; | |
714 | ||
715 | struct lttng_counter *error_counter; | |
716 | size_t error_counter_len; | |
750b05f2 FD |
717 | }; |
718 | ||
d83004aa JD |
719 | struct lttng_metadata_cache { |
720 | char *data; /* Metadata cache */ | |
721 | unsigned int cache_alloc; /* Metadata allocated size (bytes) */ | |
722 | unsigned int metadata_written; /* Number of bytes written in metadata cache */ | |
3e75e2a7 | 723 | atomic_t producing; /* Metadata being produced (incomplete) */ |
d83004aa JD |
724 | struct kref refcount; /* Metadata cache usage */ |
725 | struct list_head metadata_stream; /* Metadata stream list */ | |
a36580d5 | 726 | uuid_le uuid; /* Trace session unique ID (copy) */ |
9616f0bf JD |
727 | struct mutex lock; /* Produce/consume lock */ |
728 | uint64_t version; /* Current version of the metadata */ | |
d83004aa JD |
729 | }; |
730 | ||
3c997079 MD |
731 | void lttng_lock_sessions(void); |
732 | void lttng_unlock_sessions(void); | |
733 | ||
734 | struct list_head *lttng_get_probe_list_head(void); | |
735 | ||
b2bc0bc8 FD |
736 | struct lttng_event_enabler *lttng_event_enabler_create( |
737 | enum lttng_enabler_format_type format_type, | |
606828e4 | 738 | struct lttng_kernel_abi_event *event_param, |
3c997079 MD |
739 | struct lttng_channel *chan); |
740 | ||
b2bc0bc8 FD |
741 | int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler); |
742 | int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler); | |
dffef45d FD |
743 | struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create( |
744 | struct lttng_event_notifier_group *event_notifier_group, | |
745 | enum lttng_enabler_format_type format_type, | |
606828e4 | 746 | struct lttng_kernel_abi_event_notifier *event_notifier_param); |
dffef45d FD |
747 | |
748 | int lttng_event_notifier_enabler_enable( | |
749 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
750 | int lttng_event_notifier_enabler_disable( | |
751 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
3c997079 | 752 | int lttng_fix_pending_events(void); |
b01155ba | 753 | int lttng_fix_pending_event_notifiers(void); |
3c997079 | 754 | int lttng_session_active(void); |
b01155ba | 755 | bool lttng_event_notifier_active(void); |
3c997079 | 756 | |
a90917c3 MD |
757 | struct lttng_session *lttng_session_create(void); |
758 | int lttng_session_enable(struct lttng_session *session); | |
759 | int lttng_session_disable(struct lttng_session *session); | |
760 | void lttng_session_destroy(struct lttng_session *session); | |
9616f0bf | 761 | int lttng_session_metadata_regenerate(struct lttng_session *session); |
601252cf | 762 | int lttng_session_statedump(struct lttng_session *session); |
d83004aa | 763 | void metadata_cache_destroy(struct kref *kref); |
4e3c1b9b | 764 | |
99f52fcc FD |
765 | struct lttng_counter *lttng_kernel_counter_create( |
766 | const char *counter_transport_name, size_t number_dimensions, | |
767 | const size_t *dimensions_sizes); | |
768 | int lttng_kernel_counter_read(struct lttng_counter *counter, | |
769 | const size_t *dimension_indexes, int32_t cpu, | |
770 | int64_t *val, bool *overflow, bool *underflow); | |
771 | int lttng_kernel_counter_aggregate(struct lttng_counter *counter, | |
772 | const size_t *dimension_indexes, int64_t *val, | |
773 | bool *overflow, bool *underflow); | |
774 | int lttng_kernel_counter_clear(struct lttng_counter *counter, | |
775 | const size_t *dimension_indexes); | |
776 | ||
777 | ||
750b05f2 | 778 | struct lttng_event_notifier_group *lttng_event_notifier_group_create(void); |
99f52fcc FD |
779 | int lttng_event_notifier_group_create_error_counter( |
780 | struct file *event_notifier_group_file, | |
606828e4 | 781 | const struct lttng_kernel_abi_counter_conf *error_counter_conf); |
750b05f2 FD |
782 | void lttng_event_notifier_group_destroy( |
783 | struct lttng_event_notifier_group *event_notifier_group); | |
784 | ||
a90917c3 | 785 | struct lttng_channel *lttng_channel_create(struct lttng_session *session, |
5dbbdb43 MD |
786 | const char *transport_name, |
787 | void *buf_addr, | |
788 | size_t subbuf_size, size_t num_subbuf, | |
789 | unsigned int switch_timer_interval, | |
d83004aa JD |
790 | unsigned int read_timer_interval, |
791 | enum channel_type channel_type); | |
a90917c3 | 792 | struct lttng_channel *lttng_global_channel_create(struct lttng_session *session, |
4e3c1b9b MD |
793 | int overwrite, void *buf_addr, |
794 | size_t subbuf_size, size_t num_subbuf, | |
795 | unsigned int switch_timer_interval, | |
796 | unsigned int read_timer_interval); | |
4e3c1b9b | 797 | |
d83004aa | 798 | void lttng_metadata_channel_destroy(struct lttng_channel *chan); |
a67ba386 | 799 | struct lttng_kernel_event_recorder *lttng_kernel_event_recorder_create(struct lttng_channel *chan, |
606828e4 | 800 | struct lttng_kernel_abi_event *event_param, |
437d5aa5 | 801 | const struct lttng_kernel_event_desc *event_desc, |
606828e4 | 802 | enum lttng_kernel_abi_instrumentation itype); |
a67ba386 | 803 | struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct lttng_channel *chan, |
606828e4 | 804 | struct lttng_kernel_abi_event *event_param, |
437d5aa5 | 805 | const struct lttng_kernel_event_desc *event_desc, |
606828e4 | 806 | enum lttng_kernel_abi_instrumentation itype); |
a67ba386 | 807 | struct lttng_kernel_event_recorder *lttng_event_compat_old_create(struct lttng_channel *chan, |
606828e4 | 808 | struct lttng_kernel_abi_old_event *old_event_param, |
437d5aa5 | 809 | const struct lttng_kernel_event_desc *internal_desc); |
c0e31d2e | 810 | |
a67ba386 | 811 | struct lttng_kernel_event_notifier *lttng_event_notifier_create( |
437d5aa5 | 812 | const struct lttng_kernel_event_desc *event_notifier_desc, |
dffef45d | 813 | uint64_t id, |
99f52fcc | 814 | uint64_t error_counter_idx, |
dffef45d | 815 | struct lttng_event_notifier_group *event_notifier_group, |
606828e4 | 816 | struct lttng_kernel_abi_event_notifier *event_notifier_param, |
606828e4 | 817 | enum lttng_kernel_abi_instrumentation itype); |
a67ba386 | 818 | struct lttng_kernel_event_notifier *_lttng_event_notifier_create( |
437d5aa5 | 819 | const struct lttng_kernel_event_desc *event_notifier_desc, |
dffef45d | 820 | uint64_t id, |
99f52fcc | 821 | uint64_t error_counter_idx, |
dffef45d | 822 | struct lttng_event_notifier_group *event_notifier_group, |
606828e4 | 823 | struct lttng_kernel_abi_event_notifier *event_notifier_param, |
606828e4 | 824 | enum lttng_kernel_abi_instrumentation itype); |
dffef45d | 825 | |
a90917c3 MD |
826 | int lttng_channel_enable(struct lttng_channel *channel); |
827 | int lttng_channel_disable(struct lttng_channel *channel); | |
9d993668 MD |
828 | int lttng_event_enable(struct lttng_kernel_event_common *event); |
829 | int lttng_event_disable(struct lttng_kernel_event_common *event); | |
2b16f0c9 | 830 | |
a90917c3 MD |
831 | void lttng_transport_register(struct lttng_transport *transport); |
832 | void lttng_transport_unregister(struct lttng_transport *transport); | |
11b5a3c2 | 833 | |
a101fa10 MD |
834 | void lttng_counter_transport_register(struct lttng_counter_transport *transport); |
835 | void lttng_counter_transport_unregister(struct lttng_counter_transport *transport); | |
836 | ||
360f38ea | 837 | void synchronize_trace(void); |
80996790 | 838 | int lttng_abi_init(void); |
6dccd6c1 | 839 | int lttng_abi_compat_old_init(void); |
80996790 | 840 | void lttng_abi_exit(void); |
6dccd6c1 | 841 | void lttng_abi_compat_old_exit(void); |
1c25284c | 842 | |
437d5aa5 MD |
843 | int lttng_probe_register(struct lttng_kernel_probe_desc *desc); |
844 | void lttng_probe_unregister(struct lttng_kernel_probe_desc *desc); | |
845 | const struct lttng_kernel_event_desc *lttng_event_desc_get(const char *name); | |
846 | void lttng_event_desc_put(const struct lttng_kernel_event_desc *desc); | |
a90917c3 MD |
847 | int lttng_probes_init(void); |
848 | void lttng_probes_exit(void); | |
1ec65de1 | 849 | |
b3b8072b | 850 | int lttng_metadata_output_channel(struct lttng_metadata_stream *stream, |
8b97fd42 | 851 | struct channel *chan, bool *coherent); |
d83004aa | 852 | |
d1f652f8 MD |
853 | int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node); |
854 | int lttng_id_tracker_empty_set(struct lttng_id_tracker *lf); | |
855 | void lttng_id_tracker_destroy(struct lttng_id_tracker *lf, bool rcu); | |
856 | bool lttng_id_tracker_lookup(struct lttng_id_tracker_rcu *p, int id); | |
857 | int lttng_id_tracker_add(struct lttng_id_tracker *lf, int id); | |
858 | int lttng_id_tracker_del(struct lttng_id_tracker *lf, int id); | |
e0130fab | 859 | |
d1f652f8 MD |
860 | int lttng_session_track_id(struct lttng_session *session, |
861 | enum tracker_type tracker_type, int id); | |
862 | int lttng_session_untrack_id(struct lttng_session *session, | |
863 | enum tracker_type tracker_type, int id); | |
e0130fab | 864 | |
d1f652f8 MD |
865 | int lttng_session_list_tracker_ids(struct lttng_session *session, |
866 | enum tracker_type tracker_type); | |
7e6f9ef6 | 867 | |
2754583e MD |
868 | void lttng_clock_ref(void); |
869 | void lttng_clock_unref(void); | |
870 | ||
437d5aa5 | 871 | int lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc, |
8a8ac9a8 FD |
872 | struct lttng_enabler *enabler); |
873 | ||
3a523f5b | 874 | #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS) |
a67ba386 | 875 | int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler); |
3b82c4e1 | 876 | int lttng_syscalls_unregister_channel(struct lttng_channel *chan); |
2d6d88c6 | 877 | int lttng_syscalls_destroy_event(struct lttng_channel *chan); |
ade8a729 FD |
878 | int lttng_syscall_filter_enable_event( |
879 | struct lttng_channel *chan, | |
a67ba386 | 880 | struct lttng_kernel_event_recorder *event); |
ade8a729 FD |
881 | int lttng_syscall_filter_disable_event( |
882 | struct lttng_channel *chan, | |
a67ba386 | 883 | struct lttng_kernel_event_recorder *event); |
ade8a729 | 884 | |
12e579db | 885 | long lttng_channel_syscall_mask(struct lttng_channel *channel, |
606828e4 | 886 | struct lttng_kernel_abi_syscall_mask __user *usyscall_mask); |
2d6d88c6 | 887 | |
8a8ac9a8 | 888 | int lttng_syscalls_register_event_notifier( |
a67ba386 MD |
889 | struct lttng_event_notifier_enabler *event_notifier_enabler); |
890 | int lttng_syscalls_create_matching_event_notifiers( | |
891 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
3b82c4e1 | 892 | int lttng_syscalls_unregister_event_notifier_group(struct lttng_event_notifier_group *group); |
a67ba386 MD |
893 | int lttng_syscall_filter_enable_event_notifier(struct lttng_kernel_event_notifier *event_notifier); |
894 | int lttng_syscall_filter_disable_event_notifier(struct lttng_kernel_event_notifier *event_notifier); | |
1ec65de1 | 895 | #else |
2d6d88c6 | 896 | static inline int lttng_syscalls_register_event( |
a67ba386 | 897 | struct lttng_event_enabler *event_enabler) |
1ec65de1 MD |
898 | { |
899 | return -ENOSYS; | |
900 | } | |
901 | ||
3b82c4e1 | 902 | static inline int lttng_syscalls_unregister_channel(struct lttng_channel *chan) |
1ec65de1 MD |
903 | { |
904 | return 0; | |
905 | } | |
80f87dd2 | 906 | |
badfe9f5 MD |
907 | static inline int lttng_syscalls_destroy(struct lttng_channel *chan) |
908 | { | |
909 | return 0; | |
910 | } | |
911 | ||
2d6d88c6 | 912 | static inline int lttng_syscall_filter_enable_event(struct lttng_channel *chan, |
a67ba386 | 913 | struct lttng_kernel_event_recorder *event); |
80f87dd2 MD |
914 | { |
915 | return -ENOSYS; | |
916 | } | |
917 | ||
2d6d88c6 | 918 | static inline int lttng_syscall_filter_disable_event(struct lttng_channel *chan, |
a67ba386 | 919 | struct lttng_kernel_event_recorder *event); |
80f87dd2 MD |
920 | { |
921 | return -ENOSYS; | |
922 | } | |
12e579db | 923 | |
f127e61e | 924 | static inline long lttng_channel_syscall_mask(struct lttng_channel *channel, |
12e579db MD |
925 | struct lttng_kernel_syscall_mask __user *usyscall_mask) |
926 | { | |
927 | return -ENOSYS; | |
928 | } | |
dffef45d | 929 | |
8a8ac9a8 | 930 | static inline int lttng_syscalls_register_event_notifier( |
a67ba386 | 931 | struct lttng_event_notifier_group *group) |
8a8ac9a8 FD |
932 | { |
933 | return -ENOSYS; | |
934 | } | |
935 | ||
3b82c4e1 | 936 | static inline int lttng_syscalls_unregister_event_notifier_group( |
8a8ac9a8 FD |
937 | struct lttng_event_notifier_group *group) |
938 | { | |
939 | return 0; | |
940 | } | |
941 | ||
942 | static inline int lttng_syscall_filter_enable_event_notifier( | |
943 | struct lttng_event_notifier_group *group, | |
944 | const char *name) | |
945 | { | |
946 | return -ENOSYS; | |
947 | } | |
948 | ||
949 | static inline int lttng_syscall_filter_disable_event_notifier( | |
950 | struct lttng_event_notifier_group *group, | |
951 | const char *name) | |
952 | { | |
953 | return -ENOSYS; | |
954 | } | |
955 | ||
1ec65de1 MD |
956 | #endif |
957 | ||
183e8b3a | 958 | int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler *event_enabler, |
606828e4 | 959 | struct lttng_kernel_abi_filter_bytecode __user *bytecode); |
183e8b3a | 960 | int lttng_event_notifier_enabler_attach_filter_bytecode( |
dffef45d | 961 | struct lttng_event_notifier_enabler *event_notifier_enabler, |
606828e4 | 962 | struct lttng_kernel_abi_filter_bytecode __user *bytecode); |
99d223ad FD |
963 | int lttng_event_notifier_enabler_attach_capture_bytecode( |
964 | struct lttng_event_notifier_enabler *event_notifier_enabler, | |
606828e4 | 965 | struct lttng_kernel_abi_capture_bytecode __user *bytecode); |
2dfda770 | 966 | |
437d5aa5 MD |
967 | void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_desc, |
968 | struct lttng_kernel_ctx *ctx, | |
60206944 FD |
969 | struct list_head *instance_bytecode_runtime_head, |
970 | struct list_head *enabler_bytecode_runtime_head); | |
0648898e | 971 | void lttng_free_event_filter_runtime(struct lttng_kernel_event_common *event); |
07dfc1d0 | 972 | |
114667d5 MD |
973 | int lttng_probes_init(void); |
974 | ||
0c956676 MD |
975 | int lttng_logger_init(void); |
976 | void lttng_logger_exit(void); | |
977 | ||
c337ddc2 MD |
978 | extern int lttng_statedump_start(struct lttng_session *session); |
979 | ||
acd614cc | 980 | #ifdef CONFIG_KPROBES |
8bf17deb | 981 | int lttng_kprobes_register_event(const char *name, |
f17701fb MD |
982 | const char *symbol_name, |
983 | uint64_t offset, | |
984 | uint64_t addr, | |
a67ba386 MD |
985 | struct lttng_kernel_event_recorder *event); |
986 | void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder *event); | |
987 | void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder *event); | |
2b16f0c9 FD |
988 | int lttng_kprobes_register_event_notifier(const char *symbol_name, |
989 | uint64_t offset, | |
990 | uint64_t addr, | |
a67ba386 MD |
991 | struct lttng_kernel_event_notifier *event_notifier); |
992 | void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier); | |
993 | void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier); | |
acd614cc MD |
994 | #else |
995 | static inline | |
8bf17deb | 996 | int lttng_kprobes_register_event(const char *name, |
acd614cc MD |
997 | const char *symbol_name, |
998 | uint64_t offset, | |
999 | uint64_t addr, | |
a67ba386 | 1000 | struct lttng_kernel_event_recorder *event) |
acd614cc MD |
1001 | { |
1002 | return -ENOSYS; | |
1003 | } | |
1004 | ||
25f53c39 | 1005 | static inline |
a67ba386 | 1006 | void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder *event) |
8bf17deb FD |
1007 | { |
1008 | } | |
1009 | ||
1010 | static inline | |
a67ba386 | 1011 | void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder *event) |
acd614cc MD |
1012 | { |
1013 | } | |
edeb3137 MD |
1014 | |
1015 | static inline | |
2b16f0c9 FD |
1016 | int lttng_kprobes_register_event_notifier(const char *symbol_name, |
1017 | uint64_t offset, | |
1018 | uint64_t addr, | |
a67ba386 | 1019 | struct lttng_kernel_event_notifier *event_notifier) |
2b16f0c9 FD |
1020 | { |
1021 | return -ENOSYS; | |
1022 | } | |
1023 | ||
1024 | static inline | |
a67ba386 | 1025 | void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier) |
2b16f0c9 FD |
1026 | { |
1027 | } | |
1028 | ||
1029 | static inline | |
a67ba386 | 1030 | void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier) |
edeb3137 MD |
1031 | { |
1032 | } | |
acd614cc | 1033 | #endif |
d6d808f3 | 1034 | |
e2d5dbc7 | 1035 | int lttng_event_add_callsite(struct lttng_kernel_event_common *event, |
606828e4 | 1036 | struct lttng_kernel_abi_event_callsite __user *callsite); |
9de67196 | 1037 | |
149b9a9d | 1038 | #ifdef CONFIG_UPROBES |
83b802dc | 1039 | int lttng_uprobes_register_event(const char *name, |
a67ba386 | 1040 | int fd, struct lttng_kernel_event_recorder *event); |
e2d5dbc7 | 1041 | int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event, |
606828e4 | 1042 | struct lttng_kernel_abi_event_callsite __user *callsite); |
a67ba386 MD |
1043 | void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder *event); |
1044 | void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder *event); | |
9de67196 | 1045 | int lttng_uprobes_register_event_notifier(const char *name, |
a67ba386 | 1046 | int fd, struct lttng_kernel_event_notifier *event_notifier); |
a67ba386 MD |
1047 | void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier); |
1048 | void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier); | |
149b9a9d YB |
1049 | #else |
1050 | static inline | |
83b802dc | 1051 | int lttng_uprobes_register_event(const char *name, |
a67ba386 | 1052 | int fd, struct lttng_kernel_event_recorder *event) |
3aed4dca FD |
1053 | { |
1054 | return -ENOSYS; | |
1055 | } | |
1056 | ||
1057 | static inline | |
e2d5dbc7 | 1058 | int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event, |
606828e4 | 1059 | struct lttng_kernel_abi_event_callsite __user *callsite) |
149b9a9d YB |
1060 | { |
1061 | return -ENOSYS; | |
1062 | } | |
1063 | ||
1064 | static inline | |
a67ba386 | 1065 | void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder *event) |
149b9a9d YB |
1066 | { |
1067 | } | |
1068 | ||
1069 | static inline | |
a67ba386 | 1070 | void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder *event) |
149b9a9d YB |
1071 | { |
1072 | } | |
9de67196 FD |
1073 | |
1074 | static inline | |
1075 | int lttng_uprobes_register_event_notifier(const char *name, | |
a67ba386 | 1076 | int fd, struct lttng_kernel_event_notifier *event_notifier) |
9de67196 FD |
1077 | { |
1078 | return -ENOSYS; | |
1079 | } | |
1080 | ||
9de67196 | 1081 | static inline |
a67ba386 | 1082 | void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier) |
9de67196 FD |
1083 | { |
1084 | } | |
1085 | ||
1086 | static inline | |
a67ba386 | 1087 | void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier) |
9de67196 FD |
1088 | { |
1089 | } | |
149b9a9d YB |
1090 | #endif |
1091 | ||
7371f44c MD |
1092 | #ifdef CONFIG_KRETPROBES |
1093 | int lttng_kretprobes_register(const char *name, | |
1094 | const char *symbol_name, | |
1095 | uint64_t offset, | |
1096 | uint64_t addr, | |
a67ba386 MD |
1097 | struct lttng_kernel_event_recorder *event_entry, |
1098 | struct lttng_kernel_event_recorder *event_exit); | |
1099 | void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder *event); | |
1100 | void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder *event); | |
e2d5dbc7 | 1101 | int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event, |
a0493bef | 1102 | int enable); |
7371f44c MD |
1103 | #else |
1104 | static inline | |
1105 | int lttng_kretprobes_register(const char *name, | |
1106 | const char *symbol_name, | |
1107 | uint64_t offset, | |
1108 | uint64_t addr, | |
a67ba386 MD |
1109 | struct lttng_kernel_event_recorder *event_entry, |
1110 | struct lttng_kernel_event_recorder *event_exit) | |
7371f44c MD |
1111 | { |
1112 | return -ENOSYS; | |
1113 | } | |
1114 | ||
1115 | static inline | |
a67ba386 | 1116 | void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder *event) |
7371f44c MD |
1117 | { |
1118 | } | |
1119 | ||
1120 | static inline | |
a67ba386 | 1121 | void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder *event) |
7371f44c MD |
1122 | { |
1123 | } | |
a0493bef MD |
1124 | |
1125 | static inline | |
e2d5dbc7 | 1126 | int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event, |
a0493bef MD |
1127 | int enable) |
1128 | { | |
1129 | return -ENOSYS; | |
1130 | } | |
7371f44c MD |
1131 | #endif |
1132 | ||
606828e4 | 1133 | int lttng_calibrate(struct lttng_kernel_abi_calibrate *calibrate); |
57105fc2 | 1134 | |
271b6681 | 1135 | extern const struct file_operations lttng_tracepoint_list_fops; |
2d2464bd | 1136 | extern const struct file_operations lttng_syscall_list_fops; |
271b6681 | 1137 | |
ef200626 | 1138 | #define TRACEPOINT_HAS_DATA_ARG |
ef200626 | 1139 | |
a90917c3 | 1140 | #endif /* _LTTNG_EVENTS_H */ |