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