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 <linux/kprobes.h>
15 #include "ltt-debugfs-abi.h"
19 struct lib_ring_buffer_ctx
;
21 /* Type description */
23 /* Update the astract_types name table in lttng-types.c along with this enum */
33 /* Update the string_encodings name table in lttng-types.c along with this enum */
34 enum lttng_string_encodings
{
35 lttng_encode_none
= 0,
36 lttng_encode_UTF8
= 1,
37 lttng_encode_ASCII
= 2,
41 struct lttng_enum_entry
{
42 unsigned long long start
, end
; /* start and end are inclusive */
46 #define __type_integer(_type, _byte_order, _base) \
48 .atype = atype_integer, \
51 .size = sizeof(_type), \
52 .alignment = ltt_alignof(_type) * CHAR_BIT, \
53 .signedness = is_signed_type(_type), \
54 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
56 .encoding = lttng_encode_none, \
60 struct lttng_integer_type {
61 unsigned int size
; /* in bits */
62 unsigned short alignment
; /* in bits */
63 unsigned int signedness
:1;
64 unsigned int reverse_byte_order
:1;
65 unsigned int base
; /* 2, 8, 10, 16, for pretty print */
66 enum lttng_string_encodings encoding
;
69 union _lttng_basic_type
{
70 struct lttng_integer_type integer
;
75 enum lttng_string_encodings encoding
;
79 struct lttng_basic_type
{
80 enum abstract_types atype
;
82 union _lttng_basic_type basic
;
87 enum abstract_types atype
;
89 union _lttng_basic_type basic
;
91 struct lttng_basic_type elem_type
;
92 unsigned int length
; /* num. elems. */
95 struct lttng_basic_type length_type
;
96 struct lttng_basic_type elem_type
;
103 struct lttng_type container_type
;
104 const struct lttng_enum_entry
*entries
;
108 /* Event field description */
110 struct lttng_event_field
{
112 struct lttng_type type
;
115 struct lttng_event_ctx
{
116 const struct lttng_event_field
*fields
;
117 unsigned int nr_fields
;
120 struct lttng_event_desc
{
122 void *probe_callback
;
123 const struct lttng_event_ctx
*ctx
; /* context */
124 const struct lttng_event_field
*fields
; /* event payload */
125 unsigned int nr_fields
;
128 struct lttng_probe_desc
{
129 const struct lttng_event_desc
*event_desc
;
130 unsigned int nr_events
;
131 struct list_head head
; /* chain registered probes */
135 * ltt_event structure is referred to by the tracing fast path. It must be
140 struct ltt_channel
*chan
;
141 const struct lttng_event_desc
*desc
;
143 enum lttng_kernel_instrumentation instrumentation
;
153 struct list_head list
; /* Event list */
154 int metadata_dumped
:1;
157 struct ltt_channel_ops
{
158 struct channel
*(*channel_create
)(const char *name
,
159 struct ltt_channel
*ltt_chan
,
161 size_t subbuf_size
, size_t num_subbuf
,
162 unsigned int switch_timer_interval
,
163 unsigned int read_timer_interval
);
164 void (*channel_destroy
)(struct channel
*chan
);
165 struct lib_ring_buffer
*(*buffer_read_open
)(struct channel
*chan
);
166 void (*buffer_read_close
)(struct lib_ring_buffer
*buf
);
167 int (*event_reserve
)(struct lib_ring_buffer_ctx
*ctx
);
168 void (*event_commit
)(struct lib_ring_buffer_ctx
*ctx
);
169 void (*event_write
)(struct lib_ring_buffer_ctx
*ctx
, const void *src
,
172 * packet_avail_size returns the available size in the current
173 * packet. Note that the size returned is only a hint, since it
174 * may change due to concurrent writes.
176 size_t (*packet_avail_size
)(struct channel
*chan
);
177 wait_queue_head_t
*(*get_reader_wait_queue
)(struct ltt_channel
*chan
);
182 struct channel
*chan
; /* Channel buffers */
183 /* Event ID management */
184 struct ltt_session
*session
;
185 struct file
*file
; /* File associated to channel */
186 unsigned int free_event_id
; /* Next event ID to allocate */
187 struct list_head list
; /* Channel list */
188 wait_queue_head_t notify_wait
; /* Channel addition notif. waitqueue */
189 struct ltt_channel_ops
*ops
;
190 int header_type
; /* 0: unset, 1: compact, 2: large */
191 int metadata_dumped
:1;
195 int active
; /* Is trace session active ? */
196 struct file
*file
; /* File associated to session */
197 struct ltt_channel
*metadata
; /* Metadata channel */
198 struct list_head chan
; /* Channel list head */
199 struct list_head events
; /* Event list head */
200 struct list_head list
; /* Session list */
201 unsigned int free_chan_id
; /* Next chan ID to allocate */
202 uuid_le uuid
; /* Trace session unique ID */
203 int metadata_dumped
:1;
206 struct ltt_transport
{
208 struct module
*owner
;
209 struct list_head node
;
210 struct ltt_channel_ops ops
;
213 struct ltt_session
*ltt_session_create(void);
214 int ltt_session_start(struct ltt_session
*session
);
215 int ltt_session_stop(struct ltt_session
*session
);
216 void ltt_session_destroy(struct ltt_session
*session
);
218 struct ltt_channel
*ltt_channel_create(struct ltt_session
*session
,
219 const char *transport_name
,
221 size_t subbuf_size
, size_t num_subbuf
,
222 unsigned int switch_timer_interval
,
223 unsigned int read_timer_interval
);
224 struct ltt_channel
*ltt_global_channel_create(struct ltt_session
*session
,
225 int overwrite
, void *buf_addr
,
226 size_t subbuf_size
, size_t num_subbuf
,
227 unsigned int switch_timer_interval
,
228 unsigned int read_timer_interval
);
229 void _ltt_channel_destroy(struct ltt_channel
*chan
);
231 struct ltt_event
*ltt_event_create(struct ltt_channel
*chan
,
233 struct lttng_kernel_event
*event_param
,
235 int ltt_event_unregister(struct ltt_event
*event
);
237 void ltt_transport_register(struct ltt_transport
*transport
);
238 void ltt_transport_unregister(struct ltt_transport
*transport
);
240 int ltt_debugfs_abi_init(void);
241 void ltt_debugfs_abi_exit(void);
243 int ltt_probe_register(struct lttng_probe_desc
*desc
);
244 void ltt_probe_unregister(struct lttng_probe_desc
*desc
);
245 const struct lttng_event_desc
*ltt_event_get(const char *name
);
246 void ltt_event_put(const struct lttng_event_desc
*desc
);
247 int ltt_probes_init(void);
248 void ltt_probes_exit(void);
250 #ifdef CONFIG_KPROBES
251 int lttng_kprobes_register(const char *name
,
252 const char *symbol_name
,
255 struct ltt_event
*event
);
256 void lttng_kprobes_unregister(struct ltt_event
*event
);
259 int lttng_kprobes_register(const char *name
,
260 const char *symbol_name
,
263 struct ltt_event
*event
)
268 void lttng_kprobes_unregister(struct ltt_event
*event
)
273 #ifdef CONFIG_DYNAMIC_FTRACE
274 int lttng_ftrace_register(const char *name
,
275 const char *symbol_name
,
276 struct ltt_event
*event
);
277 void lttng_ftrace_unregister(struct ltt_event
*event
);
280 int lttng_ftrace_register(const char *name
,
281 const char *symbol_name
,
282 struct ltt_event
*event
)
288 void lttng_ftrace_unregister(struct ltt_event
*event
)
292 #endif /* _LTT_EVENTS_H */