Add event description for each kprobe event
[lttng-modules.git] / ltt-events.h
CommitLineData
11b5a3c2
MD
1#ifndef _LTT_EVENTS_H
2#define _LTT_EVENTS_H
3
4e3c1b9b
MD
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>
d793d5e1 13#include <linux/uuid.h>
d6d808f3 14#include <linux/kprobes.h>
11b5a3c2 15#include "ltt-debugfs-abi.h"
4e3c1b9b
MD
16
17struct ltt_channel;
18struct ltt_session;
1c25284c 19struct lib_ring_buffer_ctx;
4e3c1b9b 20
c0edae1d
MD
21/* Type description */
22
23/* Update the astract_types name table in lttng-types.c along with this enum */
24enum abstract_types {
25 atype_integer,
26 atype_enum,
27 atype_array,
28 atype_sequence,
29 atype_string,
30 NR_ABSTRACT_TYPES,
31};
32
33/* Update the string_encodings name table in lttng-types.c along with this enum */
34enum lttng_string_encodings {
35 lttng_encode_UTF8 = 0,
36 lttng_encode_ASCII = 1,
37 NR_STRING_ENCODINGS,
38};
39
40struct lttng_enum_entry {
41 unsigned long long start, end; /* start and end are inclusive */
42 const char *string;
43};
44
c099397a
MD
45#define __type_integer(_type, _byte_order) \
46 { \
47 .atype = atype_integer, \
48 .u.basic.integer = \
49 { \
50 .size = sizeof(_type), \
d793d5e1 51 .alignment = ltt_alignof(_type) * CHAR_BIT, \
c099397a
MD
52 .signedness = is_signed_type(_type), \
53 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
54 }, \
55 } \
56
57struct 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;
62};
63
64union _lttng_basic_type {
65 struct lttng_integer_type integer;
66 struct {
67 const char *name;
68 } enumeration;
69 struct {
70 enum lttng_string_encodings encoding;
71 } string;
72};
73
74struct lttng_basic_type {
75 enum abstract_types atype;
76 union {
77 union _lttng_basic_type basic;
78 } u;
c0edae1d
MD
79};
80
81struct lttng_type {
82 enum abstract_types atype;
c0edae1d 83 union {
c099397a 84 union _lttng_basic_type basic;
c0edae1d 85 struct {
c099397a 86 struct lttng_basic_type elem_type;
c0edae1d
MD
87 unsigned int length; /* num. elems. */
88 } array;
89 struct {
c099397a
MD
90 struct lttng_basic_type length_type;
91 struct lttng_basic_type elem_type;
c0edae1d 92 } sequence;
c0edae1d 93 } u;
c099397a
MD
94};
95
96struct lttng_enum {
97 const char *name;
98 struct lttng_type container_type;
99 const struct lttng_enum_entry *entries;
100 unsigned int len;
101};
c0edae1d
MD
102
103/* Event field description */
104
105struct lttng_event_field {
106 const char *name;
f17701fb 107 struct lttng_type type;
c0edae1d
MD
108};
109
110struct lttng_event_desc {
111 const struct lttng_event_field *fields;
112 const char *name;
113 void *probe_callback;
114 unsigned int nr_fields;
115};
116
85a9ca7f
MD
117struct lttng_probe_desc {
118 const struct lttng_event_desc *event_desc;
119 unsigned int nr_events;
120 struct list_head head; /* chain registered probes */
121};
122
123/*
124 * ltt_event structure is referred to by the tracing fast path. It must be
125 * kept small.
126 */
127struct ltt_event {
128 unsigned int id;
129 struct ltt_channel *chan;
f17701fb 130 struct lttng_event_desc *desc;
85a9ca7f 131 void *filter;
38d024ae 132 enum lttng_kernel_instrumentation instrumentation;
d6d808f3
MD
133 union {
134 struct {
135 struct kprobe kp;
136 char *symbol_name;
137 } kprobe;
138 } u;
85a9ca7f 139 struct list_head list; /* Event list */
c099397a 140 int metadata_dumped:1;
85a9ca7f
MD
141};
142
143struct ltt_channel_ops {
144 struct channel *(*channel_create)(const char *name,
9115fbdc 145 struct ltt_channel *ltt_chan,
85a9ca7f
MD
146 void *buf_addr,
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,
156 size_t len);
1ec3f75a
MD
157 /*
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.
161 */
162 size_t (*packet_avail_size)(struct channel *chan);
c099397a 163 wait_queue_head_t *(*get_reader_wait_queue)(struct ltt_channel *chan);
85a9ca7f
MD
164};
165
166struct ltt_channel {
c099397a 167 unsigned int id;
85a9ca7f
MD
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;
9115fbdc 176 int header_type; /* 0: unset, 1: compact, 2: large */
c099397a 177 int metadata_dumped:1;
85a9ca7f
MD
178};
179
180struct ltt_session {
181 int active; /* Is trace session active ? */
182 struct file *file; /* File associated to session */
c099397a 183 struct ltt_channel *metadata; /* Metadata channel */
85a9ca7f
MD
184 struct list_head chan; /* Channel list head */
185 struct list_head events; /* Event list head */
186 struct list_head list; /* Session list */
c099397a 187 unsigned int free_chan_id; /* Next chan ID to allocate */
d793d5e1 188 uuid_le uuid; /* Trace session unique ID */
c099397a 189 int metadata_dumped:1;
85a9ca7f
MD
190};
191
192struct ltt_transport {
193 char *name;
194 struct module *owner;
195 struct list_head node;
196 struct ltt_channel_ops ops;
197};
198
baf20995 199struct ltt_session *ltt_session_create(void);
c0e31d2e
MD
200int ltt_session_start(struct ltt_session *session);
201int ltt_session_stop(struct ltt_session *session);
11b5a3c2 202void ltt_session_destroy(struct ltt_session *session);
4e3c1b9b 203
baf20995 204struct ltt_channel *ltt_channel_create(struct ltt_session *session,
5dbbdb43
MD
205 const char *transport_name,
206 void *buf_addr,
207 size_t subbuf_size, size_t num_subbuf,
208 unsigned int switch_timer_interval,
209 unsigned int read_timer_interval);
210struct ltt_channel *ltt_global_channel_create(struct ltt_session *session,
4e3c1b9b
MD
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);
11b5a3c2 215void _ltt_channel_destroy(struct ltt_channel *chan);
4e3c1b9b 216
653fe716 217struct ltt_event *ltt_event_create(struct ltt_channel *chan,
653fe716 218 char *name,
d6d808f3 219 struct lttng_kernel_event *event_param,
85a9ca7f
MD
220 const struct lttng_event_desc *event_desc,
221 void *filter);
be066e6c 222int ltt_event_unregister(struct ltt_event *event);
c0e31d2e
MD
223
224void ltt_transport_register(struct ltt_transport *transport);
225void ltt_transport_unregister(struct ltt_transport *transport);
11b5a3c2 226
1c25284c
MD
227int ltt_debugfs_abi_init(void);
228void ltt_debugfs_abi_exit(void);
229
85a9ca7f
MD
230int ltt_probe_register(struct lttng_probe_desc *desc);
231void ltt_probe_unregister(struct lttng_probe_desc *desc);
232const struct lttng_event_desc *ltt_event_get(const char *name);
233void ltt_event_put(const struct lttng_event_desc *desc);
cd4bd11f
MD
234int ltt_probes_init(void);
235void ltt_probes_exit(void);
02119ee5 236
f17701fb
MD
237int lttng_kprobes_register(const char *name,
238 const char *symbol_name,
239 uint64_t offset,
240 uint64_t addr,
241 struct ltt_event *event);
242void lttng_kprobes_unregister(struct ltt_event *event);
d6d808f3 243
11b5a3c2 244#endif /* _LTT_EVENTS_H */
This page took 0.033685 seconds and 4 git commands to generate.