Build TRACEPOINT_EVENT integer type
[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
MD
89 .alignment = lttng_alignof(_type) * CHAR_BIT, \
90 .signedness = lttng_is_signed_type(_type), \
20f1eee7
MD
91 .reverse_byte_order = __BYTE_ORDER != __FLOAT_WORD_ORDER, \
92 }, \
93 } \
94
95struct lttng_float_type {
96 unsigned int exp_dig; /* exponent digits, in bits */
97 unsigned int mant_dig; /* mantissa digits, in bits */
98 unsigned short alignment; /* in bits */
99 unsigned int reverse_byte_order:1;
100};
101
8020ceb5
MD
102union _lttng_basic_type {
103 struct lttng_integer_type integer;
104 struct {
105 const char *name;
106 } enumeration;
107 struct {
108 enum lttng_string_encodings encoding;
109 } string;
20f1eee7 110 struct lttng_float_type _float;
8020ceb5
MD
111};
112
113struct lttng_basic_type {
114 enum abstract_types atype;
115 union {
116 union _lttng_basic_type basic;
117 } u;
118};
119
120struct lttng_type {
121 enum abstract_types atype;
122 union {
123 union _lttng_basic_type basic;
124 struct {
125 struct lttng_basic_type elem_type;
126 unsigned int length; /* num. elems. */
127 } array;
128 struct {
129 struct lttng_basic_type length_type;
130 struct lttng_basic_type elem_type;
131 } sequence;
132 } u;
133};
134
135struct lttng_enum {
136 const char *name;
137 struct lttng_type container_type;
138 const struct lttng_enum_entry *entries;
139 unsigned int len;
140};
141
142/* Event field description */
143
144struct lttng_event_field {
145 const char *name;
146 struct lttng_type type;
147};
148
149struct lttng_ctx_field {
150 struct lttng_event_field event_field;
151 size_t (*get_size)(size_t offset);
152 void (*record)(struct lttng_ctx_field *field,
153 struct lib_ring_buffer_ctx *ctx,
154 struct ltt_channel *chan);
155 union {
8020ceb5
MD
156 } u;
157 void (*destroy)(struct lttng_ctx_field *field);
158};
159
160struct lttng_ctx {
161 struct lttng_ctx_field *fields;
162 unsigned int nr_fields;
163 unsigned int allocated_fields;
164};
165
166struct lttng_event_desc {
167 const char *name;
168 void *probe_callback;
169 const struct lttng_event_ctx *ctx; /* context */
170 const struct lttng_event_field *fields; /* event payload */
171 unsigned int nr_fields;
8020ceb5
MD
172};
173
174struct lttng_probe_desc {
175 const struct lttng_event_desc *event_desc;
176 unsigned int nr_events;
9f3fdbc6 177 struct cds_list_head head; /* chain registered probes */
8020ceb5
MD
178};
179
180/*
181 * ltt_event structure is referred to by the tracing fast path. It must be
182 * kept small.
183 */
184struct ltt_event {
185 unsigned int id;
186 struct ltt_channel *chan;
976fe9ea 187 int enabled;
8020ceb5
MD
188 const struct lttng_event_desc *desc;
189 void *filter;
190 struct lttng_ctx *ctx;
9f3fdbc6 191 enum lttng_ust_instrumentation instrumentation;
8020ceb5 192 union {
8020ceb5 193 } u;
9f3fdbc6 194 struct cds_list_head list; /* Event list */
8020ceb5
MD
195 int metadata_dumped:1;
196};
197
8d8a24c8
MD
198struct channel;
199
8020ceb5 200struct ltt_channel_ops {
8d8a24c8 201 struct shm_handle *(*channel_create)(const char *name,
8020ceb5
MD
202 struct ltt_channel *ltt_chan,
203 void *buf_addr,
204 size_t subbuf_size, size_t num_subbuf,
205 unsigned int switch_timer_interval,
8d8a24c8
MD
206 unsigned int read_timer_interval);
207 void (*channel_destroy)(struct shm_handle *handle);
8020ceb5
MD
208 struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
209 void (*buffer_read_close)(struct lib_ring_buffer *buf);
210 int (*event_reserve)(struct lib_ring_buffer_ctx *ctx,
211 uint32_t event_id);
212 void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
213 void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
214 size_t len);
215 /*
216 * packet_avail_size returns the available size in the current
217 * packet. Note that the size returned is only a hint, since it
218 * may change due to concurrent writes.
219 */
220 size_t (*packet_avail_size)(struct channel *chan);
9f3fdbc6
MD
221 //wait_queue_head_t *(*get_reader_wait_queue)(struct channel *chan);
222 //wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
8020ceb5
MD
223 int (*is_finalized)(struct channel *chan);
224 int (*is_disabled)(struct channel *chan);
225};
226
227struct ltt_channel {
228 unsigned int id;
229 struct channel *chan; /* Channel buffers */
976fe9ea 230 int enabled;
8020ceb5
MD
231 struct lttng_ctx *ctx;
232 /* Event ID management */
233 struct ltt_session *session;
0a42beb6 234 int objd; /* Object associated to channel */
8020ceb5 235 unsigned int free_event_id; /* Next event ID to allocate */
9f3fdbc6 236 struct cds_list_head list; /* Channel list */
8020ceb5
MD
237 struct ltt_channel_ops *ops;
238 int header_type; /* 0: unset, 1: compact, 2: large */
8d8a24c8 239 struct shm_handle *handle; /* shared-memory handle */
8020ceb5
MD
240 int metadata_dumped:1;
241};
242
243struct ltt_session {
244 int active; /* Is trace session active ? */
245 int been_active; /* Has trace session been active ? */
0a42beb6 246 int objd; /* Object associated to session */
8020ceb5 247 struct ltt_channel *metadata; /* Metadata channel */
9f3fdbc6
MD
248 struct cds_list_head chan; /* Channel list head */
249 struct cds_list_head events; /* Event list head */
250 struct cds_list_head list; /* Session list */
8020ceb5 251 unsigned int free_chan_id; /* Next chan ID to allocate */
9f3fdbc6 252 uuid_t uuid; /* Trace session unique ID */
8020ceb5
MD
253 int metadata_dumped:1;
254};
255
256struct ltt_transport {
257 char *name;
9f3fdbc6 258 struct cds_list_head node;
8020ceb5
MD
259 struct ltt_channel_ops ops;
260};
261
262struct ltt_session *ltt_session_create(void);
976fe9ea
MD
263int ltt_session_enable(struct ltt_session *session);
264int ltt_session_disable(struct ltt_session *session);
8020ceb5
MD
265void ltt_session_destroy(struct ltt_session *session);
266
267struct ltt_channel *ltt_channel_create(struct ltt_session *session,
268 const char *transport_name,
269 void *buf_addr,
270 size_t subbuf_size, size_t num_subbuf,
271 unsigned int switch_timer_interval,
0a42beb6 272 unsigned int read_timer_interval);
8020ceb5
MD
273struct ltt_channel *ltt_global_channel_create(struct ltt_session *session,
274 int overwrite, void *buf_addr,
275 size_t subbuf_size, size_t num_subbuf,
276 unsigned int switch_timer_interval,
277 unsigned int read_timer_interval);
278
279struct ltt_event *ltt_event_create(struct ltt_channel *chan,
9f3fdbc6 280 struct lttng_ust_event *event_param,
8020ceb5
MD
281 void *filter);
282
976fe9ea
MD
283int ltt_channel_enable(struct ltt_channel *channel);
284int ltt_channel_disable(struct ltt_channel *channel);
285int ltt_event_enable(struct ltt_event *event);
286int ltt_event_disable(struct ltt_event *event);
287
8020ceb5
MD
288void ltt_transport_register(struct ltt_transport *transport);
289void ltt_transport_unregister(struct ltt_transport *transport);
290
4b4de73e 291void synchronize_trace(void);
9f3fdbc6
MD
292//int ltt_debugfs_abi_init(void);
293//void ltt_debugfs_abi_exit(void);
8020ceb5
MD
294
295int ltt_probe_register(struct lttng_probe_desc *desc);
296void ltt_probe_unregister(struct lttng_probe_desc *desc);
297const struct lttng_event_desc *ltt_event_get(const char *name);
298void ltt_event_put(const struct lttng_event_desc *desc);
299int ltt_probes_init(void);
300void ltt_probes_exit(void);
301struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx);
302void lttng_remove_context_field(struct lttng_ctx **ctx,
303 struct lttng_ctx_field *field);
304void lttng_destroy_context(struct lttng_ctx *ctx);
9f3fdbc6
MD
305int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
306
307//extern const struct file_operations lttng_tracepoint_list_fops;
8020ceb5 308
0a42beb6 309#endif /* _UST_LTTNG_EVENTS_H */
This page took 0.057701 seconds and 4 git commands to generate.