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