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 struct perf_event_attr
;
23 /* Type description */
25 /* Update the astract_types name table in lttng-types.c along with this enum */
35 /* Update the string_encodings name table in lttng-types.c along with this enum */
36 enum lttng_string_encodings
{
37 lttng_encode_none
= 0,
38 lttng_encode_UTF8
= 1,
39 lttng_encode_ASCII
= 2,
43 struct lttng_enum_entry
{
44 unsigned long long start
, end
; /* start and end are inclusive */
48 #define __type_integer(_type, _byte_order, _base, _encoding) \
50 .atype = atype_integer, \
53 .size = sizeof(_type) * CHAR_BIT, \
54 .alignment = ltt_alignof(_type) * CHAR_BIT, \
55 .signedness = is_signed_type(_type), \
56 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
58 .encoding = lttng_encode_##_encoding, \
62 struct lttng_integer_type {
63 unsigned int size
; /* in bits */
64 unsigned short alignment
; /* in bits */
65 unsigned int signedness
:1;
66 unsigned int reverse_byte_order
:1;
67 unsigned int base
; /* 2, 8, 10, 16, for pretty print */
68 enum lttng_string_encodings encoding
;
71 union _lttng_basic_type
{
72 struct lttng_integer_type integer
;
77 enum lttng_string_encodings encoding
;
81 struct lttng_basic_type
{
82 enum abstract_types atype
;
84 union _lttng_basic_type basic
;
89 enum abstract_types atype
;
91 union _lttng_basic_type basic
;
93 struct lttng_basic_type elem_type
;
94 unsigned int length
; /* num. elems. */
97 struct lttng_basic_type length_type
;
98 struct lttng_basic_type elem_type
;
105 struct lttng_type container_type
;
106 const struct lttng_enum_entry
*entries
;
110 /* Event field description */
112 struct lttng_event_field
{
114 struct lttng_type type
;
117 struct lttng_ctx_field
{
119 struct lttng_type type
;
123 struct perf_event
**e
; /* per-cpu array */
124 struct list_head head
;
125 struct perf_event_attr
*attr
;
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
;
143 struct module
*owner
;
146 struct lttng_probe_desc
{
147 const struct lttng_event_desc
*event_desc
;
148 unsigned int nr_events
;
149 struct list_head head
; /* chain registered probes */
153 * ltt_event structure is referred to by the tracing fast path. It must be
158 struct ltt_channel
*chan
;
159 const struct lttng_event_desc
*desc
;
161 enum lttng_kernel_instrumentation instrumentation
;
171 struct list_head list
; /* Event list */
172 int metadata_dumped
:1;
175 struct ltt_channel_ops
{
176 struct channel
*(*channel_create
)(const char *name
,
177 struct ltt_channel
*ltt_chan
,
179 size_t subbuf_size
, size_t num_subbuf
,
180 unsigned int switch_timer_interval
,
181 unsigned int read_timer_interval
);
182 void (*channel_destroy
)(struct channel
*chan
);
183 struct lib_ring_buffer
*(*buffer_read_open
)(struct channel
*chan
);
184 void (*buffer_read_close
)(struct lib_ring_buffer
*buf
);
185 int (*event_reserve
)(struct lib_ring_buffer_ctx
*ctx
,
187 void (*event_commit
)(struct lib_ring_buffer_ctx
*ctx
);
188 void (*event_write
)(struct lib_ring_buffer_ctx
*ctx
, const void *src
,
191 * packet_avail_size returns the available size in the current
192 * packet. Note that the size returned is only a hint, since it
193 * may change due to concurrent writes.
195 size_t (*packet_avail_size
)(struct channel
*chan
);
196 wait_queue_head_t
*(*get_reader_wait_queue
)(struct ltt_channel
*chan
);
201 struct channel
*chan
; /* Channel buffers */
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 list_head list
; /* Channel list */
207 wait_queue_head_t notify_wait
; /* Channel addition notif. waitqueue */
208 struct ltt_channel_ops
*ops
;
209 int header_type
; /* 0: unset, 1: compact, 2: large */
210 int metadata_dumped
:1;
214 int active
; /* Is trace session active ? */
215 struct file
*file
; /* File associated to session */
216 struct ltt_channel
*metadata
; /* Metadata channel */
217 struct list_head chan
; /* Channel list head */
218 struct list_head events
; /* Event list head */
219 struct list_head list
; /* Session list */
220 unsigned int free_chan_id
; /* Next chan ID to allocate */
221 uuid_le uuid
; /* Trace session unique ID */
222 int metadata_dumped
:1;
225 struct ltt_transport
{
227 struct module
*owner
;
228 struct list_head node
;
229 struct ltt_channel_ops ops
;
232 struct ltt_session
*ltt_session_create(void);
233 int ltt_session_start(struct ltt_session
*session
);
234 int ltt_session_stop(struct ltt_session
*session
);
235 void ltt_session_destroy(struct ltt_session
*session
);
237 struct ltt_channel
*ltt_channel_create(struct ltt_session
*session
,
238 const char *transport_name
,
240 size_t subbuf_size
, size_t num_subbuf
,
241 unsigned int switch_timer_interval
,
242 unsigned int read_timer_interval
);
243 struct ltt_channel
*ltt_global_channel_create(struct ltt_session
*session
,
244 int overwrite
, void *buf_addr
,
245 size_t subbuf_size
, size_t num_subbuf
,
246 unsigned int switch_timer_interval
,
247 unsigned int read_timer_interval
);
249 struct ltt_event
*ltt_event_create(struct ltt_channel
*chan
,
250 struct lttng_kernel_event
*event_param
,
253 void ltt_transport_register(struct ltt_transport
*transport
);
254 void ltt_transport_unregister(struct ltt_transport
*transport
);
256 int ltt_debugfs_abi_init(void);
257 void ltt_debugfs_abi_exit(void);
259 int ltt_probe_register(struct lttng_probe_desc
*desc
);
260 void ltt_probe_unregister(struct lttng_probe_desc
*desc
);
261 const struct lttng_event_desc
*ltt_event_get(const char *name
);
262 void ltt_event_put(const struct lttng_event_desc
*desc
);
263 int ltt_probes_init(void);
264 void ltt_probes_exit(void);
265 struct lttng_ctx_field
*lttng_append_context(struct lttng_ctx
**ctx
);
266 void lttng_destroy_context(struct lttng_ctx
*ctx
);
268 #ifdef CONFIG_KPROBES
269 int lttng_kprobes_register(const char *name
,
270 const char *symbol_name
,
273 struct ltt_event
*event
);
274 void lttng_kprobes_unregister(struct ltt_event
*event
);
275 void lttng_kprobes_destroy_private(struct ltt_event
*event
);
278 int lttng_kprobes_register(const char *name
,
279 const char *symbol_name
,
282 struct ltt_event
*event
)
288 void lttng_kprobes_unregister(struct ltt_event
*event
)
293 void lttng_kprobes_destroy_private(struct ltt_event
*event
)
298 #ifdef CONFIG_DYNAMIC_FTRACE
299 int lttng_ftrace_register(const char *name
,
300 const char *symbol_name
,
301 struct ltt_event
*event
);
302 void lttng_ftrace_unregister(struct ltt_event
*event
);
303 void lttng_ftrace_destroy_private(struct ltt_event
*event
);
306 int lttng_ftrace_register(const char *name
,
307 const char *symbol_name
,
308 struct ltt_event
*event
)
314 void lttng_ftrace_unregister(struct ltt_event
*event
)
319 void lttng_ftrace_destroy_private(struct ltt_event
*event
)
324 extern const struct file_operations lttng_tracepoint_list_fops
;
326 #endif /* _LTT_EVENTS_H */