fix block instrumentation probe signature mismatch for 3.9.x kernels
[lttng-modules.git] / lttng-events.h
... / ...
CommitLineData
1#ifndef _LTTNG_EVENTS_H
2#define _LTTNG_EVENTS_H
3
4/*
5 * lttng-events.h
6 *
7 * Holds LTTng per-session event registry.
8 *
9 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; only
14 * version 2.1 of the License.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26#include <linux/version.h>
27#include <linux/list.h>
28#include <linux/kprobes.h>
29#include "wrapper/uuid.h"
30#include "lttng-abi.h"
31#include "lttng-abi-old.h"
32
33#define lttng_is_signed_type(type) (((type)(-1)) < 0)
34
35struct lttng_channel;
36struct lttng_session;
37struct lib_ring_buffer_ctx;
38struct perf_event;
39struct perf_event_attr;
40
41/* Type description */
42
43/* Update the astract_types name table in lttng-types.c along with this enum */
44enum abstract_types {
45 atype_integer,
46 atype_enum,
47 atype_array,
48 atype_sequence,
49 atype_string,
50 NR_ABSTRACT_TYPES,
51};
52
53/* Update the string_encodings name table in lttng-types.c along with this enum */
54enum lttng_string_encodings {
55 lttng_encode_none = 0,
56 lttng_encode_UTF8 = 1,
57 lttng_encode_ASCII = 2,
58 NR_STRING_ENCODINGS,
59};
60
61struct lttng_enum_entry {
62 unsigned long long start, end; /* start and end are inclusive */
63 const char *string;
64};
65
66#define __type_integer(_type, _byte_order, _base, _encoding) \
67 { \
68 .atype = atype_integer, \
69 .u.basic.integer = \
70 { \
71 .size = sizeof(_type) * CHAR_BIT, \
72 .alignment = lttng_alignof(_type) * CHAR_BIT, \
73 .signedness = lttng_is_signed_type(_type), \
74 .reverse_byte_order = _byte_order != __BYTE_ORDER, \
75 .base = _base, \
76 .encoding = lttng_encode_##_encoding, \
77 }, \
78 } \
79
80struct lttng_integer_type {
81 unsigned int size; /* in bits */
82 unsigned short alignment; /* in bits */
83 unsigned int signedness:1,
84 reverse_byte_order:1;
85 unsigned int base; /* 2, 8, 10, 16, for pretty print */
86 enum lttng_string_encodings encoding;
87};
88
89union _lttng_basic_type {
90 struct lttng_integer_type integer;
91 struct {
92 const char *name;
93 } enumeration;
94 struct {
95 enum lttng_string_encodings encoding;
96 } string;
97};
98
99struct lttng_basic_type {
100 enum abstract_types atype;
101 union {
102 union _lttng_basic_type basic;
103 } u;
104};
105
106struct lttng_type {
107 enum abstract_types atype;
108 union {
109 union _lttng_basic_type basic;
110 struct {
111 struct lttng_basic_type elem_type;
112 unsigned int length; /* num. elems. */
113 } array;
114 struct {
115 struct lttng_basic_type length_type;
116 struct lttng_basic_type elem_type;
117 } sequence;
118 } u;
119};
120
121struct lttng_enum {
122 const char *name;
123 struct lttng_type container_type;
124 const struct lttng_enum_entry *entries;
125 unsigned int len;
126};
127
128/* Event field description */
129
130struct lttng_event_field {
131 const char *name;
132 struct lttng_type type;
133};
134
135/*
136 * We need to keep this perf counter field separately from struct
137 * lttng_ctx_field because cpu hotplug needs fixed-location addresses.
138 */
139struct lttng_perf_counter_field {
140 struct notifier_block nb;
141 int hp_enable;
142 struct perf_event_attr *attr;
143 struct perf_event **e; /* per-cpu array */
144};
145
146struct lttng_ctx_field {
147 struct lttng_event_field event_field;
148 size_t (*get_size)(size_t offset);
149 void (*record)(struct lttng_ctx_field *field,
150 struct lib_ring_buffer_ctx *ctx,
151 struct lttng_channel *chan);
152 union {
153 struct lttng_perf_counter_field *perf_counter;
154 } u;
155 void (*destroy)(struct lttng_ctx_field *field);
156};
157
158struct lttng_ctx {
159 struct lttng_ctx_field *fields;
160 unsigned int nr_fields;
161 unsigned int allocated_fields;
162};
163
164struct lttng_event_desc {
165 const char *name;
166 void *probe_callback;
167 const struct lttng_event_ctx *ctx; /* context */
168 const struct lttng_event_field *fields; /* event payload */
169 unsigned int nr_fields;
170 struct module *owner;
171};
172
173struct lttng_probe_desc {
174 const struct lttng_event_desc **event_desc;
175 unsigned int nr_events;
176 struct list_head head; /* chain registered probes */
177};
178
179struct lttng_krp; /* Kretprobe handling */
180
181/*
182 * lttng_event structure is referred to by the tracing fast path. It must be
183 * kept small.
184 */
185struct lttng_event {
186 unsigned int id;
187 struct lttng_channel *chan;
188 int enabled;
189 const struct lttng_event_desc *desc;
190 void *filter;
191 struct lttng_ctx *ctx;
192 enum lttng_kernel_instrumentation instrumentation;
193 union {
194 struct {
195 struct kprobe kp;
196 char *symbol_name;
197 } kprobe;
198 struct {
199 struct lttng_krp *lttng_krp;
200 char *symbol_name;
201 } kretprobe;
202 struct {
203 char *symbol_name;
204 } ftrace;
205 } u;
206 struct list_head list; /* Event list */
207 unsigned int metadata_dumped:1;
208};
209
210struct lttng_channel_ops {
211 struct channel *(*channel_create)(const char *name,
212 struct lttng_channel *lttng_chan,
213 void *buf_addr,
214 size_t subbuf_size, size_t num_subbuf,
215 unsigned int switch_timer_interval,
216 unsigned int read_timer_interval);
217 void (*channel_destroy)(struct channel *chan);
218 struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
219 int (*buffer_has_read_closed_stream)(struct channel *chan);
220 void (*buffer_read_close)(struct lib_ring_buffer *buf);
221 int (*event_reserve)(struct lib_ring_buffer_ctx *ctx,
222 uint32_t event_id);
223 void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
224 void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
225 size_t len);
226 void (*event_write_from_user)(struct lib_ring_buffer_ctx *ctx,
227 const void *src, size_t len);
228 void (*event_memset)(struct lib_ring_buffer_ctx *ctx,
229 int c, size_t len);
230 /*
231 * packet_avail_size returns the available size in the current
232 * packet. Note that the size returned is only a hint, since it
233 * may change due to concurrent writes.
234 */
235 size_t (*packet_avail_size)(struct channel *chan);
236 wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu);
237 wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
238 int (*is_finalized)(struct channel *chan);
239 int (*is_disabled)(struct channel *chan);
240};
241
242struct lttng_transport {
243 char *name;
244 struct module *owner;
245 struct list_head node;
246 struct lttng_channel_ops ops;
247};
248
249struct lttng_channel {
250 unsigned int id;
251 struct channel *chan; /* Channel buffers */
252 int enabled;
253 struct lttng_ctx *ctx;
254 /* Event ID management */
255 struct lttng_session *session;
256 struct file *file; /* File associated to channel */
257 unsigned int free_event_id; /* Next event ID to allocate */
258 struct list_head list; /* Channel list */
259 struct lttng_channel_ops *ops;
260 struct lttng_transport *transport;
261 struct lttng_event **sc_table; /* for syscall tracing */
262 struct lttng_event **compat_sc_table;
263 struct lttng_event *sc_unknown; /* for unknown syscalls */
264 struct lttng_event *sc_compat_unknown;
265 struct lttng_event *sc_exit; /* for syscall exit */
266 int header_type; /* 0: unset, 1: compact, 2: large */
267 unsigned int metadata_dumped:1;
268};
269
270struct lttng_session {
271 int active; /* Is trace session active ? */
272 int been_active; /* Has trace session been active ? */
273 struct file *file; /* File associated to session */
274 struct lttng_channel *metadata; /* Metadata channel */
275 struct list_head chan; /* Channel list head */
276 struct list_head events; /* Event list head */
277 struct list_head list; /* Session list */
278 unsigned int free_chan_id; /* Next chan ID to allocate */
279 uuid_le uuid; /* Trace session unique ID */
280 unsigned int metadata_dumped:1;
281};
282
283struct lttng_session *lttng_session_create(void);
284int lttng_session_enable(struct lttng_session *session);
285int lttng_session_disable(struct lttng_session *session);
286void lttng_session_destroy(struct lttng_session *session);
287
288struct lttng_channel *lttng_channel_create(struct lttng_session *session,
289 const char *transport_name,
290 void *buf_addr,
291 size_t subbuf_size, size_t num_subbuf,
292 unsigned int switch_timer_interval,
293 unsigned int read_timer_interval);
294struct lttng_channel *lttng_global_channel_create(struct lttng_session *session,
295 int overwrite, void *buf_addr,
296 size_t subbuf_size, size_t num_subbuf,
297 unsigned int switch_timer_interval,
298 unsigned int read_timer_interval);
299
300struct lttng_event *lttng_event_create(struct lttng_channel *chan,
301 struct lttng_kernel_event *event_param,
302 void *filter,
303 const struct lttng_event_desc *internal_desc);
304struct lttng_event *lttng_event_compat_old_create(struct lttng_channel *chan,
305 struct lttng_kernel_old_event *old_event_param,
306 void *filter,
307 const struct lttng_event_desc *internal_desc);
308
309int lttng_channel_enable(struct lttng_channel *channel);
310int lttng_channel_disable(struct lttng_channel *channel);
311int lttng_event_enable(struct lttng_event *event);
312int lttng_event_disable(struct lttng_event *event);
313
314void lttng_transport_register(struct lttng_transport *transport);
315void lttng_transport_unregister(struct lttng_transport *transport);
316
317void synchronize_trace(void);
318int lttng_abi_init(void);
319int lttng_abi_compat_old_init(void);
320void lttng_abi_exit(void);
321void lttng_abi_compat_old_exit(void);
322
323int lttng_probe_register(struct lttng_probe_desc *desc);
324void lttng_probe_unregister(struct lttng_probe_desc *desc);
325const struct lttng_event_desc *lttng_event_get(const char *name);
326void lttng_event_put(const struct lttng_event_desc *desc);
327int lttng_probes_init(void);
328void lttng_probes_exit(void);
329
330#if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
331int lttng_syscalls_register(struct lttng_channel *chan, void *filter);
332int lttng_syscalls_unregister(struct lttng_channel *chan);
333#else
334static inline int lttng_syscalls_register(struct lttng_channel *chan, void *filter)
335{
336 return -ENOSYS;
337}
338
339static inline int lttng_syscalls_unregister(struct lttng_channel *chan)
340{
341 return 0;
342}
343#endif
344
345struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx);
346int lttng_find_context(struct lttng_ctx *ctx, const char *name);
347void lttng_remove_context_field(struct lttng_ctx **ctx,
348 struct lttng_ctx_field *field);
349void lttng_destroy_context(struct lttng_ctx *ctx);
350int lttng_add_pid_to_ctx(struct lttng_ctx **ctx);
351int lttng_add_procname_to_ctx(struct lttng_ctx **ctx);
352int lttng_add_prio_to_ctx(struct lttng_ctx **ctx);
353int lttng_add_nice_to_ctx(struct lttng_ctx **ctx);
354int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx);
355int lttng_add_tid_to_ctx(struct lttng_ctx **ctx);
356int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
357int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx);
358int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx);
359int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx);
360#if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
361int lttng_add_perf_counter_to_ctx(uint32_t type,
362 uint64_t config,
363 const char *name,
364 struct lttng_ctx **ctx);
365#else
366static inline
367int lttng_add_perf_counter_to_ctx(uint32_t type,
368 uint64_t config,
369 const char *name,
370 struct lttng_ctx **ctx)
371{
372 return -ENOSYS;
373}
374#endif
375
376extern int lttng_statedump_start(struct lttng_session *session);
377
378#ifdef CONFIG_KPROBES
379int lttng_kprobes_register(const char *name,
380 const char *symbol_name,
381 uint64_t offset,
382 uint64_t addr,
383 struct lttng_event *event);
384void lttng_kprobes_unregister(struct lttng_event *event);
385void lttng_kprobes_destroy_private(struct lttng_event *event);
386#else
387static inline
388int lttng_kprobes_register(const char *name,
389 const char *symbol_name,
390 uint64_t offset,
391 uint64_t addr,
392 struct lttng_event *event)
393{
394 return -ENOSYS;
395}
396
397static inline
398void lttng_kprobes_unregister(struct lttng_event *event)
399{
400}
401
402static inline
403void lttng_kprobes_destroy_private(struct lttng_event *event)
404{
405}
406#endif
407
408#ifdef CONFIG_KRETPROBES
409int lttng_kretprobes_register(const char *name,
410 const char *symbol_name,
411 uint64_t offset,
412 uint64_t addr,
413 struct lttng_event *event_entry,
414 struct lttng_event *event_exit);
415void lttng_kretprobes_unregister(struct lttng_event *event);
416void lttng_kretprobes_destroy_private(struct lttng_event *event);
417#else
418static inline
419int lttng_kretprobes_register(const char *name,
420 const char *symbol_name,
421 uint64_t offset,
422 uint64_t addr,
423 struct lttng_event *event_entry,
424 struct lttng_event *event_exit)
425{
426 return -ENOSYS;
427}
428
429static inline
430void lttng_kretprobes_unregister(struct lttng_event *event)
431{
432}
433
434static inline
435void lttng_kretprobes_destroy_private(struct lttng_event *event)
436{
437}
438#endif
439
440#ifdef CONFIG_DYNAMIC_FTRACE
441int lttng_ftrace_register(const char *name,
442 const char *symbol_name,
443 struct lttng_event *event);
444void lttng_ftrace_unregister(struct lttng_event *event);
445void lttng_ftrace_destroy_private(struct lttng_event *event);
446#else
447static inline
448int lttng_ftrace_register(const char *name,
449 const char *symbol_name,
450 struct lttng_event *event)
451{
452 return -ENOSYS;
453}
454
455static inline
456void lttng_ftrace_unregister(struct lttng_event *event)
457{
458}
459
460static inline
461void lttng_ftrace_destroy_private(struct lttng_event *event)
462{
463}
464#endif
465
466int lttng_calibrate(struct lttng_kernel_calibrate *calibrate);
467
468extern const struct file_operations lttng_tracepoint_list_fops;
469
470#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
471#define TRACEPOINT_HAS_DATA_ARG
472#endif
473
474#endif /* _LTTNG_EVENTS_H */
This page took 0.023442 seconds and 4 git commands to generate.