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 | ||
311e655a MD |
13 | enum lttng_enabler_format_type { |
14 | LTTNG_ENABLER_FORMAT_STAR_GLOB, | |
15 | LTTNG_ENABLER_FORMAT_NAME, | |
16 | }; | |
17 | ||
18 | /* | |
19 | * Objects in a linked-list of enablers, owned by an event. | |
20 | */ | |
21 | struct lttng_enabler_ref { | |
22 | struct list_head node; /* enabler ref list */ | |
23 | struct lttng_enabler *ref; /* backward ref */ | |
24 | }; | |
25 | ||
a67ba386 MD |
26 | struct lttng_kernel_event_common_private { |
27 | struct lttng_kernel_event_common *pub; /* Public event interface */ | |
28 | ||
29 | const struct lttng_kernel_event_desc *desc; | |
30 | /* Backward references: list of lttng_enabler_ref (ref to enablers) */ | |
31 | struct list_head enablers_ref_head; | |
32 | int registered; /* has reg'd tracepoint probe */ | |
33 | uint64_t user_token; | |
34 | ||
35 | int has_enablers_without_filter_bytecode; | |
218585b9 | 36 | /* list of struct lttng_kernel_bytecode_runtime, sorted by seqnum */ |
a67ba386 MD |
37 | struct list_head filter_bytecode_runtime_head; |
38 | enum lttng_kernel_abi_instrumentation instrumentation; | |
39 | /* Selected by instrumentation */ | |
40 | union { | |
41 | struct lttng_kprobe kprobe; | |
42 | struct lttng_uprobe uprobe; | |
43 | struct { | |
44 | struct lttng_krp *lttng_krp; | |
45 | char *symbol_name; | |
46 | } kretprobe; | |
47 | struct { | |
48 | enum lttng_syscall_entryexit entryexit; | |
49 | enum lttng_syscall_abi abi; | |
50 | struct hlist_node node; /* chain registered syscall event_notifier */ | |
51 | unsigned int syscall_id; | |
52 | } syscall; | |
53 | } u; | |
54 | }; | |
55 | ||
56 | struct lttng_kernel_event_recorder_private { | |
57 | struct lttng_kernel_event_common_private parent; | |
58 | ||
59 | struct lttng_kernel_event_recorder *pub; /* Public event interface */ | |
60 | struct list_head node; /* Event recorder list */ | |
61 | struct hlist_node hlist; /* Hash table of event recorders */ | |
62 | struct lttng_kernel_ctx *ctx; | |
63 | unsigned int id; | |
64 | unsigned int metadata_dumped:1; | |
65 | }; | |
66 | ||
67 | struct lttng_kernel_event_notifier_private { | |
68 | struct lttng_kernel_event_common_private parent; | |
69 | ||
70 | struct lttng_kernel_event_notifier *pub; /* Public event notifier interface */ | |
71 | struct lttng_event_notifier_group *group; /* weak ref */ | |
72 | size_t num_captures; /* Needed to allocate the msgpack array. */ | |
73 | uint64_t error_counter_index; | |
74 | struct list_head node; /* Event notifier list */ | |
75 | struct hlist_node hlist; /* Hash table of event notifiers */ | |
76 | struct list_head capture_bytecode_runtime_head; | |
77 | ||
78 | }; | |
79 | ||
8a445457 MD |
80 | enum lttng_kernel_bytecode_interpreter_ret { |
81 | LTTNG_KERNEL_BYTECODE_INTERPRETER_ERROR = -1, | |
82 | LTTNG_KERNEL_BYTECODE_INTERPRETER_OK = 0, | |
83 | }; | |
84 | ||
85 | enum lttng_kernel_bytecode_filter_result { | |
86 | LTTNG_KERNEL_BYTECODE_FILTER_ACCEPT = 0, | |
87 | LTTNG_KERNEL_BYTECODE_FILTER_REJECT = 1, | |
88 | }; | |
89 | ||
90 | struct lttng_kernel_bytecode_filter_ctx { | |
91 | enum lttng_kernel_bytecode_filter_result result; | |
92 | }; | |
93 | ||
1efb0502 MD |
94 | struct lttng_interpreter_output; |
95 | ||
96 | enum lttng_kernel_bytecode_type { | |
97 | LTTNG_KERNEL_BYTECODE_TYPE_FILTER, | |
98 | LTTNG_KERNEL_BYTECODE_TYPE_CAPTURE, | |
99 | }; | |
100 | ||
101 | struct lttng_kernel_bytecode_node { | |
102 | enum lttng_kernel_bytecode_type type; | |
103 | struct list_head node; | |
104 | struct lttng_enabler *enabler; | |
105 | struct { | |
106 | uint32_t len; | |
107 | uint32_t reloc_offset; | |
108 | uint64_t seqnum; | |
109 | char data[]; | |
110 | } bc; | |
111 | }; | |
112 | ||
113 | struct lttng_kernel_bytecode_runtime { | |
114 | /* Associated bytecode */ | |
115 | enum lttng_kernel_bytecode_type type; | |
116 | struct lttng_kernel_bytecode_node *bc; | |
117 | int (*interpreter_func)(struct lttng_kernel_bytecode_runtime *kernel_bytecode, | |
118 | const char *interpreter_stack_data, | |
119 | struct lttng_kernel_probe_ctx *lttng_probe_ctx, | |
120 | void *caller_ctx); | |
121 | int link_failed; | |
122 | struct list_head node; /* list of bytecode runtime in event */ | |
123 | struct lttng_kernel_ctx *ctx; | |
124 | }; | |
125 | ||
5e08a34f MD |
126 | /* |
127 | * Enabler field, within whatever object is enabling an event. Target of | |
128 | * backward reference. | |
129 | */ | |
130 | struct lttng_enabler { | |
131 | enum lttng_enabler_format_type format_type; | |
132 | ||
d64ca521 | 133 | /* head list of struct lttng_kernel_bytecode_node */ |
5e08a34f MD |
134 | struct list_head filter_bytecode_head; |
135 | ||
136 | struct lttng_kernel_abi_event event_param; | |
137 | unsigned int enabled:1; | |
138 | ||
139 | uint64_t user_token; /* User-provided token. */ | |
140 | }; | |
141 | ||
142 | struct lttng_event_enabler { | |
143 | struct lttng_enabler base; | |
144 | struct list_head node; /* per-session list of enablers */ | |
145 | struct lttng_channel *chan; | |
146 | }; | |
147 | ||
148 | struct lttng_event_notifier_enabler { | |
149 | struct lttng_enabler base; | |
150 | uint64_t error_counter_index; | |
151 | struct list_head node; /* List of event_notifier enablers */ | |
152 | struct lttng_event_notifier_group *group; | |
153 | ||
d64ca521 | 154 | /* head list of struct lttng_kernel_bytecode_node */ |
5e08a34f MD |
155 | struct list_head capture_bytecode_head; |
156 | uint64_t num_captures; | |
157 | }; | |
158 | ||
0fe45627 MD |
159 | struct lttng_ctx_value { |
160 | union { | |
161 | int64_t s64; | |
162 | const char *str; | |
163 | double d; | |
164 | } u; | |
165 | }; | |
166 | ||
167 | /* | |
168 | * We need to keep this perf counter field separately from struct | |
169 | * lttng_kernel_ctx_field because cpu hotplug needs fixed-location addresses. | |
170 | */ | |
171 | struct lttng_perf_counter_field { | |
172 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,10,0)) | |
173 | struct lttng_cpuhp_node cpuhp_prepare; | |
174 | struct lttng_cpuhp_node cpuhp_online; | |
175 | #else | |
176 | struct notifier_block nb; | |
177 | int hp_enable; | |
178 | #endif | |
179 | struct perf_event_attr *attr; | |
180 | struct perf_event **e; /* per-cpu array */ | |
181 | char *name; | |
182 | struct lttng_kernel_event_field *event_field; | |
183 | }; | |
184 | ||
185 | struct lttng_kernel_ctx_field { | |
186 | const struct lttng_kernel_event_field *event_field; | |
a92e844e | 187 | size_t (*get_size)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, |
0fe45627 | 188 | size_t offset); |
a92e844e | 189 | void (*record)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, |
0fe45627 MD |
190 | struct lib_ring_buffer_ctx *ctx, |
191 | struct lttng_channel *chan); | |
a92e844e | 192 | void (*get_value)(void *priv, struct lttng_kernel_probe_ctx *probe_ctx, |
0fe45627 MD |
193 | struct lttng_ctx_value *value); |
194 | void (*destroy)(void *priv); | |
195 | void *priv; | |
196 | }; | |
197 | ||
198 | struct lttng_kernel_ctx { | |
199 | struct lttng_kernel_ctx_field *fields; | |
200 | unsigned int nr_fields; | |
201 | unsigned int allocated_fields; | |
202 | size_t largest_align; /* in bytes */ | |
203 | }; | |
204 | ||
205 | extern struct lttng_kernel_ctx *lttng_static_ctx; | |
206 | ||
437d5aa5 MD |
207 | static inline |
208 | const struct lttng_kernel_type_integer *lttng_kernel_get_type_integer(const struct lttng_kernel_type_common *type) | |
209 | { | |
210 | if (type->type != lttng_kernel_type_integer) | |
211 | return NULL; | |
212 | return container_of(type, const struct lttng_kernel_type_integer, parent); | |
213 | } | |
214 | ||
215 | static inline | |
216 | const struct lttng_kernel_type_string *lttng_kernel_get_type_string(const struct lttng_kernel_type_common *type) | |
217 | { | |
218 | if (type->type != lttng_kernel_type_string) | |
219 | return NULL; | |
220 | return container_of(type, const struct lttng_kernel_type_string, parent); | |
221 | } | |
222 | ||
223 | static inline | |
224 | const struct lttng_kernel_type_enum *lttng_kernel_get_type_enum(const struct lttng_kernel_type_common *type) | |
225 | { | |
226 | if (type->type != lttng_kernel_type_enum) | |
227 | return NULL; | |
228 | return container_of(type, const struct lttng_kernel_type_enum, parent); | |
229 | } | |
230 | ||
231 | static inline | |
232 | const struct lttng_kernel_type_array *lttng_kernel_get_type_array(const struct lttng_kernel_type_common *type) | |
233 | { | |
234 | if (type->type != lttng_kernel_type_array) | |
235 | return NULL; | |
236 | return container_of(type, const struct lttng_kernel_type_array, parent); | |
237 | } | |
238 | ||
239 | static inline | |
240 | const struct lttng_kernel_type_sequence *lttng_kernel_get_type_sequence(const struct lttng_kernel_type_common *type) | |
241 | { | |
242 | if (type->type != lttng_kernel_type_sequence) | |
243 | return NULL; | |
244 | return container_of(type, const struct lttng_kernel_type_sequence, parent); | |
245 | } | |
246 | ||
247 | static inline | |
248 | const struct lttng_kernel_type_struct *lttng_kernel_get_type_struct(const struct lttng_kernel_type_common *type) | |
249 | { | |
250 | if (type->type != lttng_kernel_type_struct) | |
251 | return NULL; | |
252 | return container_of(type, const struct lttng_kernel_type_struct, parent); | |
253 | } | |
254 | ||
255 | static inline | |
256 | const struct lttng_kernel_type_variant *lttng_kernel_get_type_variant(const struct lttng_kernel_type_common *type) | |
257 | { | |
258 | if (type->type != lttng_kernel_type_variant) | |
259 | return NULL; | |
260 | return container_of(type, const struct lttng_kernel_type_variant, parent); | |
261 | } | |
262 | ||
263 | static inline bool lttng_kernel_type_is_bytewise_integer(const struct lttng_kernel_type_common *type) | |
264 | { | |
265 | const struct lttng_kernel_type_integer *type_integer = lttng_kernel_get_type_integer(type); | |
266 | ||
267 | if (!type_integer) | |
268 | return false; | |
269 | switch (type_integer->size) { | |
270 | case 8: /* Fall-through. */ | |
271 | case 16: /* Fall-through. */ | |
272 | case 32: /* Fall-through. */ | |
273 | case 64: | |
274 | break; | |
275 | default: | |
276 | return false; | |
277 | } | |
278 | return true; | |
279 | } | |
280 | ||
8a445457 MD |
281 | int lttng_kernel_interpret_event_filter(const struct lttng_kernel_event_common *event, |
282 | const char *interpreter_stack_data, | |
a92e844e | 283 | struct lttng_kernel_probe_ctx *probe_ctx, |
8a445457 MD |
284 | void *event_filter_ctx); |
285 | ||
5e08a34f MD |
286 | static inline |
287 | struct lttng_enabler *lttng_event_enabler_as_enabler( | |
288 | struct lttng_event_enabler *event_enabler) | |
289 | { | |
290 | return &event_enabler->base; | |
291 | } | |
292 | ||
293 | static inline | |
294 | struct lttng_enabler *lttng_event_notifier_enabler_as_enabler( | |
295 | struct lttng_event_notifier_enabler *event_notifier_enabler) | |
296 | { | |
297 | return &event_notifier_enabler->base; | |
298 | } | |
299 | ||
0fe45627 MD |
300 | int lttng_context_init(void); |
301 | void lttng_context_exit(void); | |
302 | int lttng_kernel_context_append(struct lttng_kernel_ctx **ctx_p, | |
303 | const struct lttng_kernel_ctx_field *f); | |
304 | void lttng_kernel_context_remove_last(struct lttng_kernel_ctx **ctx_p); | |
305 | struct lttng_kernel_ctx_field *lttng_kernel_get_context_field_from_index(struct lttng_kernel_ctx *ctx, | |
306 | size_t index); | |
307 | int lttng_kernel_find_context(struct lttng_kernel_ctx *ctx, const char *name); | |
308 | int lttng_kernel_get_context_index(struct lttng_kernel_ctx *ctx, const char *name); | |
309 | void lttng_kernel_destroy_context(struct lttng_kernel_ctx *ctx); | |
310 | int lttng_add_pid_to_ctx(struct lttng_kernel_ctx **ctx); | |
311 | int lttng_add_cpu_id_to_ctx(struct lttng_kernel_ctx **ctx); | |
312 | int lttng_add_procname_to_ctx(struct lttng_kernel_ctx **ctx); | |
313 | int lttng_add_prio_to_ctx(struct lttng_kernel_ctx **ctx); | |
314 | int lttng_add_nice_to_ctx(struct lttng_kernel_ctx **ctx); | |
315 | int lttng_add_vpid_to_ctx(struct lttng_kernel_ctx **ctx); | |
316 | int lttng_add_tid_to_ctx(struct lttng_kernel_ctx **ctx); | |
317 | int lttng_add_vtid_to_ctx(struct lttng_kernel_ctx **ctx); | |
318 | int lttng_add_ppid_to_ctx(struct lttng_kernel_ctx **ctx); | |
319 | int lttng_add_vppid_to_ctx(struct lttng_kernel_ctx **ctx); | |
320 | int lttng_add_hostname_to_ctx(struct lttng_kernel_ctx **ctx); | |
321 | int lttng_add_interruptible_to_ctx(struct lttng_kernel_ctx **ctx); | |
322 | int lttng_add_need_reschedule_to_ctx(struct lttng_kernel_ctx **ctx); | |
323 | #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT) | |
324 | int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx); | |
325 | #else | |
326 | static inline | |
327 | int lttng_add_preemptible_to_ctx(struct lttng_kernel_ctx **ctx) | |
328 | { | |
329 | return -ENOSYS; | |
330 | } | |
331 | #endif | |
332 | #ifdef CONFIG_PREEMPT_RT_FULL | |
333 | int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx); | |
334 | #else | |
335 | static inline | |
336 | int lttng_add_migratable_to_ctx(struct lttng_kernel_ctx **ctx) | |
337 | { | |
338 | return -ENOSYS; | |
339 | } | |
340 | #endif | |
341 | ||
342 | int lttng_add_callstack_to_ctx(struct lttng_kernel_ctx **ctx, int type); | |
343 | ||
344 | #if defined(CONFIG_CGROUPS) && \ | |
345 | ((LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) || \ | |
346 | LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0)) | |
347 | int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
348 | #else | |
349 | static inline | |
350 | int lttng_add_cgroup_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
351 | { | |
352 | return -ENOSYS; | |
353 | } | |
354 | #endif | |
355 | ||
356 | #if defined(CONFIG_IPC_NS) && \ | |
357 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
358 | int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
359 | #else | |
360 | static inline | |
361 | int lttng_add_ipc_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
362 | { | |
363 | return -ENOSYS; | |
364 | } | |
365 | #endif | |
366 | ||
367 | #if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \ | |
368 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
369 | int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
370 | #else | |
371 | static inline | |
372 | int lttng_add_mnt_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
373 | { | |
374 | return -ENOSYS; | |
375 | } | |
376 | #endif | |
377 | ||
378 | #if defined(CONFIG_NET_NS) && \ | |
379 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
380 | int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
381 | #else | |
382 | static inline | |
383 | int lttng_add_net_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
384 | { | |
385 | return -ENOSYS; | |
386 | } | |
387 | #endif | |
388 | ||
389 | #if defined(CONFIG_PID_NS) && \ | |
390 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
391 | int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
392 | #else | |
393 | static inline | |
394 | int lttng_add_pid_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
395 | { | |
396 | return -ENOSYS; | |
397 | } | |
398 | #endif | |
399 | ||
400 | #if defined(CONFIG_USER_NS) && \ | |
401 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
402 | int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
403 | #else | |
404 | static inline | |
405 | int lttng_add_user_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
406 | { | |
407 | return -ENOSYS; | |
408 | } | |
409 | #endif | |
410 | ||
411 | #if defined(CONFIG_UTS_NS) && \ | |
412 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) | |
413 | int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
414 | #else | |
415 | static inline | |
416 | int lttng_add_uts_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
417 | { | |
418 | return -ENOSYS; | |
419 | } | |
420 | #endif | |
421 | ||
422 | #if defined(CONFIG_TIME_NS) && \ | |
423 | (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0)) | |
424 | int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx); | |
425 | #else | |
426 | static inline | |
427 | int lttng_add_time_ns_to_ctx(struct lttng_kernel_ctx **ctx) | |
428 | { | |
429 | return -ENOSYS; | |
430 | } | |
431 | #endif | |
432 | ||
433 | int lttng_add_uid_to_ctx(struct lttng_kernel_ctx **ctx); | |
434 | int lttng_add_euid_to_ctx(struct lttng_kernel_ctx **ctx); | |
435 | int lttng_add_suid_to_ctx(struct lttng_kernel_ctx **ctx); | |
436 | int lttng_add_gid_to_ctx(struct lttng_kernel_ctx **ctx); | |
437 | int lttng_add_egid_to_ctx(struct lttng_kernel_ctx **ctx); | |
438 | int lttng_add_sgid_to_ctx(struct lttng_kernel_ctx **ctx); | |
439 | int lttng_add_vuid_to_ctx(struct lttng_kernel_ctx **ctx); | |
440 | int lttng_add_veuid_to_ctx(struct lttng_kernel_ctx **ctx); | |
441 | int lttng_add_vsuid_to_ctx(struct lttng_kernel_ctx **ctx); | |
442 | int lttng_add_vgid_to_ctx(struct lttng_kernel_ctx **ctx); | |
443 | int lttng_add_vegid_to_ctx(struct lttng_kernel_ctx **ctx); | |
444 | int lttng_add_vsgid_to_ctx(struct lttng_kernel_ctx **ctx); | |
445 | ||
446 | #if defined(CONFIG_PERF_EVENTS) | |
447 | int lttng_add_perf_counter_to_ctx(uint32_t type, | |
448 | uint64_t config, | |
449 | const char *name, | |
450 | struct lttng_kernel_ctx **ctx); | |
451 | int lttng_cpuhp_perf_counter_online(unsigned int cpu, | |
452 | struct lttng_cpuhp_node *node); | |
453 | int lttng_cpuhp_perf_counter_dead(unsigned int cpu, | |
454 | struct lttng_cpuhp_node *node); | |
455 | #else | |
456 | static inline | |
457 | int lttng_add_perf_counter_to_ctx(uint32_t type, | |
458 | uint64_t config, | |
459 | const char *name, | |
460 | struct lttng_kernel_ctx **ctx) | |
461 | { | |
462 | return -ENOSYS; | |
463 | } | |
464 | static inline | |
465 | int lttng_cpuhp_perf_counter_online(unsigned int cpu, | |
466 | struct lttng_cpuhp_node *node) | |
467 | { | |
468 | return 0; | |
469 | } | |
470 | static inline | |
471 | int lttng_cpuhp_perf_counter_dead(unsigned int cpu, | |
472 | struct lttng_cpuhp_node *node) | |
473 | { | |
474 | return 0; | |
475 | } | |
476 | #endif | |
477 | ||
311e655a MD |
478 | struct lttng_event_enabler *lttng_event_enabler_create( |
479 | enum lttng_enabler_format_type format_type, | |
480 | struct lttng_kernel_abi_event *event_param, | |
481 | struct lttng_channel *chan); | |
482 | ||
483 | int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler); | |
484 | int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler); | |
485 | struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create( | |
486 | struct lttng_event_notifier_group *event_notifier_group, | |
487 | enum lttng_enabler_format_type format_type, | |
488 | struct lttng_kernel_abi_event_notifier *event_notifier_param); | |
489 | ||
490 | int lttng_event_notifier_enabler_enable( | |
491 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
492 | int lttng_event_notifier_enabler_disable( | |
493 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
494 | ||
495 | int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler *event_enabler, | |
496 | struct lttng_kernel_abi_filter_bytecode __user *bytecode); | |
497 | int lttng_event_notifier_enabler_attach_filter_bytecode( | |
498 | struct lttng_event_notifier_enabler *event_notifier_enabler, | |
499 | struct lttng_kernel_abi_filter_bytecode __user *bytecode); | |
500 | int lttng_event_notifier_enabler_attach_capture_bytecode( | |
501 | struct lttng_event_notifier_enabler *event_notifier_enabler, | |
502 | struct lttng_kernel_abi_capture_bytecode __user *bytecode); | |
503 | ||
504 | int lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc, | |
505 | struct lttng_enabler *enabler); | |
506 | ||
507 | void lttng_enabler_link_bytecode(const struct lttng_kernel_event_desc *event_desc, | |
508 | struct lttng_kernel_ctx *ctx, | |
509 | struct list_head *instance_bytecode_runtime_head, | |
510 | struct list_head *enabler_bytecode_runtime_head); | |
511 | ||
512 | #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS) | |
513 | int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler); | |
514 | int lttng_syscalls_unregister_channel(struct lttng_channel *chan); | |
515 | int lttng_syscalls_destroy_event(struct lttng_channel *chan); | |
516 | int lttng_syscall_filter_enable_event( | |
517 | struct lttng_channel *chan, | |
518 | struct lttng_kernel_event_recorder *event); | |
519 | int lttng_syscall_filter_disable_event( | |
520 | struct lttng_channel *chan, | |
521 | struct lttng_kernel_event_recorder *event); | |
522 | ||
523 | long lttng_channel_syscall_mask(struct lttng_channel *channel, | |
524 | struct lttng_kernel_abi_syscall_mask __user *usyscall_mask); | |
525 | ||
526 | int lttng_syscalls_register_event_notifier( | |
527 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
528 | int lttng_syscalls_create_matching_event_notifiers( | |
529 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
530 | int lttng_syscalls_unregister_event_notifier_group(struct lttng_event_notifier_group *group); | |
531 | int lttng_syscall_filter_enable_event_notifier(struct lttng_kernel_event_notifier *event_notifier); | |
532 | int lttng_syscall_filter_disable_event_notifier(struct lttng_kernel_event_notifier *event_notifier); | |
533 | #else | |
534 | static inline int lttng_syscalls_register_event( | |
535 | struct lttng_event_enabler *event_enabler) | |
536 | { | |
537 | return -ENOSYS; | |
538 | } | |
539 | ||
540 | static inline int lttng_syscalls_unregister_channel(struct lttng_channel *chan) | |
541 | { | |
542 | return 0; | |
543 | } | |
544 | ||
545 | static inline int lttng_syscalls_destroy(struct lttng_channel *chan) | |
546 | { | |
547 | return 0; | |
548 | } | |
549 | ||
550 | static inline int lttng_syscall_filter_enable_event(struct lttng_channel *chan, | |
551 | struct lttng_kernel_event_recorder *event); | |
552 | { | |
553 | return -ENOSYS; | |
554 | } | |
555 | ||
556 | static inline int lttng_syscall_filter_disable_event(struct lttng_channel *chan, | |
557 | struct lttng_kernel_event_recorder *event); | |
558 | { | |
559 | return -ENOSYS; | |
560 | } | |
561 | ||
562 | static inline long lttng_channel_syscall_mask(struct lttng_channel *channel, | |
563 | struct lttng_kernel_syscall_mask __user *usyscall_mask) | |
564 | { | |
565 | return -ENOSYS; | |
566 | } | |
567 | ||
568 | static inline int lttng_syscalls_register_event_notifier( | |
569 | struct lttng_event_notifier_group *group) | |
570 | { | |
571 | return -ENOSYS; | |
572 | } | |
573 | ||
574 | static inline int lttng_syscalls_unregister_event_notifier_group( | |
575 | struct lttng_event_notifier_group *group) | |
576 | { | |
577 | return 0; | |
578 | } | |
579 | ||
580 | static inline int lttng_syscall_filter_enable_event_notifier( | |
581 | struct lttng_event_notifier_group *group, | |
582 | const char *name) | |
583 | { | |
584 | return -ENOSYS; | |
585 | } | |
586 | ||
587 | static inline int lttng_syscall_filter_disable_event_notifier( | |
588 | struct lttng_event_notifier_group *group, | |
589 | const char *name) | |
590 | { | |
591 | return -ENOSYS; | |
592 | } | |
0fe45627 | 593 | |
311e655a | 594 | #endif |
0fe45627 | 595 | |
e4a26d6b MD |
596 | #ifdef CONFIG_KPROBES |
597 | int lttng_kprobes_register_event(const char *name, | |
598 | const char *symbol_name, | |
599 | uint64_t offset, | |
600 | uint64_t addr, | |
601 | struct lttng_kernel_event_recorder *event); | |
602 | void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder *event); | |
603 | void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder *event); | |
604 | int lttng_kprobes_register_event_notifier(const char *symbol_name, | |
605 | uint64_t offset, | |
606 | uint64_t addr, | |
607 | struct lttng_kernel_event_notifier *event_notifier); | |
608 | void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier); | |
609 | void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier); | |
610 | #else | |
611 | static inline | |
612 | int lttng_kprobes_register_event(const char *name, | |
613 | const char *symbol_name, | |
614 | uint64_t offset, | |
615 | uint64_t addr, | |
616 | struct lttng_kernel_event_recorder *event) | |
617 | { | |
618 | return -ENOSYS; | |
619 | } | |
620 | ||
621 | static inline | |
622 | void lttng_kprobes_unregister_event(struct lttng_kernel_event_recorder *event) | |
623 | { | |
624 | } | |
625 | ||
626 | static inline | |
627 | void lttng_kprobes_destroy_event_private(struct lttng_kernel_event_recorder *event) | |
628 | { | |
629 | } | |
630 | ||
631 | static inline | |
632 | int lttng_kprobes_register_event_notifier(const char *symbol_name, | |
633 | uint64_t offset, | |
634 | uint64_t addr, | |
635 | struct lttng_kernel_event_notifier *event_notifier) | |
636 | { | |
637 | return -ENOSYS; | |
638 | } | |
639 | ||
640 | static inline | |
641 | void lttng_kprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier) | |
642 | { | |
643 | } | |
644 | ||
645 | static inline | |
646 | void lttng_kprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier) | |
647 | { | |
648 | } | |
649 | #endif | |
650 | ||
651 | int lttng_event_add_callsite(struct lttng_kernel_event_common *event, | |
652 | struct lttng_kernel_abi_event_callsite __user *callsite); | |
653 | ||
654 | #ifdef CONFIG_UPROBES | |
655 | int lttng_uprobes_register_event(const char *name, | |
656 | int fd, struct lttng_kernel_event_recorder *event); | |
657 | int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event, | |
658 | struct lttng_kernel_abi_event_callsite __user *callsite); | |
659 | void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder *event); | |
660 | void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder *event); | |
661 | int lttng_uprobes_register_event_notifier(const char *name, | |
662 | int fd, struct lttng_kernel_event_notifier *event_notifier); | |
663 | void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier); | |
664 | void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier); | |
665 | #else | |
666 | static inline | |
667 | int lttng_uprobes_register_event(const char *name, | |
668 | int fd, struct lttng_kernel_event_recorder *event) | |
669 | { | |
670 | return -ENOSYS; | |
671 | } | |
672 | ||
673 | static inline | |
674 | int lttng_uprobes_event_add_callsite(struct lttng_kernel_event_common *event, | |
675 | struct lttng_kernel_abi_event_callsite __user *callsite) | |
676 | { | |
677 | return -ENOSYS; | |
678 | } | |
679 | ||
680 | static inline | |
681 | void lttng_uprobes_unregister_event(struct lttng_kernel_event_recorder *event) | |
682 | { | |
683 | } | |
684 | ||
685 | static inline | |
686 | void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_recorder *event) | |
687 | { | |
688 | } | |
689 | ||
690 | static inline | |
691 | int lttng_uprobes_register_event_notifier(const char *name, | |
692 | int fd, struct lttng_kernel_event_notifier *event_notifier) | |
693 | { | |
694 | return -ENOSYS; | |
695 | } | |
696 | ||
697 | static inline | |
698 | void lttng_uprobes_unregister_event_notifier(struct lttng_kernel_event_notifier *event_notifier) | |
699 | { | |
700 | } | |
701 | ||
702 | static inline | |
703 | void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier) | |
704 | { | |
705 | } | |
706 | #endif | |
707 | ||
708 | #ifdef CONFIG_KRETPROBES | |
709 | int lttng_kretprobes_register(const char *name, | |
710 | const char *symbol_name, | |
711 | uint64_t offset, | |
712 | uint64_t addr, | |
713 | struct lttng_kernel_event_recorder *event_entry, | |
714 | struct lttng_kernel_event_recorder *event_exit); | |
715 | void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder *event); | |
716 | void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder *event); | |
717 | int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event, | |
718 | int enable); | |
719 | #else | |
720 | static inline | |
721 | int lttng_kretprobes_register(const char *name, | |
722 | const char *symbol_name, | |
723 | uint64_t offset, | |
724 | uint64_t addr, | |
725 | struct lttng_kernel_event_recorder *event_entry, | |
726 | struct lttng_kernel_event_recorder *event_exit) | |
727 | { | |
728 | return -ENOSYS; | |
729 | } | |
730 | ||
731 | static inline | |
732 | void lttng_kretprobes_unregister(struct lttng_kernel_event_recorder *event) | |
733 | { | |
734 | } | |
735 | ||
736 | static inline | |
737 | void lttng_kretprobes_destroy_private(struct lttng_kernel_event_recorder *event) | |
738 | { | |
739 | } | |
740 | ||
741 | static inline | |
742 | int lttng_kretprobes_event_enable_state(struct lttng_kernel_event_common *event, | |
743 | int enable) | |
744 | { | |
745 | return -ENOSYS; | |
746 | } | |
747 | #endif | |
748 | ||
0fe45627 MD |
749 | #define lttng_kernel_static_ctx_field(_event_field, _get_size, _record, _get_value, _destroy, _priv) \ |
750 | __LTTNG_COMPOUND_LITERAL(const struct lttng_kernel_ctx_field, { \ | |
751 | .event_field = (_event_field), \ | |
752 | .get_size = (_get_size), \ | |
753 | .record = (_record), \ | |
754 | .get_value = (_get_value), \ | |
755 | .destroy = (_destroy), \ | |
756 | .priv = (_priv), \ | |
757 | }) | |
758 | ||
92bc1e23 | 759 | #endif /* _LTTNG_EVENTS_INTERNAL_H */ |