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_UTF8
= 0,
36 lttng_encode_ASCII
= 1,
40 struct lttng_enum_entry
{
41 unsigned long long start
, end
; /* start and end are inclusive */
45 #define __type_integer(_type, _byte_order) \
47 .atype = atype_integer, \
50 .size = sizeof(_type), \
51 .alignment = ltt_alignof(_type) * CHAR_BIT, \
52 .signedness = is_signed_type(_type), \
53 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
57 struct lttng_integer_type {
58 unsigned int size
; /* in bits */
59 unsigned short alignment
; /* in bits */
60 unsigned int signedness
:1;
61 unsigned int reverse_byte_order
:1;
64 union _lttng_basic_type
{
65 struct lttng_integer_type integer
;
70 enum lttng_string_encodings encoding
;
74 struct lttng_basic_type
{
75 enum abstract_types atype
;
77 union _lttng_basic_type basic
;
82 enum abstract_types atype
;
84 union _lttng_basic_type basic
;
86 struct lttng_basic_type elem_type
;
87 unsigned int length
; /* num. elems. */
90 struct lttng_basic_type length_type
;
91 struct lttng_basic_type elem_type
;
98 struct lttng_type container_type
;
99 const struct lttng_enum_entry
*entries
;
103 /* Event field description */
105 struct lttng_event_field
{
107 struct lttng_type type
;
110 struct lttng_event_desc
{
111 const struct lttng_event_field
*fields
;
113 void *probe_callback
;
114 unsigned int nr_fields
;
117 struct lttng_probe_desc
{
118 const struct lttng_event_desc
*event_desc
;
119 unsigned int nr_events
;
120 struct list_head head
; /* chain registered probes */
124 * ltt_event structure is referred to by the tracing fast path. It must be
129 struct ltt_channel
*chan
;
130 const struct lttng_event_desc
*desc
;
132 enum lttng_kernel_instrumentation instrumentation
;
139 struct list_head list
; /* Event list */
140 int metadata_dumped
:1;
143 struct ltt_channel_ops
{
144 struct channel
*(*channel_create
)(const char *name
,
145 struct ltt_channel
*ltt_chan
,
147 size_t subbuf_size
, size_t num_subbuf
,
148 unsigned int switch_timer_interval
,
149 unsigned int read_timer_interval
);
150 void (*channel_destroy
)(struct channel
*chan
);
151 struct lib_ring_buffer
*(*buffer_read_open
)(struct channel
*chan
);
152 void (*buffer_read_close
)(struct lib_ring_buffer
*buf
);
153 int (*event_reserve
)(struct lib_ring_buffer_ctx
*ctx
);
154 void (*event_commit
)(struct lib_ring_buffer_ctx
*ctx
);
155 void (*event_write
)(struct lib_ring_buffer_ctx
*ctx
, const void *src
,
158 * packet_avail_size returns the available size in the current
159 * packet. Note that the size returned is only a hint, since it
160 * may change due to concurrent writes.
162 size_t (*packet_avail_size
)(struct channel
*chan
);
163 wait_queue_head_t
*(*get_reader_wait_queue
)(struct ltt_channel
*chan
);
168 struct channel
*chan
; /* Channel buffers */
169 /* Event ID management */
170 struct ltt_session
*session
;
171 struct file
*file
; /* File associated to channel */
172 unsigned int free_event_id
; /* Next event ID to allocate */
173 struct list_head list
; /* Channel list */
174 wait_queue_head_t notify_wait
; /* Channel addition notif. waitqueue */
175 struct ltt_channel_ops
*ops
;
176 int header_type
; /* 0: unset, 1: compact, 2: large */
177 int metadata_dumped
:1;
181 int active
; /* Is trace session active ? */
182 struct file
*file
; /* File associated to session */
183 struct ltt_channel
*metadata
; /* Metadata channel */
184 struct list_head chan
; /* Channel list head */
185 struct list_head events
; /* Event list head */
186 struct list_head list
; /* Session list */
187 unsigned int free_chan_id
; /* Next chan ID to allocate */
188 uuid_le uuid
; /* Trace session unique ID */
189 int metadata_dumped
:1;
192 struct ltt_transport
{
194 struct module
*owner
;
195 struct list_head node
;
196 struct ltt_channel_ops ops
;
199 struct ltt_session
*ltt_session_create(void);
200 int ltt_session_start(struct ltt_session
*session
);
201 int ltt_session_stop(struct ltt_session
*session
);
202 void ltt_session_destroy(struct ltt_session
*session
);
204 struct ltt_channel
*ltt_channel_create(struct ltt_session
*session
,
205 const char *transport_name
,
207 size_t subbuf_size
, size_t num_subbuf
,
208 unsigned int switch_timer_interval
,
209 unsigned int read_timer_interval
);
210 struct ltt_channel
*ltt_global_channel_create(struct ltt_session
*session
,
211 int overwrite
, void *buf_addr
,
212 size_t subbuf_size
, size_t num_subbuf
,
213 unsigned int switch_timer_interval
,
214 unsigned int read_timer_interval
);
215 void _ltt_channel_destroy(struct ltt_channel
*chan
);
217 struct ltt_event
*ltt_event_create(struct ltt_channel
*chan
,
219 struct lttng_kernel_event
*event_param
,
221 int ltt_event_unregister(struct ltt_event
*event
);
223 void ltt_transport_register(struct ltt_transport
*transport
);
224 void ltt_transport_unregister(struct ltt_transport
*transport
);
226 int ltt_debugfs_abi_init(void);
227 void ltt_debugfs_abi_exit(void);
229 int ltt_probe_register(struct lttng_probe_desc
*desc
);
230 void ltt_probe_unregister(struct lttng_probe_desc
*desc
);
231 const struct lttng_event_desc
*ltt_event_get(const char *name
);
232 void ltt_event_put(const struct lttng_event_desc
*desc
);
233 int ltt_probes_init(void);
234 void ltt_probes_exit(void);
236 int lttng_kprobes_register(const char *name
,
237 const char *symbol_name
,
240 struct ltt_event
*event
);
241 void lttng_kprobes_unregister(struct ltt_event
*event
);
243 #endif /* _LTT_EVENTS_H */