Commit | Line | Data |
---|---|---|
9f36eaed MJ |
1 | /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) |
2 | * | |
a90917c3 | 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 | ||
3a523f5b | 13 | #include <linux/version.h> |
4e3c1b9b | 14 | #include <linux/list.h> |
d6d808f3 | 15 | #include <linux/kprobes.h> |
d83004aa | 16 | #include <linux/kref.h> |
1e367326 | 17 | #include <lttng-cpuhotplug.h> |
41f229dc | 18 | #include <linux/uuid.h> |
149b9a9d | 19 | #include <wrapper/uprobes.h> |
f64dd4be | 20 | #include <lttng-tracer.h> |
bbd023d6 MD |
21 | #include <lttng-abi.h> |
22 | #include <lttng-abi-old.h> | |
63629d86 | 23 | #include <linux/irq_work.h> |
4e3c1b9b | 24 | |
06254b0f | 25 | #define lttng_is_signed_type(type) (((type)(-1)) < 0) |
9e7e4892 | 26 | |
a90917c3 MD |
27 | struct lttng_channel; |
28 | struct lttng_session; | |
d83004aa | 29 | struct lttng_metadata_cache; |
1c25284c | 30 | struct lib_ring_buffer_ctx; |
ba1f5986 | 31 | struct perf_event; |
833ad6a0 | 32 | struct perf_event_attr; |
3b731ab1 | 33 | struct lib_ring_buffer_config; |
4e3c1b9b | 34 | |
c0edae1d MD |
35 | /* Type description */ |
36 | ||
c0edae1d MD |
37 | enum abstract_types { |
38 | atype_integer, | |
39 | atype_enum, | |
40 | atype_array, | |
41 | atype_sequence, | |
42 | atype_string, | |
f513b2bf MD |
43 | atype_struct, |
44 | atype_array_compound, /* Array of compound types. */ | |
45 | atype_sequence_compound, /* Sequence of compound types. */ | |
65c85aa6 | 46 | atype_variant, |
3834b99f MD |
47 | atype_array_bitfield, |
48 | atype_sequence_bitfield, | |
c0edae1d MD |
49 | NR_ABSTRACT_TYPES, |
50 | }; | |
51 | ||
c0edae1d | 52 | enum lttng_string_encodings { |
e0a7a7c4 MD |
53 | lttng_encode_none = 0, |
54 | lttng_encode_UTF8 = 1, | |
55 | lttng_encode_ASCII = 2, | |
c0edae1d MD |
56 | NR_STRING_ENCODINGS, |
57 | }; | |
58 | ||
d83004aa JD |
59 | enum channel_type { |
60 | PER_CPU_CHANNEL, | |
61 | METADATA_CHANNEL, | |
62 | }; | |
63 | ||
141ddf28 MD |
64 | struct lttng_enum_value { |
65 | unsigned long long value; | |
66 | unsigned int signedness:1; | |
67 | }; | |
68 | ||
c0edae1d | 69 | struct lttng_enum_entry { |
141ddf28 | 70 | struct lttng_enum_value start, end; /* start and end are inclusive */ |
c0edae1d | 71 | const char *string; |
08ad1061 PP |
72 | struct { |
73 | unsigned int is_auto:1; | |
74 | } options; | |
c0edae1d MD |
75 | }; |
76 | ||
43803cf2 MD |
77 | #define __type_integer(_type, _size, _alignment, _signedness, \ |
78 | _byte_order, _base, _encoding) \ | |
c099397a MD |
79 | { \ |
80 | .atype = atype_integer, \ | |
81 | .u.basic.integer = \ | |
82 | { \ | |
43803cf2 MD |
83 | .size = (_size) ? : sizeof(_type) * CHAR_BIT, \ |
84 | .alignment = (_alignment) ? : lttng_alignof(_type) * CHAR_BIT, \ | |
85 | .signedness = (_signedness) >= 0 ? (_signedness) : lttng_is_signed_type(_type), \ | |
86 | .reverse_byte_order = _byte_order != __BYTE_ORDER, \ | |
e0a7a7c4 | 87 | .base = _base, \ |
64c796d8 | 88 | .encoding = lttng_encode_##_encoding, \ |
c099397a MD |
89 | }, \ |
90 | } \ | |
91 | ||
92 | struct lttng_integer_type { | |
93 | unsigned int size; /* in bits */ | |
94 | unsigned short alignment; /* in bits */ | |
9cccf98a MD |
95 | unsigned int signedness:1, |
96 | reverse_byte_order:1; | |
e0a7a7c4 MD |
97 | unsigned int base; /* 2, 8, 10, 16, for pretty print */ |
98 | enum lttng_string_encodings encoding; | |
c099397a MD |
99 | }; |
100 | ||
101 | union _lttng_basic_type { | |
102 | struct lttng_integer_type integer; | |
103 | struct { | |
141ddf28 MD |
104 | const struct lttng_enum_desc *desc; /* Enumeration mapping */ |
105 | struct lttng_integer_type container_type; | |
c099397a MD |
106 | } enumeration; |
107 | struct { | |
108 | enum lttng_string_encodings encoding; | |
109 | } string; | |
110 | }; | |
111 | ||
112 | struct lttng_basic_type { | |
113 | enum abstract_types atype; | |
114 | union { | |
115 | union _lttng_basic_type basic; | |
116 | } u; | |
c0edae1d MD |
117 | }; |
118 | ||
119 | struct lttng_type { | |
120 | enum abstract_types atype; | |
c0edae1d | 121 | union { |
c099397a | 122 | union _lttng_basic_type basic; |
c0edae1d | 123 | struct { |
c099397a | 124 | struct lttng_basic_type elem_type; |
c0edae1d | 125 | unsigned int length; /* num. elems. */ |
43803cf2 | 126 | unsigned int elem_alignment; /* alignment override */ |
c0edae1d MD |
127 | } array; |
128 | struct { | |
c099397a MD |
129 | struct lttng_basic_type length_type; |
130 | struct lttng_basic_type elem_type; | |
43803cf2 | 131 | unsigned int elem_alignment; /* alignment override */ |
c0edae1d | 132 | } sequence; |
f513b2bf MD |
133 | struct { |
134 | uint32_t nr_fields; | |
135 | struct lttng_event_field *fields; /* Array of fields. */ | |
136 | } _struct; | |
137 | struct { | |
138 | struct lttng_type *elem_type; | |
139 | unsigned int length; /* num. elems. */ | |
140 | } array_compound; | |
141 | struct { | |
142 | struct lttng_type *elem_type; | |
143 | const char *length_name; | |
144 | } sequence_compound; | |
65c85aa6 MD |
145 | struct { |
146 | const char *tag_name; | |
147 | struct lttng_event_field *choices; /* Array of fields. */ | |
148 | uint32_t nr_choices; | |
149 | } variant; | |
c0edae1d | 150 | } u; |
c099397a MD |
151 | }; |
152 | ||
141ddf28 | 153 | struct lttng_enum_desc { |
c099397a | 154 | const char *name; |
c099397a | 155 | const struct lttng_enum_entry *entries; |
141ddf28 | 156 | unsigned int nr_entries; |
c099397a | 157 | }; |
c0edae1d MD |
158 | |
159 | /* Event field description */ | |
160 | ||
161 | struct lttng_event_field { | |
162 | const char *name; | |
f17701fb | 163 | struct lttng_type type; |
f127e61e MD |
164 | unsigned int nowrite:1, /* do not write into trace */ |
165 | user:1; /* fetch from user-space */ | |
c0edae1d MD |
166 | }; |
167 | ||
07dfc1d0 MD |
168 | union lttng_ctx_value { |
169 | int64_t s64; | |
170 | const char *str; | |
171 | double d; | |
172 | }; | |
173 | ||
2001023e MD |
174 | /* |
175 | * We need to keep this perf counter field separately from struct | |
176 | * lttng_ctx_field because cpu hotplug needs fixed-location addresses. | |
177 | */ | |
178 | struct lttng_perf_counter_field { | |
1e367326 MD |
179 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) |
180 | struct lttng_cpuhp_node cpuhp_prepare; | |
181 | struct lttng_cpuhp_node cpuhp_online; | |
182 | #else | |
2001023e MD |
183 | struct notifier_block nb; |
184 | int hp_enable; | |
1e367326 | 185 | #endif |
2001023e MD |
186 | struct perf_event_attr *attr; |
187 | struct perf_event **e; /* per-cpu array */ | |
188 | }; | |
189 | ||
79150a49 JD |
190 | struct lttng_probe_ctx { |
191 | struct lttng_event *event; | |
63629d86 | 192 | struct lttng_trigger *trigger; // Not sure if we will ever need it. |
79150a49 JD |
193 | uint8_t interruptible; |
194 | }; | |
195 | ||
ba1f5986 | 196 | struct lttng_ctx_field { |
8070f5c0 | 197 | struct lttng_event_field event_field; |
f1676205 | 198 | size_t (*get_size)(size_t offset); |
1474c8e2 FG |
199 | size_t (*get_size_arg)(size_t offset, struct lttng_ctx_field *field, |
200 | struct lib_ring_buffer_ctx *ctx, | |
201 | struct lttng_channel *chan); | |
f1676205 MD |
202 | void (*record)(struct lttng_ctx_field *field, |
203 | struct lib_ring_buffer_ctx *ctx, | |
a90917c3 | 204 | struct lttng_channel *chan); |
07dfc1d0 | 205 | void (*get_value)(struct lttng_ctx_field *field, |
79150a49 | 206 | struct lttng_probe_ctx *lttng_probe_ctx, |
07dfc1d0 | 207 | union lttng_ctx_value *value); |
ba1f5986 | 208 | union { |
2001023e | 209 | struct lttng_perf_counter_field *perf_counter; |
ba1f5986 | 210 | } u; |
2dccf128 | 211 | void (*destroy)(struct lttng_ctx_field *field); |
3c1a57e8 MD |
212 | /* |
213 | * Private data to keep state between get_size and record. | |
214 | * User must perform its own synchronization to protect against | |
215 | * concurrent and reentrant contexts. | |
216 | */ | |
217 | void *priv; | |
ba1f5986 MD |
218 | }; |
219 | ||
220 | struct lttng_ctx { | |
833ad6a0 | 221 | struct lttng_ctx_field *fields; |
0d1a681e | 222 | unsigned int nr_fields; |
ba1f5986 | 223 | unsigned int allocated_fields; |
a9dd15da | 224 | size_t largest_align; /* in bytes */ |
0d1a681e MD |
225 | }; |
226 | ||
227 | struct lttng_event_desc { | |
a26a7e4f MD |
228 | const char *name; /* lttng-modules name */ |
229 | const char *kname; /* Linux kernel name (tracepoints) */ | |
c0edae1d | 230 | void *probe_callback; |
0d1a681e MD |
231 | const struct lttng_event_ctx *ctx; /* context */ |
232 | const struct lttng_event_field *fields; /* event payload */ | |
c0edae1d | 233 | unsigned int nr_fields; |
dc7f600a | 234 | struct module *owner; |
63629d86 | 235 | void *trigger_callback; |
c0edae1d MD |
236 | }; |
237 | ||
85a9ca7f | 238 | struct lttng_probe_desc { |
3c997079 | 239 | const char *provider; |
f7bdf4db | 240 | const struct lttng_event_desc **event_desc; |
85a9ca7f MD |
241 | unsigned int nr_events; |
242 | struct list_head head; /* chain registered probes */ | |
3c997079 MD |
243 | struct list_head lazy_init_head; |
244 | int lazy; /* lazy registration */ | |
85a9ca7f MD |
245 | }; |
246 | ||
7371f44c MD |
247 | struct lttng_krp; /* Kretprobe handling */ |
248 | ||
3c997079 MD |
249 | enum lttng_event_type { |
250 | LTTNG_TYPE_EVENT = 0, | |
251 | LTTNG_TYPE_ENABLER = 1, | |
252 | }; | |
253 | ||
07dfc1d0 MD |
254 | struct lttng_filter_bytecode_node { |
255 | struct list_head node; | |
256 | struct lttng_enabler *enabler; | |
257 | /* | |
258 | * struct lttng_kernel_filter_bytecode has var. sized array, must be | |
259 | * last field. | |
260 | */ | |
261 | struct lttng_kernel_filter_bytecode bc; | |
262 | }; | |
263 | ||
264 | /* | |
265 | * Filter return value masks. | |
266 | */ | |
267 | enum lttng_filter_ret { | |
268 | LTTNG_FILTER_DISCARD = 0, | |
269 | LTTNG_FILTER_RECORD_FLAG = (1ULL << 0), | |
270 | /* Other bits are kept for future use. */ | |
271 | }; | |
272 | ||
273 | struct lttng_bytecode_runtime { | |
274 | /* Associated bytecode */ | |
275 | struct lttng_filter_bytecode_node *bc; | |
79150a49 JD |
276 | uint64_t (*filter)(void *filter_data, struct lttng_probe_ctx *lttng_probe_ctx, |
277 | const char *filter_stack_data); | |
07dfc1d0 MD |
278 | int link_failed; |
279 | struct list_head node; /* list of bytecode runtime in event */ | |
63629d86 | 280 | struct lttng_ctx *ctx; |
07dfc1d0 MD |
281 | }; |
282 | ||
3c997079 MD |
283 | /* |
284 | * Objects in a linked-list of enablers, owned by an event. | |
285 | */ | |
286 | struct lttng_enabler_ref { | |
287 | struct list_head node; /* enabler ref list */ | |
288 | struct lttng_enabler *ref; /* backward ref */ | |
289 | }; | |
290 | ||
3aed4dca | 291 | struct lttng_uprobe_handler { |
63629d86 FD |
292 | union { |
293 | struct lttng_event *event; | |
294 | struct lttng_trigger *trigger; | |
295 | } u; | |
3aed4dca FD |
296 | loff_t offset; |
297 | struct uprobe_consumer up_consumer; | |
298 | struct list_head node; | |
299 | }; | |
300 | ||
63629d86 FD |
301 | struct lttng_kprobe { |
302 | struct kprobe kp; | |
303 | char *symbol_name; | |
304 | }; | |
305 | ||
306 | struct lttng_uprobe { | |
307 | struct inode *inode; | |
308 | struct list_head head; | |
309 | }; | |
310 | ||
311 | struct lttng_syscall { | |
312 | struct list_head node; /* chain registered syscall trigger */ | |
313 | unsigned int syscall_id; | |
314 | bool is_compat; | |
315 | }; | |
316 | ||
85a9ca7f | 317 | /* |
a90917c3 | 318 | * lttng_event structure is referred to by the tracing fast path. It must be |
85a9ca7f MD |
319 | * kept small. |
320 | */ | |
a90917c3 | 321 | struct lttng_event { |
3c997079 | 322 | enum lttng_event_type evtype; /* First field. */ |
85a9ca7f | 323 | unsigned int id; |
a90917c3 | 324 | struct lttng_channel *chan; |
e64957da | 325 | int enabled; |
d3dbe23c | 326 | const struct lttng_event_desc *desc; |
85a9ca7f | 327 | void *filter; |
f1676205 | 328 | struct lttng_ctx *ctx; |
38d024ae | 329 | enum lttng_kernel_instrumentation instrumentation; |
d6d808f3 | 330 | union { |
63629d86 | 331 | struct lttng_kprobe kprobe; |
7371f44c MD |
332 | struct { |
333 | struct lttng_krp *lttng_krp; | |
334 | char *symbol_name; | |
335 | } kretprobe; | |
e0a7a7c4 MD |
336 | struct { |
337 | char *symbol_name; | |
338 | } ftrace; | |
63629d86 | 339 | struct lttng_uprobe uprobe; |
d6d808f3 | 340 | } u; |
3c997079 | 341 | struct list_head list; /* Event list in session */ |
9cccf98a | 342 | unsigned int metadata_dumped:1; |
3c997079 MD |
343 | |
344 | /* Backward references: list of lttng_enabler_ref (ref to enablers) */ | |
345 | struct list_head enablers_ref_head; | |
346 | struct hlist_node hlist; /* session ht of events */ | |
347 | int registered; /* has reg'd tracepoint probe */ | |
07dfc1d0 MD |
348 | /* list of struct lttng_bytecode_runtime, sorted by seqnum */ |
349 | struct list_head bytecode_runtime_head; | |
350 | int has_enablers_without_bytecode; | |
3c997079 MD |
351 | }; |
352 | ||
63629d86 FD |
353 | // FIXME: Really similar to lttng_event above. Could those be merged ? |
354 | struct lttng_trigger { | |
355 | enum lttng_event_type evtype; /* First field. */ | |
356 | uint64_t id; | |
357 | int enabled; | |
358 | int registered; /* has reg'd tracepoint probe */ | |
359 | const struct lttng_event_desc *desc; | |
360 | void *filter; | |
361 | struct list_head list; /* Trigger list in trigger group */ | |
362 | ||
363 | enum lttng_kernel_instrumentation instrumentation; | |
364 | union { | |
365 | struct lttng_kprobe kprobe; | |
366 | struct lttng_uprobe uprobe; | |
367 | struct lttng_syscall syscall; | |
368 | } u; | |
369 | ||
370 | /* Backward references: list of lttng_enabler_ref (ref to enablers) */ | |
371 | struct list_head enablers_ref_head; | |
372 | struct hlist_node hlist; /* session ht of triggers */ | |
373 | /* list of struct lttng_bytecode_runtime, sorted by seqnum */ | |
374 | struct list_head bytecode_runtime_head; | |
375 | int has_enablers_without_bytecode; | |
376 | ||
377 | void (*send_notification)(struct lttng_trigger *trigger); | |
378 | struct lttng_trigger_group *group; /* Weak ref */ | |
379 | }; | |
380 | ||
381 | enum lttng_enabler_format_type { | |
382 | LTTNG_ENABLER_FORMAT_STAR_GLOB, | |
383 | LTTNG_ENABLER_FORMAT_NAME, | |
3c997079 MD |
384 | }; |
385 | ||
386 | /* | |
387 | * Enabler field, within whatever object is enabling an event. Target of | |
388 | * backward reference. | |
389 | */ | |
390 | struct lttng_enabler { | |
391 | enum lttng_event_type evtype; /* First field. */ | |
392 | ||
63629d86 | 393 | enum lttng_enabler_format_type format_type; |
3c997079 | 394 | |
07dfc1d0 MD |
395 | /* head list of struct lttng_ust_filter_bytecode_node */ |
396 | struct list_head filter_bytecode_head; | |
3c997079 MD |
397 | |
398 | struct lttng_kernel_event event_param; | |
63629d86 FD |
399 | unsigned int enabled:1; |
400 | }; | |
401 | ||
402 | struct lttng_event_enabler { | |
403 | struct lttng_enabler base; | |
404 | struct list_head node; /* per-session list of enablers */ | |
3c997079 | 405 | struct lttng_channel *chan; |
63629d86 FD |
406 | /* |
407 | * Unused, but kept around to make it explicit that the tracer can do | |
408 | * it. | |
409 | */ | |
3c997079 | 410 | struct lttng_ctx *ctx; |
85a9ca7f MD |
411 | }; |
412 | ||
63629d86 FD |
413 | struct lttng_trigger_enabler { |
414 | struct lttng_enabler base; | |
415 | uint64_t id; | |
416 | struct list_head node; /* List of trigger enablers */ | |
417 | struct lttng_trigger_group *group; | |
418 | }; | |
419 | ||
420 | static inline | |
421 | struct lttng_enabler *lttng_event_enabler_as_enabler( | |
422 | struct lttng_event_enabler *event_enabler) | |
423 | { | |
424 | return &event_enabler->base; | |
425 | } | |
426 | ||
427 | static inline | |
428 | struct lttng_enabler *lttng_trigger_enabler_as_enabler( | |
429 | struct lttng_trigger_enabler *trigger_enabler) | |
430 | { | |
431 | return &trigger_enabler->base; | |
432 | } | |
433 | ||
a90917c3 | 434 | struct lttng_channel_ops { |
85a9ca7f | 435 | struct channel *(*channel_create)(const char *name, |
63629d86 | 436 | void *priv, |
85a9ca7f MD |
437 | void *buf_addr, |
438 | size_t subbuf_size, size_t num_subbuf, | |
439 | unsigned int switch_timer_interval, | |
440 | unsigned int read_timer_interval); | |
441 | void (*channel_destroy)(struct channel *chan); | |
442 | struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan); | |
f71ecafa | 443 | int (*buffer_has_read_closed_stream)(struct channel *chan); |
85a9ca7f | 444 | void (*buffer_read_close)(struct lib_ring_buffer *buf); |
4e1f08f4 | 445 | int (*event_reserve)(struct lib_ring_buffer_ctx *ctx, |
64c796d8 | 446 | uint32_t event_id); |
85a9ca7f MD |
447 | void (*event_commit)(struct lib_ring_buffer_ctx *ctx); |
448 | void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src, | |
449 | size_t len); | |
4ea00e4f JD |
450 | void (*event_write_from_user)(struct lib_ring_buffer_ctx *ctx, |
451 | const void *src, size_t len); | |
58aa5d24 MD |
452 | void (*event_memset)(struct lib_ring_buffer_ctx *ctx, |
453 | int c, size_t len); | |
16f78f3a MD |
454 | void (*event_strcpy)(struct lib_ring_buffer_ctx *ctx, const char *src, |
455 | size_t len); | |
456 | void (*event_strcpy_from_user)(struct lib_ring_buffer_ctx *ctx, | |
457 | const char __user *src, size_t len); | |
1ec3f75a MD |
458 | /* |
459 | * packet_avail_size returns the available size in the current | |
460 | * packet. Note that the size returned is only a hint, since it | |
461 | * may change due to concurrent writes. | |
462 | */ | |
463 | size_t (*packet_avail_size)(struct channel *chan); | |
71c1d843 | 464 | wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu); |
24cedcfe MD |
465 | wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan); |
466 | int (*is_finalized)(struct channel *chan); | |
254ec7bc | 467 | int (*is_disabled)(struct channel *chan); |
3b731ab1 JD |
468 | int (*timestamp_begin) (const struct lib_ring_buffer_config *config, |
469 | struct lib_ring_buffer *bufb, | |
470 | uint64_t *timestamp_begin); | |
471 | int (*timestamp_end) (const struct lib_ring_buffer_config *config, | |
472 | struct lib_ring_buffer *bufb, | |
473 | uint64_t *timestamp_end); | |
474 | int (*events_discarded) (const struct lib_ring_buffer_config *config, | |
475 | struct lib_ring_buffer *bufb, | |
476 | uint64_t *events_discarded); | |
477 | int (*content_size) (const struct lib_ring_buffer_config *config, | |
478 | struct lib_ring_buffer *bufb, | |
479 | uint64_t *content_size); | |
480 | int (*packet_size) (const struct lib_ring_buffer_config *config, | |
481 | struct lib_ring_buffer *bufb, | |
482 | uint64_t *packet_size); | |
483 | int (*stream_id) (const struct lib_ring_buffer_config *config, | |
484 | struct lib_ring_buffer *bufb, | |
485 | uint64_t *stream_id); | |
2348ca17 JD |
486 | int (*current_timestamp) (const struct lib_ring_buffer_config *config, |
487 | struct lib_ring_buffer *bufb, | |
488 | uint64_t *ts); | |
5b3cf4f9 JD |
489 | int (*sequence_number) (const struct lib_ring_buffer_config *config, |
490 | struct lib_ring_buffer *bufb, | |
491 | uint64_t *seq); | |
5594698f JD |
492 | int (*instance_id) (const struct lib_ring_buffer_config *config, |
493 | struct lib_ring_buffer *bufb, | |
494 | uint64_t *id); | |
85a9ca7f MD |
495 | }; |
496 | ||
a90917c3 | 497 | struct lttng_transport { |
a33c9927 MD |
498 | char *name; |
499 | struct module *owner; | |
500 | struct list_head node; | |
a90917c3 | 501 | struct lttng_channel_ops ops; |
a33c9927 MD |
502 | }; |
503 | ||
80f87dd2 MD |
504 | struct lttng_syscall_filter; |
505 | ||
3c997079 MD |
506 | #define LTTNG_EVENT_HT_BITS 12 |
507 | #define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS) | |
508 | ||
509 | struct lttng_event_ht { | |
510 | struct hlist_head table[LTTNG_EVENT_HT_SIZE]; | |
511 | }; | |
512 | ||
63629d86 FD |
513 | #define LTTNG_TRIGGER_HT_BITS 12 |
514 | #define LTTNG_TRIGGER_HT_SIZE (1U << LTTNG_TRIGGER_HT_BITS) | |
515 | ||
516 | struct lttng_trigger_ht { | |
517 | struct hlist_head table[LTTNG_TRIGGER_HT_SIZE]; | |
518 | }; | |
519 | ||
a90917c3 | 520 | struct lttng_channel { |
c099397a | 521 | unsigned int id; |
85a9ca7f | 522 | struct channel *chan; /* Channel buffers */ |
e64957da | 523 | int enabled; |
f1676205 | 524 | struct lttng_ctx *ctx; |
85a9ca7f | 525 | /* Event ID management */ |
a90917c3 | 526 | struct lttng_session *session; |
85a9ca7f MD |
527 | struct file *file; /* File associated to channel */ |
528 | unsigned int free_event_id; /* Next event ID to allocate */ | |
529 | struct list_head list; /* Channel list */ | |
a90917c3 MD |
530 | struct lttng_channel_ops *ops; |
531 | struct lttng_transport *transport; | |
532 | struct lttng_event **sc_table; /* for syscall tracing */ | |
533 | struct lttng_event **compat_sc_table; | |
5b7ac358 MD |
534 | struct lttng_event **sc_exit_table; /* for syscall exit tracing */ |
535 | struct lttng_event **compat_sc_exit_table; | |
a90917c3 MD |
536 | struct lttng_event *sc_unknown; /* for unknown syscalls */ |
537 | struct lttng_event *sc_compat_unknown; | |
5b7ac358 MD |
538 | struct lttng_event *sc_exit_unknown; |
539 | struct lttng_event *compat_sc_exit_unknown; | |
80f87dd2 | 540 | struct lttng_syscall_filter *sc_filter; |
9115fbdc | 541 | int header_type; /* 0: unset, 1: compact, 2: large */ |
d83004aa | 542 | enum channel_type channel_type; |
80f87dd2 MD |
543 | unsigned int metadata_dumped:1, |
544 | sys_enter_registered:1, | |
545 | sys_exit_registered:1, | |
3c997079 MD |
546 | syscall_all:1, |
547 | tstate:1; /* Transient enable state */ | |
85a9ca7f MD |
548 | }; |
549 | ||
d83004aa JD |
550 | struct lttng_metadata_stream { |
551 | void *priv; /* Ring buffer private data */ | |
552 | struct lttng_metadata_cache *metadata_cache; | |
f613e3e6 MD |
553 | unsigned int metadata_in; /* Bytes read from the cache */ |
554 | unsigned int metadata_out; /* Bytes consumed from stream */ | |
d83004aa JD |
555 | int finalized; /* Has channel been finalized */ |
556 | wait_queue_head_t read_wait; /* Reader buffer-level wait queue */ | |
557 | struct list_head list; /* Stream list */ | |
b3b8072b | 558 | struct lttng_transport *transport; |
9616f0bf | 559 | uint64_t version; /* Current version of the metadata cache */ |
d83004aa JD |
560 | }; |
561 | ||
114667d5 MD |
562 | #define LTTNG_DYNAMIC_LEN_STACK_SIZE 128 |
563 | ||
564 | struct lttng_dynamic_len_stack { | |
565 | size_t stack[LTTNG_DYNAMIC_LEN_STACK_SIZE]; | |
566 | size_t offset; | |
567 | }; | |
568 | ||
569 | DECLARE_PER_CPU(struct lttng_dynamic_len_stack, lttng_dynamic_len_stack); | |
e0130fab MD |
570 | |
571 | /* | |
d1f652f8 | 572 | * struct lttng_id_tracker declared in header due to deferencing of *v |
e0130fab MD |
573 | * in RCU_INITIALIZER(v). |
574 | */ | |
d1f652f8 MD |
575 | #define LTTNG_ID_HASH_BITS 6 |
576 | #define LTTNG_ID_TABLE_SIZE (1 << LTTNG_ID_HASH_BITS) | |
e0130fab | 577 | |
d1f652f8 MD |
578 | enum tracker_type { |
579 | TRACKER_PID, | |
580 | TRACKER_VPID, | |
581 | TRACKER_UID, | |
582 | TRACKER_VUID, | |
583 | TRACKER_GID, | |
584 | TRACKER_VGID, | |
585 | ||
586 | TRACKER_UNKNOWN, | |
587 | }; | |
588 | ||
589 | struct lttng_id_tracker_rcu { | |
590 | struct hlist_head id_hash[LTTNG_ID_TABLE_SIZE]; | |
591 | }; | |
592 | ||
593 | struct lttng_id_tracker { | |
594 | struct lttng_session *session; | |
595 | enum tracker_type tracker_type; | |
596 | struct lttng_id_tracker_rcu *p; /* RCU dereferenced. */ | |
e0130fab MD |
597 | }; |
598 | ||
d1f652f8 | 599 | struct lttng_id_hash_node { |
7e6f9ef6 | 600 | struct hlist_node hlist; |
d1f652f8 | 601 | int id; |
7e6f9ef6 MD |
602 | }; |
603 | ||
a90917c3 | 604 | struct lttng_session { |
85a9ca7f | 605 | int active; /* Is trace session active ? */ |
8070f5c0 | 606 | int been_active; /* Has trace session been active ? */ |
85a9ca7f MD |
607 | struct file *file; /* File associated to session */ |
608 | struct list_head chan; /* Channel list head */ | |
609 | struct list_head events; /* Event list head */ | |
610 | struct list_head list; /* Session list */ | |
c099397a | 611 | unsigned int free_chan_id; /* Next chan ID to allocate */ |
d793d5e1 | 612 | uuid_le uuid; /* Trace session unique ID */ |
d83004aa | 613 | struct lttng_metadata_cache *metadata_cache; |
d1f652f8 MD |
614 | struct lttng_id_tracker pid_tracker; |
615 | struct lttng_id_tracker vpid_tracker; | |
616 | struct lttng_id_tracker uid_tracker; | |
617 | struct lttng_id_tracker vuid_tracker; | |
618 | struct lttng_id_tracker gid_tracker; | |
619 | struct lttng_id_tracker vgid_tracker; | |
3c997079 MD |
620 | unsigned int metadata_dumped:1, |
621 | tstate:1; /* Transient enable state */ | |
63629d86 | 622 | /* List of event enablers */ |
3c997079 | 623 | struct list_head enablers_head; |
63629d86 | 624 | /* Hash table of events */ |
3c997079 | 625 | struct lttng_event_ht events_ht; |
7f859fbf | 626 | char name[LTTNG_KERNEL_SESSION_NAME_LEN]; |
1c88f269 | 627 | char creation_time[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN]; |
85a9ca7f MD |
628 | }; |
629 | ||
63629d86 FD |
630 | struct lttng_trigger_group { |
631 | struct file *file; /* File associated to trigger group */ | |
632 | struct file *notif_file; /* File used to expose notifications to userspace. */ | |
633 | struct list_head node; /* Trigger group list */ | |
634 | struct list_head enablers_head; /* List of enablers */ | |
635 | struct list_head triggers_head; /* List of triggers */ | |
636 | struct lttng_trigger_ht triggers_ht; /* Hash table of triggers */ | |
637 | struct lttng_ctx *ctx; /* Contexts for filters. */ | |
638 | struct lttng_channel_ops *ops; | |
639 | struct lttng_transport *transport; | |
640 | struct channel *chan; /* Ring buffer channel for trigger group. */ | |
641 | struct lib_ring_buffer *buf; /* Ring buffer for trigger group. */ | |
642 | wait_queue_head_t read_wait; | |
643 | struct irq_work wakeup_pending; /* Pending wakeup irq work. */ | |
644 | ||
645 | struct list_head *trigger_syscall_dispatch; | |
646 | struct list_head *trigger_compat_syscall_dispatch; | |
647 | ||
648 | unsigned int syscall_all:1, | |
649 | sys_enter_registered:1; | |
650 | }; | |
651 | ||
d83004aa JD |
652 | struct lttng_metadata_cache { |
653 | char *data; /* Metadata cache */ | |
654 | unsigned int cache_alloc; /* Metadata allocated size (bytes) */ | |
655 | unsigned int metadata_written; /* Number of bytes written in metadata cache */ | |
656 | struct kref refcount; /* Metadata cache usage */ | |
657 | struct list_head metadata_stream; /* Metadata stream list */ | |
a36580d5 | 658 | uuid_le uuid; /* Trace session unique ID (copy) */ |
9616f0bf JD |
659 | struct mutex lock; /* Produce/consume lock */ |
660 | uint64_t version; /* Current version of the metadata */ | |
d83004aa JD |
661 | }; |
662 | ||
3c997079 MD |
663 | void lttng_lock_sessions(void); |
664 | void lttng_unlock_sessions(void); | |
665 | ||
666 | struct list_head *lttng_get_probe_list_head(void); | |
667 | ||
63629d86 FD |
668 | struct lttng_event_enabler *lttng_event_enabler_create( |
669 | enum lttng_enabler_format_type format_type, | |
3c997079 MD |
670 | struct lttng_kernel_event *event_param, |
671 | struct lttng_channel *chan); | |
672 | ||
63629d86 FD |
673 | int lttng_event_enabler_enable(struct lttng_event_enabler *event_enabler); |
674 | int lttng_event_enabler_disable(struct lttng_event_enabler *event_enabler); | |
675 | struct lttng_trigger_enabler *lttng_trigger_enabler_create( | |
676 | struct lttng_trigger_group *trigger_group, | |
677 | enum lttng_enabler_format_type format_type, | |
678 | struct lttng_kernel_trigger *trigger_param); | |
679 | ||
680 | int lttng_trigger_enabler_enable(struct lttng_trigger_enabler *trigger_enabler); | |
681 | int lttng_trigger_enabler_disable(struct lttng_trigger_enabler *trigger_enabler); | |
3c997079 | 682 | int lttng_fix_pending_events(void); |
63629d86 | 683 | int lttng_fix_pending_triggers(void); |
3c997079 | 684 | int lttng_session_active(void); |
63629d86 | 685 | bool lttng_trigger_active(void); |
3c997079 | 686 | |
a90917c3 MD |
687 | struct lttng_session *lttng_session_create(void); |
688 | int lttng_session_enable(struct lttng_session *session); | |
689 | int lttng_session_disable(struct lttng_session *session); | |
690 | void lttng_session_destroy(struct lttng_session *session); | |
9616f0bf | 691 | int lttng_session_metadata_regenerate(struct lttng_session *session); |
601252cf | 692 | int lttng_session_statedump(struct lttng_session *session); |
d83004aa | 693 | void metadata_cache_destroy(struct kref *kref); |
4e3c1b9b | 694 | |
63629d86 FD |
695 | struct lttng_trigger_group *lttng_trigger_group_create(void); |
696 | void lttng_trigger_group_destroy(struct lttng_trigger_group *trigger_group); | |
697 | ||
a90917c3 | 698 | struct lttng_channel *lttng_channel_create(struct lttng_session *session, |
5dbbdb43 MD |
699 | const char *transport_name, |
700 | void *buf_addr, | |
701 | size_t subbuf_size, size_t num_subbuf, | |
702 | unsigned int switch_timer_interval, | |
d83004aa JD |
703 | unsigned int read_timer_interval, |
704 | enum channel_type channel_type); | |
a90917c3 | 705 | struct lttng_channel *lttng_global_channel_create(struct lttng_session *session, |
4e3c1b9b MD |
706 | int overwrite, void *buf_addr, |
707 | size_t subbuf_size, size_t num_subbuf, | |
708 | unsigned int switch_timer_interval, | |
709 | unsigned int read_timer_interval); | |
4e3c1b9b | 710 | |
d83004aa | 711 | void lttng_metadata_channel_destroy(struct lttng_channel *chan); |
a90917c3 | 712 | struct lttng_event *lttng_event_create(struct lttng_channel *chan, |
3c997079 MD |
713 | struct lttng_kernel_event *event_param, |
714 | void *filter, | |
715 | const struct lttng_event_desc *event_desc, | |
716 | enum lttng_kernel_instrumentation itype); | |
33a39a3c MD |
717 | struct lttng_event *_lttng_event_create(struct lttng_channel *chan, |
718 | struct lttng_kernel_event *event_param, | |
719 | void *filter, | |
720 | const struct lttng_event_desc *event_desc, | |
721 | enum lttng_kernel_instrumentation itype); | |
6dccd6c1 JD |
722 | struct lttng_event *lttng_event_compat_old_create(struct lttng_channel *chan, |
723 | struct lttng_kernel_old_event *old_event_param, | |
724 | void *filter, | |
725 | const struct lttng_event_desc *internal_desc); | |
c0e31d2e | 726 | |
63629d86 FD |
727 | struct lttng_trigger *lttng_trigger_create( |
728 | const struct lttng_event_desc *trigger_desc, | |
729 | uint64_t id, | |
730 | struct lttng_trigger_group *trigger_group, | |
731 | struct lttng_kernel_trigger *trigger_param, | |
732 | void *filter, | |
733 | enum lttng_kernel_instrumentation itype); | |
734 | struct lttng_trigger *_lttng_trigger_create( | |
735 | const struct lttng_event_desc *trigger_desc, | |
736 | uint64_t id, | |
737 | struct lttng_trigger_group *trigger_group, | |
738 | struct lttng_kernel_trigger *trigger_param, | |
739 | void *filter, | |
740 | enum lttng_kernel_instrumentation itype); | |
741 | ||
a90917c3 MD |
742 | int lttng_channel_enable(struct lttng_channel *channel); |
743 | int lttng_channel_disable(struct lttng_channel *channel); | |
744 | int lttng_event_enable(struct lttng_event *event); | |
745 | int lttng_event_disable(struct lttng_event *event); | |
e64957da | 746 | |
63629d86 FD |
747 | int lttng_trigger_enable(struct lttng_trigger *trigger); |
748 | int lttng_trigger_disable(struct lttng_trigger *trigger); | |
749 | ||
a90917c3 MD |
750 | void lttng_transport_register(struct lttng_transport *transport); |
751 | void lttng_transport_unregister(struct lttng_transport *transport); | |
11b5a3c2 | 752 | |
360f38ea | 753 | void synchronize_trace(void); |
80996790 | 754 | int lttng_abi_init(void); |
6dccd6c1 | 755 | int lttng_abi_compat_old_init(void); |
80996790 | 756 | void lttng_abi_exit(void); |
6dccd6c1 | 757 | void lttng_abi_compat_old_exit(void); |
1c25284c | 758 | |
a90917c3 MD |
759 | int lttng_probe_register(struct lttng_probe_desc *desc); |
760 | void lttng_probe_unregister(struct lttng_probe_desc *desc); | |
63629d86 FD |
761 | const struct lttng_event_desc *lttng_event_desc_get(const char *name); |
762 | void lttng_event_desc_put(const struct lttng_event_desc *desc); | |
a90917c3 MD |
763 | int lttng_probes_init(void); |
764 | void lttng_probes_exit(void); | |
1ec65de1 | 765 | |
b3b8072b MD |
766 | int lttng_metadata_output_channel(struct lttng_metadata_stream *stream, |
767 | struct channel *chan); | |
d83004aa | 768 | |
d1f652f8 MD |
769 | int lttng_id_tracker_get_node_id(const struct lttng_id_hash_node *node); |
770 | int lttng_id_tracker_empty_set(struct lttng_id_tracker *lf); | |
771 | void lttng_id_tracker_destroy(struct lttng_id_tracker *lf, bool rcu); | |
772 | bool lttng_id_tracker_lookup(struct lttng_id_tracker_rcu *p, int id); | |
773 | int lttng_id_tracker_add(struct lttng_id_tracker *lf, int id); | |
774 | int lttng_id_tracker_del(struct lttng_id_tracker *lf, int id); | |
e0130fab | 775 | |
d1f652f8 MD |
776 | int lttng_session_track_id(struct lttng_session *session, |
777 | enum tracker_type tracker_type, int id); | |
778 | int lttng_session_untrack_id(struct lttng_session *session, | |
779 | enum tracker_type tracker_type, int id); | |
e0130fab | 780 | |
d1f652f8 MD |
781 | int lttng_session_list_tracker_ids(struct lttng_session *session, |
782 | enum tracker_type tracker_type); | |
7e6f9ef6 | 783 | |
2754583e MD |
784 | void lttng_clock_ref(void); |
785 | void lttng_clock_unref(void); | |
786 | ||
63629d86 FD |
787 | int lttng_desc_match_enabler(const struct lttng_event_desc *desc, |
788 | struct lttng_enabler *enabler); | |
789 | ||
3a523f5b | 790 | #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS) |
63629d86 FD |
791 | int lttng_syscalls_register_event(struct lttng_channel *chan, void *filter); |
792 | int lttng_syscalls_unregister_event(struct lttng_channel *chan); | |
793 | int lttng_syscall_filter_enable_event(struct lttng_channel *chan, | |
80f87dd2 | 794 | const char *name); |
63629d86 | 795 | int lttng_syscall_filter_disable_event(struct lttng_channel *chan, |
80f87dd2 | 796 | const char *name); |
12e579db MD |
797 | long lttng_channel_syscall_mask(struct lttng_channel *channel, |
798 | struct lttng_kernel_syscall_mask __user *usyscall_mask); | |
63629d86 FD |
799 | |
800 | int lttng_syscalls_register_trigger(struct lttng_trigger_enabler *trigger_enabler, void *filter); | |
801 | int lttng_syscals_create_matching_triggers(struct lttng_trigger_enabler *trigger_enabler, void *filter); | |
802 | int lttng_syscalls_unregister_trigger(struct lttng_trigger_group *group); | |
803 | int lttng_syscall_filter_enable_trigger(struct lttng_trigger *trigger); | |
804 | int lttng_syscall_filter_disable_trigger(struct lttng_trigger *trigger); | |
1ec65de1 | 805 | #else |
63629d86 FD |
806 | static inline int lttng_syscalls_register_event( |
807 | struct lttng_channel *chan, void *filter) | |
1ec65de1 MD |
808 | { |
809 | return -ENOSYS; | |
810 | } | |
811 | ||
63629d86 | 812 | static inline int lttng_syscalls_unregister_event(struct lttng_channel *chan) |
1ec65de1 MD |
813 | { |
814 | return 0; | |
815 | } | |
80f87dd2 | 816 | |
63629d86 | 817 | static inline int lttng_syscall_filter_enable_event(struct lttng_channel *chan, |
80f87dd2 MD |
818 | const char *name) |
819 | { | |
820 | return -ENOSYS; | |
821 | } | |
822 | ||
63629d86 | 823 | static inline int lttng_syscall_filter_disable_event(struct lttng_channel *chan, |
80f87dd2 MD |
824 | const char *name) |
825 | { | |
826 | return -ENOSYS; | |
827 | } | |
12e579db | 828 | |
f127e61e | 829 | static inline long lttng_channel_syscall_mask(struct lttng_channel *channel, |
12e579db MD |
830 | struct lttng_kernel_syscall_mask __user *usyscall_mask) |
831 | { | |
832 | return -ENOSYS; | |
833 | } | |
63629d86 FD |
834 | |
835 | static inline int lttng_syscalls_register_trigger( | |
836 | struct lttng_trigger_group *group, void *filter) | |
837 | { | |
838 | return -ENOSYS; | |
839 | } | |
840 | ||
841 | static inline int lttng_syscalls_unregister_trigger(struct lttng_trigger_group *group) | |
842 | { | |
843 | return 0; | |
844 | } | |
845 | ||
846 | static inline int lttng_syscall_filter_enable_trigger(struct lttng_trigger_group *group, | |
847 | const char *name) | |
848 | { | |
849 | return -ENOSYS; | |
850 | } | |
851 | ||
852 | static inline int lttng_syscall_filter_disable_trigger(struct lttng_trigger_group *group, | |
853 | const char *name) | |
854 | { | |
855 | return -ENOSYS; | |
856 | } | |
857 | ||
1ec65de1 MD |
858 | #endif |
859 | ||
07dfc1d0 | 860 | void lttng_filter_sync_state(struct lttng_bytecode_runtime *runtime); |
63629d86 FD |
861 | int lttng_event_enabler_attach_bytecode(struct lttng_event_enabler *event_enabler, |
862 | struct lttng_kernel_filter_bytecode __user *bytecode); | |
863 | int lttng_trigger_enabler_attach_bytecode(struct lttng_trigger_enabler *trigger_enabler, | |
07dfc1d0 | 864 | struct lttng_kernel_filter_bytecode __user *bytecode); |
63629d86 FD |
865 | |
866 | void lttng_enabler_link_bytecode(const struct lttng_event_desc *event_desc, | |
867 | struct lttng_ctx *ctx, | |
868 | struct list_head *bytecode_runtime_head, | |
f127e61e | 869 | struct lttng_enabler *enabler); |
07dfc1d0 | 870 | |
114667d5 MD |
871 | int lttng_probes_init(void); |
872 | ||
07dfc1d0 MD |
873 | extern struct lttng_ctx *lttng_static_ctx; |
874 | ||
875 | int lttng_context_init(void); | |
876 | void lttng_context_exit(void); | |
2dccf128 | 877 | struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx); |
a9dd15da | 878 | void lttng_context_update(struct lttng_ctx *ctx); |
44252f0f | 879 | int lttng_find_context(struct lttng_ctx *ctx, const char *name); |
07dfc1d0 | 880 | int lttng_get_context_index(struct lttng_ctx *ctx, const char *name); |
8289661d MD |
881 | void lttng_remove_context_field(struct lttng_ctx **ctx, |
882 | struct lttng_ctx_field *field); | |
2dccf128 | 883 | void lttng_destroy_context(struct lttng_ctx *ctx); |
8070f5c0 | 884 | int lttng_add_pid_to_ctx(struct lttng_ctx **ctx); |
b3699d90 | 885 | int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx); |
a2563e83 | 886 | int lttng_add_procname_to_ctx(struct lttng_ctx **ctx); |
a8ad3613 | 887 | int lttng_add_prio_to_ctx(struct lttng_ctx **ctx); |
53f1f0ca | 888 | int lttng_add_nice_to_ctx(struct lttng_ctx **ctx); |
b64bc438 MD |
889 | int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx); |
890 | int lttng_add_tid_to_ctx(struct lttng_ctx **ctx); | |
891 | int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx); | |
892 | int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx); | |
893 | int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx); | |
975da2c0 | 894 | int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx); |
79150a49 JD |
895 | int lttng_add_interruptible_to_ctx(struct lttng_ctx **ctx); |
896 | int lttng_add_need_reschedule_to_ctx(struct lttng_ctx **ctx); | |
897 | #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT) | |
898 | int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx); | |
899 | #else | |
900 | static inline | |
901 | int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx) | |
902 | { | |
903 | return -ENOSYS; | |
904 | } | |
905 | #endif | |
906 | #ifdef CONFIG_PREEMPT_RT_FULL | |
907 | int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx); | |
908 | #else | |
909 | static inline | |
910 | int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx) | |
911 | { | |
912 | return -ENOSYS; | |
913 | } | |
914 | #endif | |
2fa2d39a FG |
915 | |
916 | int lttng_add_callstack_to_ctx(struct lttng_ctx **ctx, int type); | |
917 | ||
a6cf40a4 MJ |
918 | #if defined(CONFIG_CGROUPS) && \ |
919 | ((LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) || \ | |
920 | LTTNG_UBUNTU_KERNEL_RANGE(4,4,0,0, 4,5,0,0)) | |
921 | int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx); | |
922 | #else | |
923 | static inline | |
924 | int lttng_add_cgroup_ns_to_ctx(struct lttng_ctx **ctx) | |
925 | { | |
926 | return -ENOSYS; | |
927 | } | |
928 | #endif | |
929 | ||
930 | #if defined(CONFIG_IPC_NS) && \ | |
931 | (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) | |
932 | int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx); | |
933 | #else | |
934 | static inline | |
935 | int lttng_add_ipc_ns_to_ctx(struct lttng_ctx **ctx) | |
936 | { | |
937 | return -ENOSYS; | |
938 | } | |
939 | #endif | |
940 | ||
941 | #if !defined(LTTNG_MNT_NS_MISSING_HEADER) && \ | |
942 | (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) | |
943 | int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx); | |
944 | #else | |
945 | static inline | |
946 | int lttng_add_mnt_ns_to_ctx(struct lttng_ctx **ctx) | |
947 | { | |
948 | return -ENOSYS; | |
949 | } | |
950 | #endif | |
951 | ||
952 | #if defined(CONFIG_NET_NS) && \ | |
953 | (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) | |
954 | int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx); | |
955 | #else | |
956 | static inline | |
957 | int lttng_add_net_ns_to_ctx(struct lttng_ctx **ctx) | |
958 | { | |
959 | return -ENOSYS; | |
960 | } | |
961 | #endif | |
962 | ||
963 | #if defined(CONFIG_PID_NS) && \ | |
964 | (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) | |
965 | int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx); | |
966 | #else | |
967 | static inline | |
968 | int lttng_add_pid_ns_to_ctx(struct lttng_ctx **ctx) | |
969 | { | |
970 | return -ENOSYS; | |
971 | } | |
972 | #endif | |
973 | ||
974 | #if defined(CONFIG_USER_NS) && \ | |
975 | (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) | |
976 | int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx); | |
977 | #else | |
978 | static inline | |
979 | int lttng_add_user_ns_to_ctx(struct lttng_ctx **ctx) | |
980 | { | |
981 | return -ENOSYS; | |
982 | } | |
983 | #endif | |
984 | ||
985 | #if defined(CONFIG_UTS_NS) && \ | |
986 | (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) | |
987 | int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx); | |
988 | #else | |
989 | static inline | |
990 | int lttng_add_uts_ns_to_ctx(struct lttng_ctx **ctx) | |
991 | { | |
992 | return -ENOSYS; | |
993 | } | |
994 | #endif | |
995 | ||
dc923e75 MJ |
996 | int lttng_add_uid_to_ctx(struct lttng_ctx **ctx); |
997 | int lttng_add_euid_to_ctx(struct lttng_ctx **ctx); | |
998 | int lttng_add_suid_to_ctx(struct lttng_ctx **ctx); | |
999 | int lttng_add_gid_to_ctx(struct lttng_ctx **ctx); | |
1000 | int lttng_add_egid_to_ctx(struct lttng_ctx **ctx); | |
1001 | int lttng_add_sgid_to_ctx(struct lttng_ctx **ctx); | |
1002 | int lttng_add_vuid_to_ctx(struct lttng_ctx **ctx); | |
1003 | int lttng_add_veuid_to_ctx(struct lttng_ctx **ctx); | |
1004 | int lttng_add_vsuid_to_ctx(struct lttng_ctx **ctx); | |
1005 | int lttng_add_vgid_to_ctx(struct lttng_ctx **ctx); | |
1006 | int lttng_add_vegid_to_ctx(struct lttng_ctx **ctx); | |
1007 | int lttng_add_vsgid_to_ctx(struct lttng_ctx **ctx); | |
1008 | ||
8a3af9ee | 1009 | #if defined(CONFIG_PERF_EVENTS) |
c24a0d71 MD |
1010 | int lttng_add_perf_counter_to_ctx(uint32_t type, |
1011 | uint64_t config, | |
1012 | const char *name, | |
1013 | struct lttng_ctx **ctx); | |
1e367326 MD |
1014 | int lttng_cpuhp_perf_counter_online(unsigned int cpu, |
1015 | struct lttng_cpuhp_node *node); | |
1016 | int lttng_cpuhp_perf_counter_dead(unsigned int cpu, | |
1017 | struct lttng_cpuhp_node *node); | |
1d443b34 MD |
1018 | #else |
1019 | static inline | |
1020 | int lttng_add_perf_counter_to_ctx(uint32_t type, | |
1021 | uint64_t config, | |
1022 | const char *name, | |
1023 | struct lttng_ctx **ctx) | |
1024 | { | |
1025 | return -ENOSYS; | |
1026 | } | |
1e367326 MD |
1027 | static inline |
1028 | int lttng_cpuhp_perf_counter_online(unsigned int cpu, | |
1029 | struct lttng_cpuhp_node *node) | |
1030 | { | |
1031 | return 0; | |
1032 | } | |
1033 | static inline | |
1034 | int lttng_cpuhp_perf_counter_dead(unsigned int cpu, | |
1035 | struct lttng_cpuhp_node *node) | |
1036 | { | |
1037 | return 0; | |
1038 | } | |
1d443b34 | 1039 | #endif |
02119ee5 | 1040 | |
0c956676 MD |
1041 | int lttng_logger_init(void); |
1042 | void lttng_logger_exit(void); | |
1043 | ||
c337ddc2 MD |
1044 | extern int lttng_statedump_start(struct lttng_session *session); |
1045 | ||
acd614cc | 1046 | #ifdef CONFIG_KPROBES |
63629d86 | 1047 | int lttng_kprobes_register_event(const char *name, |
f17701fb MD |
1048 | const char *symbol_name, |
1049 | uint64_t offset, | |
1050 | uint64_t addr, | |
a90917c3 | 1051 | struct lttng_event *event); |
63629d86 FD |
1052 | void lttng_kprobes_unregister_event(struct lttng_event *event); |
1053 | void lttng_kprobes_destroy_event_private(struct lttng_event *event); | |
1054 | int lttng_kprobes_register_trigger(const char *symbol_name, | |
1055 | uint64_t offset, | |
1056 | uint64_t addr, | |
1057 | struct lttng_trigger *trigger); | |
1058 | void lttng_kprobes_unregister_trigger(struct lttng_trigger *trigger); | |
1059 | void lttng_kprobes_destroy_trigger_private(struct lttng_trigger *trigger); | |
acd614cc MD |
1060 | #else |
1061 | static inline | |
63629d86 | 1062 | int lttng_kprobes_register_event(const char *name, |
acd614cc MD |
1063 | const char *symbol_name, |
1064 | uint64_t offset, | |
1065 | uint64_t addr, | |
a90917c3 | 1066 | struct lttng_event *event) |
acd614cc MD |
1067 | { |
1068 | return -ENOSYS; | |
1069 | } | |
1070 | ||
25f53c39 | 1071 | static inline |
63629d86 | 1072 | void lttng_kprobes_unregister_event(struct lttng_event *event) |
acd614cc MD |
1073 | { |
1074 | } | |
edeb3137 MD |
1075 | |
1076 | static inline | |
63629d86 FD |
1077 | void lttng_kprobes_destroy_event_private(struct lttng_event *event) |
1078 | { | |
1079 | } | |
1080 | ||
1081 | static inline | |
1082 | int lttng_kprobes_register_trigger(const char *symbol_name, | |
1083 | uint64_t offset, | |
1084 | uint64_t addr, | |
1085 | struct lttng_trigger *trigger) | |
1086 | { | |
1087 | return -ENOSYS; | |
1088 | } | |
1089 | ||
1090 | static inline | |
1091 | void lttng_kprobes_unregister_trigger(struct lttng_trigger *trigger) | |
1092 | { | |
1093 | } | |
1094 | ||
1095 | static inline | |
1096 | void lttng_kprobes_destroy_trigger_private(struct lttng_trigger *trigger) | |
edeb3137 MD |
1097 | { |
1098 | } | |
acd614cc | 1099 | #endif |
d6d808f3 | 1100 | |
3aed4dca FD |
1101 | int lttng_event_add_callsite(struct lttng_event *event, |
1102 | struct lttng_kernel_event_callsite *callsite); | |
e33fc900 | 1103 | |
63629d86 FD |
1104 | int lttng_trigger_add_callsite(struct lttng_trigger *trigger, |
1105 | struct lttng_kernel_event_callsite *callsite); | |
1106 | ||
149b9a9d | 1107 | #ifdef CONFIG_UPROBES |
63629d86 | 1108 | int lttng_uprobes_register_event(const char *name, |
3aed4dca | 1109 | int fd, struct lttng_event *event); |
63629d86 | 1110 | int lttng_uprobes_event_add_callsite(struct lttng_event *event, |
3aed4dca | 1111 | struct lttng_kernel_event_callsite *callsite); |
63629d86 FD |
1112 | void lttng_uprobes_unregister_event(struct lttng_event *event); |
1113 | void lttng_uprobes_destroy_event_private(struct lttng_event *event); | |
1114 | int lttng_uprobes_register_trigger(const char *name, | |
1115 | int fd, struct lttng_trigger *trigger); | |
1116 | int lttng_uprobes_trigger_add_callsite(struct lttng_trigger *trigger, | |
1117 | struct lttng_kernel_event_callsite *callsite); | |
1118 | void lttng_uprobes_unregister_trigger(struct lttng_trigger *trigger); | |
1119 | void lttng_uprobes_destroy_trigger_private(struct lttng_trigger *trigger); | |
149b9a9d YB |
1120 | #else |
1121 | static inline | |
63629d86 | 1122 | int lttng_uprobes_register_event(const char *name, |
3aed4dca FD |
1123 | int fd, struct lttng_event *event) |
1124 | { | |
1125 | return -ENOSYS; | |
1126 | } | |
1127 | ||
1128 | static inline | |
63629d86 FD |
1129 | int lttng_uprobes_event_add_callsite(struct lttng_event *event, |
1130 | struct lttng_kernel_event_callsite *callsite) | |
1131 | { | |
1132 | return -ENOSYS; | |
1133 | } | |
1134 | ||
1135 | static inline | |
1136 | void lttng_uprobes_unregister_event(struct lttng_event *event) | |
1137 | { | |
1138 | } | |
1139 | ||
1140 | static inline | |
1141 | void lttng_uprobes_destroy_event_private(struct lttng_event *event) | |
1142 | { | |
1143 | } | |
1144 | ||
1145 | static inline | |
1146 | int lttng_uprobes_register_trigger(const char *name, | |
1147 | int fd, struct lttng_trigger *trigger) | |
1148 | { | |
1149 | return -ENOSYS; | |
1150 | } | |
1151 | ||
1152 | static inline | |
1153 | int lttng_uprobes_trigger_add_callsite(struct lttng_trigger *trigger, | |
e33fc900 | 1154 | struct lttng_kernel_event_callsite *callsite) |
149b9a9d YB |
1155 | { |
1156 | return -ENOSYS; | |
1157 | } | |
1158 | ||
1159 | static inline | |
63629d86 | 1160 | void lttng_uprobes_unregister_trigger(struct lttng_trigger *trigger) |
149b9a9d YB |
1161 | { |
1162 | } | |
1163 | ||
1164 | static inline | |
63629d86 | 1165 | void lttng_uprobes_destroy_trigger_private(struct lttng_trigger *trigger) |
149b9a9d YB |
1166 | { |
1167 | } | |
1168 | #endif | |
1169 | ||
7371f44c MD |
1170 | #ifdef CONFIG_KRETPROBES |
1171 | int lttng_kretprobes_register(const char *name, | |
1172 | const char *symbol_name, | |
1173 | uint64_t offset, | |
1174 | uint64_t addr, | |
a90917c3 MD |
1175 | struct lttng_event *event_entry, |
1176 | struct lttng_event *event_exit); | |
1177 | void lttng_kretprobes_unregister(struct lttng_event *event); | |
1178 | void lttng_kretprobes_destroy_private(struct lttng_event *event); | |
a0493bef MD |
1179 | int lttng_kretprobes_event_enable_state(struct lttng_event *event, |
1180 | int enable); | |
7371f44c MD |
1181 | #else |
1182 | static inline | |
1183 | int lttng_kretprobes_register(const char *name, | |
1184 | const char *symbol_name, | |
1185 | uint64_t offset, | |
1186 | uint64_t addr, | |
a90917c3 MD |
1187 | struct lttng_event *event_entry, |
1188 | struct lttng_event *event_exit) | |
7371f44c MD |
1189 | { |
1190 | return -ENOSYS; | |
1191 | } | |
1192 | ||
1193 | static inline | |
a90917c3 | 1194 | void lttng_kretprobes_unregister(struct lttng_event *event) |
7371f44c MD |
1195 | { |
1196 | } | |
1197 | ||
1198 | static inline | |
a90917c3 | 1199 | void lttng_kretprobes_destroy_private(struct lttng_event *event) |
7371f44c MD |
1200 | { |
1201 | } | |
a0493bef MD |
1202 | |
1203 | static inline | |
1204 | int lttng_kretprobes_event_enable_state(struct lttng_event *event, | |
1205 | int enable) | |
1206 | { | |
1207 | return -ENOSYS; | |
1208 | } | |
7371f44c MD |
1209 | #endif |
1210 | ||
f61d99f9 | 1211 | #if defined(CONFIG_DYNAMIC_FTRACE) && !defined(LTTNG_FTRACE_MISSING_HEADER) |
e0a7a7c4 MD |
1212 | int lttng_ftrace_register(const char *name, |
1213 | const char *symbol_name, | |
a90917c3 MD |
1214 | struct lttng_event *event); |
1215 | void lttng_ftrace_unregister(struct lttng_event *event); | |
1216 | void lttng_ftrace_destroy_private(struct lttng_event *event); | |
e0a7a7c4 MD |
1217 | #else |
1218 | static inline | |
1219 | int lttng_ftrace_register(const char *name, | |
1220 | const char *symbol_name, | |
a90917c3 | 1221 | struct lttng_event *event) |
e0a7a7c4 | 1222 | { |
acd614cc | 1223 | return -ENOSYS; |
e0a7a7c4 MD |
1224 | } |
1225 | ||
1226 | static inline | |
a90917c3 | 1227 | void lttng_ftrace_unregister(struct lttng_event *event) |
e0a7a7c4 MD |
1228 | { |
1229 | } | |
edeb3137 MD |
1230 | |
1231 | static inline | |
a90917c3 | 1232 | void lttng_ftrace_destroy_private(struct lttng_event *event) |
edeb3137 MD |
1233 | { |
1234 | } | |
e0a7a7c4 | 1235 | #endif |
271b6681 | 1236 | |
3db41b2c | 1237 | int lttng_calibrate(struct lttng_kernel_calibrate *calibrate); |
57105fc2 | 1238 | |
271b6681 | 1239 | extern const struct file_operations lttng_tracepoint_list_fops; |
2d2464bd | 1240 | extern const struct file_operations lttng_syscall_list_fops; |
271b6681 | 1241 | |
ef200626 | 1242 | #define TRACEPOINT_HAS_DATA_ARG |
ef200626 | 1243 | |
a90917c3 | 1244 | #endif /* _LTTNG_EVENTS_H */ |