Fix missing alignment includes
[lttng-ust.git] / include / ust / lttng-events.h
CommitLineData
0a42beb6
MD
1#ifndef _UST_LTTNG_EVENTS_H
2#define _UST_LTTNG_EVENTS_H
8020ceb5
MD
3
4/*
0a42beb6 5 * ust/lttng-events.h
8020ceb5
MD
6 *
7 * Copyright 2010 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
9 * Holds LTTng per-session event registry.
10 *
11 * Dual LGPL v2.1/GPL v2 license.
12 */
13
9f3fdbc6
MD
14#include <urcu/list.h>
15#include <uuid/uuid.h>
16#include <stdint.h>
17#include <ust/lttng-ust-abi.h>
1dbfff0c 18#include <ust/lttng-tracer.h>
20f1eee7
MD
19#include <endian.h>
20#include <float.h>
8020ceb5 21
8020ceb5
MD
22struct ltt_channel;
23struct ltt_session;
24struct lib_ring_buffer_ctx;
8020ceb5
MD
25
26/* Type description */
27
28/* Update the astract_types name table in lttng-types.c along with this enum */
29enum abstract_types {
30 atype_integer,
31 atype_enum,
32 atype_array,
33 atype_sequence,
34 atype_string,
20f1eee7 35 atype_float,
8020ceb5
MD
36 NR_ABSTRACT_TYPES,
37};
38
39/* Update the string_encodings name table in lttng-types.c along with this enum */
40enum lttng_string_encodings {
41 lttng_encode_none = 0,
42 lttng_encode_UTF8 = 1,
43 lttng_encode_ASCII = 2,
44 NR_STRING_ENCODINGS,
45};
46
47struct lttng_enum_entry {
48 unsigned long long start, end; /* start and end are inclusive */
49 const char *string;
50};
51
52#define __type_integer(_type, _byte_order, _base, _encoding) \
53 { \
54 .atype = atype_integer, \
55 .u.basic.integer = \
56 { \
57 .size = sizeof(_type) * CHAR_BIT, \
1dbfff0c
MD
58 .alignment = lttng_alignof(_type) * CHAR_BIT, \
59 .signedness = lttng_is_signed_type(_type), \
8020ceb5
MD
60 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
61 .base = _base, \
62 .encoding = lttng_encode_##_encoding, \
63 }, \
64 } \
65
66struct lttng_integer_type {
67 unsigned int size; /* in bits */
68 unsigned short alignment; /* in bits */
69 unsigned int signedness:1;
70 unsigned int reverse_byte_order:1;
71 unsigned int base; /* 2, 8, 10, 16, for pretty print */
72 enum lttng_string_encodings encoding;
73};
74
20f1eee7
MD
75#define _float_mant_dig(_type) \
76 (sizeof(_type) == sizeof(float) ? FLT_MANT_DIG \
77 : (sizeof(_type) == sizeof(double) ? DBL_MANT_DIG \
78 : (sizeof(_type) == sizeof(long double) ? LDBL_MANT_DIG \
79 : 0)))
80
81#define __type_float(_type) \
82 { \
83 .atype = atype_float, \
84 .u.basic._float = \
85 { \
86 .exp_dig = sizeof(_type) * CHAR_BIT \
87 - _float_mant_dig(_type), \
88 .mant_dig = _float_mant_dig(_type), \
1dbfff0c 89 .alignment = lttng_alignof(_type) * CHAR_BIT, \
20f1eee7
MD
90 .reverse_byte_order = __BYTE_ORDER != __FLOAT_WORD_ORDER, \
91 }, \
92 } \
93
94struct lttng_float_type {
95 unsigned int exp_dig; /* exponent digits, in bits */
96 unsigned int mant_dig; /* mantissa digits, in bits */
97 unsigned short alignment; /* in bits */
98 unsigned int reverse_byte_order:1;
99};
100
8020ceb5
MD
101union _lttng_basic_type {
102 struct lttng_integer_type integer;
103 struct {
104 const char *name;
105 } enumeration;
106 struct {
107 enum lttng_string_encodings encoding;
108 } string;
20f1eee7 109 struct lttng_float_type _float;
8020ceb5
MD
110};
111
112struct lttng_basic_type {
113 enum abstract_types atype;
114 union {
115 union _lttng_basic_type basic;
116 } u;
117};
118
119struct lttng_type {
120 enum abstract_types atype;
121 union {
122 union _lttng_basic_type basic;
123 struct {
124 struct lttng_basic_type elem_type;
125 unsigned int length; /* num. elems. */
126 } array;
127 struct {
128 struct lttng_basic_type length_type;
129 struct lttng_basic_type elem_type;
130 } sequence;
131 } u;
132};
133
134struct lttng_enum {
135 const char *name;
136 struct lttng_type container_type;
137 const struct lttng_enum_entry *entries;
138 unsigned int len;
139};
140
141/* Event field description */
142
143struct lttng_event_field {
144 const char *name;
145 struct lttng_type type;
146};
147
148struct lttng_ctx_field {
149 struct lttng_event_field event_field;
150 size_t (*get_size)(size_t offset);
151 void (*record)(struct lttng_ctx_field *field,
152 struct lib_ring_buffer_ctx *ctx,
153 struct ltt_channel *chan);
154 union {
8020ceb5
MD
155 } u;
156 void (*destroy)(struct lttng_ctx_field *field);
157};
158
159struct lttng_ctx {
160 struct lttng_ctx_field *fields;
161 unsigned int nr_fields;
162 unsigned int allocated_fields;
163};
164
165struct lttng_event_desc {
166 const char *name;
167 void *probe_callback;
168 const struct lttng_event_ctx *ctx; /* context */
169 const struct lttng_event_field *fields; /* event payload */
170 unsigned int nr_fields;
8020ceb5
MD
171};
172
173struct lttng_probe_desc {
174 const struct lttng_event_desc *event_desc;
175 unsigned int nr_events;
9f3fdbc6 176 struct cds_list_head head; /* chain registered probes */
8020ceb5
MD
177};
178
8165c8da
MD
179struct ust_pending_probe;
180
8020ceb5
MD
181/*
182 * ltt_event structure is referred to by the tracing fast path. It must be
183 * kept small.
184 */
185struct ltt_event {
186 unsigned int id;
187 struct ltt_channel *chan;
976fe9ea 188 int enabled;
8020ceb5
MD
189 const struct lttng_event_desc *desc;
190 void *filter;
191 struct lttng_ctx *ctx;
9f3fdbc6 192 enum lttng_ust_instrumentation instrumentation;
8020ceb5 193 union {
8020ceb5 194 } u;
9f3fdbc6 195 struct cds_list_head list; /* Event list */
8165c8da 196 struct ust_pending_probe *pending_probe;
8020ceb5
MD
197 int metadata_dumped:1;
198};
199
8d8a24c8 200struct channel;
1d498196 201struct shm_handle;
8d8a24c8 202
8020ceb5 203struct ltt_channel_ops {
1d498196 204 struct ltt_channel *(*channel_create)(const char *name,
8020ceb5
MD
205 struct ltt_channel *ltt_chan,
206 void *buf_addr,
207 size_t subbuf_size, size_t num_subbuf,
208 unsigned int switch_timer_interval,
193183fb
MD
209 unsigned int read_timer_interval,
210 int *shm_fd, int *wait_fd,
211 uint64_t *memory_map_size);
1d498196
MD
212 void (*channel_destroy)(struct ltt_channel *ltt_chan);
213 struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan,
381c0f1e
MD
214 struct shm_handle *handle,
215 int *shm_fd, int *wait_fd,
216 uint64_t *memory_map_size);
1d498196
MD
217 void (*buffer_read_close)(struct lib_ring_buffer *buf,
218 struct shm_handle *handle);
8020ceb5
MD
219 int (*event_reserve)(struct lib_ring_buffer_ctx *ctx,
220 uint32_t event_id);
221 void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
222 void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
223 size_t len);
224 /*
225 * packet_avail_size returns the available size in the current
226 * packet. Note that the size returned is only a hint, since it
227 * may change due to concurrent writes.
228 */
1d498196
MD
229 size_t (*packet_avail_size)(struct channel *chan,
230 struct shm_handle *handle);
9f3fdbc6
MD
231 //wait_queue_head_t *(*get_reader_wait_queue)(struct channel *chan);
232 //wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
8020ceb5
MD
233 int (*is_finalized)(struct channel *chan);
234 int (*is_disabled)(struct channel *chan);
235};
236
237struct ltt_channel {
238 unsigned int id;
239 struct channel *chan; /* Channel buffers */
976fe9ea 240 int enabled;
8020ceb5
MD
241 struct lttng_ctx *ctx;
242 /* Event ID management */
243 struct ltt_session *session;
0a42beb6 244 int objd; /* Object associated to channel */
8020ceb5 245 unsigned int free_event_id; /* Next event ID to allocate */
8165c8da 246 unsigned int used_event_id; /* Max allocated event IDs */
9f3fdbc6 247 struct cds_list_head list; /* Channel list */
8020ceb5
MD
248 struct ltt_channel_ops *ops;
249 int header_type; /* 0: unset, 1: compact, 2: large */
8d8a24c8 250 struct shm_handle *handle; /* shared-memory handle */
8020ceb5
MD
251 int metadata_dumped:1;
252};
253
254struct ltt_session {
255 int active; /* Is trace session active ? */
256 int been_active; /* Has trace session been active ? */
0a42beb6 257 int objd; /* Object associated to session */
8020ceb5 258 struct ltt_channel *metadata; /* Metadata channel */
9f3fdbc6
MD
259 struct cds_list_head chan; /* Channel list head */
260 struct cds_list_head events; /* Event list head */
261 struct cds_list_head list; /* Session list */
8020ceb5 262 unsigned int free_chan_id; /* Next chan ID to allocate */
9f3fdbc6 263 uuid_t uuid; /* Trace session unique ID */
8020ceb5
MD
264 int metadata_dumped:1;
265};
266
267struct ltt_transport {
268 char *name;
9f3fdbc6 269 struct cds_list_head node;
8020ceb5
MD
270 struct ltt_channel_ops ops;
271};
272
273struct ltt_session *ltt_session_create(void);
976fe9ea
MD
274int ltt_session_enable(struct ltt_session *session);
275int ltt_session_disable(struct ltt_session *session);
8020ceb5
MD
276void ltt_session_destroy(struct ltt_session *session);
277
278struct ltt_channel *ltt_channel_create(struct ltt_session *session,
279 const char *transport_name,
280 void *buf_addr,
281 size_t subbuf_size, size_t num_subbuf,
282 unsigned int switch_timer_interval,
193183fb
MD
283 unsigned int read_timer_interval,
284 int *shm_fd, int *wait_fd,
285 uint64_t *memory_map_size);
8020ceb5
MD
286struct ltt_channel *ltt_global_channel_create(struct ltt_session *session,
287 int overwrite, void *buf_addr,
288 size_t subbuf_size, size_t num_subbuf,
289 unsigned int switch_timer_interval,
193183fb
MD
290 unsigned int read_timer_interval,
291 int *shm_fd, int *wait_fd,
292 uint64_t *memory_map_size);
8020ceb5
MD
293
294struct ltt_event *ltt_event_create(struct ltt_channel *chan,
9f3fdbc6 295 struct lttng_ust_event *event_param,
8020ceb5
MD
296 void *filter);
297
976fe9ea
MD
298int ltt_channel_enable(struct ltt_channel *channel);
299int ltt_channel_disable(struct ltt_channel *channel);
300int ltt_event_enable(struct ltt_event *event);
301int ltt_event_disable(struct ltt_event *event);
302
8020ceb5
MD
303void ltt_transport_register(struct ltt_transport *transport);
304void ltt_transport_unregister(struct ltt_transport *transport);
305
4b4de73e 306void synchronize_trace(void);
9f3fdbc6
MD
307//int ltt_debugfs_abi_init(void);
308//void ltt_debugfs_abi_exit(void);
8020ceb5
MD
309
310int ltt_probe_register(struct lttng_probe_desc *desc);
311void ltt_probe_unregister(struct lttng_probe_desc *desc);
8165c8da 312int pending_probe_fix_events(const struct lttng_event_desc *desc);
8020ceb5
MD
313const struct lttng_event_desc *ltt_event_get(const char *name);
314void ltt_event_put(const struct lttng_event_desc *desc);
315int ltt_probes_init(void);
316void ltt_probes_exit(void);
317struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx);
318void lttng_remove_context_field(struct lttng_ctx **ctx,
319 struct lttng_ctx_field *field);
320void lttng_destroy_context(struct lttng_ctx *ctx);
9f3fdbc6
MD
321int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
322
323//extern const struct file_operations lttng_tracepoint_list_fops;
8020ceb5 324
0a42beb6 325#endif /* _UST_LTTNG_EVENTS_H */
This page took 0.036553 seconds and 4 git commands to generate.