Metadata generation (partial)
[lttng-modules.git] / ltt-events.h
1 #ifndef _LTT_EVENTS_H
2 #define _LTT_EVENTS_H
3
4 /*
5 * ltt-events.h
6 *
7 * Copyright 2010 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
9 * Holds LTTng per-session event registry.
10 */
11
12 #include <linux/list.h>
13 #include "ltt-debugfs-abi.h"
14
15 struct ltt_channel;
16 struct ltt_session;
17 struct lib_ring_buffer_ctx;
18
19 /* Type description */
20
21 /* Update the astract_types name table in lttng-types.c along with this enum */
22 enum abstract_types {
23 atype_integer,
24 atype_enum,
25 atype_array,
26 atype_sequence,
27 atype_string,
28 NR_ABSTRACT_TYPES,
29 };
30
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,
35 NR_STRING_ENCODINGS,
36 };
37
38 struct lttng_enum_entry {
39 unsigned long long start, end; /* start and end are inclusive */
40 const char *string;
41 };
42
43 #define __type_integer(_type, _byte_order) \
44 { \
45 .atype = atype_integer, \
46 .u.basic.integer = \
47 { \
48 .size = sizeof(_type), \
49 .alignment = __alignof__(_type), \
50 .signedness = is_signed_type(_type), \
51 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
52 }, \
53 } \
54
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;
60 };
61
62 union _lttng_basic_type {
63 struct lttng_integer_type integer;
64 struct {
65 const char *name;
66 } enumeration;
67 struct {
68 enum lttng_string_encodings encoding;
69 } string;
70 };
71
72 struct lttng_basic_type {
73 enum abstract_types atype;
74 union {
75 union _lttng_basic_type basic;
76 } u;
77 };
78
79 struct lttng_type {
80 enum abstract_types atype;
81 union {
82 union _lttng_basic_type basic;
83 struct {
84 struct lttng_basic_type elem_type;
85 unsigned int length; /* num. elems. */
86 } array;
87 struct {
88 struct lttng_basic_type length_type;
89 struct lttng_basic_type elem_type;
90 } sequence;
91 } u;
92 };
93
94 struct lttng_enum {
95 const char *name;
96 struct lttng_type container_type;
97 const struct lttng_enum_entry *entries;
98 unsigned int len;
99 };
100
101 /* Event field description */
102
103 struct lttng_event_field {
104 const char *name;
105 const struct lttng_type type;
106 };
107
108 struct lttng_event_desc {
109 const struct lttng_event_field *fields;
110 const char *name;
111 void *probe_callback;
112 unsigned int nr_fields;
113 };
114
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 */
119 };
120
121 /*
122 * ltt_event structure is referred to by the tracing fast path. It must be
123 * kept small.
124 */
125 struct ltt_event {
126 unsigned int id;
127 struct ltt_channel *chan;
128 const struct lttng_event_desc *desc;
129 void *filter;
130 enum instrum_type itype;
131 struct list_head list; /* Event list */
132 int metadata_dumped:1;
133 };
134
135 struct ltt_channel_ops {
136 struct channel *(*channel_create)(const char *name,
137 struct ltt_session *session,
138 void *buf_addr,
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,
148 size_t len);
149 wait_queue_head_t *(*get_reader_wait_queue)(struct ltt_channel *chan);
150 };
151
152 struct ltt_channel {
153 unsigned int id;
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 */
164 };
165
166 struct ltt_session {
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;
175 };
176
177 struct ltt_transport {
178 char *name;
179 struct module *owner;
180 struct list_head node;
181 struct ltt_channel_ops ops;
182 };
183
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);
188
189 struct ltt_channel *ltt_channel_create(struct ltt_session *session,
190 const char *transport_name,
191 void *buf_addr,
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);
201
202 struct ltt_event *ltt_event_create(struct ltt_channel *chan,
203 char *name,
204 enum instrum_type itype,
205 const struct lttng_event_desc *event_desc,
206 void *filter);
207 int _ltt_event_unregister(struct ltt_event *event);
208 void _ltt_event_destroy(struct ltt_event *event);
209
210 void ltt_transport_register(struct ltt_transport *transport);
211 void ltt_transport_unregister(struct ltt_transport *transport);
212
213 int ltt_debugfs_abi_init(void);
214 void ltt_debugfs_abi_exit(void);
215
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
221 #endif /* _LTT_EVENTS_H */
This page took 0.043604 seconds and 5 git commands to generate.