library mass rename: add lttng- prefix
[lttng-ust.git] / include / lttng / ust-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>
4318ae1b
MD
17#include <lttng/ust-abi.h>
18#include <lttng/ust-tracer.h>
20f1eee7
MD
19#include <endian.h>
20#include <float.h>
8020ceb5 21
8020ceb5
MD
22struct ltt_channel;
23struct ltt_session;
4cfec15c 24struct lttng_ust_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
d3ed854b
MD
75/*
76 * Only float and double are supported. long double is not supported at
77 * the moment.
78 */
20f1eee7
MD
79#define _float_mant_dig(_type) \
80 (sizeof(_type) == sizeof(float) ? FLT_MANT_DIG \
81 : (sizeof(_type) == sizeof(double) ? DBL_MANT_DIG \
d3ed854b 82 : 0))
20f1eee7
MD
83
84#define __type_float(_type) \
85 { \
86 .atype = atype_float, \
87 .u.basic._float = \
88 { \
89 .exp_dig = sizeof(_type) * CHAR_BIT \
90 - _float_mant_dig(_type), \
91 .mant_dig = _float_mant_dig(_type), \
1dbfff0c 92 .alignment = lttng_alignof(_type) * CHAR_BIT, \
20f1eee7
MD
93 .reverse_byte_order = __BYTE_ORDER != __FLOAT_WORD_ORDER, \
94 }, \
95 } \
96
97struct lttng_float_type {
98 unsigned int exp_dig; /* exponent digits, in bits */
99 unsigned int mant_dig; /* mantissa digits, in bits */
100 unsigned short alignment; /* in bits */
101 unsigned int reverse_byte_order:1;
102};
103
8020ceb5
MD
104union _lttng_basic_type {
105 struct lttng_integer_type integer;
106 struct {
107 const char *name;
108 } enumeration;
109 struct {
110 enum lttng_string_encodings encoding;
111 } string;
20f1eee7 112 struct lttng_float_type _float;
8020ceb5
MD
113};
114
115struct lttng_basic_type {
116 enum abstract_types atype;
117 union {
118 union _lttng_basic_type basic;
119 } u;
120};
121
122struct lttng_type {
123 enum abstract_types atype;
124 union {
125 union _lttng_basic_type basic;
126 struct {
127 struct lttng_basic_type elem_type;
128 unsigned int length; /* num. elems. */
129 } array;
130 struct {
131 struct lttng_basic_type length_type;
132 struct lttng_basic_type elem_type;
133 } sequence;
134 } u;
135};
136
137struct lttng_enum {
138 const char *name;
139 struct lttng_type container_type;
140 const struct lttng_enum_entry *entries;
141 unsigned int len;
142};
143
144/* Event field description */
145
146struct lttng_event_field {
147 const char *name;
148 struct lttng_type type;
149};
150
151struct lttng_ctx_field {
152 struct lttng_event_field event_field;
153 size_t (*get_size)(size_t offset);
154 void (*record)(struct lttng_ctx_field *field,
4cfec15c 155 struct lttng_ust_lib_ring_buffer_ctx *ctx,
8020ceb5
MD
156 struct ltt_channel *chan);
157 union {
8020ceb5
MD
158 } u;
159 void (*destroy)(struct lttng_ctx_field *field);
160};
161
162struct lttng_ctx {
163 struct lttng_ctx_field *fields;
164 unsigned int nr_fields;
165 unsigned int allocated_fields;
166};
167
168struct lttng_event_desc {
169 const char *name;
170 void *probe_callback;
171 const struct lttng_event_ctx *ctx; /* context */
172 const struct lttng_event_field *fields; /* event payload */
173 unsigned int nr_fields;
8020ceb5
MD
174};
175
176struct lttng_probe_desc {
177 const struct lttng_event_desc *event_desc;
178 unsigned int nr_events;
9f3fdbc6 179 struct cds_list_head head; /* chain registered probes */
8020ceb5
MD
180};
181
8165c8da
MD
182struct ust_pending_probe;
183
8020ceb5
MD
184/*
185 * ltt_event structure is referred to by the tracing fast path. It must be
186 * kept small.
187 */
188struct ltt_event {
189 unsigned int id;
190 struct ltt_channel *chan;
976fe9ea 191 int enabled;
8020ceb5
MD
192 const struct lttng_event_desc *desc;
193 void *filter;
194 struct lttng_ctx *ctx;
9f3fdbc6 195 enum lttng_ust_instrumentation instrumentation;
8020ceb5 196 union {
8020ceb5 197 } u;
9f3fdbc6 198 struct cds_list_head list; /* Event list */
8165c8da 199 struct ust_pending_probe *pending_probe;
8020ceb5
MD
200 int metadata_dumped:1;
201};
202
8d8a24c8 203struct channel;
38fae1d3 204struct lttng_ust_shm_handle;
8d8a24c8 205
8020ceb5 206struct ltt_channel_ops {
1d498196 207 struct ltt_channel *(*channel_create)(const char *name,
8020ceb5
MD
208 struct ltt_channel *ltt_chan,
209 void *buf_addr,
210 size_t subbuf_size, size_t num_subbuf,
211 unsigned int switch_timer_interval,
193183fb
MD
212 unsigned int read_timer_interval,
213 int *shm_fd, int *wait_fd,
214 uint64_t *memory_map_size);
1d498196 215 void (*channel_destroy)(struct ltt_channel *ltt_chan);
4cfec15c 216 struct lttng_ust_lib_ring_buffer *(*buffer_read_open)(struct channel *chan,
38fae1d3 217 struct lttng_ust_shm_handle *handle,
381c0f1e
MD
218 int *shm_fd, int *wait_fd,
219 uint64_t *memory_map_size);
4cfec15c 220 void (*buffer_read_close)(struct lttng_ust_lib_ring_buffer *buf,
38fae1d3 221 struct lttng_ust_shm_handle *handle);
4cfec15c 222 int (*event_reserve)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
8020ceb5 223 uint32_t event_id);
4cfec15c
MD
224 void (*event_commit)(struct lttng_ust_lib_ring_buffer_ctx *ctx);
225 void (*event_write)(struct lttng_ust_lib_ring_buffer_ctx *ctx, const void *src,
8020ceb5
MD
226 size_t len);
227 /*
228 * packet_avail_size returns the available size in the current
229 * packet. Note that the size returned is only a hint, since it
230 * may change due to concurrent writes.
231 */
1d498196 232 size_t (*packet_avail_size)(struct channel *chan,
38fae1d3 233 struct lttng_ust_shm_handle *handle);
9f3fdbc6
MD
234 //wait_queue_head_t *(*get_reader_wait_queue)(struct channel *chan);
235 //wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
8020ceb5
MD
236 int (*is_finalized)(struct channel *chan);
237 int (*is_disabled)(struct channel *chan);
38fae1d3 238 int (*flush_buffer)(struct channel *chan, struct lttng_ust_shm_handle *handle);
8020ceb5
MD
239};
240
241struct ltt_channel {
242 unsigned int id;
243 struct channel *chan; /* Channel buffers */
976fe9ea 244 int enabled;
8020ceb5
MD
245 struct lttng_ctx *ctx;
246 /* Event ID management */
247 struct ltt_session *session;
0a42beb6 248 int objd; /* Object associated to channel */
8020ceb5 249 unsigned int free_event_id; /* Next event ID to allocate */
8165c8da 250 unsigned int used_event_id; /* Max allocated event IDs */
9f3fdbc6 251 struct cds_list_head list; /* Channel list */
8020ceb5
MD
252 struct ltt_channel_ops *ops;
253 int header_type; /* 0: unset, 1: compact, 2: large */
38fae1d3 254 struct lttng_ust_shm_handle *handle; /* shared-memory handle */
8020ceb5
MD
255 int metadata_dumped:1;
256};
257
258struct ltt_session {
259 int active; /* Is trace session active ? */
260 int been_active; /* Has trace session been active ? */
0a42beb6 261 int objd; /* Object associated to session */
8020ceb5 262 struct ltt_channel *metadata; /* Metadata channel */
9f3fdbc6
MD
263 struct cds_list_head chan; /* Channel list head */
264 struct cds_list_head events; /* Event list head */
265 struct cds_list_head list; /* Session list */
8020ceb5 266 unsigned int free_chan_id; /* Next chan ID to allocate */
9f3fdbc6 267 uuid_t uuid; /* Trace session unique ID */
8020ceb5
MD
268 int metadata_dumped:1;
269};
270
271struct ltt_transport {
272 char *name;
9f3fdbc6 273 struct cds_list_head node;
8020ceb5
MD
274 struct ltt_channel_ops ops;
275};
276
277struct ltt_session *ltt_session_create(void);
976fe9ea
MD
278int ltt_session_enable(struct ltt_session *session);
279int ltt_session_disable(struct ltt_session *session);
8020ceb5
MD
280void ltt_session_destroy(struct ltt_session *session);
281
282struct ltt_channel *ltt_channel_create(struct ltt_session *session,
283 const char *transport_name,
284 void *buf_addr,
285 size_t subbuf_size, size_t num_subbuf,
286 unsigned int switch_timer_interval,
193183fb
MD
287 unsigned int read_timer_interval,
288 int *shm_fd, int *wait_fd,
289 uint64_t *memory_map_size);
8020ceb5
MD
290struct ltt_channel *ltt_global_channel_create(struct ltt_session *session,
291 int overwrite, void *buf_addr,
292 size_t subbuf_size, size_t num_subbuf,
293 unsigned int switch_timer_interval,
193183fb
MD
294 unsigned int read_timer_interval,
295 int *shm_fd, int *wait_fd,
296 uint64_t *memory_map_size);
8020ceb5
MD
297
298struct ltt_event *ltt_event_create(struct ltt_channel *chan,
9f3fdbc6 299 struct lttng_ust_event *event_param,
8020ceb5
MD
300 void *filter);
301
976fe9ea
MD
302int ltt_channel_enable(struct ltt_channel *channel);
303int ltt_channel_disable(struct ltt_channel *channel);
304int ltt_event_enable(struct ltt_event *event);
305int ltt_event_disable(struct ltt_event *event);
306
8020ceb5
MD
307void ltt_transport_register(struct ltt_transport *transport);
308void ltt_transport_unregister(struct ltt_transport *transport);
309
4b4de73e 310void synchronize_trace(void);
8020ceb5
MD
311
312int ltt_probe_register(struct lttng_probe_desc *desc);
313void ltt_probe_unregister(struct lttng_probe_desc *desc);
8165c8da 314int pending_probe_fix_events(const struct lttng_event_desc *desc);
8020ceb5
MD
315const struct lttng_event_desc *ltt_event_get(const char *name);
316void ltt_event_put(const struct lttng_event_desc *desc);
317int ltt_probes_init(void);
318void ltt_probes_exit(void);
8173ec7c
MD
319int lttng_find_context(struct lttng_ctx *ctx, const char *name);
320struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx_p);
321void lttng_remove_context_field(struct lttng_ctx **ctx_p,
8020ceb5
MD
322 struct lttng_ctx_field *field);
323void lttng_destroy_context(struct lttng_ctx *ctx);
3b402b40 324int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
c1ef86f0 325int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx);
8173ec7c 326int lttng_add_pthread_id_to_ctx(struct lttng_ctx **ctx);
4847e9bb 327int lttng_add_procname_to_ctx(struct lttng_ctx **ctx);
a93bfc45 328void lttng_context_vtid_reset(void);
c1ef86f0 329void lttng_context_vpid_reset(void);
9f3fdbc6 330
0a42beb6 331#endif /* _UST_LTTNG_EVENTS_H */
This page took 0.038555 seconds and 4 git commands to generate.