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