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