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
;
22 /* Type description */
24 /* Update the astract_types name table in lttng-types.c along with this enum */
34 /* Update the string_encodings name table in lttng-types.c along with this enum */
35 enum lttng_string_encodings
{
36 lttng_encode_none
= 0,
37 lttng_encode_UTF8
= 1,
38 lttng_encode_ASCII
= 2,
42 struct lttng_enum_entry
{
43 unsigned long long start
, end
; /* start and end are inclusive */
47 #define __type_integer(_type, _byte_order, _base) \
49 .atype = atype_integer, \
52 .size = sizeof(_type), \
53 .alignment = ltt_alignof(_type) * CHAR_BIT, \
54 .signedness = is_signed_type(_type), \
55 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
57 .encoding = lttng_encode_none, \
61 struct lttng_integer_type {
62 unsigned int size
; /* in bits */
63 unsigned short alignment
; /* in bits */
64 unsigned int signedness
:1;
65 unsigned int reverse_byte_order
:1;
66 unsigned int base
; /* 2, 8, 10, 16, for pretty print */
67 enum lttng_string_encodings encoding
;
70 union _lttng_basic_type
{
71 struct lttng_integer_type integer
;
76 enum lttng_string_encodings encoding
;
80 struct lttng_basic_type
{
81 enum abstract_types atype
;
83 union _lttng_basic_type basic
;
88 enum abstract_types atype
;
90 union _lttng_basic_type basic
;
92 struct lttng_basic_type elem_type
;
93 unsigned int length
; /* num. elems. */
96 struct lttng_basic_type length_type
;
97 struct lttng_basic_type elem_type
;
104 struct lttng_type container_type
;
105 const struct lttng_enum_entry
*entries
;
109 /* Event field description */
111 struct lttng_event_field
{
113 struct lttng_type type
;
116 struct lttng_ctx_field
{
118 struct lttng_type type
;
119 void *ctx_field_callback
;
122 struct perf_event
**e
; /* per-cpu array */
123 struct list_head
*head
;
129 const struct lttng_ctx_field
*fields
;
130 unsigned int nr_fields
;
131 unsigned int allocated_fields
;
134 struct lttng_event_desc
{
136 void *probe_callback
;
137 const struct lttng_event_ctx
*ctx
; /* context */
138 const struct lttng_event_field
*fields
; /* event payload */
139 unsigned int nr_fields
;
142 struct lttng_probe_desc
{
143 const struct lttng_event_desc
*event_desc
;
144 unsigned int nr_events
;
145 struct list_head head
; /* chain registered probes */
149 * ltt_event structure is referred to by the tracing fast path. It must be
154 struct ltt_channel
*chan
;
155 const struct lttng_event_desc
*desc
;
157 enum lttng_kernel_instrumentation instrumentation
;
167 struct list_head list
; /* Event list */
168 int metadata_dumped
:1;
171 struct ltt_channel_ops
{
172 struct channel
*(*channel_create
)(const char *name
,
173 struct ltt_channel
*ltt_chan
,
175 size_t subbuf_size
, size_t num_subbuf
,
176 unsigned int switch_timer_interval
,
177 unsigned int read_timer_interval
);
178 void (*channel_destroy
)(struct channel
*chan
);
179 struct lib_ring_buffer
*(*buffer_read_open
)(struct channel
*chan
);
180 void (*buffer_read_close
)(struct lib_ring_buffer
*buf
);
181 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 ltt_channel
*chan
);
196 struct channel
*chan
; /* Channel buffers */
197 /* Event ID management */
198 struct ltt_session
*session
;
199 struct file
*file
; /* File associated to channel */
200 unsigned int free_event_id
; /* Next event ID to allocate */
201 struct list_head list
; /* Channel list */
202 wait_queue_head_t notify_wait
; /* Channel addition notif. waitqueue */
203 struct ltt_channel_ops
*ops
;
204 int header_type
; /* 0: unset, 1: compact, 2: large */
205 int metadata_dumped
:1;
209 int active
; /* Is trace session active ? */
210 struct file
*file
; /* File associated to session */
211 struct ltt_channel
*metadata
; /* Metadata channel */
212 struct list_head chan
; /* Channel list head */
213 struct list_head events
; /* Event list head */
214 struct list_head list
; /* Session list */
215 unsigned int free_chan_id
; /* Next chan ID to allocate */
216 uuid_le uuid
; /* Trace session unique ID */
217 int metadata_dumped
:1;
220 struct ltt_transport
{
222 struct module
*owner
;
223 struct list_head node
;
224 struct ltt_channel_ops ops
;
227 struct ltt_session
*ltt_session_create(void);
228 int ltt_session_start(struct ltt_session
*session
);
229 int ltt_session_stop(struct ltt_session
*session
);
230 void ltt_session_destroy(struct ltt_session
*session
);
232 struct ltt_channel
*ltt_channel_create(struct ltt_session
*session
,
233 const char *transport_name
,
235 size_t subbuf_size
, size_t num_subbuf
,
236 unsigned int switch_timer_interval
,
237 unsigned int read_timer_interval
);
238 struct ltt_channel
*ltt_global_channel_create(struct ltt_session
*session
,
239 int overwrite
, void *buf_addr
,
240 size_t subbuf_size
, size_t num_subbuf
,
241 unsigned int switch_timer_interval
,
242 unsigned int read_timer_interval
);
243 void _ltt_channel_destroy(struct ltt_channel
*chan
);
245 struct ltt_event
*ltt_event_create(struct ltt_channel
*chan
,
247 struct lttng_kernel_event
*event_param
,
249 int ltt_event_unregister(struct ltt_event
*event
);
251 void ltt_transport_register(struct ltt_transport
*transport
);
252 void ltt_transport_unregister(struct ltt_transport
*transport
);
254 int ltt_debugfs_abi_init(void);
255 void ltt_debugfs_abi_exit(void);
257 int ltt_probe_register(struct lttng_probe_desc
*desc
);
258 void ltt_probe_unregister(struct lttng_probe_desc
*desc
);
259 const struct lttng_event_desc
*ltt_event_get(const char *name
);
260 void ltt_event_put(const struct lttng_event_desc
*desc
);
261 int ltt_probes_init(void);
262 void ltt_probes_exit(void);
264 #ifdef CONFIG_KPROBES
265 int lttng_kprobes_register(const char *name
,
266 const char *symbol_name
,
269 struct ltt_event
*event
);
270 void lttng_kprobes_unregister(struct ltt_event
*event
);
273 int lttng_kprobes_register(const char *name
,
274 const char *symbol_name
,
277 struct ltt_event
*event
)
282 void lttng_kprobes_unregister(struct ltt_event
*event
)
287 #ifdef CONFIG_DYNAMIC_FTRACE
288 int lttng_ftrace_register(const char *name
,
289 const char *symbol_name
,
290 struct ltt_event
*event
);
291 void lttng_ftrace_unregister(struct ltt_event
*event
);
294 int lttng_ftrace_register(const char *name
,
295 const char *symbol_name
,
296 struct ltt_event
*event
)
302 void lttng_ftrace_unregister(struct ltt_event
*event
)
306 #endif /* _LTT_EVENTS_H */