Keep event description registry instead of just name callback mapping
[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 struct lttng_enum {
44 const struct lttng_enum_entry *entries;
45 unsigned int len;
46 };
47
48 struct lttng_type {
49 enum abstract_types atype;
50 const char *name;
51 union {
52 struct {
53 unsigned int size; /* in bits */
54 unsigned short alignment; /* in bits */
55 unsigned int signedness:1;
56 unsigned int reverse_byte_order:1;
57 } integer;
58 struct {
59 const char *parent_type;
60 const struct lttng_enum def;
61 } enumeration;
62 struct {
63 const char *elem_type;
64 unsigned int length; /* num. elems. */
65 } array;
66 struct {
67 const char *elem_type;
68 const char *length_type;
69 } sequence;
70 struct {
71 enum lttng_string_encodings encoding;
72 } string;
73 } u;
74 } __attribute__((packed));
75
76 /* Event field description */
77
78 struct lttng_event_field {
79 const char *name;
80 const struct lttng_type type;
81 };
82
83 struct lttng_event_desc {
84 const struct lttng_event_field *fields;
85 const char *name;
86 void *probe_callback;
87 unsigned int nr_fields;
88 };
89
90 struct lttng_probe_desc {
91 const struct lttng_event_desc *event_desc;
92 unsigned int nr_events;
93 struct list_head head; /* chain registered probes */
94 };
95
96 /*
97 * ltt_event structure is referred to by the tracing fast path. It must be
98 * kept small.
99 */
100 struct ltt_event {
101 unsigned int id;
102 struct ltt_channel *chan;
103 const struct lttng_event_desc *desc;
104 void *filter;
105 enum instrum_type itype;
106 struct list_head list; /* Event list */
107 };
108
109 struct ltt_channel_ops {
110 struct channel *(*channel_create)(const char *name,
111 struct ltt_session *session,
112 void *buf_addr,
113 size_t subbuf_size, size_t num_subbuf,
114 unsigned int switch_timer_interval,
115 unsigned int read_timer_interval);
116 void (*channel_destroy)(struct channel *chan);
117 struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
118 void (*buffer_read_close)(struct lib_ring_buffer *buf);
119 int (*event_reserve)(struct lib_ring_buffer_ctx *ctx);
120 void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
121 void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
122 size_t len);
123 };
124
125 struct ltt_channel {
126 struct channel *chan; /* Channel buffers */
127 /* Event ID management */
128 struct ltt_session *session;
129 struct file *file; /* File associated to channel */
130 unsigned int free_event_id; /* Next event ID to allocate */
131 struct list_head list; /* Channel list */
132 wait_queue_head_t notify_wait; /* Channel addition notif. waitqueue */
133 struct ltt_channel_ops *ops;
134 };
135
136 struct ltt_session {
137 int active; /* Is trace session active ? */
138 struct file *file; /* File associated to session */
139 struct list_head chan; /* Channel list head */
140 struct list_head events; /* Event list head */
141 struct list_head list; /* Session list */
142 };
143
144 struct ltt_transport {
145 char *name;
146 struct module *owner;
147 struct list_head node;
148 struct ltt_channel_ops ops;
149 };
150
151 struct ltt_session *ltt_session_create(void);
152 int ltt_session_start(struct ltt_session *session);
153 int ltt_session_stop(struct ltt_session *session);
154 void ltt_session_destroy(struct ltt_session *session);
155
156 struct ltt_channel *ltt_channel_create(struct ltt_session *session,
157 const char *transport_name,
158 void *buf_addr,
159 size_t subbuf_size, size_t num_subbuf,
160 unsigned int switch_timer_interval,
161 unsigned int read_timer_interval);
162 struct ltt_channel *ltt_global_channel_create(struct ltt_session *session,
163 int overwrite, void *buf_addr,
164 size_t subbuf_size, size_t num_subbuf,
165 unsigned int switch_timer_interval,
166 unsigned int read_timer_interval);
167 void _ltt_channel_destroy(struct ltt_channel *chan);
168
169 struct ltt_event *ltt_event_create(struct ltt_channel *chan,
170 char *name,
171 enum instrum_type itype,
172 const struct lttng_event_desc *event_desc,
173 void *filter);
174 int _ltt_event_unregister(struct ltt_event *event);
175 void _ltt_event_destroy(struct ltt_event *event);
176
177 void ltt_transport_register(struct ltt_transport *transport);
178 void ltt_transport_unregister(struct ltt_transport *transport);
179
180 int ltt_debugfs_abi_init(void);
181 void ltt_debugfs_abi_exit(void);
182
183 int ltt_probe_register(struct lttng_probe_desc *desc);
184 void ltt_probe_unregister(struct lttng_probe_desc *desc);
185 const struct lttng_event_desc *ltt_event_get(const char *name);
186 void ltt_event_put(const struct lttng_event_desc *desc);
187
188 #endif /* _LTT_EVENTS_H */
This page took 0.032617 seconds and 4 git commands to generate.