7 * Copyright 2010 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * Holds LTTng per-session event registry.
12 #include <linux/list.h>
13 #include <linux/uuid.h>
14 #include "ltt-debugfs-abi.h"
18 struct lib_ring_buffer_ctx
;
20 /* Type description */
22 /* Update the astract_types name table in lttng-types.c along with this enum */
32 /* Update the string_encodings name table in lttng-types.c along with this enum */
33 enum lttng_string_encodings
{
34 lttng_encode_UTF8
= 0,
35 lttng_encode_ASCII
= 1,
39 struct lttng_enum_entry
{
40 unsigned long long start
, end
; /* start and end are inclusive */
44 #define __type_integer(_type, _byte_order) \
46 .atype = atype_integer, \
49 .size = sizeof(_type), \
50 .alignment = ltt_alignof(_type) * CHAR_BIT, \
51 .signedness = is_signed_type(_type), \
52 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
56 struct lttng_integer_type {
57 unsigned int size
; /* in bits */
58 unsigned short alignment
; /* in bits */
59 unsigned int signedness
:1;
60 unsigned int reverse_byte_order
:1;
63 union _lttng_basic_type
{
64 struct lttng_integer_type integer
;
69 enum lttng_string_encodings encoding
;
73 struct lttng_basic_type
{
74 enum abstract_types atype
;
76 union _lttng_basic_type basic
;
81 enum abstract_types atype
;
83 union _lttng_basic_type basic
;
85 struct lttng_basic_type elem_type
;
86 unsigned int length
; /* num. elems. */
89 struct lttng_basic_type length_type
;
90 struct lttng_basic_type elem_type
;
97 struct lttng_type container_type
;
98 const struct lttng_enum_entry
*entries
;
102 /* Event field description */
104 struct lttng_event_field
{
106 const struct lttng_type type
;
109 struct lttng_event_desc
{
110 const struct lttng_event_field
*fields
;
112 void *probe_callback
;
113 unsigned int nr_fields
;
116 struct lttng_probe_desc
{
117 const struct lttng_event_desc
*event_desc
;
118 unsigned int nr_events
;
119 struct list_head head
; /* chain registered probes */
123 * ltt_event structure is referred to by the tracing fast path. It must be
128 struct ltt_channel
*chan
;
129 const struct lttng_event_desc
*desc
;
131 enum instrum_type itype
;
132 struct list_head list
; /* Event list */
133 int metadata_dumped
:1;
136 struct ltt_channel_ops
{
137 struct channel
*(*channel_create
)(const char *name
,
138 struct ltt_session
*session
,
140 size_t subbuf_size
, size_t num_subbuf
,
141 unsigned int switch_timer_interval
,
142 unsigned int read_timer_interval
);
143 void (*channel_destroy
)(struct channel
*chan
);
144 struct lib_ring_buffer
*(*buffer_read_open
)(struct channel
*chan
);
145 void (*buffer_read_close
)(struct lib_ring_buffer
*buf
);
146 int (*event_reserve
)(struct lib_ring_buffer_ctx
*ctx
);
147 void (*event_commit
)(struct lib_ring_buffer_ctx
*ctx
);
148 void (*event_write
)(struct lib_ring_buffer_ctx
*ctx
, const void *src
,
151 * packet_avail_size returns the available size in the current
152 * packet. Note that the size returned is only a hint, since it
153 * may change due to concurrent writes.
155 size_t (*packet_avail_size
)(struct channel
*chan
);
156 wait_queue_head_t
*(*get_reader_wait_queue
)(struct ltt_channel
*chan
);
161 struct channel
*chan
; /* Channel buffers */
162 /* Event ID management */
163 struct ltt_session
*session
;
164 struct file
*file
; /* File associated to channel */
165 unsigned int free_event_id
; /* Next event ID to allocate */
166 struct list_head list
; /* Channel list */
167 wait_queue_head_t notify_wait
; /* Channel addition notif. waitqueue */
168 struct ltt_channel_ops
*ops
;
169 int metadata_dumped
:1;
170 int header_type
:2; /* 0: unset, 1: compact, 2: large */
174 int active
; /* Is trace session active ? */
175 struct file
*file
; /* File associated to session */
176 struct ltt_channel
*metadata
; /* Metadata channel */
177 struct list_head chan
; /* Channel list head */
178 struct list_head events
; /* Event list head */
179 struct list_head list
; /* Session list */
180 unsigned int free_chan_id
; /* Next chan ID to allocate */
181 uuid_le uuid
; /* Trace session unique ID */
182 int metadata_dumped
:1;
185 struct ltt_transport
{
187 struct module
*owner
;
188 struct list_head node
;
189 struct ltt_channel_ops ops
;
192 struct ltt_session
*ltt_session_create(void);
193 int ltt_session_start(struct ltt_session
*session
);
194 int ltt_session_stop(struct ltt_session
*session
);
195 void ltt_session_destroy(struct ltt_session
*session
);
197 struct ltt_channel
*ltt_channel_create(struct ltt_session
*session
,
198 const char *transport_name
,
200 size_t subbuf_size
, size_t num_subbuf
,
201 unsigned int switch_timer_interval
,
202 unsigned int read_timer_interval
);
203 struct ltt_channel
*ltt_global_channel_create(struct ltt_session
*session
,
204 int overwrite
, void *buf_addr
,
205 size_t subbuf_size
, size_t num_subbuf
,
206 unsigned int switch_timer_interval
,
207 unsigned int read_timer_interval
);
208 void _ltt_channel_destroy(struct ltt_channel
*chan
);
210 struct ltt_event
*ltt_event_create(struct ltt_channel
*chan
,
212 enum instrum_type itype
,
213 const struct lttng_event_desc
*event_desc
,
215 int ltt_event_unregister(struct ltt_event
*event
);
217 void ltt_transport_register(struct ltt_transport
*transport
);
218 void ltt_transport_unregister(struct ltt_transport
*transport
);
220 int ltt_debugfs_abi_init(void);
221 void ltt_debugfs_abi_exit(void);
223 int ltt_probe_register(struct lttng_probe_desc
*desc
);
224 void ltt_probe_unregister(struct lttng_probe_desc
*desc
);
225 const struct lttng_event_desc
*ltt_event_get(const char *name
);
226 void ltt_event_put(const struct lttng_event_desc
*desc
);
227 int ltt_probes_init(void);
228 void ltt_probes_exit(void);
230 #endif /* _LTT_EVENTS_H */