Add syscall tracing
[lttng-modules.git] / ltt-events.h
CommitLineData
11b5a3c2
MD
1#ifndef _LTT_EVENTS_H
2#define _LTT_EVENTS_H
3
4e3c1b9b
MD
4/*
5 * ltt-events.h
6 *
7 * Copyright 2010 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
9 * Holds LTTng per-session event registry.
10 */
11
12#include <linux/list.h>
d793d5e1 13#include <linux/uuid.h>
11b5a3c2 14#include "ltt-debugfs-abi.h"
4e3c1b9b
MD
15
16struct ltt_channel;
17struct ltt_session;
1c25284c 18struct lib_ring_buffer_ctx;
4e3c1b9b 19
c0edae1d
MD
20/* Type description */
21
22/* Update the astract_types name table in lttng-types.c along with this enum */
23enum abstract_types {
24 atype_integer,
25 atype_enum,
26 atype_array,
27 atype_sequence,
28 atype_string,
29 NR_ABSTRACT_TYPES,
30};
31
32/* Update the string_encodings name table in lttng-types.c along with this enum */
33enum lttng_string_encodings {
34 lttng_encode_UTF8 = 0,
35 lttng_encode_ASCII = 1,
36 NR_STRING_ENCODINGS,
37};
38
39struct lttng_enum_entry {
40 unsigned long long start, end; /* start and end are inclusive */
41 const char *string;
42};
43
c099397a
MD
44#define __type_integer(_type, _byte_order) \
45 { \
46 .atype = atype_integer, \
47 .u.basic.integer = \
48 { \
49 .size = sizeof(_type), \
d793d5e1 50 .alignment = ltt_alignof(_type) * CHAR_BIT, \
c099397a
MD
51 .signedness = is_signed_type(_type), \
52 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
53 }, \
54 } \
55
56struct lttng_integer_type {
57 unsigned int size; /* in bits */
58 unsigned short alignment; /* in bits */
59 unsigned int signedness:1;
60 unsigned int reverse_byte_order:1;
61};
62
63union _lttng_basic_type {
64 struct lttng_integer_type integer;
65 struct {
66 const char *name;
67 } enumeration;
68 struct {
69 enum lttng_string_encodings encoding;
70 } string;
71};
72
73struct lttng_basic_type {
74 enum abstract_types atype;
75 union {
76 union _lttng_basic_type basic;
77 } u;
c0edae1d
MD
78};
79
80struct lttng_type {
81 enum abstract_types atype;
c0edae1d 82 union {
c099397a 83 union _lttng_basic_type basic;
c0edae1d 84 struct {
c099397a 85 struct lttng_basic_type elem_type;
c0edae1d
MD
86 unsigned int length; /* num. elems. */
87 } array;
88 struct {
c099397a
MD
89 struct lttng_basic_type length_type;
90 struct lttng_basic_type elem_type;
c0edae1d 91 } sequence;
c0edae1d 92 } u;
c099397a
MD
93};
94
95struct lttng_enum {
96 const char *name;
97 struct lttng_type container_type;
98 const struct lttng_enum_entry *entries;
99 unsigned int len;
100};
c0edae1d
MD
101
102/* Event field description */
103
104struct lttng_event_field {
105 const char *name;
106 const struct lttng_type type;
107};
108
109struct lttng_event_desc {
110 const struct lttng_event_field *fields;
111 const char *name;
112 void *probe_callback;
113 unsigned int nr_fields;
114};
115
85a9ca7f
MD
116struct lttng_probe_desc {
117 const struct lttng_event_desc *event_desc;
118 unsigned int nr_events;
119 struct list_head head; /* chain registered probes */
120};
121
122/*
123 * ltt_event structure is referred to by the tracing fast path. It must be
124 * kept small.
125 */
126struct ltt_event {
127 unsigned int id;
128 struct ltt_channel *chan;
129 const struct lttng_event_desc *desc;
130 void *filter;
131 enum instrum_type itype;
132 struct list_head list; /* Event list */
c099397a 133 int metadata_dumped:1;
85a9ca7f
MD
134};
135
136struct ltt_channel_ops {
137 struct channel *(*channel_create)(const char *name,
9115fbdc 138 struct ltt_channel *ltt_chan,
85a9ca7f
MD
139 void *buf_addr,
140 size_t subbuf_size, size_t num_subbuf,
141 unsigned int switch_timer_interval,
142 unsigned int read_timer_interval);
143 void (*channel_destroy)(struct channel *chan);
144 struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
145 void (*buffer_read_close)(struct lib_ring_buffer *buf);
146 int (*event_reserve)(struct lib_ring_buffer_ctx *ctx);
147 void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
148 void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
149 size_t len);
1ec3f75a
MD
150 /*
151 * packet_avail_size returns the available size in the current
152 * packet. Note that the size returned is only a hint, since it
153 * may change due to concurrent writes.
154 */
155 size_t (*packet_avail_size)(struct channel *chan);
c099397a 156 wait_queue_head_t *(*get_reader_wait_queue)(struct ltt_channel *chan);
85a9ca7f
MD
157};
158
159struct ltt_channel {
c099397a 160 unsigned int id;
85a9ca7f
MD
161 struct channel *chan; /* Channel buffers */
162 /* Event ID management */
163 struct ltt_session *session;
164 struct file *file; /* File associated to channel */
165 unsigned int free_event_id; /* Next event ID to allocate */
166 struct list_head list; /* Channel list */
167 wait_queue_head_t notify_wait; /* Channel addition notif. waitqueue */
168 struct ltt_channel_ops *ops;
9115fbdc 169 int header_type; /* 0: unset, 1: compact, 2: large */
c099397a 170 int metadata_dumped:1;
85a9ca7f
MD
171};
172
173struct ltt_session {
174 int active; /* Is trace session active ? */
175 struct file *file; /* File associated to session */
c099397a 176 struct ltt_channel *metadata; /* Metadata channel */
85a9ca7f
MD
177 struct list_head chan; /* Channel list head */
178 struct list_head events; /* Event list head */
179 struct list_head list; /* Session list */
c099397a 180 unsigned int free_chan_id; /* Next chan ID to allocate */
d793d5e1 181 uuid_le uuid; /* Trace session unique ID */
c099397a 182 int metadata_dumped:1;
85a9ca7f
MD
183};
184
185struct ltt_transport {
186 char *name;
187 struct module *owner;
188 struct list_head node;
189 struct ltt_channel_ops ops;
190};
191
baf20995 192struct ltt_session *ltt_session_create(void);
c0e31d2e
MD
193int ltt_session_start(struct ltt_session *session);
194int ltt_session_stop(struct ltt_session *session);
11b5a3c2 195void ltt_session_destroy(struct ltt_session *session);
4e3c1b9b 196
baf20995 197struct ltt_channel *ltt_channel_create(struct ltt_session *session,
5dbbdb43
MD
198 const char *transport_name,
199 void *buf_addr,
200 size_t subbuf_size, size_t num_subbuf,
201 unsigned int switch_timer_interval,
202 unsigned int read_timer_interval);
203struct ltt_channel *ltt_global_channel_create(struct ltt_session *session,
4e3c1b9b
MD
204 int overwrite, void *buf_addr,
205 size_t subbuf_size, size_t num_subbuf,
206 unsigned int switch_timer_interval,
207 unsigned int read_timer_interval);
11b5a3c2 208void _ltt_channel_destroy(struct ltt_channel *chan);
4e3c1b9b 209
653fe716 210struct ltt_event *ltt_event_create(struct ltt_channel *chan,
653fe716 211 char *name,
11b5a3c2 212 enum instrum_type itype,
85a9ca7f
MD
213 const struct lttng_event_desc *event_desc,
214 void *filter);
be066e6c 215int ltt_event_unregister(struct ltt_event *event);
c0e31d2e
MD
216
217void ltt_transport_register(struct ltt_transport *transport);
218void ltt_transport_unregister(struct ltt_transport *transport);
11b5a3c2 219
1c25284c
MD
220int ltt_debugfs_abi_init(void);
221void ltt_debugfs_abi_exit(void);
222
85a9ca7f
MD
223int ltt_probe_register(struct lttng_probe_desc *desc);
224void ltt_probe_unregister(struct lttng_probe_desc *desc);
225const struct lttng_event_desc *ltt_event_get(const char *name);
226void ltt_event_put(const struct lttng_event_desc *desc);
cd4bd11f
MD
227int ltt_probes_init(void);
228void ltt_probes_exit(void);
02119ee5 229
11b5a3c2 230#endif /* _LTT_EVENTS_H */
This page took 0.033858 seconds and 4 git commands to generate.