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>
20 #define is_signed_type(type) (((type)(-1)) < 0)
24 struct lib_ring_buffer_ctx
;
26 /* Type description */
28 /* Update the astract_types name table in lttng-types.c along with this enum */
38 /* Update the string_encodings name table in lttng-types.c along with this enum */
39 enum lttng_string_encodings
{
40 lttng_encode_none
= 0,
41 lttng_encode_UTF8
= 1,
42 lttng_encode_ASCII
= 2,
46 struct lttng_enum_entry
{
47 unsigned long long start
, end
; /* start and end are inclusive */
51 #define __type_integer(_type, _byte_order, _base, _encoding) \
53 .atype = atype_integer, \
56 .size = sizeof(_type) * CHAR_BIT, \
57 .alignment = ltt_alignof(_type) * CHAR_BIT, \
58 .signedness = is_signed_type(_type), \
59 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
61 .encoding = lttng_encode_##_encoding, \
65 struct lttng_integer_type {
66 unsigned int size
; /* in bits */
67 unsigned short alignment
; /* in bits */
68 unsigned int signedness
:1;
69 unsigned int reverse_byte_order
:1;
70 unsigned int base
; /* 2, 8, 10, 16, for pretty print */
71 enum lttng_string_encodings encoding
;
74 union _lttng_basic_type
{
75 struct lttng_integer_type integer
;
80 enum lttng_string_encodings encoding
;
84 struct lttng_basic_type
{
85 enum abstract_types atype
;
87 union _lttng_basic_type basic
;
92 enum abstract_types atype
;
94 union _lttng_basic_type basic
;
96 struct lttng_basic_type elem_type
;
97 unsigned int length
; /* num. elems. */
100 struct lttng_basic_type length_type
;
101 struct lttng_basic_type elem_type
;
108 struct lttng_type container_type
;
109 const struct lttng_enum_entry
*entries
;
113 /* Event field description */
115 struct lttng_event_field
{
117 struct lttng_type type
;
120 struct lttng_ctx_field
{
121 struct lttng_event_field event_field
;
122 size_t (*get_size
)(size_t offset
);
123 void (*record
)(struct lttng_ctx_field
*field
,
124 struct lib_ring_buffer_ctx
*ctx
,
125 struct ltt_channel
*chan
);
128 void (*destroy
)(struct lttng_ctx_field
*field
);
132 struct lttng_ctx_field
*fields
;
133 unsigned int nr_fields
;
134 unsigned int allocated_fields
;
137 struct lttng_event_desc
{
139 void *probe_callback
;
140 const struct lttng_event_ctx
*ctx
; /* context */
141 const struct lttng_event_field
*fields
; /* event payload */
142 unsigned int nr_fields
;
145 struct lttng_probe_desc
{
146 const struct lttng_event_desc
*event_desc
;
147 unsigned int nr_events
;
148 struct cds_list_head head
; /* chain registered probes */
152 * ltt_event structure is referred to by the tracing fast path. It must be
157 struct ltt_channel
*chan
;
159 const struct lttng_event_desc
*desc
;
161 struct lttng_ctx
*ctx
;
162 enum lttng_ust_instrumentation instrumentation
;
165 struct cds_list_head list
; /* Event list */
166 int metadata_dumped
:1;
169 struct ltt_channel_ops
{
170 struct channel
*(*channel_create
)(const char *name
,
171 struct ltt_channel
*ltt_chan
,
173 size_t subbuf_size
, size_t num_subbuf
,
174 unsigned int switch_timer_interval
,
175 unsigned int read_timer_interval
,
177 void (*channel_destroy
)(struct channel
*chan
);
178 struct lib_ring_buffer
*(*buffer_read_open
)(struct channel
*chan
);
179 void (*buffer_read_close
)(struct lib_ring_buffer
*buf
);
180 int (*event_reserve
)(struct lib_ring_buffer_ctx
*ctx
,
182 void (*event_commit
)(struct lib_ring_buffer_ctx
*ctx
);
183 void (*event_write
)(struct lib_ring_buffer_ctx
*ctx
, const void *src
,
186 * packet_avail_size returns the available size in the current
187 * packet. Note that the size returned is only a hint, since it
188 * may change due to concurrent writes.
190 size_t (*packet_avail_size
)(struct channel
*chan
);
191 //wait_queue_head_t *(*get_reader_wait_queue)(struct channel *chan);
192 //wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
193 int (*is_finalized
)(struct channel
*chan
);
194 int (*is_disabled
)(struct channel
*chan
);
199 struct channel
*chan
; /* Channel buffers */
201 struct lttng_ctx
*ctx
;
202 /* Event ID management */
203 struct ltt_session
*session
;
204 struct file
*file
; /* File associated to channel */
205 unsigned int free_event_id
; /* Next event ID to allocate */
206 struct cds_list_head list
; /* Channel list */
207 struct ltt_channel_ops
*ops
;
208 int header_type
; /* 0: unset, 1: compact, 2: large */
209 int metadata_dumped
:1;
213 int active
; /* Is trace session active ? */
214 int been_active
; /* Has trace session been active ? */
215 struct file
*file
; /* File associated to session */
216 struct ltt_channel
*metadata
; /* Metadata channel */
217 struct cds_list_head chan
; /* Channel list head */
218 struct cds_list_head events
; /* Event list head */
219 struct cds_list_head list
; /* Session list */
220 unsigned int free_chan_id
; /* Next chan ID to allocate */
221 uuid_t uuid
; /* Trace session unique ID */
222 int metadata_dumped
:1;
225 struct ltt_transport
{
227 struct cds_list_head node
;
228 struct ltt_channel_ops ops
;
231 struct ltt_session
*ltt_session_create(void);
232 int ltt_session_enable(struct ltt_session
*session
);
233 int ltt_session_disable(struct ltt_session
*session
);
234 void ltt_session_destroy(struct ltt_session
*session
);
236 struct ltt_channel
*ltt_channel_create(struct ltt_session
*session
,
237 const char *transport_name
,
239 size_t subbuf_size
, size_t num_subbuf
,
240 unsigned int switch_timer_interval
,
241 unsigned int read_timer_interval
);
242 struct ltt_channel
*ltt_global_channel_create(struct ltt_session
*session
,
243 int overwrite
, void *buf_addr
,
244 size_t subbuf_size
, size_t num_subbuf
,
245 unsigned int switch_timer_interval
,
246 unsigned int read_timer_interval
);
248 struct ltt_event
*ltt_event_create(struct ltt_channel
*chan
,
249 struct lttng_ust_event
*event_param
,
252 int ltt_channel_enable(struct ltt_channel
*channel
);
253 int ltt_channel_disable(struct ltt_channel
*channel
);
254 int ltt_event_enable(struct ltt_event
*event
);
255 int ltt_event_disable(struct ltt_event
*event
);
257 void ltt_transport_register(struct ltt_transport
*transport
);
258 void ltt_transport_unregister(struct ltt_transport
*transport
);
260 void synchronize_trace(void);
261 //int ltt_debugfs_abi_init(void);
262 //void ltt_debugfs_abi_exit(void);
264 int ltt_probe_register(struct lttng_probe_desc
*desc
);
265 void ltt_probe_unregister(struct lttng_probe_desc
*desc
);
266 const struct lttng_event_desc
*ltt_event_get(const char *name
);
267 void ltt_event_put(const struct lttng_event_desc
*desc
);
268 int ltt_probes_init(void);
269 void ltt_probes_exit(void);
270 struct lttng_ctx_field
*lttng_append_context(struct lttng_ctx
**ctx
);
271 void lttng_remove_context_field(struct lttng_ctx
**ctx
,
272 struct lttng_ctx_field
*field
);
273 void lttng_destroy_context(struct lttng_ctx
*ctx
);
274 int lttng_add_vtid_to_ctx(struct lttng_ctx
**ctx
);
276 //extern const struct file_operations lttng_tracepoint_list_fops;
278 #endif /* _LTT_EVENTS_H */