2 * Copyright (C) 2011 Julien Desfossez <julien.desfossez@polymtl.ca>
3 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
6 * SPDX-License-Identifier: GPL-2.0-only
10 #ifndef _LTTNG_KERNEL_H
11 #define _LTTNG_KERNEL_H
14 #include <common/macros.h>
15 #include <lttng/constant.h>
16 #include <lttng/event.h>
18 #define LTTNG_KERNEL_SYM_NAME_LEN 256
19 #define LTTNG_KERNEL_MAX_UPROBE_NUM 32
20 #define LTTNG_KERNEL_SESSION_NAME_LEN 256
21 #define LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN 26
24 * LTTng DebugFS ABI structures.
26 * This is the kernel ABI copied from lttng-modules tree.
29 enum lttng_kernel_instrumentation
{
30 LTTNG_KERNEL_ALL
= -1, /* Used within lttng-tools */
31 LTTNG_KERNEL_TRACEPOINT
= 0,
32 LTTNG_KERNEL_KPROBE
= 1,
33 LTTNG_KERNEL_FUNCTION
= 2,
34 LTTNG_KERNEL_KRETPROBE
= 3,
35 LTTNG_KERNEL_NOOP
= 4, /* not hooked */
36 LTTNG_KERNEL_SYSCALL
= 5,
37 LTTNG_KERNEL_UPROBE
= 6,
40 enum lttng_kernel_context_type
{
41 LTTNG_KERNEL_CONTEXT_PID
= 0,
42 LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER
= 1,
43 LTTNG_KERNEL_CONTEXT_PROCNAME
= 2,
44 LTTNG_KERNEL_CONTEXT_PRIO
= 3,
45 LTTNG_KERNEL_CONTEXT_NICE
= 4,
46 LTTNG_KERNEL_CONTEXT_VPID
= 5,
47 LTTNG_KERNEL_CONTEXT_TID
= 6,
48 LTTNG_KERNEL_CONTEXT_VTID
= 7,
49 LTTNG_KERNEL_CONTEXT_PPID
= 8,
50 LTTNG_KERNEL_CONTEXT_VPPID
= 9,
51 LTTNG_KERNEL_CONTEXT_HOSTNAME
= 10,
52 LTTNG_KERNEL_CONTEXT_CPU_ID
= 11,
53 LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE
= 12,
54 LTTNG_KERNEL_CONTEXT_PREEMPTIBLE
= 13,
55 LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE
= 14,
56 LTTNG_KERNEL_CONTEXT_MIGRATABLE
= 15,
57 LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL
= 16,
58 LTTNG_KERNEL_CONTEXT_CALLSTACK_USER
= 17,
59 LTTNG_KERNEL_CONTEXT_CGROUP_NS
= 18,
60 LTTNG_KERNEL_CONTEXT_IPC_NS
= 19,
61 LTTNG_KERNEL_CONTEXT_MNT_NS
= 20,
62 LTTNG_KERNEL_CONTEXT_NET_NS
= 21,
63 LTTNG_KERNEL_CONTEXT_PID_NS
= 22,
64 LTTNG_KERNEL_CONTEXT_USER_NS
= 23,
65 LTTNG_KERNEL_CONTEXT_UTS_NS
= 24,
66 LTTNG_KERNEL_CONTEXT_UID
= 25,
67 LTTNG_KERNEL_CONTEXT_EUID
= 26,
68 LTTNG_KERNEL_CONTEXT_SUID
= 27,
69 LTTNG_KERNEL_CONTEXT_GID
= 28,
70 LTTNG_KERNEL_CONTEXT_EGID
= 29,
71 LTTNG_KERNEL_CONTEXT_SGID
= 30,
72 LTTNG_KERNEL_CONTEXT_VUID
= 31,
73 LTTNG_KERNEL_CONTEXT_VEUID
= 32,
74 LTTNG_KERNEL_CONTEXT_VSUID
= 33,
75 LTTNG_KERNEL_CONTEXT_VGID
= 34,
76 LTTNG_KERNEL_CONTEXT_VEGID
= 35,
77 LTTNG_KERNEL_CONTEXT_VSGID
= 36,
80 /* Perf counter attributes */
81 struct lttng_kernel_perf_counter_ctx
{
84 char name
[LTTNG_KERNEL_SYM_NAME_LEN
];
87 /* Event/Channel context */
88 #define LTTNG_KERNEL_CONTEXT_PADDING1 16
89 #define LTTNG_KERNEL_CONTEXT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32
90 struct lttng_kernel_context
{
91 enum lttng_kernel_context_type ctx
;
92 char padding
[LTTNG_KERNEL_CONTEXT_PADDING1
];
95 struct lttng_kernel_perf_counter_ctx perf_counter
;
96 char padding
[LTTNG_KERNEL_CONTEXT_PADDING2
];
100 struct lttng_kernel_kretprobe
{
104 char symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
];
108 * Either addr is used, or symbol_name and offset.
110 struct lttng_kernel_kprobe
{
114 char symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
];
117 struct lttng_kernel_uprobe
{
121 struct lttng_kernel_event_callsite_uprobe
{
125 struct lttng_kernel_event_callsite
{
127 struct lttng_kernel_event_callsite_uprobe uprobe
;
131 /* Function tracer */
132 struct lttng_kernel_function
{
133 char symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
];
136 #define LTTNG_KERNEL_EVENT_PADDING1 16
137 #define LTTNG_KERNEL_EVENT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32
138 struct lttng_kernel_event
{
139 char name
[LTTNG_KERNEL_SYM_NAME_LEN
];
140 enum lttng_kernel_instrumentation instrumentation
;
141 char padding
[LTTNG_KERNEL_EVENT_PADDING1
];
143 /* Per instrumentation type configuration */
145 struct lttng_kernel_kretprobe kretprobe
;
146 struct lttng_kernel_kprobe kprobe
;
147 struct lttng_kernel_uprobe uprobe
;
148 struct lttng_kernel_function ftrace
;
149 char padding
[LTTNG_KERNEL_EVENT_PADDING2
];
153 #define LTTNG_KERNEL_TRIGGER_PADDING1 16
154 #define LTTNG_KERNEL_TRIGGER_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32
155 struct lttng_kernel_trigger
{
157 char name
[LTTNG_KERNEL_SYM_NAME_LEN
]; /* event name */
158 enum lttng_kernel_instrumentation instrumentation
;
159 char padding
[LTTNG_KERNEL_TRIGGER_PADDING1
];
161 /* Per instrumentation type configuration */
163 struct lttng_kernel_kretprobe kretprobe
;
164 struct lttng_kernel_kprobe kprobe
;
165 struct lttng_kernel_uprobe uprobe
;
166 struct lttng_kernel_function ftrace
;
167 char padding
[LTTNG_KERNEL_TRIGGER_PADDING2
];
171 struct lttng_kernel_tracer_version
{
177 struct lttng_kernel_tracer_abi_version
{
182 struct lttng_kernel_syscall_mask
{
183 uint32_t len
; /* in bits */
190 #define LTTNG_KERNEL_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32
191 struct lttng_kernel_channel
{
192 uint64_t subbuf_size
; /* bytes */
193 uint64_t num_subbuf
; /* power of 2 */
194 unsigned int switch_timer_interval
; /* usec */
195 unsigned int read_timer_interval
; /* usec */
196 enum lttng_event_output output
; /* splice, mmap */
198 int overwrite
; /* 1: overwrite, 0: discard */
199 char padding
[LTTNG_KERNEL_CHANNEL_PADDING1
];
202 #define KERNEL_FILTER_BYTECODE_MAX_LEN 65536
203 struct lttng_kernel_filter_bytecode
{
205 uint32_t reloc_offset
;
211 * kernel session name
213 struct lttng_kernel_session_name
{
214 char name
[LTTNG_KERNEL_SESSION_NAME_LEN
];
218 * kernel session creation datetime
220 struct lttng_kernel_session_creation_time
{
221 char iso8601
[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN
];
224 enum lttng_kernel_tracker_type
{
225 LTTNG_KERNEL_TRACKER_UNKNOWN
= -1,
227 LTTNG_KERNEL_TRACKER_PID
= 0,
228 LTTNG_KERNEL_TRACKER_VPID
= 1,
229 LTTNG_KERNEL_TRACKER_UID
= 2,
230 LTTNG_KERNEL_TRACKER_VUID
= 3,
231 LTTNG_KERNEL_TRACKER_GID
= 4,
232 LTTNG_KERNEL_TRACKER_VGID
= 5,
235 struct lttng_kernel_tracker_args
{
236 enum lttng_kernel_tracker_type type
;
240 #endif /* _LTTNG_KERNEL_H */