7 * Copyright 2010 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * Holds LTTng per-session event registry.
12 #include <linux/list.h>
13 #include "ltt-debugfs-abi.h"
17 struct lib_ring_buffer_ctx
;
19 /* Type description */
21 /* Update the astract_types name table in lttng-types.c along with this enum */
31 /* Update the string_encodings name table in lttng-types.c along with this enum */
32 enum lttng_string_encodings
{
33 lttng_encode_UTF8
= 0,
34 lttng_encode_ASCII
= 1,
38 struct lttng_enum_entry
{
39 unsigned long long start
, end
; /* start and end are inclusive */
43 #define __type_integer(_type, _byte_order) \
45 .atype = atype_integer, \
48 .size = sizeof(_type), \
49 .alignment = __alignof__(_type), \
50 .signedness = is_signed_type(_type), \
51 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
55 struct lttng_integer_type {
56 unsigned int size
; /* in bits */
57 unsigned short alignment
; /* in bits */
58 unsigned int signedness
:1;
59 unsigned int reverse_byte_order
:1;
62 union _lttng_basic_type
{
63 struct lttng_integer_type integer
;
68 enum lttng_string_encodings encoding
;
72 struct lttng_basic_type
{
73 enum abstract_types atype
;
75 union _lttng_basic_type basic
;
80 enum abstract_types atype
;
82 union _lttng_basic_type basic
;
84 struct lttng_basic_type elem_type
;
85 unsigned int length
; /* num. elems. */
88 struct lttng_basic_type length_type
;
89 struct lttng_basic_type elem_type
;
96 struct lttng_type container_type
;
97 const struct lttng_enum_entry
*entries
;
101 /* Event field description */
103 struct lttng_event_field
{
105 const struct lttng_type type
;
108 struct lttng_event_desc
{
109 const struct lttng_event_field
*fields
;
111 void *probe_callback
;
112 unsigned int nr_fields
;
115 struct lttng_probe_desc
{
116 const struct lttng_event_desc
*event_desc
;
117 unsigned int nr_events
;
118 struct list_head head
; /* chain registered probes */
122 * ltt_event structure is referred to by the tracing fast path. It must be
127 struct ltt_channel
*chan
;
128 const struct lttng_event_desc
*desc
;
130 enum instrum_type itype
;
131 struct list_head list
; /* Event list */
132 int metadata_dumped
:1;
135 struct ltt_channel_ops
{
136 struct channel
*(*channel_create
)(const char *name
,
137 struct ltt_session
*session
,
139 size_t subbuf_size
, size_t num_subbuf
,
140 unsigned int switch_timer_interval
,
141 unsigned int read_timer_interval
);
142 void (*channel_destroy
)(struct channel
*chan
);
143 struct lib_ring_buffer
*(*buffer_read_open
)(struct channel
*chan
);
144 void (*buffer_read_close
)(struct lib_ring_buffer
*buf
);
145 int (*event_reserve
)(struct lib_ring_buffer_ctx
*ctx
);
146 void (*event_commit
)(struct lib_ring_buffer_ctx
*ctx
);
147 void (*event_write
)(struct lib_ring_buffer_ctx
*ctx
, const void *src
,
149 wait_queue_head_t
*(*get_reader_wait_queue
)(struct ltt_channel
*chan
);
154 struct channel
*chan
; /* Channel buffers */
155 /* Event ID management */
156 struct ltt_session
*session
;
157 struct file
*file
; /* File associated to channel */
158 unsigned int free_event_id
; /* Next event ID to allocate */
159 struct list_head list
; /* Channel list */
160 wait_queue_head_t notify_wait
; /* Channel addition notif. waitqueue */
161 struct ltt_channel_ops
*ops
;
162 int metadata_dumped
:1;
163 int header_type
:2; /* 0: unset, 1: compact, 2: large */
167 int active
; /* Is trace session active ? */
168 struct file
*file
; /* File associated to session */
169 struct ltt_channel
*metadata
; /* Metadata channel */
170 struct list_head chan
; /* Channel list head */
171 struct list_head events
; /* Event list head */
172 struct list_head list
; /* Session list */
173 unsigned int free_chan_id
; /* Next chan ID to allocate */
174 int metadata_dumped
:1;
177 struct ltt_transport
{
179 struct module
*owner
;
180 struct list_head node
;
181 struct ltt_channel_ops ops
;
184 struct ltt_session
*ltt_session_create(void);
185 int ltt_session_start(struct ltt_session
*session
);
186 int ltt_session_stop(struct ltt_session
*session
);
187 void ltt_session_destroy(struct ltt_session
*session
);
189 struct ltt_channel
*ltt_channel_create(struct ltt_session
*session
,
190 const char *transport_name
,
192 size_t subbuf_size
, size_t num_subbuf
,
193 unsigned int switch_timer_interval
,
194 unsigned int read_timer_interval
);
195 struct ltt_channel
*ltt_global_channel_create(struct ltt_session
*session
,
196 int overwrite
, void *buf_addr
,
197 size_t subbuf_size
, size_t num_subbuf
,
198 unsigned int switch_timer_interval
,
199 unsigned int read_timer_interval
);
200 void _ltt_channel_destroy(struct ltt_channel
*chan
);
202 struct ltt_event
*ltt_event_create(struct ltt_channel
*chan
,
204 enum instrum_type itype
,
205 const struct lttng_event_desc
*event_desc
,
207 int _ltt_event_unregister(struct ltt_event
*event
);
208 void _ltt_event_destroy(struct ltt_event
*event
);
210 void ltt_transport_register(struct ltt_transport
*transport
);
211 void ltt_transport_unregister(struct ltt_transport
*transport
);
213 int ltt_debugfs_abi_init(void);
214 void ltt_debugfs_abi_exit(void);
216 int ltt_probe_register(struct lttng_probe_desc
*desc
);
217 void ltt_probe_unregister(struct lttng_probe_desc
*desc
);
218 const struct lttng_event_desc
*ltt_event_get(const char *name
);
219 void ltt_event_put(const struct lttng_event_desc
*desc
);
220 int ltt_probes_init(void);
221 void ltt_probes_exit(void);
223 #endif /* _LTT_EVENTS_H */