Fix: timer_expire_entry changed in 4.19.312
[lttng-modules.git] / lttng-events.h
1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
2 *
3 * lttng-events.h
4 *
5 * Holds LTTng per-session event registry.
6 *
7 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 */
9
10 #ifndef _LTTNG_EVENTS_H
11 #define _LTTNG_EVENTS_H
12
13 #include <linux/version.h>
14 #include <linux/list.h>
15 #include <linux/kprobes.h>
16 #include <linux/kref.h>
17 #include <lttng-cpuhotplug.h>
18 #include <wrapper/uuid.h>
19 #include <lttng-tracer.h>
20 #include <lttng-abi.h>
21 #include <lttng-abi-old.h>
22
23 #define lttng_is_signed_type(type) (((type)(-1)) < 0)
24
25 struct lttng_channel;
26 struct lttng_session;
27 struct lttng_metadata_cache;
28 struct lib_ring_buffer_ctx;
29 struct perf_event;
30 struct perf_event_attr;
31 struct lib_ring_buffer_config;
32
33 /* Type description */
34
35 enum abstract_types {
36 atype_integer,
37 atype_enum,
38 atype_array,
39 atype_sequence,
40 atype_string,
41 atype_struct,
42 atype_array_compound, /* Array of compound types. */
43 atype_sequence_compound, /* Sequence of compound types. */
44 atype_variant,
45 atype_array_bitfield,
46 atype_sequence_bitfield,
47 NR_ABSTRACT_TYPES,
48 };
49
50 enum lttng_string_encodings {
51 lttng_encode_none = 0,
52 lttng_encode_UTF8 = 1,
53 lttng_encode_ASCII = 2,
54 NR_STRING_ENCODINGS,
55 };
56
57 enum channel_type {
58 PER_CPU_CHANNEL,
59 METADATA_CHANNEL,
60 };
61
62 struct lttng_enum_value {
63 unsigned long long value;
64 unsigned int signedness:1;
65 };
66
67 struct lttng_enum_entry {
68 struct lttng_enum_value start, end; /* start and end are inclusive */
69 const char *string;
70 struct {
71 unsigned int is_auto:1;
72 } options;
73 };
74
75 #define __type_integer(_type, _size, _alignment, _signedness, \
76 _byte_order, _base, _encoding) \
77 { \
78 .atype = atype_integer, \
79 .u.basic.integer = \
80 { \
81 .size = (_size) ? : sizeof(_type) * CHAR_BIT, \
82 .alignment = (_alignment) ? : lttng_alignof(_type) * CHAR_BIT, \
83 .signedness = (_signedness) >= 0 ? (_signedness) : lttng_is_signed_type(_type), \
84 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
85 .base = _base, \
86 .encoding = lttng_encode_##_encoding, \
87 }, \
88 } \
89
90 struct lttng_integer_type {
91 unsigned int size; /* in bits */
92 unsigned short alignment; /* in bits */
93 unsigned int signedness:1,
94 reverse_byte_order:1;
95 unsigned int base; /* 2, 8, 10, 16, for pretty print */
96 enum lttng_string_encodings encoding;
97 };
98
99 union _lttng_basic_type {
100 struct lttng_integer_type integer;
101 struct {
102 const struct lttng_enum_desc *desc; /* Enumeration mapping */
103 struct lttng_integer_type container_type;
104 } enumeration;
105 struct {
106 enum lttng_string_encodings encoding;
107 } string;
108 };
109
110 struct lttng_basic_type {
111 enum abstract_types atype;
112 union {
113 union _lttng_basic_type basic;
114 } u;
115 };
116
117 struct lttng_type {
118 enum abstract_types atype;
119 union {
120 union _lttng_basic_type basic;
121 struct {
122 struct lttng_basic_type elem_type;
123 unsigned int length; /* num. elems. */
124 unsigned int elem_alignment; /* alignment override */
125 } array;
126 struct {
127 struct lttng_basic_type length_type;
128 struct lttng_basic_type elem_type;
129 unsigned int elem_alignment; /* alignment override */
130 } sequence;
131 struct {
132 uint32_t nr_fields;
133 struct lttng_event_field *fields; /* Array of fields. */
134 } _struct;
135 struct {
136 struct lttng_type *elem_type;
137 unsigned int length; /* num. elems. */
138 } array_compound;
139 struct {
140 struct lttng_type *elem_type;
141 const char *length_name;
142 } sequence_compound;
143 struct {
144 const char *tag_name;
145 struct lttng_event_field *choices; /* Array of fields. */
146 uint32_t nr_choices;
147 } variant;
148 } u;
149 };
150
151 struct lttng_enum_desc {
152 const char *name;
153 const struct lttng_enum_entry *entries;
154 unsigned int nr_entries;
155 };
156
157 /* Event field description */
158
159 struct lttng_event_field {
160 const char *name;
161 struct lttng_type type;
162 unsigned int nowrite:1, /* do not write into trace */
163 user:1; /* fetch from user-space */
164 };
165
166 union lttng_ctx_value {
167 int64_t s64;
168 const char *str;
169 double d;
170 };
171
172 /*
173 * We need to keep this perf counter field separately from struct
174 * lttng_ctx_field because cpu hotplug needs fixed-location addresses.
175 */
176 struct lttng_perf_counter_field {
177 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0))
178 struct lttng_cpuhp_node cpuhp_prepare;
179 struct lttng_cpuhp_node cpuhp_online;
180 #else
181 struct notifier_block nb;
182 int hp_enable;
183 #endif
184 struct perf_event_attr *attr;
185 struct perf_event **e; /* per-cpu array */
186 };
187
188 struct lttng_probe_ctx {
189 struct lttng_event *event;
190 uint8_t interruptible;
191 };
192
193 struct lttng_ctx_field {
194 struct lttng_event_field event_field;
195 size_t (*get_size)(size_t offset);
196 size_t (*get_size_arg)(size_t offset, struct lttng_ctx_field *field,
197 struct lib_ring_buffer_ctx *ctx,
198 struct lttng_channel *chan);
199 void (*record)(struct lttng_ctx_field *field,
200 struct lib_ring_buffer_ctx *ctx,
201 struct lttng_channel *chan);
202 void (*get_value)(struct lttng_ctx_field *field,
203 struct lttng_probe_ctx *lttng_probe_ctx,
204 union lttng_ctx_value *value);
205 union {
206 struct lttng_perf_counter_field *perf_counter;
207 } u;
208 void (*destroy)(struct lttng_ctx_field *field);
209 /*
210 * Private data to keep state between get_size and record.
211 * User must perform its own synchronization to protect against
212 * concurrent and reentrant contexts.
213 */
214 void *priv;
215 };
216
217 struct lttng_ctx {
218 struct lttng_ctx_field *fields;
219 unsigned int nr_fields;
220 unsigned int allocated_fields;
221 size_t largest_align; /* in bytes */
222 };
223
224 struct lttng_event_desc {
225 const char *name; /* lttng-modules name */
226 const char *kname; /* Linux kernel name (tracepoints) */
227 void *probe_callback;
228 const struct lttng_event_ctx *ctx; /* context */
229 const struct lttng_event_field *fields; /* event payload */
230 unsigned int nr_fields;
231 struct module *owner;
232 };
233
234 struct lttng_probe_desc {
235 const char *provider;
236 const struct lttng_event_desc **event_desc;
237 unsigned int nr_events;
238 struct list_head head; /* chain registered probes */
239 struct list_head lazy_init_head;
240 int lazy; /* lazy registration */
241 };
242
243 struct lttng_krp; /* Kretprobe handling */
244
245 enum lttng_event_type {
246 LTTNG_TYPE_EVENT = 0,
247 LTTNG_TYPE_ENABLER = 1,
248 };
249
250 struct lttng_filter_bytecode_node {
251 struct list_head node;
252 struct lttng_enabler *enabler;
253 /*
254 * struct lttng_kernel_filter_bytecode has var. sized array, must be
255 * last field.
256 */
257 struct lttng_kernel_filter_bytecode bc;
258 };
259
260 /*
261 * Filter return value masks.
262 */
263 enum lttng_filter_ret {
264 LTTNG_FILTER_DISCARD = 0,
265 LTTNG_FILTER_RECORD_FLAG = (1ULL << 0),
266 /* Other bits are kept for future use. */
267 };
268
269 struct lttng_bytecode_runtime {
270 /* Associated bytecode */
271 struct lttng_filter_bytecode_node *bc;
272 uint64_t (*filter)(void *filter_data, struct lttng_probe_ctx *lttng_probe_ctx,
273 const char *filter_stack_data);
274 int link_failed;
275 struct list_head node; /* list of bytecode runtime in event */
276 struct lttng_event *event;
277 };
278
279 /*
280 * Objects in a linked-list of enablers, owned by an event.
281 */
282 struct lttng_enabler_ref {
283 struct list_head node; /* enabler ref list */
284 struct lttng_enabler *ref; /* backward ref */
285 };
286
287 /*
288 * lttng_event structure is referred to by the tracing fast path. It must be
289 * kept small.
290 */
291 struct lttng_event {
292 enum lttng_event_type evtype; /* First field. */
293 unsigned int id;
294 struct lttng_channel *chan;
295 int enabled;
296 const struct lttng_event_desc *desc;
297 void *filter;
298 struct lttng_ctx *ctx;
299 enum lttng_kernel_instrumentation instrumentation;
300 union {
301 struct {
302 struct kprobe kp;
303 char *symbol_name;
304 } kprobe;
305 struct {
306 struct lttng_krp *lttng_krp;
307 char *symbol_name;
308 } kretprobe;
309 struct {
310 char *symbol_name;
311 } ftrace;
312 } u;
313 struct list_head list; /* Event list in session */
314 unsigned int metadata_dumped:1;
315
316 /* Backward references: list of lttng_enabler_ref (ref to enablers) */
317 struct list_head enablers_ref_head;
318 struct hlist_node hlist; /* session ht of events */
319 int registered; /* has reg'd tracepoint probe */
320 /* list of struct lttng_bytecode_runtime, sorted by seqnum */
321 struct list_head bytecode_runtime_head;
322 int has_enablers_without_bytecode;
323 };
324
325 enum lttng_enabler_type {
326 LTTNG_ENABLER_STAR_GLOB,
327 LTTNG_ENABLER_NAME,
328 };
329
330 /*
331 * Enabler field, within whatever object is enabling an event. Target of
332 * backward reference.
333 */
334 struct lttng_enabler {
335 enum lttng_event_type evtype; /* First field. */
336
337 enum lttng_enabler_type type;
338
339 struct list_head node; /* per-session list of enablers */
340 /* head list of struct lttng_ust_filter_bytecode_node */
341 struct list_head filter_bytecode_head;
342
343 struct lttng_kernel_event event_param;
344 struct lttng_channel *chan;
345 struct lttng_ctx *ctx;
346 unsigned int enabled:1;
347 };
348
349 struct lttng_channel_ops {
350 struct channel *(*channel_create)(const char *name,
351 struct lttng_channel *lttng_chan,
352 void *buf_addr,
353 size_t subbuf_size, size_t num_subbuf,
354 unsigned int switch_timer_interval,
355 unsigned int read_timer_interval);
356 void (*channel_destroy)(struct channel *chan);
357 struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
358 int (*buffer_has_read_closed_stream)(struct channel *chan);
359 void (*buffer_read_close)(struct lib_ring_buffer *buf);
360 int (*event_reserve)(struct lib_ring_buffer_ctx *ctx,
361 uint32_t event_id);
362 void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
363 void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
364 size_t len);
365 void (*event_write_from_user)(struct lib_ring_buffer_ctx *ctx,
366 const void *src, size_t len);
367 void (*event_memset)(struct lib_ring_buffer_ctx *ctx,
368 int c, size_t len);
369 void (*event_strcpy)(struct lib_ring_buffer_ctx *ctx, const char *src,
370 size_t len);
371 void (*event_strcpy_from_user)(struct lib_ring_buffer_ctx *ctx,
372 const char __user *src, size_t len);
373 /*
374 * packet_avail_size returns the available size in the current
375 * packet. Note that the size returned is only a hint, since it
376 * may change due to concurrent writes.
377 */
378 size_t (*packet_avail_size)(struct channel *chan);
379 wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu);
380 wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
381 int (*is_finalized)(struct channel *chan);
382 int (*is_disabled)(struct channel *chan);
383 int (*timestamp_begin) (const struct lib_ring_buffer_config *config,
384 struct lib_ring_buffer *bufb,
385 uint64_t *timestamp_begin);
386 int (*timestamp_end) (const struct lib_ring_buffer_config *config,
387 struct lib_ring_buffer *bufb,
388 uint64_t *timestamp_end);
389 int (*events_discarded) (const struct lib_ring_buffer_config *config,
390 struct lib_ring_buffer *bufb,
391 uint64_t *events_discarded);
392 int (*content_size) (const struct lib_ring_buffer_config *config,
393 struct lib_ring_buffer *bufb,
394 uint64_t *content_size);
395 int (*packet_size) (const struct lib_ring_buffer_config *config,
396 struct lib_ring_buffer *bufb,
397 uint64_t *packet_size);
398 int (*stream_id) (const struct lib_ring_buffer_config *config,
399 struct lib_ring_buffer *bufb,
400 uint64_t *stream_id);
401 int (*current_timestamp) (const struct lib_ring_buffer_config *config,
402 struct lib_ring_buffer *bufb,
403 uint64_t *ts);
404 int (*sequence_number) (const struct lib_ring_buffer_config *config,
405 struct lib_ring_buffer *bufb,
406 uint64_t *seq);
407 int (*instance_id) (const struct lib_ring_buffer_config *config,
408 struct lib_ring_buffer *bufb,
409 uint64_t *id);
410 };
411
412 struct lttng_transport {
413 char *name;
414 struct module *owner;
415 struct list_head node;
416 struct lttng_channel_ops ops;
417 };
418
419 struct lttng_syscall_filter;
420
421 #define LTTNG_EVENT_HT_BITS 12
422 #define LTTNG_EVENT_HT_SIZE (1U << LTTNG_EVENT_HT_BITS)
423
424 struct lttng_event_ht {
425 struct hlist_head table[LTTNG_EVENT_HT_SIZE];
426 };
427
428 struct lttng_channel {
429 unsigned int id;
430 struct channel *chan; /* Channel buffers */
431 int enabled;
432 struct lttng_ctx *ctx;
433 /* Event ID management */
434 struct lttng_session *session;
435 struct file *file; /* File associated to channel */
436 unsigned int free_event_id; /* Next event ID to allocate */
437 struct list_head list; /* Channel list */
438 struct lttng_channel_ops *ops;
439 struct lttng_transport *transport;
440 struct lttng_event **sc_table; /* for syscall tracing */
441 struct lttng_event **compat_sc_table;
442 struct lttng_event **sc_exit_table; /* for syscall exit tracing */
443 struct lttng_event **compat_sc_exit_table;
444 struct lttng_event *sc_unknown; /* for unknown syscalls */
445 struct lttng_event *sc_compat_unknown;
446 struct lttng_event *sc_exit_unknown;
447 struct lttng_event *compat_sc_exit_unknown;
448 struct lttng_syscall_filter *sc_filter;
449 int header_type; /* 0: unset, 1: compact, 2: large */
450 enum channel_type channel_type;
451 unsigned int metadata_dumped:1,
452 sys_enter_registered:1,
453 sys_exit_registered:1,
454 syscall_all:1,
455 tstate:1; /* Transient enable state */
456 };
457
458 struct lttng_metadata_stream {
459 void *priv; /* Ring buffer private data */
460 struct lttng_metadata_cache *metadata_cache;
461 unsigned int metadata_in; /* Bytes read from the cache */
462 unsigned int metadata_out; /* Bytes consumed from stream */
463 int finalized; /* Has channel been finalized */
464 wait_queue_head_t read_wait; /* Reader buffer-level wait queue */
465 struct list_head list; /* Stream list */
466 struct lttng_transport *transport;
467 uint64_t version; /* Current version of the metadata cache */
468 };
469
470 #define LTTNG_DYNAMIC_LEN_STACK_SIZE 128
471
472 struct lttng_dynamic_len_stack {
473 size_t stack[LTTNG_DYNAMIC_LEN_STACK_SIZE];
474 size_t offset;
475 };
476
477 DECLARE_PER_CPU(struct lttng_dynamic_len_stack, lttng_dynamic_len_stack);
478
479 /*
480 * struct lttng_pid_tracker declared in header due to deferencing of *v
481 * in RCU_INITIALIZER(v).
482 */
483 #define LTTNG_PID_HASH_BITS 6
484 #define LTTNG_PID_TABLE_SIZE (1 << LTTNG_PID_HASH_BITS)
485
486 struct lttng_pid_tracker {
487 struct hlist_head pid_hash[LTTNG_PID_TABLE_SIZE];
488 };
489
490 struct lttng_pid_hash_node {
491 struct hlist_node hlist;
492 int pid;
493 };
494
495 struct lttng_session {
496 int active; /* Is trace session active ? */
497 int been_active; /* Has trace session been active ? */
498 struct file *file; /* File associated to session */
499 struct list_head chan; /* Channel list head */
500 struct list_head events; /* Event list head */
501 struct list_head list; /* Session list */
502 unsigned int free_chan_id; /* Next chan ID to allocate */
503 uuid_le uuid; /* Trace session unique ID */
504 struct lttng_metadata_cache *metadata_cache;
505 struct lttng_pid_tracker *pid_tracker;
506 unsigned int metadata_dumped:1,
507 tstate:1; /* Transient enable state */
508 /* List of enablers */
509 struct list_head enablers_head;
510 /* Hash table of events */
511 struct lttng_event_ht events_ht;
512 };
513
514 struct lttng_metadata_cache {
515 char *data; /* Metadata cache */
516 unsigned int cache_alloc; /* Metadata allocated size (bytes) */
517 unsigned int metadata_written; /* Number of bytes written in metadata cache */
518 struct kref refcount; /* Metadata cache usage */
519 struct list_head metadata_stream; /* Metadata stream list */
520 uuid_le uuid; /* Trace session unique ID (copy) */
521 struct mutex lock; /* Produce/consume lock */
522 uint64_t version; /* Current version of the metadata */
523 };
524
525 void lttng_lock_sessions(void);
526 void lttng_unlock_sessions(void);
527
528 struct list_head *lttng_get_probe_list_head(void);
529
530 struct lttng_enabler *lttng_enabler_create(enum lttng_enabler_type type,
531 struct lttng_kernel_event *event_param,
532 struct lttng_channel *chan);
533
534 int lttng_enabler_enable(struct lttng_enabler *enabler);
535 int lttng_enabler_disable(struct lttng_enabler *enabler);
536 int lttng_fix_pending_events(void);
537 int lttng_session_active(void);
538
539 struct lttng_session *lttng_session_create(void);
540 int lttng_session_enable(struct lttng_session *session);
541 int lttng_session_disable(struct lttng_session *session);
542 void lttng_session_destroy(struct lttng_session *session);
543 int lttng_session_metadata_regenerate(struct lttng_session *session);
544 int lttng_session_statedump(struct lttng_session *session);
545 void metadata_cache_destroy(struct kref *kref);
546
547 struct lttng_channel *lttng_channel_create(struct lttng_session *session,
548 const char *transport_name,
549 void *buf_addr,
550 size_t subbuf_size, size_t num_subbuf,
551 unsigned int switch_timer_interval,
552 unsigned int read_timer_interval,
553 enum channel_type channel_type);
554 struct lttng_channel *lttng_global_channel_create(struct lttng_session *session,
555 int overwrite, void *buf_addr,
556 size_t subbuf_size, size_t num_subbuf,
557 unsigned int switch_timer_interval,
558 unsigned int read_timer_interval);
559
560 void lttng_metadata_channel_destroy(struct lttng_channel *chan);
561 struct lttng_event *lttng_event_create(struct lttng_channel *chan,
562 struct lttng_kernel_event *event_param,
563 void *filter,
564 const struct lttng_event_desc *event_desc,
565 enum lttng_kernel_instrumentation itype);
566 struct lttng_event *_lttng_event_create(struct lttng_channel *chan,
567 struct lttng_kernel_event *event_param,
568 void *filter,
569 const struct lttng_event_desc *event_desc,
570 enum lttng_kernel_instrumentation itype);
571 struct lttng_event *lttng_event_compat_old_create(struct lttng_channel *chan,
572 struct lttng_kernel_old_event *old_event_param,
573 void *filter,
574 const struct lttng_event_desc *internal_desc);
575
576 int lttng_channel_enable(struct lttng_channel *channel);
577 int lttng_channel_disable(struct lttng_channel *channel);
578 int lttng_event_enable(struct lttng_event *event);
579 int lttng_event_disable(struct lttng_event *event);
580
581 void lttng_transport_register(struct lttng_transport *transport);
582 void lttng_transport_unregister(struct lttng_transport *transport);
583
584 void synchronize_trace(void);
585 int lttng_abi_init(void);
586 int lttng_abi_compat_old_init(void);
587 void lttng_abi_exit(void);
588 void lttng_abi_compat_old_exit(void);
589
590 int lttng_probe_register(struct lttng_probe_desc *desc);
591 void lttng_probe_unregister(struct lttng_probe_desc *desc);
592 const struct lttng_event_desc *lttng_event_get(const char *name);
593 void lttng_event_put(const struct lttng_event_desc *desc);
594 int lttng_probes_init(void);
595 void lttng_probes_exit(void);
596
597 int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
598 struct channel *chan);
599
600 int lttng_pid_tracker_get_node_pid(const struct lttng_pid_hash_node *node);
601 struct lttng_pid_tracker *lttng_pid_tracker_create(void);
602 void lttng_pid_tracker_destroy(struct lttng_pid_tracker *lpf);
603 bool lttng_pid_tracker_lookup(struct lttng_pid_tracker *lpf, int pid);
604 int lttng_pid_tracker_add(struct lttng_pid_tracker *lpf, int pid);
605 int lttng_pid_tracker_del(struct lttng_pid_tracker *lpf, int pid);
606
607 int lttng_session_track_pid(struct lttng_session *session, int pid);
608 int lttng_session_untrack_pid(struct lttng_session *session, int pid);
609
610 int lttng_session_list_tracker_pids(struct lttng_session *session);
611
612 void lttng_clock_ref(void);
613 void lttng_clock_unref(void);
614
615 #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
616 int lttng_syscalls_register(struct lttng_channel *chan, void *filter);
617 int lttng_syscalls_unregister(struct lttng_channel *chan);
618 int lttng_syscall_filter_enable(struct lttng_channel *chan,
619 const char *name);
620 int lttng_syscall_filter_disable(struct lttng_channel *chan,
621 const char *name);
622 long lttng_channel_syscall_mask(struct lttng_channel *channel,
623 struct lttng_kernel_syscall_mask __user *usyscall_mask);
624 #else
625 static inline int lttng_syscalls_register(struct lttng_channel *chan, void *filter)
626 {
627 return -ENOSYS;
628 }
629
630 static inline int lttng_syscalls_unregister(struct lttng_channel *chan)
631 {
632 return 0;
633 }
634
635 static inline int lttng_syscall_filter_enable(struct lttng_channel *chan,
636 const char *name)
637 {
638 return -ENOSYS;
639 }
640
641 static inline int lttng_syscall_filter_disable(struct lttng_channel *chan,
642 const char *name)
643 {
644 return -ENOSYS;
645 }
646
647 static inline long lttng_channel_syscall_mask(struct lttng_channel *channel,
648 struct lttng_kernel_syscall_mask __user *usyscall_mask)
649 {
650 return -ENOSYS;
651 }
652 #endif
653
654 void lttng_filter_sync_state(struct lttng_bytecode_runtime *runtime);
655 int lttng_enabler_attach_bytecode(struct lttng_enabler *enabler,
656 struct lttng_kernel_filter_bytecode __user *bytecode);
657 void lttng_enabler_event_link_bytecode(struct lttng_event *event,
658 struct lttng_enabler *enabler);
659
660 int lttng_probes_init(void);
661
662 extern struct lttng_ctx *lttng_static_ctx;
663
664 int lttng_context_init(void);
665 void lttng_context_exit(void);
666 struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx);
667 void lttng_context_update(struct lttng_ctx *ctx);
668 int lttng_find_context(struct lttng_ctx *ctx, const char *name);
669 int lttng_get_context_index(struct lttng_ctx *ctx, const char *name);
670 void lttng_remove_context_field(struct lttng_ctx **ctx,
671 struct lttng_ctx_field *field);
672 void lttng_destroy_context(struct lttng_ctx *ctx);
673 int lttng_add_pid_to_ctx(struct lttng_ctx **ctx);
674 int lttng_add_cpu_id_to_ctx(struct lttng_ctx **ctx);
675 int lttng_add_procname_to_ctx(struct lttng_ctx **ctx);
676 int lttng_add_prio_to_ctx(struct lttng_ctx **ctx);
677 int lttng_add_nice_to_ctx(struct lttng_ctx **ctx);
678 int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx);
679 int lttng_add_tid_to_ctx(struct lttng_ctx **ctx);
680 int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
681 int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx);
682 int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx);
683 int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx);
684 int lttng_add_interruptible_to_ctx(struct lttng_ctx **ctx);
685 int lttng_add_need_reschedule_to_ctx(struct lttng_ctx **ctx);
686 #if defined(CONFIG_PREEMPT_RT_FULL) || defined(CONFIG_PREEMPT)
687 int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx);
688 #else
689 static inline
690 int lttng_add_preemptible_to_ctx(struct lttng_ctx **ctx)
691 {
692 return -ENOSYS;
693 }
694 #endif
695 #ifdef CONFIG_PREEMPT_RT_FULL
696 int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx);
697 #else
698 static inline
699 int lttng_add_migratable_to_ctx(struct lttng_ctx **ctx)
700 {
701 return -ENOSYS;
702 }
703 #endif
704
705 int lttng_add_callstack_to_ctx(struct lttng_ctx **ctx, int type);
706
707 #if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
708 int lttng_add_perf_counter_to_ctx(uint32_t type,
709 uint64_t config,
710 const char *name,
711 struct lttng_ctx **ctx);
712 int lttng_cpuhp_perf_counter_online(unsigned int cpu,
713 struct lttng_cpuhp_node *node);
714 int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
715 struct lttng_cpuhp_node *node);
716 #else
717 static inline
718 int lttng_add_perf_counter_to_ctx(uint32_t type,
719 uint64_t config,
720 const char *name,
721 struct lttng_ctx **ctx)
722 {
723 return -ENOSYS;
724 }
725 static inline
726 int lttng_cpuhp_perf_counter_online(unsigned int cpu,
727 struct lttng_cpuhp_node *node)
728 {
729 return 0;
730 }
731 static inline
732 int lttng_cpuhp_perf_counter_dead(unsigned int cpu,
733 struct lttng_cpuhp_node *node)
734 {
735 return 0;
736 }
737 #endif
738
739 int lttng_logger_init(void);
740 void lttng_logger_exit(void);
741
742 extern int lttng_statedump_start(struct lttng_session *session);
743
744 #ifdef CONFIG_KPROBES
745 int lttng_kprobes_register(const char *name,
746 const char *symbol_name,
747 uint64_t offset,
748 uint64_t addr,
749 struct lttng_event *event);
750 void lttng_kprobes_unregister(struct lttng_event *event);
751 void lttng_kprobes_destroy_private(struct lttng_event *event);
752 #else
753 static inline
754 int lttng_kprobes_register(const char *name,
755 const char *symbol_name,
756 uint64_t offset,
757 uint64_t addr,
758 struct lttng_event *event)
759 {
760 return -ENOSYS;
761 }
762
763 static inline
764 void lttng_kprobes_unregister(struct lttng_event *event)
765 {
766 }
767
768 static inline
769 void lttng_kprobes_destroy_private(struct lttng_event *event)
770 {
771 }
772 #endif
773
774 #ifdef CONFIG_KRETPROBES
775 int lttng_kretprobes_register(const char *name,
776 const char *symbol_name,
777 uint64_t offset,
778 uint64_t addr,
779 struct lttng_event *event_entry,
780 struct lttng_event *event_exit);
781 void lttng_kretprobes_unregister(struct lttng_event *event);
782 void lttng_kretprobes_destroy_private(struct lttng_event *event);
783 int lttng_kretprobes_event_enable_state(struct lttng_event *event,
784 int enable);
785 #else
786 static inline
787 int lttng_kretprobes_register(const char *name,
788 const char *symbol_name,
789 uint64_t offset,
790 uint64_t addr,
791 struct lttng_event *event_entry,
792 struct lttng_event *event_exit)
793 {
794 return -ENOSYS;
795 }
796
797 static inline
798 void lttng_kretprobes_unregister(struct lttng_event *event)
799 {
800 }
801
802 static inline
803 void lttng_kretprobes_destroy_private(struct lttng_event *event)
804 {
805 }
806
807 static inline
808 int lttng_kretprobes_event_enable_state(struct lttng_event *event,
809 int enable)
810 {
811 return -ENOSYS;
812 }
813 #endif
814
815 #if defined(CONFIG_DYNAMIC_FTRACE) && !defined(LTTNG_FTRACE_MISSING_HEADER)
816 int lttng_ftrace_register(const char *name,
817 const char *symbol_name,
818 struct lttng_event *event);
819 void lttng_ftrace_unregister(struct lttng_event *event);
820 void lttng_ftrace_destroy_private(struct lttng_event *event);
821 #else
822 static inline
823 int lttng_ftrace_register(const char *name,
824 const char *symbol_name,
825 struct lttng_event *event)
826 {
827 return -ENOSYS;
828 }
829
830 static inline
831 void lttng_ftrace_unregister(struct lttng_event *event)
832 {
833 }
834
835 static inline
836 void lttng_ftrace_destroy_private(struct lttng_event *event)
837 {
838 }
839 #endif
840
841 int lttng_calibrate(struct lttng_kernel_calibrate *calibrate);
842
843 extern const struct file_operations lttng_tracepoint_list_fops;
844 extern const struct file_operations lttng_syscall_list_fops;
845
846 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
847 #define TRACEPOINT_HAS_DATA_ARG
848 #endif
849
850 #endif /* _LTTNG_EVENTS_H */
This page took 0.045593 seconds and 4 git commands to generate.