1 #ifndef _UST_LTTNG_EVENTS_H
2 #define _UST_LTTNG_EVENTS_H
7 * Copyright 2010 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * Holds LTTng per-session event registry.
11 * Dual LGPL v2.1/GPL v2 license.
14 #include <urcu/list.h>
15 #include <uuid/uuid.h>
17 #include <ust/lttng-ust-abi.h>
18 #include <ust/lttng-tracer.h>
24 struct lib_ring_buffer_ctx
;
26 /* Type description */
28 /* Update the astract_types name table in lttng-types.c along with this enum */
39 /* Update the string_encodings name table in lttng-types.c along with this enum */
40 enum lttng_string_encodings
{
41 lttng_encode_none
= 0,
42 lttng_encode_UTF8
= 1,
43 lttng_encode_ASCII
= 2,
47 struct lttng_enum_entry
{
48 unsigned long long start
, end
; /* start and end are inclusive */
52 #define __type_integer(_type, _byte_order, _base, _encoding) \
54 .atype = atype_integer, \
57 .size = sizeof(_type) * CHAR_BIT, \
58 .alignment = lttng_alignof(_type) * CHAR_BIT, \
59 .signedness = lttng_is_signed_type(_type), \
60 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
62 .encoding = lttng_encode_##_encoding, \
66 struct 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
;
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 \
81 #define __type_float(_type) \
83 .atype = atype_float, \
86 .exp_dig = sizeof(_type) * CHAR_BIT \
87 - _float_mant_dig(_type), \
88 .mant_dig = _float_mant_dig(_type), \
89 .alignment = lttng_alignof(_type) * CHAR_BIT, \
90 .reverse_byte_order = __BYTE_ORDER != __FLOAT_WORD_ORDER, \
94 struct 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;
101 union _lttng_basic_type
{
102 struct lttng_integer_type integer
;
107 enum lttng_string_encodings encoding
;
109 struct lttng_float_type _float
;
112 struct lttng_basic_type
{
113 enum abstract_types atype
;
115 union _lttng_basic_type basic
;
120 enum abstract_types atype
;
122 union _lttng_basic_type basic
;
124 struct lttng_basic_type elem_type
;
125 unsigned int length
; /* num. elems. */
128 struct lttng_basic_type length_type
;
129 struct lttng_basic_type elem_type
;
136 struct lttng_type container_type
;
137 const struct lttng_enum_entry
*entries
;
141 /* Event field description */
143 struct lttng_event_field
{
145 struct lttng_type type
;
148 struct 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
);
156 void (*destroy
)(struct lttng_ctx_field
*field
);
160 struct lttng_ctx_field
*fields
;
161 unsigned int nr_fields
;
162 unsigned int allocated_fields
;
165 struct lttng_event_desc
{
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
;
173 struct lttng_probe_desc
{
174 const struct lttng_event_desc
*event_desc
;
175 unsigned int nr_events
;
176 struct cds_list_head head
; /* chain registered probes */
179 struct ust_pending_probe
;
182 * ltt_event structure is referred to by the tracing fast path. It must be
187 struct ltt_channel
*chan
;
189 const struct lttng_event_desc
*desc
;
191 struct lttng_ctx
*ctx
;
192 enum lttng_ust_instrumentation instrumentation
;
195 struct cds_list_head list
; /* Event list */
196 struct ust_pending_probe
*pending_probe
;
197 int metadata_dumped
:1;
203 struct ltt_channel_ops
{
204 struct ltt_channel
*(*channel_create
)(const char *name
,
205 struct ltt_channel
*ltt_chan
,
207 size_t subbuf_size
, size_t num_subbuf
,
208 unsigned int switch_timer_interval
,
209 unsigned int read_timer_interval
);
210 void (*channel_destroy
)(struct ltt_channel
*ltt_chan
);
211 struct lib_ring_buffer
*(*buffer_read_open
)(struct channel
*chan
,
212 struct shm_handle
*handle
);
213 void (*buffer_read_close
)(struct lib_ring_buffer
*buf
,
214 struct shm_handle
*handle
);
215 int (*event_reserve
)(struct lib_ring_buffer_ctx
*ctx
,
217 void (*event_commit
)(struct lib_ring_buffer_ctx
*ctx
);
218 void (*event_write
)(struct lib_ring_buffer_ctx
*ctx
, const void *src
,
221 * packet_avail_size returns the available size in the current
222 * packet. Note that the size returned is only a hint, since it
223 * may change due to concurrent writes.
225 size_t (*packet_avail_size
)(struct channel
*chan
,
226 struct shm_handle
*handle
);
227 //wait_queue_head_t *(*get_reader_wait_queue)(struct channel *chan);
228 //wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
229 int (*is_finalized
)(struct channel
*chan
);
230 int (*is_disabled
)(struct channel
*chan
);
235 struct channel
*chan
; /* Channel buffers */
237 struct lttng_ctx
*ctx
;
238 /* Event ID management */
239 struct ltt_session
*session
;
240 int objd
; /* Object associated to channel */
241 unsigned int free_event_id
; /* Next event ID to allocate */
242 unsigned int used_event_id
; /* Max allocated event IDs */
243 struct cds_list_head list
; /* Channel list */
244 struct ltt_channel_ops
*ops
;
245 int header_type
; /* 0: unset, 1: compact, 2: large */
246 struct shm_handle
*handle
; /* shared-memory handle */
247 int metadata_dumped
:1;
251 int active
; /* Is trace session active ? */
252 int been_active
; /* Has trace session been active ? */
253 int objd
; /* Object associated to session */
254 struct ltt_channel
*metadata
; /* Metadata channel */
255 struct cds_list_head chan
; /* Channel list head */
256 struct cds_list_head events
; /* Event list head */
257 struct cds_list_head list
; /* Session list */
258 unsigned int free_chan_id
; /* Next chan ID to allocate */
259 uuid_t uuid
; /* Trace session unique ID */
260 int metadata_dumped
:1;
263 struct ltt_transport
{
265 struct cds_list_head node
;
266 struct ltt_channel_ops ops
;
269 struct ltt_session
*ltt_session_create(void);
270 int ltt_session_enable(struct ltt_session
*session
);
271 int ltt_session_disable(struct ltt_session
*session
);
272 void ltt_session_destroy(struct ltt_session
*session
);
274 struct ltt_channel
*ltt_channel_create(struct ltt_session
*session
,
275 const char *transport_name
,
277 size_t subbuf_size
, size_t num_subbuf
,
278 unsigned int switch_timer_interval
,
279 unsigned int read_timer_interval
);
280 struct ltt_channel
*ltt_global_channel_create(struct ltt_session
*session
,
281 int overwrite
, void *buf_addr
,
282 size_t subbuf_size
, size_t num_subbuf
,
283 unsigned int switch_timer_interval
,
284 unsigned int read_timer_interval
);
286 struct ltt_event
*ltt_event_create(struct ltt_channel
*chan
,
287 struct lttng_ust_event
*event_param
,
290 int ltt_channel_enable(struct ltt_channel
*channel
);
291 int ltt_channel_disable(struct ltt_channel
*channel
);
292 int ltt_event_enable(struct ltt_event
*event
);
293 int ltt_event_disable(struct ltt_event
*event
);
295 void ltt_transport_register(struct ltt_transport
*transport
);
296 void ltt_transport_unregister(struct ltt_transport
*transport
);
298 void synchronize_trace(void);
299 //int ltt_debugfs_abi_init(void);
300 //void ltt_debugfs_abi_exit(void);
302 int ltt_probe_register(struct lttng_probe_desc
*desc
);
303 void ltt_probe_unregister(struct lttng_probe_desc
*desc
);
304 int pending_probe_fix_events(const struct lttng_event_desc
*desc
);
305 const struct lttng_event_desc
*ltt_event_get(const char *name
);
306 void ltt_event_put(const struct lttng_event_desc
*desc
);
307 int ltt_probes_init(void);
308 void ltt_probes_exit(void);
309 struct lttng_ctx_field
*lttng_append_context(struct lttng_ctx
**ctx
);
310 void lttng_remove_context_field(struct lttng_ctx
**ctx
,
311 struct lttng_ctx_field
*field
);
312 void lttng_destroy_context(struct lttng_ctx
*ctx
);
313 int lttng_add_vtid_to_ctx(struct lttng_ctx
**ctx
);
315 //extern const struct file_operations lttng_tracepoint_list_fops;
317 #endif /* _UST_LTTNG_EVENTS_H */