Update licensing info
[lttng-modules.git] / ltt-tracer.h
CommitLineData
17baffe2
MD
1#ifndef _LTT_TRACER_H
2#define _LTT_TRACER_H
3
1c8284eb 4/*
17baffe2
MD
5 * ltt-tracer.h
6 *
7 * Copyright (C) 2005-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
1c8284eb
MD
8 *
9 * This contains the definitions for the Linux Trace Toolkit tracer.
10 *
11 * Dual LGPL v2.1/GPL v2 license.
12 */
13
1c8284eb
MD
14#include <stdarg.h>
15#include <linux/types.h>
16#include <linux/limits.h>
17#include <linux/list.h>
18#include <linux/cache.h>
1c8284eb
MD
19#include <linux/timex.h>
20#include <linux/wait.h>
1c8284eb
MD
21#include <asm/atomic.h>
22#include <asm/local.h>
23
f3bc08c5 24#include "wrapper/trace-clock.h"
1c8284eb 25#include "ltt-tracer-core.h"
1c25284c 26#include "ltt-events.h"
1c8284eb 27
80c16bcf
MD
28#define LTTNG_VERSION 0
29#define LTTNG_PATCHLEVEL 9
30#define LTTNG_SUBLEVEL 1
31
c099397a
MD
32#ifndef CHAR_BIT
33#define CHAR_BIT 8
34#endif
35
1c8284eb
MD
36/* Number of bytes to log with a read/write event */
37#define LTT_LOG_RW_SIZE 32L
38
1c8284eb
MD
39/* Maximum number of callbacks per marker */
40#define LTT_NR_CALLBACKS 10
41
11b5a3c2
MD
42struct ltt_serialize_closure;
43
44/* Serialization callback */
45typedef size_t (*ltt_serialize_cb)(struct lib_ring_buffer *buf,
46 size_t buf_offset,
47 struct ltt_serialize_closure *closure,
48 void *serialize_private,
49 unsigned int stack_pos_ctx,
50 int *largest_align,
51 const char *fmt, va_list *args);
52
1c8284eb
MD
53struct ltt_serialize_closure {
54 ltt_serialize_cb *callbacks;
55 long cb_args[LTT_NR_CALLBACKS];
56 unsigned int cb_idx;
57};
58
11b5a3c2 59size_t ltt_serialize_data(struct lib_ring_buffer *buf, size_t buf_offset,
1c8284eb
MD
60 struct ltt_serialize_closure *closure,
61 void *serialize_private, unsigned int stack_pos_ctx,
62 int *largest_align, const char *fmt, va_list *args);
63
1c8284eb
MD
64enum ltt_channels {
65 LTT_CHANNEL_METADATA,
66 LTT_CHANNEL_FD_STATE,
67 LTT_CHANNEL_GLOBAL_STATE,
68 LTT_CHANNEL_IRQ_STATE,
69 LTT_CHANNEL_MODULE_STATE,
70 LTT_CHANNEL_NETIF_STATE,
71 LTT_CHANNEL_SOFTIRQ_STATE,
72 LTT_CHANNEL_SWAP_STATE,
73 LTT_CHANNEL_SYSCALL_STATE,
74 LTT_CHANNEL_TASK_STATE,
75 LTT_CHANNEL_VM_STATE,
76 LTT_CHANNEL_FS,
77 LTT_CHANNEL_INPUT,
78 LTT_CHANNEL_IPC,
79 LTT_CHANNEL_KERNEL,
80 LTT_CHANNEL_MM,
81 LTT_CHANNEL_RCU,
82 LTT_CHANNEL_DEFAULT,
83};
84
7514523f
MD
85/*
86 * Hardcoded event headers
1c8284eb
MD
87 *
88 * event header for a trace with active heartbeat : 27 bits timestamps
89 *
90 * headers are 32-bits aligned. In order to insure such alignment, a dynamic per
91 * trace alignment value must be done.
92 *
93 * Remember that the C compiler does align each member on the boundary
94 * equivalent to their own size.
95 *
96 * As relay subbuffers are aligned on pages, we are sure that they are 4 and 8
97 * bytes aligned, so the buffer header and trace header are aligned.
98 *
99 * Event headers are aligned depending on the trace alignment option.
100 *
101 * Note using C structure bitfields for cross-endianness and portability
102 * concerns.
103 */
104
1c8284eb
MD
105#define LTT_MAX_SMALL_SIZE 0xFFFFU
106
d793d5e1 107#ifdef RING_BUFFER_ALIGN
d793d5e1 108#define ltt_alignof(type) __alignof__(type)
c099397a 109#else
d793d5e1
MD
110#define ltt_alignof(type) 1
111#endif
1c8284eb 112
1c8284eb 113/* Tracer properties */
1c25284c 114#define CTF_MAGIC_NUMBER 0xC1FC1FC1
881833e3 115#define TSDL_MAGIC_NUMBER 0x75D11D57
d793d5e1
MD
116#define CTF_VERSION_MAJOR 0
117#define CTF_VERSION_MINOR 1
1c8284eb 118
c099397a
MD
119/*
120 * Number of milliseconds to retry before failing metadata writes on buffer full
121 * condition. (10 seconds)
122 */
123#define LTTNG_METADATA_TIMEOUT_MSEC 10000
124
1c8284eb
MD
125/*
126 * Size reserved for high priority events (interrupts, NMI, BH) at the end of a
127 * nearly full buffer. User space won't use this last amount of space when in
128 * blocking mode. This space also includes the event header that would be
129 * written by this user space event.
130 */
131#define LTT_RESERVE_CRITICAL 4096
132
64c796d8
MD
133#define LTT_RFLAG_EXTENDED RING_BUFFER_RFLAG_END
134#define LTT_RFLAG_END (LTT_RFLAG_EXTENDED << 1)
135
1c8284eb
MD
136/* Register and unregister function pointers */
137
138enum ltt_module_function {
139 LTT_FUNCTION_RUN_FILTER,
140 LTT_FUNCTION_FILTER_CONTROL,
141 LTT_FUNCTION_STATEDUMP
142};
143
144extern int ltt_module_register(enum ltt_module_function name, void *function,
145 struct module *owner);
146extern void ltt_module_unregister(enum ltt_module_function name);
147
1c8284eb
MD
148/* Exported control function */
149
1c8284eb
MD
150void ltt_core_register(int (*function)(u8, void *));
151
152void ltt_core_unregister(void);
153
1c8284eb
MD
154extern
155void ltt_statedump_register_kprobes_dump(void (*callback)(void *call_data));
156extern
157void ltt_statedump_unregister_kprobes_dump(void (*callback)(void *call_data));
158
159extern void ltt_dump_softirq_vec(void *call_data);
160
f277b4c1 161#ifdef CONFIG_HAVE_LTT_DUMP_TABLES
1c8284eb
MD
162extern void ltt_dump_sys_call_table(void *call_data);
163extern void ltt_dump_idt_table(void *call_data);
f277b4c1
MD
164#else
165static inline void ltt_dump_sys_call_table(void *call_data)
166{
167}
168
169static inline void ltt_dump_idt_table(void *call_data)
170{
171}
172#endif
1c8284eb 173
1c8284eb 174#endif /* _LTT_TRACER_H */
This page took 0.030494 seconds and 4 git commands to generate.