Commit | Line | Data |
---|---|---|
92bc1e23 MD |
1 | /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
2 | * | |
3 | * lttng/events-internal.h | |
4 | * | |
5 | * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
6 | */ | |
7 | ||
8 | #ifndef _LTTNG_EVENTS_INTERNAL_H | |
9 | #define _LTTNG_EVENTS_INTERNAL_H | |
10 | ||
437d5aa5 MD |
11 | #include <lttng/events.h> |
12 | ||
344fe0f6 | 13 | struct lttng_syscall_filter; |
7c1ba2ca MD |
14 | struct lttng_metadata_cache; |
15 | struct perf_event; | |
16 | struct perf_event_attr; | |
17 | struct lib_ring_buffer_config; | |
344fe0f6 | 18 | |
311e655a MD |
19 | enum lttng_enabler_format_type { |
20 | LTTNG_ENABLER_FORMAT_STAR_GLOB, | |
21 | LTTNG_ENABLER_FORMAT_NAME, | |
22 | }; | |
23 | ||
24 | /* | |
25 | * Objects in a linked-list of enablers, owned by an event. | |
26 | */ | |
27 | struct lttng_enabler_ref { | |
28 | struct list_head node; /* enabler ref list */ | |
29 | struct lttng_enabler *ref; /* backward ref */ | |
30 | }; | |
31 | ||
e978f274 MD |
32 | struct lttng_krp; /* Kretprobe handling */ |
33 | ||
34 | struct lttng_uprobe_handler { | |
35 | struct lttng_kernel_event_common *event; | |
36 | loff_t offset; | |
37 | struct uprobe_consumer up_consumer; | |
38 | struct list_head node; | |
39 | }; | |
40 | ||
41 | struct lttng_kprobe { | |
42 | struct kprobe kp; | |
43 | char *symbol_name; | |
44 | }; | |
45 | ||
46 | struct lttng_uprobe { | |
47 | struct inode *inode; | |
48 | struct list_head head; | |
49 | }; | |
50 | ||
51 | enum lttng_syscall_entryexit { | |
52 | LTTNG_SYSCALL_ENTRY, | |
53 | LTTNG_SYSCALL_EXIT, | |
54 | }; | |
55 | ||
56 | enum lttng_syscall_abi { | |
57 | LTTNG_SYSCALL_ABI_NATIVE, | |
58 | LTTNG_SYSCALL_ABI_COMPAT, | |
59 | }; | |
60 | ||
a67ba386 MD |
61 | struct lttng_kernel_event_common_private { |
62 | struct lttng_kernel_event_common *pub; /* Public event interface */ | |
63 | ||
64 | const struct lttng_kernel_event_desc *desc; | |
65 | /* Backward references: list of lttng_enabler_ref (ref to enablers) */ | |
66 | struct list_head enablers_ref_head; | |
67 | int registered; /* has reg'd tracepoint probe */ | |
68 | uint64_t user_token; | |
69 | ||
70 | int has_enablers_without_filter_bytecode; | |
218585b9 | 71 | /* list of struct lttng_kernel_bytecode_runtime, sorted by seqnum */ |
a67ba386 MD |
72 | struct list_head filter_bytecode_runtime_head; |
73 | enum lttng_kernel_abi_instrumentation instrumentation; | |
74 | /* Selected by instrumentation */ | |
75 | union { | |
76 | struct lttng_kprobe kprobe; | |
77 | struct lttng_uprobe uprobe; | |
78 | struct { | |
79 | struct lttng_krp *lttng_krp; | |
80 | char *symbol_name; | |
81 | } kretprobe; | |
82 | struct { | |
83 | enum lttng_syscall_entryexit entryexit; | |
84 | enum lttng_syscall_abi abi; | |
85 | struct hlist_node node; /* chain registered syscall event_notifier */ | |
86 | unsigned int syscall_id; | |
87 | } syscall; | |
88 | } u; | |
89 | }; | |
90 | ||
91 | struct lttng_kernel_event_recorder_private { | |
92 | struct lttng_kernel_event_common_private parent; | |
93 | ||
94 | struct lttng_kernel_event_recorder *pub; /* Public event interface */ | |
95 | struct list_head node; /* Event recorder list */ | |
96 | struct hlist_node hlist; /* Hash table of event recorders */ | |
97 | struct lttng_kernel_ctx *ctx; | |
98 | unsigned int id; | |
99 | unsigned int metadata_dumped:1; | |
100 | }; | |
101 | ||
102 | struct lttng_kernel_event_notifier_private { | |
103 | struct lttng_kernel_event_common_private parent; | |
104 | ||
105 | struct lttng_kernel_event_notifier *pub; /* Public event notifier interface */ | |
106 | struct lttng_event_notifier_group *group; /* weak ref */ | |
107 | size_t num_captures; /* Needed to allocate the msgpack array. */ | |
108 | uint64_t error_counter_index; | |
109 | struct list_head node; /* Event notifier list */ | |
110 | struct hlist_node hlist; /* Hash table of event notifiers */ | |
111 | struct list_head capture_bytecode_runtime_head; | |
112 | ||
113 | }; | |
114 | ||
8a445457 MD |
115 | enum lttng_kernel_bytecode_interpreter_ret { |
116 | LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR = -1, | |
117 | LTTNG_KERNEL_BYTECODE_INTERPRETER_OK = 0, | |
118 | }; | |
119 | ||
120 | enum lttng_kernel_bytecode_filter_result { | |
121 | LTTNG_KERNEL_BYTECODE_FILTER_ACCEPT = 0, | |
122 | LTTNG_KERNEL_BYTECODE_FILTER_REJECT = 1, | |
123 | }; | |
124 | ||
125 | struct lttng_kernel_bytecode_filter_ctx { | |
126 | enum lttng_kernel_bytecode_filter_result result; | |
127 | }; | |
128 | ||
1efb0502 MD |
129 | struct lttng_interpreter_output; |
130 | ||
131 | enum lttng_kernel_bytecode_type { | |
132 | LTTNG_KERNEL_BYTECODE_TYPE_FILTER, | |
133 | LTTNG_KERNEL_BYTECODE_TYPE_CAPTURE, | |
134 | }; | |
135 | ||
136 | struct lttng_kernel_bytecode_node { | |
137 | enum lttng_kernel_bytecode_type type; | |
138 | struct list_head node; | |
139 | struct lttng_enabler *enabler; | |
140 | struct { | |
141 | uint32_t len; | |
142 | uint32_t reloc_offset; | |
143 | uint64_t seqnum; | |
144 | char data[]; | |
145 | } bc; | |
146 | }; | |
147 | ||
148 | struct lttng_kernel_bytecode_runtime { | |
149 | /* Associated bytecode */ | |
150 | enum lttng_kernel_bytecode_type type; | |
151 | struct lttng_kernel_bytecode_node *bc; | |
152 | int (*interpreter_func)(struct lttng_kernel_bytecode_runtime *kernel_bytecode, | |
153 | const char *interpreter_stack_data, | |
154 | struct lttng_kernel_probe_ctx *lttng_probe_ctx, | |
155 | void *caller_ctx); | |
156 | int link_failed; | |
157 | struct list_head node; /* list of bytecode runtime in event */ | |
158 | struct lttng_kernel_ctx *ctx; | |
159 | }; | |
160 | ||
5e08a34f MD |
161 | /* |
162 | * Enabler field, within whatever object is enabling an event. Target of | |
163 | * backward reference. | |
164 | */ | |
165 | struct lttng_enabler { | |
166 | enum lttng_enabler_format_type format_type; | |
167 | ||
d64ca521 | 168 | /* head list of struct lttng_kernel_bytecode_node */ |
5e08a34f MD |
169 | struct list_head filter_bytecode_head; |
170 | ||
171 | struct lttng_kernel_abi_event event_param; | |
172 | unsigned int enabled:1; | |
173 | ||
174 | uint64_t user_token; /* User-provided token. */ | |
175 | }; | |
176 | ||
177 | struct lttng_event_enabler { | |
178 | struct lttng_enabler base; | |
179 | struct list_head node; /* per-session list of enablers */ | |
180 | struct lttng_channel *chan; | |
181 | }; | |
182 | ||
183 | struct lttng_event_notifier_enabler { | |
184 | struct lttng_enabler base; | |
185 | uint64_t error_counter_index; | |
186 | struct list_head node; /* List of event_notifier enablers */ | |
187 | struct lttng_event_notifier_group *group; | |
188 | ||
d64ca521 | 189 | /* head list of struct lttng_kernel_bytecode_node */ |
5e08a34f MD |
190 | struct list_head capture_bytecode_head; |
191 | uint64_t num_captures; | |
192 | }; | |
193 | ||
0fe45627 MD |
194 | struct lttng_ctx_value { |
195 | union { | |
196 | int64_t s64; | |
197 | const char *str; | |
198 | double d; | |
199 | } u; | |
200 | }; | |
201 | ||
202 | /* | |
203 | * We need to keep this perf counter field separately from struct | |
204 | * lttng_kernel_ctx_field because cpu hotplug needs fixed-location addresses. | |
205 | */ | |
206 | struct lttng_perf_counter_field { | |
207 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) | |
208 | struct lttng_cpuhp_node cpuhp_prepare; | |
209 | struct lttng_cpuhp_node cpuhp_online; | |
210 | #else | |
211 | struct notifier_block nb; | |
212 | int hp_enable; | |
213 | #endif | |
214 | struct perf_event_attr *attr; | |
215 | struct perf_event **e; /* per-cpu array */ | |
216 | char *name; | |
217 | struct lttng_kernel_event_field *event_field; | |
218 | }; | |
219 | ||
220 | struct lttng_kernel_ctx_field { | |
221 | const struct lttng_kernel_event_field *event_field; | |
a92e844e | 222 | size_t (*get_size)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, |
0fe45627 | 223 | size_t offset); |
a92e844e | 224 | void (*record)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, |
8a57ec02 | 225 | struct lttng_kernel_ring_buffer_ctx *ctx, |
0fe45627 | 226 | struct lttng_channel *chan); |
a92e844e | 227 | void (*get_value)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, |
0fe45627 MD |
228 | struct lttng_ctx_value *value); |
229 | void (*destroy)(void *priv); | |
230 | void *priv; | |
231 | }; | |
232 | ||
233 | struct lttng_kernel_ctx { | |
234 | struct lttng_kernel_ctx_field *fields; | |
235 | unsigned int nr_fields; | |
236 | unsigned int allocated_fields; | |
237 | size_t largest_align; /* in bytes */ | |
238 | }; | |
239 | ||
8a20497f MD |
240 | struct lttng_metadata_cache { |
241 | char *data; /* Metadata cache */ | |
242 | unsigned int cache_alloc; /* Metadata allocated size (bytes) */ | |
243 | unsigned int metadata_written; /* Number of bytes written in metadata cache */ | |
244 | atomic_t producing; /* Metadata being produced (incomplete) */ | |
245 | struct kref refcount; /* Metadata cache usage */ | |
246 | struct list_head metadata_stream; /* Metadata stream list */ | |
247 | uuid_le uuid; /* Trace session unique ID (copy) */ | |
248 | struct mutex lock; /* Produce/consume lock */ | |
249 | uint64_t version; /* Current version of the metadata */ | |
250 | }; | |
251 | ||
a44f47dd MD |
252 | struct lttng_metadata_stream { |
253 | void *priv; /* Ring buffer private data */ | |
254 | struct lttng_metadata_cache *metadata_cache; | |
255 | unsigned int metadata_in; /* Bytes read from the cache */ | |
256 | unsigned int metadata_out; /* Bytes consumed from stream */ | |
257 | int finalized; /* Has channel been finalized */ | |
258 | wait_queue_head_t read_wait; /* Reader buffer-level wait queue */ | |
259 | struct list_head list; /* Stream list */ | |
260 | struct lttng_transport *transport; | |
261 | uint64_t version; /* Current version of the metadata cache */ | |
262 | bool coherent; /* Stream in a coherent state */ | |
263 | }; | |
264 | ||
4a399b76 MD |
265 | struct lttng_kernel_channel_buffer_ops_private { |
266 | struct lttng_kernel_channel_buffer_ops *pub; /* Public channel buffer ops interface */ | |
267 | ||
268 | struct channel *(*channel_create)(const char *name, | |
269 | void *priv, | |
270 | void *buf_addr, | |
271 | size_t subbuf_size, size_t num_subbuf, | |
272 | unsigned int switch_timer_interval, | |
273 | unsigned int read_timer_interval); | |
274 | void (*channel_destroy)(struct channel *chan); | |
275 | struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan); | |
276 | int (*buffer_has_read_closed_stream)(struct channel *chan); | |
277 | void (*buffer_read_close)(struct lib_ring_buffer *buf); | |
278 | /* | |
279 | * packet_avail_size returns the available size in the current | |
280 | * packet. Note that the size returned is only a hint, since it | |
281 | * may change due to concurrent writes. | |
282 | */ | |
283 | size_t (*packet_avail_size)(struct channel *chan); | |
284 | wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu); | |
285 | wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan); | |
286 | int (*is_finalized)(struct channel *chan); | |
287 | int (*is_disabled)(struct channel *chan); | |
288 | int (*timestamp_begin) (const struct lib_ring_buffer_config *config, | |
289 | struct lib_ring_buffer *bufb, | |
290 | uint64_t *timestamp_begin); | |
291 | int (*timestamp_end) (const struct lib_ring_buffer_config *config, | |
292 | struct lib_ring_buffer *bufb, | |
293 | uint64_t *timestamp_end); | |
294 | int (*events_discarded) (const struct lib_ring_buffer_config *config, | |
295 | struct lib_ring_buffer *bufb, | |
296 | uint64_t *events_discarded); | |
297 | int (*content_size) (const struct lib_ring_buffer_config *config, | |
298 | struct lib_ring_buffer *bufb, | |
299 | uint64_t *content_size); | |
300 | int (*packet_size) (const struct lib_ring_buffer_config *config, | |
301 | struct lib_ring_buffer *bufb, | |
302 | uint64_t *packet_size); | |
303 | int (*stream_id) (const struct lib_ring_buffer_config *config, | |
304 | struct lib_ring_buffer *bufb, | |
305 | uint64_t *stream_id); | |
306 | int (*current_timestamp) (const struct lib_ring_buffer_config *config, | |
307 | struct lib_ring_buffer *bufb, | |
308 | uint64_t *ts); | |
309 | int (*sequence_number) (const struct lib_ring_buffer_config *config, | |
310 | struct lib_ring_buffer *bufb, | |
311 | uint64_t *seq); | |
312 | int (*instance_id) (const struct lib_ring_buffer_config *config, | |
313 | struct lib_ring_buffer *bufb, | |
314 | uint64_t *id); | |
315 | }; | |
316 | ||
b0315544 MD |
317 | struct lttng_counter_ops { |
318 | struct lib_counter *(*counter_create)(size_t nr_dimensions, | |
319 | const size_t *max_nr_elem, /* for each dimension */ | |
320 | int64_t global_sum_step); | |
321 | void (*counter_destroy)(struct lib_counter *counter); | |
322 | int (*counter_add)(struct lib_counter *counter, const size_t *dimension_indexes, | |
323 | int64_t v); | |
324 | /* | |
325 | * counter_read reads a specific cpu's counter if @cpu >= 0, or | |
326 | * the global aggregation counter if @cpu == -1. | |
327 | */ | |
328 | int (*counter_read)(struct lib_counter *counter, const size_t *dimension_indexes, int cpu, | |
329 | int64_t *value, bool *overflow, bool *underflow); | |
330 | /* | |
331 | * counter_aggregate returns the total sum of all per-cpu counters and | |
332 | * the global aggregation counter. | |
333 | */ | |
334 | int (*counter_aggregate)(struct lib_counter *counter, const size_t *dimension_indexes, | |
335 | int64_t *value, bool *overflow, bool *underflow); | |
336 | int (*counter_clear)(struct lib_counter *counter, const size_t *dimension_indexes); | |
337 | }; | |
338 | ||
339 | struct lttng_counter { | |
340 | struct file *file; /* File associated to counter. */ | |
341 | struct file *owner; | |
342 | struct lttng_counter_transport *transport; | |
343 | struct lib_counter *counter; | |
344 | struct lttng_counter_ops *ops; | |
345 | }; | |
346 | ||
9190fb56 MD |
347 | #define LTTNG_EVENT_NOTIFIER_HT_BITS 12 |
348 | #define LTTNG_EVENT_NOTIFIER_HT_SIZE (1U << LTTNG_EVENT_NOTIFIER_HT_BITS) | |
349 | ||
350 | struct lttng_event_notifier_ht { | |
351 | struct hlist_head table[LTTNG_EVENT_NOTIFIER_HT_SIZE]; | |
352 | }; | |
353 | ||
b0315544 MD |
354 | struct lttng_event_notifier_group { |
355 | struct file *file; /* File associated to event notifier group */ | |
356 | struct file *notif_file; /* File used to expose notifications to userspace. */ | |
357 | struct list_head node; /* event notifier group list */ | |
358 | struct list_head enablers_head; /* List of enablers */ | |
359 | struct list_head event_notifiers_head; /* List of event notifier */ | |
360 | struct lttng_event_notifier_ht event_notifiers_ht; /* Hash table of event notifiers */ | |
361 | struct lttng_kernel_channel_buffer_ops *ops; | |
362 | struct lttng_transport *transport; | |
363 | struct channel *chan; /* Ring buffer channel for event notifier group. */ | |
364 | struct lib_ring_buffer *buf; /* Ring buffer for event notifier group. */ | |
365 | wait_queue_head_t read_wait; | |
366 | struct irq_work wakeup_pending; /* Pending wakeup irq work. */ | |
367 | struct lttng_kernel_event_notifier *sc_unknown; /* for unknown syscalls */ | |
368 | struct lttng_kernel_event_notifier *sc_compat_unknown; | |
369 | ||
370 | struct lttng_syscall_filter *sc_filter; | |
371 | ||
372 | struct hlist_head *event_notifier_syscall_dispatch; | |
373 | struct hlist_head *event_notifier_compat_syscall_dispatch; | |
374 | struct hlist_head *event_notifier_exit_syscall_dispatch; | |
375 | struct hlist_head *event_notifier_exit_compat_syscall_dispatch; | |
376 | ||
377 | struct hlist_head event_notifier_unknown_syscall_dispatch; | |
378 | struct hlist_head event_notifier_compat_unknown_syscall_dispatch; | |
379 | struct hlist_head event_notifier_exit_unknown_syscall_dispatch; | |
380 | struct hlist_head event_notifier_exit_compat_unknown_syscall_dispatch; | |
381 | ||
382 | int syscall_all_entry; | |
383 | int syscall_all_exit; | |
384 | ||
385 | unsigned int sys_enter_registered:1, sys_exit_registered:1; | |
386 | ||
387 | struct lttng_counter *error_counter; | |
388 | size_t error_counter_len; | |
389 | }; | |
390 | ||
391 | struct lttng_transport { | |
392 | char *name; | |
393 | struct module *owner; | |
394 | struct list_head node; | |
395 | struct lttng_kernel_channel_buffer_ops ops; | |
396 | }; | |
397 | ||
398 | struct lttng_counter_transport { | |
399 | char *name; | |
400 | struct module *owner; | |
401 | struct list_head node; | |
402 | struct lttng_counter_ops ops; | |
403 | }; | |
404 | ||
9190fb56 MD |
405 | #define LTTNG_EVENT_HT_BITS 12 |
406 | #define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS) | |
407 | ||
408 | struct lttng_event_ht { | |
409 | struct hlist_head table[LTTNG_EVENT_HT_SIZE]; | |
410 | }; | |
411 | ||
8cdc1a81 MD |
412 | struct lttng_kernel_session_private { |
413 | struct lttng_kernel_session *pub; /* Public session interface */ | |
414 | ||
415 | int been_active; /* Has trace session been active ? */ | |
416 | struct file *file; /* File associated to session */ | |
417 | struct list_head chan; /* Channel list head */ | |
418 | struct list_head events; /* Event list head */ | |
419 | struct list_head list; /* Session list */ | |
420 | unsigned int free_chan_id; /* Next chan ID to allocate */ | |
421 | uuid_le uuid; /* Trace session unique ID */ | |
422 | struct lttng_metadata_cache *metadata_cache; | |
423 | unsigned int metadata_dumped:1, | |
424 | tstate:1; /* Transient enable state */ | |
425 | /* List of event enablers */ | |
426 | struct list_head enablers_head; | |
427 | /* Hash table of events */ | |
428 | struct lttng_event_ht events_ht; | |
429 | char name[LTTNG_KERNEL_ABI_SESSION_NAME_LEN]; | |
430 | char creation_time[LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN]; | |
431 | }; | |
432 | ||
fc66bf6a MD |
433 | struct lttng_id_hash_node { |
434 | struct hlist_node hlist; | |
435 | int id; | |
436 | }; | |
437 | ||
8c0393c3 MD |
438 | enum tracker_type { |
439 | TRACKER_PID, | |
440 | TRACKER_VPID, | |
441 | TRACKER_UID, | |
442 | TRACKER_VUID, | |
443 | TRACKER_GID, | |
444 | TRACKER_VGID, | |
445 | ||
446 | TRACKER_UNKNOWN, | |
447 | }; | |
448 | ||
449 | struct lttng_kernel_id_tracker_private { | |
450 | struct lttng_kernel_id_tracker *pub; /* Public interface */ | |
451 | ||
452 | struct lttng_kernel_session *session; | |
453 | enum tracker_type tracker_type; | |
454 | }; | |
455 | ||
0fe45627 MD |
456 | extern struct lttng_kernel_ctx *lttng_static_ctx; |
457 | ||
437d5aa5 MD |
458 | static inline |
459 | const struct lttng_kernel_type_integer *lttng_kernel_get_type_integer(const struct lttng_kernel_type_common *type) | |
460 | { | |
461 | if (type->type != lttng_kernel_type_integer) | |
462 | return NULL; | |
463 | return container_of(type, const struct lttng_kernel_type_integer, parent); | |
464 | } | |
465 | ||
466 | static inline | |
467 | const struct lttng_kernel_type_string *lttng_kernel_get_type_string(const struct lttng_kernel_type_common *type) | |
468 | { | |
469 | if (type->type != lttng_kernel_type_string) | |
470 | return NULL; | |
471 | return container_of(type, const struct lttng_kernel_type_string, parent); | |
472 | } | |
473 | ||
474 | static inline | |
475 | const struct lttng_kernel_type_enum *lttng_kernel_get_type_enum(const struct lttng_kernel_type_common *type) | |
476 | { | |
477 | if (type->type != lttng_kernel_type_enum) | |
478 | return NULL; | |
479 | return container_of(type, const struct lttng_kernel_type_enum, parent); | |
480 | } | |
481 | ||
482 | static inline | |
483 | const struct lttng_kernel_type_array *lttng_kernel_get_type_array(const struct lttng_kernel_type_common *type) | |
484 | { | |
485 | if (type->type != lttng_kernel_type_array) | |
486 | return NULL; | |
487 | return container_of(type, const struct lttng_kernel_type_array, parent); | |
488 | } | |
489 | ||
490 | static inline | |
491 | const struct lttng_kernel_type_sequence *lttng_kernel_get_type_sequence(const struct lttng_kernel_type_common *type) | |
492 | { | |
493 | if (type->type != lttng_kernel_type_sequence) | |
494 | return NULL; | |
495 | return container_of(type, const struct lttng_kernel_type_sequence, parent); | |
496 | } | |
497 | ||
498 | static inline | |
499 | const struct lttng_kernel_type_struct *lttng_kernel_get_type_struct(const struct lttng_kernel_type_common *type) | |
500 | { | |
501 | if (type->type != lttng_kernel_type_struct) | |
502 | return NULL; | |
503 | return container_of(type, const struct lttng_kernel_type_struct, parent); | |
504 | } | |
505 | ||
506 | static inline | |
507 | const struct lttng_kernel_type_variant *lttng_kernel_get_type_variant(const struct lttng_kernel_type_common *type) | |
508 | { | |
509 | if (type->type != lttng_kernel_type_variant) | |
510 | return NULL; | |
511 | return container_of(type, const struct lttng_kernel_type_variant, parent); | |
512 | } | |
513 | ||
514 | static inline bool lttng_kernel_type_is_bytewise_integer(const struct lttng_kernel_type_common *type) | |
515 | { | |
516 | const struct lttng_kernel_type_integer *type_integer = lttng_kernel_get_type_integer(type); | |
517 | ||
518 | if (!type_integer) | |
519 | return false; | |
520 | switch (type_integer->size) { | |
521 | case 8: /* Fall-through. */ | |
522 | case 16: /* Fall-through. */ | |
523 | case 32: /* Fall-through. */ | |
524 | case 64: | |
525 | break; | |
526 | default: | |
527 | return false; | |
528 | } | |
529 | return true; | |
530 | } | |
531 | ||
8a445457 MD |
532 | int lttng_kernel_interpret_event_filter(const struct lttng_kernel_event_common *event, |
533 | const char *interpreter_stack_data, | |
a92e844e | 534 | struct lttng_kernel_probe_ctx *probe_ctx, |
8a445457 MD |
535 | void *event_filter_ctx); |
536 | ||
5e08a34f MD |
537 | static inline |
538 | struct lttng_enabler *lttng_event_enabler_as_enabler( | |
539 | struct lttng_event_enabler *event_enabler) | |
540 | { | |
541 | return &event_enabler->base; | |
542 | } | |
543 | ||
544 | static inline | |
545 | struct lttng_enabler *lttng_event_notifier_enabler_as_enabler( | |
546 | struct lttng_event_notifier_enabler *event_notifier_enabler) | |
547 | { | |
548 | return &event_notifier_enabler->base; | |
549 | } | |
550 | ||
0fe45627 MD |
551 | int lttng_context_init(void); |
552 | void lttng_context_exit(void); | |
553 | int lttng_kernel_context_append(struct lttng_kernel_ctx **ctx_p, | |
554 | const struct lttng_kernel_ctx_field *f); | |
555 | void lttng_kernel_context_remove_last(struct lttng_kernel_ctx **ctx_p); | |
556 | struct lttng_kernel_ctx_field *lttng_kernel_get_context_field_from_index(struct lttng_kernel_ctx *ctx, | |
557 | size_t index); | |
558 | int lttng_kernel_find_context(struct lttng_kernel_ctx *ctx, const char *name); | |
559 | int lttng_kernel_get_context_index(struct lttng_kernel_ctx *ctx, const char *name); | |
560 | void lttng_kernel_destroy_context(struct lttng_kernel_ctx *ctx); | |
561 | int lttng_add_pid_to_ctx(struct lttng_kernel_ctx **ctx); | |
562 | int lttng_add_cpu_id_to_ctx(struct lttng_kernel_ctx **ctx); | |
563 | int lttng_add_procname_to_ctx(struct lttng_kernel_ctx **ctx); | |
564 | int lttng_add_prio_to_ctx(struct lttng_kernel_ctx **ctx); | |
565 | int lttng_add_nice_to_ctx(struct lttng_kernel_ctx **ctx); | |
566 | int lttng_add_vpid_to_ctx(struct lttng_kernel_ctx **ctx); | |
567 | int lttng_add_tid_to_ctx(struct lttng_kernel_ctx **ctx); | |
568 | int lttng_add_vtid_to_ctx(struct lttng_kernel_ctx **ctx); | |
569 | int lttng_add_ppid_to_ctx(struct lttng_kernel_ctx **ctx); | |
570 | int lttng_add_vppid_to_ctx(struct lttng_kernel_ctx **ctx); | |
571 | int lttng_add_hostname_to_ctx(struct lttng_kernel_ctx **ctx); | |
572 | int lttng_add_interruptible_to_ctx(struct lttng_kernel_ctx **ctx); | |
573 | int lttng_add_need_reschedule_to_ctx(struct lttng_kernel_ctx **ctx); | |
574 | #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT) | |
575 | int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx); | |
576 | #else | |
577 | static inline | |
578 | int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx) | |
579 | { | |
580 | return -ENOSYS; | |
581 | } | |
582 | #endif | |
583 | #ifdef CONFIG_PREEMPT_RT_FULL | |
584 | int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx); | |
585 | #else | |
586 | static inline | |
587 | int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx) | |
588 | { | |
589 | return -ENOSYS; | |
590 | } | |
591 | #endif | |
592 | ||
593 | int lttng_add_callstack_to_ctx(struct lttng_kernel_ctx **ctx, int type); | |
594 | ||
595 | #if defined(CONFIG_CGROUPS) && \ | |
596 | ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) || \ | |
597 | LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0)) | |
598 | int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
599 | #else | |
600 | static inline | |
601 | int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
602 | { | |
603 | return -ENOSYS; | |
604 | } | |
605 | #endif | |
606 | ||
607 | #if defined(CONFIG_IPC_NS) && \ | |
608 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
609 | int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
610 | #else | |
611 | static inline | |
612 | int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
613 | { | |
614 | return -ENOSYS; | |
615 | } | |
616 | #endif | |
617 | ||
618 | #if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \ | |
619 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
620 | int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
621 | #else | |
622 | static inline | |
623 | int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
624 | { | |
625 | return -ENOSYS; | |
626 | } | |
627 | #endif | |
628 | ||
629 | #if defined(CONFIG_NET_NS) && \ | |
630 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
631 | int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
632 | #else | |
633 | static inline | |
634 | int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
635 | { | |
636 | return -ENOSYS; | |
637 | } | |
638 | #endif | |
639 | ||
640 | #if defined(CONFIG_PID_NS) && \ | |
641 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
642 | int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
643 | #else | |
644 | static inline | |
645 | int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
646 | { | |
647 | return -ENOSYS; | |
648 | } | |
649 | #endif | |
650 | ||
651 | #if defined(CONFIG_USER_NS) && \ | |
652 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
653 | int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
654 | #else | |
655 | static inline | |
656 | int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
657 | { | |
658 | return -ENOSYS; | |
659 | } | |
660 | #endif | |
661 | ||
662 | #if defined(CONFIG_UTS_NS) && \ | |
663 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
664 | int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
665 | #else | |
666 | static inline | |
667 | int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
668 | { | |
669 | return -ENOSYS; | |
670 | } | |
671 | #endif | |
672 | ||
673 | #if defined(CONFIG_TIME_NS) && \ | |
674 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0)) | |
675 | int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
676 | #else | |
677 | static inline | |
678 | int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
679 | { | |
680 | return -ENOSYS; | |
681 | } | |
682 | #endif | |
683 | ||
684 | int lttng_add_uid_to_ctx(struct lttng_kernel_ctx **ctx); | |
685 | int lttng_add_euid_to_ctx(struct lttng_kernel_ctx **ctx); | |
686 | int lttng_add_suid_to_ctx(struct lttng_kernel_ctx **ctx); | |
687 | int lttng_add_gid_to_ctx(struct lttng_kernel_ctx **ctx); | |
688 | int lttng_add_egid_to_ctx(struct lttng_kernel_ctx **ctx); | |
689 | int lttng_add_sgid_to_ctx(struct lttng_kernel_ctx **ctx); | |
690 | int lttng_add_vuid_to_ctx(struct lttng_kernel_ctx **ctx); | |
691 | int lttng_add_veuid_to_ctx(struct lttng_kernel_ctx **ctx); | |
692 | int lttng_add_vsuid_to_ctx(struct lttng_kernel_ctx **ctx); | |
693 | int lttng_add_vgid_to_ctx(struct lttng_kernel_ctx **ctx); | |
694 | int lttng_add_vegid_to_ctx(struct lttng_kernel_ctx **ctx); | |
695 | int lttng_add_vsgid_to_ctx(struct lttng_kernel_ctx **ctx); | |
696 | ||
697 | #if defined(CONFIG_PERF_EVENTS) | |
698 | int lttng_add_perf_counter_to_ctx(uint32_t type, | |
699 | uint64_t config, | |
700 | const char *name, | |
701 | struct lttng_kernel_ctx **ctx); | |
702 | int lttng_cpuhp_perf_counter_online(unsigned int cpu, | |
703 | struct lttng_cpuhp_node *node); | |
704 | int lttng_cpuhp_perf_counter_dead(unsigned int cpu, | |
705 | struct lttng_cpuhp_node *node); | |
706 | #else | |
707 | static inline | |
708 | int lttng_add_perf_counter_to_ctx(uint32_t type, | |
709 | uint64_t config, | |
710 | const char *name, | |
711 | struct lttng_kernel_ctx **ctx) | |
712 | { | |
713 | return -ENOSYS; | |
714 | } | |
715 | static inline | |
716 | int lttng_cpuhp_perf_counter_online(unsigned int cpu, | |
717 | struct lttng_cpuhp_node *node) | |
718 | { | |
719 | return 0; | |
720 | } | |
721 | static inline | |
722 | int lttng_cpuhp_perf_counter_dead(unsigned int cpu, | |
723 | struct lttng_cpuhp_node *node) | |
724 | { | |
725 | return 0; | |
726 | } | |
727 | #endif | |
728 | ||
311e655a MD |
729 | struct lttng_event_enabler *lttng_event_enabler_create( |
730 | enum lttng_enabler_format_type format_type, | |
731 | struct lttng_kernel_abi_event *event_param, | |
732 | struct lttng_channel *chan); | |
733 | ||
734 | int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler); | |
735 | int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler); | |
736 | struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create( | |
737 | struct lttng_event_notifier_group *event_notifier_group, | |
738 | enum lttng_enabler_format_type format_type, | |
739 | struct lttng_kernel_abi_event_notifier *event_notifier_param); | |
740 | ||
741 | int lttng_event_notifier_enabler_enable( | |
742 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
743 | int lttng_event_notifier_enabler_disable( | |
744 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
745 | ||
746 | int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler *event_enabler, | |
747 | struct lttng_kernel_abi_filter_bytecode __user *bytecode); | |
748 | int lttng_event_notifier_enabler_attach_filter_bytecode( | |
749 | struct lttng_event_notifier_enabler *event_notifier_enabler, | |
750 | struct lttng_kernel_abi_filter_bytecode __user *bytecode); | |
751 | int lttng_event_notifier_enabler_attach_capture_bytecode( | |
752 | struct lttng_event_notifier_enabler *event_notifier_enabler, | |
753 | struct lttng_kernel_abi_capture_bytecode __user *bytecode); | |
754 | ||
755 | int lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc, | |
756 | struct lttng_enabler *enabler); | |
757 | ||
758 | void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_desc, | |
759 | struct lttng_kernel_ctx *ctx, | |
760 | struct list_head *instance_bytecode_runtime_head, | |
761 | struct list_head *enabler_bytecode_runtime_head); | |
762 | ||
763 | #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS) | |
764 | int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler); | |
765 | int lttng_syscalls_unregister_channel(struct lttng_channel *chan); | |
766 | int lttng_syscalls_destroy_event(struct lttng_channel *chan); | |
767 | int lttng_syscall_filter_enable_event( | |
768 | struct lttng_channel *chan, | |
769 | struct lttng_kernel_event_recorder *event); | |
770 | int lttng_syscall_filter_disable_event( | |
771 | struct lttng_channel *chan, | |
772 | struct lttng_kernel_event_recorder *event); | |
773 | ||
774 | long lttng_channel_syscall_mask(struct lttng_channel *channel, | |
775 | struct lttng_kernel_abi_syscall_mask __user *usyscall_mask); | |
776 | ||
777 | int lttng_syscalls_register_event_notifier( | |
778 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
779 | int lttng_syscalls_create_matching_event_notifiers( | |
780 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
781 | int lttng_syscalls_unregister_event_notifier_group(struct lttng_event_notifier_group *group); | |
782 | int lttng_syscall_filter_enable_event_notifier(struct lttng_kernel_event_notifier *event_notifier); | |
783 | int lttng_syscall_filter_disable_event_notifier(struct lttng_kernel_event_notifier *event_notifier); | |
784 | #else | |
785 | static inline int lttng_syscalls_register_event( | |
786 | struct lttng_event_enabler *event_enabler) | |
787 | { | |
788 | return -ENOSYS; | |
789 | } | |
790 | ||
791 | static inline int lttng_syscalls_unregister_channel(struct lttng_channel *chan) | |
792 | { | |
793 | return 0; | |
794 | } | |
795 | ||
796 | static inline int lttng_syscalls_destroy(struct lttng_channel *chan) | |
797 | { | |
798 | return 0; | |
799 | } | |
800 | ||
801 | static inline int lttng_syscall_filter_enable_event(struct lttng_channel *chan, | |
802 | struct lttng_kernel_event_recorder *event); | |
803 | { | |
804 | return -ENOSYS; | |
805 | } | |
806 | ||
807 | static inline int lttng_syscall_filter_disable_event(struct lttng_channel *chan, | |
808 | struct lttng_kernel_event_recorder *event); | |
809 | { | |
810 | return -ENOSYS; | |
811 | } | |
812 | ||
813 | static inline long lttng_channel_syscall_mask(struct lttng_channel *channel, | |
814 | struct lttng_kernel_syscall_mask __user *usyscall_mask) | |
815 | { | |
816 | return -ENOSYS; | |
817 | } | |
818 | ||
819 | static inline int lttng_syscalls_register_event_notifier( | |
820 | struct lttng_event_notifier_group *group) | |
821 | { | |
822 | return -ENOSYS; | |
823 | } | |
824 | ||
825 | static inline int lttng_syscalls_unregister_event_notifier_group( | |
826 | struct lttng_event_notifier_group *group) | |
827 | { | |
828 | return 0; | |
829 | } | |
830 | ||
831 | static inline int lttng_syscall_filter_enable_event_notifier( | |
832 | struct lttng_event_notifier_group *group, | |
833 | const char *name) | |
834 | { | |
835 | return -ENOSYS; | |
836 | } | |
837 | ||
838 | static inline int lttng_syscall_filter_disable_event_notifier( | |
839 | struct lttng_event_notifier_group *group, | |
840 | const char *name) | |
841 | { | |
842 | return -ENOSYS; | |
843 | } | |
0fe45627 | 844 | |
311e655a | 845 | #endif |
0fe45627 | 846 | |
e4a26d6b MD |
847 | #ifdef CONFIG_KPROBES |
848 | int lttng_kprobes_register_event(const char *name, | |
849 | const char *symbol_name, | |
850 | uint64_t offset, | |
851 | uint64_t addr, | |
852 | struct lttng_kernel_event_recorder *event); | |
853 | void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder *event); | |
854 | void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder *event); | |
855 | int lttng_kprobes_register_event_notifier(const char *symbol_name, | |
856 | uint64_t offset, | |
857 | uint64_t addr, | |
858 | struct lttng_kernel_event_notifier *event_notifier); | |
859 | void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier); | |
860 | void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier); | |
861 | #else | |
862 | static inline | |
863 | int lttng_kprobes_register_event(const char *name, | |
864 | const char *symbol_name, | |
865 | uint64_t offset, | |
866 | uint64_t addr, | |
867 | struct lttng_kernel_event_recorder *event) | |
868 | { | |
869 | return -ENOSYS; | |
870 | } | |
871 | ||
872 | static inline | |
873 | void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder *event) | |
874 | { | |
875 | } | |
876 | ||
877 | static inline | |
878 | void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder *event) | |
879 | { | |
880 | } | |
881 | ||
882 | static inline | |
883 | int lttng_kprobes_register_event_notifier(const char *symbol_name, | |
884 | uint64_t offset, | |
885 | uint64_t addr, | |
886 | struct lttng_kernel_event_notifier *event_notifier) | |
887 | { | |
888 | return -ENOSYS; | |
889 | } | |
890 | ||
891 | static inline | |
892 | void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier) | |
893 | { | |
894 | } | |
895 | ||
896 | static inline | |
897 | void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier) | |
898 | { | |
899 | } | |
900 | #endif | |
901 | ||
902 | int lttng_event_add_callsite(struct lttng_kernel_event_common *event, | |
903 | struct lttng_kernel_abi_event_callsite __user *callsite); | |
904 | ||
905 | #ifdef CONFIG_UPROBES | |
906 | int lttng_uprobes_register_event(const char *name, | |
907 | int fd, struct lttng_kernel_event_recorder *event); | |
908 | int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event, | |
909 | struct lttng_kernel_abi_event_callsite __user *callsite); | |
910 | void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder *event); | |
911 | void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder *event); | |
912 | int lttng_uprobes_register_event_notifier(const char *name, | |
913 | int fd, struct lttng_kernel_event_notifier *event_notifier); | |
914 | void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier); | |
915 | void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier); | |
916 | #else | |
917 | static inline | |
918 | int lttng_uprobes_register_event(const char *name, | |
919 | int fd, struct lttng_kernel_event_recorder *event) | |
920 | { | |
921 | return -ENOSYS; | |
922 | } | |
923 | ||
924 | static inline | |
925 | int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event, | |
926 | struct lttng_kernel_abi_event_callsite __user *callsite) | |
927 | { | |
928 | return -ENOSYS; | |
929 | } | |
930 | ||
931 | static inline | |
932 | void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder *event) | |
933 | { | |
934 | } | |
935 | ||
936 | static inline | |
937 | void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder *event) | |
938 | { | |
939 | } | |
940 | ||
941 | static inline | |
942 | int lttng_uprobes_register_event_notifier(const char *name, | |
943 | int fd, struct lttng_kernel_event_notifier *event_notifier) | |
944 | { | |
945 | return -ENOSYS; | |
946 | } | |
947 | ||
948 | static inline | |
949 | void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier) | |
950 | { | |
951 | } | |
952 | ||
953 | static inline | |
954 | void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier) | |
955 | { | |
956 | } | |
957 | #endif | |
958 | ||
959 | #ifdef CONFIG_KRETPROBES | |
960 | int lttng_kretprobes_register(const char *name, | |
961 | const char *symbol_name, | |
962 | uint64_t offset, | |
963 | uint64_t addr, | |
964 | struct lttng_kernel_event_recorder *event_entry, | |
965 | struct lttng_kernel_event_recorder *event_exit); | |
966 | void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder *event); | |
967 | void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder *event); | |
968 | int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event, | |
969 | int enable); | |
970 | #else | |
971 | static inline | |
972 | int lttng_kretprobes_register(const char *name, | |
973 | const char *symbol_name, | |
974 | uint64_t offset, | |
975 | uint64_t addr, | |
976 | struct lttng_kernel_event_recorder *event_entry, | |
977 | struct lttng_kernel_event_recorder *event_exit) | |
978 | { | |
979 | return -ENOSYS; | |
980 | } | |
981 | ||
982 | static inline | |
983 | void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder *event) | |
984 | { | |
985 | } | |
986 | ||
987 | static inline | |
988 | void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder *event) | |
989 | { | |
990 | } | |
991 | ||
992 | static inline | |
993 | int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event, | |
994 | int enable) | |
995 | { | |
996 | return -ENOSYS; | |
997 | } | |
998 | #endif | |
999 | ||
e8c0bbd3 MD |
1000 | void lttng_lock_sessions(void); |
1001 | void lttng_unlock_sessions(void); | |
1002 | ||
1003 | struct list_head *lttng_get_probe_list_head(void); | |
1004 | ||
1005 | int lttng_fix_pending_events(void); | |
1006 | int lttng_fix_pending_event_notifiers(void); | |
1007 | int lttng_session_active(void); | |
1008 | bool lttng_event_notifier_active(void); | |
1009 | ||
8cdc1a81 MD |
1010 | struct lttng_kernel_session *lttng_session_create(void); |
1011 | int lttng_session_enable(struct lttng_kernel_session *session); | |
1012 | int lttng_session_disable(struct lttng_kernel_session *session); | |
1013 | void lttng_session_destroy(struct lttng_kernel_session *session); | |
1014 | int lttng_session_metadata_regenerate(struct lttng_kernel_session *session); | |
1015 | int lttng_session_statedump(struct lttng_kernel_session *session); | |
e8c0bbd3 MD |
1016 | void metadata_cache_destroy(struct kref *kref); |
1017 | ||
1018 | struct lttng_counter *lttng_kernel_counter_create( | |
1019 | const char *counter_transport_name, size_t number_dimensions, | |
1020 | const size_t *dimensions_sizes); | |
1021 | int lttng_kernel_counter_read(struct lttng_counter *counter, | |
1022 | const size_t *dimension_indexes, int32_t cpu, | |
1023 | int64_t *val, bool *overflow, bool *underflow); | |
1024 | int lttng_kernel_counter_aggregate(struct lttng_counter *counter, | |
1025 | const size_t *dimension_indexes, int64_t *val, | |
1026 | bool *overflow, bool *underflow); | |
1027 | int lttng_kernel_counter_clear(struct lttng_counter *counter, | |
1028 | const size_t *dimension_indexes); | |
1029 | struct lttng_event_notifier_group *lttng_event_notifier_group_create(void); | |
1030 | int lttng_event_notifier_group_create_error_counter( | |
1031 | struct file *event_notifier_group_file, | |
1032 | const struct lttng_kernel_abi_counter_conf *error_counter_conf); | |
1033 | void lttng_event_notifier_group_destroy( | |
1034 | struct lttng_event_notifier_group *event_notifier_group); | |
1035 | ||
8cdc1a81 | 1036 | struct lttng_channel *lttng_channel_create(struct lttng_kernel_session *session, |
e8c0bbd3 MD |
1037 | const char *transport_name, |
1038 | void *buf_addr, | |
1039 | size_t subbuf_size, size_t num_subbuf, | |
1040 | unsigned int switch_timer_interval, | |
1041 | unsigned int read_timer_interval, | |
1042 | enum channel_type channel_type); | |
8cdc1a81 | 1043 | struct lttng_channel *lttng_global_channel_create(struct lttng_kernel_session *session, |
e8c0bbd3 MD |
1044 | int overwrite, void *buf_addr, |
1045 | size_t subbuf_size, size_t num_subbuf, | |
1046 | unsigned int switch_timer_interval, | |
1047 | unsigned int read_timer_interval); | |
1048 | ||
1049 | void lttng_metadata_channel_destroy(struct lttng_channel *chan); | |
1050 | struct lttng_kernel_event_recorder *lttng_kernel_event_recorder_create(struct lttng_channel *chan, | |
1051 | struct lttng_kernel_abi_event *event_param, | |
1052 | const struct lttng_kernel_event_desc *event_desc, | |
1053 | enum lttng_kernel_abi_instrumentation itype); | |
1054 | struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct lttng_channel *chan, | |
1055 | struct lttng_kernel_abi_event *event_param, | |
1056 | const struct lttng_kernel_event_desc *event_desc, | |
1057 | enum lttng_kernel_abi_instrumentation itype); | |
1058 | struct lttng_kernel_event_recorder *lttng_event_compat_old_create(struct lttng_channel *chan, | |
1059 | struct lttng_kernel_abi_old_event *old_event_param, | |
1060 | const struct lttng_kernel_event_desc *internal_desc); | |
1061 | ||
1062 | struct lttng_kernel_event_notifier *lttng_event_notifier_create( | |
1063 | const struct lttng_kernel_event_desc *event_notifier_desc, | |
1064 | uint64_t id, | |
1065 | uint64_t error_counter_idx, | |
1066 | struct lttng_event_notifier_group *event_notifier_group, | |
1067 | struct lttng_kernel_abi_event_notifier *event_notifier_param, | |
1068 | enum lttng_kernel_abi_instrumentation itype); | |
1069 | struct lttng_kernel_event_notifier *_lttng_event_notifier_create( | |
1070 | const struct lttng_kernel_event_desc *event_notifier_desc, | |
1071 | uint64_t id, | |
1072 | uint64_t error_counter_idx, | |
1073 | struct lttng_event_notifier_group *event_notifier_group, | |
1074 | struct lttng_kernel_abi_event_notifier *event_notifier_param, | |
1075 | enum lttng_kernel_abi_instrumentation itype); | |
1076 | ||
1077 | int lttng_channel_enable(struct lttng_channel *channel); | |
1078 | int lttng_channel_disable(struct lttng_channel *channel); | |
1079 | int lttng_event_enable(struct lttng_kernel_event_common *event); | |
1080 | int lttng_event_disable(struct lttng_kernel_event_common *event); | |
1081 | ||
1082 | void lttng_transport_register(struct lttng_transport *transport); | |
1083 | void lttng_transport_unregister(struct lttng_transport *transport); | |
1084 | ||
1085 | void lttng_counter_transport_register(struct lttng_counter_transport *transport); | |
1086 | void lttng_counter_transport_unregister(struct lttng_counter_transport *transport); | |
1087 | ||
1088 | void synchronize_trace(void); | |
1089 | int lttng_abi_init(void); | |
1090 | int lttng_abi_compat_old_init(void); | |
1091 | void lttng_abi_exit(void); | |
1092 | void lttng_abi_compat_old_exit(void); | |
1093 | ||
1094 | const struct lttng_kernel_event_desc *lttng_event_desc_get(const char *name); | |
1095 | void lttng_event_desc_put(const struct lttng_kernel_event_desc *desc); | |
1096 | int lttng_probes_init(void); | |
1097 | void lttng_probes_exit(void); | |
1098 | ||
1099 | int lttng_metadata_output_channel(struct lttng_metadata_stream *stream, | |
1100 | struct channel *chan, bool *coherent); | |
1101 | ||
1102 | int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node); | |
8c0393c3 MD |
1103 | int lttng_id_tracker_empty_set(struct lttng_kernel_id_tracker *lf); |
1104 | int lttng_id_tracker_init(struct lttng_kernel_id_tracker *lf, | |
1105 | struct lttng_kernel_session *session, | |
1106 | enum tracker_type type); | |
1107 | void lttng_id_tracker_fini(struct lttng_kernel_id_tracker *lf); | |
1108 | void lttng_id_tracker_destroy(struct lttng_kernel_id_tracker *lf, bool rcu); | |
1109 | int lttng_id_tracker_add(struct lttng_kernel_id_tracker *lf, int id); | |
1110 | int lttng_id_tracker_del(struct lttng_kernel_id_tracker *lf, int id); | |
e8c0bbd3 | 1111 | |
8cdc1a81 | 1112 | int lttng_session_track_id(struct lttng_kernel_session *session, |
e8c0bbd3 | 1113 | enum tracker_type tracker_type, int id); |
8cdc1a81 | 1114 | int lttng_session_untrack_id(struct lttng_kernel_session *session, |
e8c0bbd3 MD |
1115 | enum tracker_type tracker_type, int id); |
1116 | ||
8cdc1a81 | 1117 | int lttng_session_list_tracker_ids(struct lttng_kernel_session *session, |
e8c0bbd3 MD |
1118 | enum tracker_type tracker_type); |
1119 | ||
1120 | void lttng_clock_ref(void); | |
1121 | void lttng_clock_unref(void); | |
1122 | ||
1123 | void lttng_free_event_filter_runtime(struct lttng_kernel_event_common *event); | |
1124 | ||
1125 | int lttng_probes_init(void); | |
1126 | ||
1127 | int lttng_logger_init(void); | |
1128 | void lttng_logger_exit(void); | |
1129 | ||
8cdc1a81 | 1130 | extern int lttng_statedump_start(struct lttng_kernel_session *session); |
e8c0bbd3 MD |
1131 | |
1132 | int lttng_calibrate(struct lttng_kernel_abi_calibrate *calibrate); | |
1133 | ||
1134 | extern const struct file_operations lttng_tracepoint_list_fops; | |
1135 | extern const struct file_operations lttng_syscall_list_fops; | |
1136 | ||
0fe45627 MD |
1137 | #define lttng_kernel_static_ctx_field(_event_field, _get_size, _record, _get_value, _destroy, _priv) \ |
1138 | __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_ctx_field, { \ | |
1139 | .event_field = (_event_field), \ | |
1140 | .get_size = (_get_size), \ | |
1141 | .record = (_record), \ | |
1142 | .get_value = (_get_value), \ | |
1143 | .destroy = (_destroy), \ | |
1144 | .priv = (_priv), \ | |
1145 | }) | |
1146 | ||
92bc1e23 | 1147 | #endif /* _LTTNG_EVENTS_INTERNAL_H */ |