Fix: lttng: uninitialized pointer free'd when no sessiond is present
[lttng-tools.git] / src / common / lttng-kernel.h
CommitLineData
93128a92 1/*
ab5be9fa
MJ
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>
93128a92 5 *
ab5be9fa 6 * SPDX-License-Identifier: GPL-2.0-only
93128a92 7 *
93128a92
DG
8 */
9
10#ifndef _LTTNG_KERNEL_H
11#define _LTTNG_KERNEL_H
12
e848fc76 13#include <stdint.h>
113373e4 14#include <common/macros.h>
0ef03255
FD
15#include <lttng/constant.h>
16#include <lttng/event.h>
e848fc76 17
dbbb3ec5 18#define LTTNG_KERNEL_SYM_NAME_LEN 256
0ef03255 19#define LTTNG_KERNEL_MAX_UPROBE_NUM 32
8ff4109e 20#define LTTNG_KERNEL_SESSION_NAME_LEN 256
e04b2181 21#define LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN 26
9cb98350 22
7d29a247
DG
23/*
24 * LTTng DebugFS ABI structures.
25 *
26 * This is the kernel ABI copied from lttng-modules tree.
27 */
28
9cb98350 29enum lttng_kernel_instrumentation {
5f822d0a 30 LTTNG_KERNEL_ALL = -1, /* Used within lttng-tools */
e6ddca71
DG
31 LTTNG_KERNEL_TRACEPOINT = 0,
32 LTTNG_KERNEL_KPROBE = 1,
33 LTTNG_KERNEL_FUNCTION = 2,
8f0d098b 34 LTTNG_KERNEL_KRETPROBE = 3,
0133c199 35 LTTNG_KERNEL_NOOP = 4, /* not hooked */
a54bd42d 36 LTTNG_KERNEL_SYSCALL = 5,
1ab8c2ad 37 LTTNG_KERNEL_UPROBE = 6,
e6ddca71
DG
38};
39
7d29a247
DG
40enum lttng_kernel_context_type {
41 LTTNG_KERNEL_CONTEXT_PID = 0,
aa3514e9 42 LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER = 1,
9197c5c4 43 LTTNG_KERNEL_CONTEXT_PROCNAME = 2,
7d29a247
DG
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,
54773d68 51 LTTNG_KERNEL_CONTEXT_HOSTNAME = 10,
33e801a9 52 LTTNG_KERNEL_CONTEXT_CPU_ID = 11,
1ae5e83e
JD
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,
373148e9
FG
57 LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL = 16,
58 LTTNG_KERNEL_CONTEXT_CALLSTACK_USER = 17,
40e14884
MJ
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,
499cbfa1
MJ
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,
7d29a247
DG
78};
79
80/* Perf counter attributes */
81struct lttng_kernel_perf_counter_ctx {
82 uint32_t type;
83 uint64_t config;
dbbb3ec5 84 char name[LTTNG_KERNEL_SYM_NAME_LEN];
113373e4 85} LTTNG_PACKED;
7d29a247
DG
86
87/* Event/Channel context */
dbbb3ec5
DG
88#define LTTNG_KERNEL_CONTEXT_PADDING1 16
89#define LTTNG_KERNEL_CONTEXT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32
7d29a247
DG
90struct lttng_kernel_context {
91 enum lttng_kernel_context_type ctx;
dbbb3ec5
DG
92 char padding[LTTNG_KERNEL_CONTEXT_PADDING1];
93
7d29a247
DG
94 union {
95 struct lttng_kernel_perf_counter_ctx perf_counter;
dbbb3ec5 96 char padding[LTTNG_KERNEL_CONTEXT_PADDING2];
7d29a247 97 } u;
113373e4 98} LTTNG_PACKED;
9cb98350 99
8f0d098b
MD
100struct lttng_kernel_kretprobe {
101 uint64_t addr;
102
103 uint64_t offset;
dbbb3ec5 104 char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
113373e4 105} LTTNG_PACKED;
8f0d098b 106
93128a92 107/*
7d29a247 108 * Either addr is used, or symbol_name and offset.
93128a92 109 */
7d29a247
DG
110struct lttng_kernel_kprobe {
111 uint64_t addr;
112
113 uint64_t offset;
dbbb3ec5 114 char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
113373e4 115} LTTNG_PACKED;
9cb98350 116
1ab8c2ad
FD
117struct lttng_kernel_uprobe {
118 int fd;
119} LTTNG_PACKED;
120
121struct lttng_kernel_event_callsite_uprobe {
122 uint64_t offset;
123} LTTNG_PACKED;
124
125struct lttng_kernel_event_callsite {
126 union {
127 struct lttng_kernel_event_callsite_uprobe uprobe;
128 } u;
129} LTTNG_PACKED;
130
f05b5f07 131/* Function tracer */
7d29a247 132struct lttng_kernel_function {
dbbb3ec5 133 char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
113373e4 134} LTTNG_PACKED;
93128a92 135
dbbb3ec5
DG
136#define LTTNG_KERNEL_EVENT_PADDING1 16
137#define LTTNG_KERNEL_EVENT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32
9cb98350 138struct lttng_kernel_event {
dbbb3ec5 139 char name[LTTNG_KERNEL_SYM_NAME_LEN];
9cb98350 140 enum lttng_kernel_instrumentation instrumentation;
dbbb3ec5
DG
141 char padding[LTTNG_KERNEL_EVENT_PADDING1];
142
9cb98350
JD
143 /* Per instrumentation type configuration */
144 union {
8f0d098b 145 struct lttng_kernel_kretprobe kretprobe;
7d29a247 146 struct lttng_kernel_kprobe kprobe;
1ab8c2ad 147 struct lttng_kernel_uprobe uprobe;
7d29a247 148 struct lttng_kernel_function ftrace;
dbbb3ec5 149 char padding[LTTNG_KERNEL_EVENT_PADDING2];
9cb98350 150 } u;
113373e4 151} LTTNG_PACKED;
93128a92 152
9cb98350 153struct lttng_kernel_tracer_version {
a62a6556
MD
154 uint32_t major;
155 uint32_t minor;
9cb98350 156 uint32_t patchlevel;
113373e4 157} LTTNG_PACKED;
93128a92 158
c052142c
MD
159struct lttng_kernel_tracer_abi_version {
160 uint32_t major;
161 uint32_t minor;
162} LTTNG_PACKED;
163
e80c3634 164struct lttng_kernel_syscall_mask {
46820c8b 165 uint32_t len; /* in bits */
e80c3634
MD
166 char mask[];
167} LTTNG_PACKED;
168
4dbc372b
JD
169/*
170 * kernel channel
171 */
172#define LTTNG_KERNEL_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32
173struct lttng_kernel_channel {
174 uint64_t subbuf_size; /* bytes */
175 uint64_t num_subbuf; /* power of 2 */
176 unsigned int switch_timer_interval; /* usec */
177 unsigned int read_timer_interval; /* usec */
178 enum lttng_event_output output; /* splice, mmap */
179
180 int overwrite; /* 1: overwrite, 0: discard */
181 char padding[LTTNG_KERNEL_CHANNEL_PADDING1];
113373e4 182} LTTNG_PACKED;
d0254c7c 183
00a62084
MD
184#define KERNEL_FILTER_BYTECODE_MAX_LEN 65536
185struct lttng_kernel_filter_bytecode {
186 uint32_t len;
187 uint32_t reloc_offset;
188 uint64_t seqnum;
189 char data[0];
190} LTTNG_PACKED;
191
8ff4109e
JR
192/*
193 * kernel session name
194 */
195struct lttng_kernel_session_name {
196 char name[LTTNG_KERNEL_SESSION_NAME_LEN];
197} LTTNG_PACKED;
198
e04b2181
JR
199/*
200 * kernel session creation datetime
201 */
202struct lttng_kernel_session_creation_time {
203 char iso8601[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN];
204} LTTNG_PACKED;
205
d01c0e56
MD
206enum lttng_kernel_tracker_type {
207 LTTNG_KERNEL_TRACKER_UNKNOWN = -1,
208
209 LTTNG_KERNEL_TRACKER_PID = 0,
210 LTTNG_KERNEL_TRACKER_VPID = 1,
211 LTTNG_KERNEL_TRACKER_UID = 2,
212 LTTNG_KERNEL_TRACKER_VUID = 3,
213 LTTNG_KERNEL_TRACKER_GID = 4,
214 LTTNG_KERNEL_TRACKER_VGID = 5,
215};
216
217struct lttng_kernel_tracker_args {
218 enum lttng_kernel_tracker_type type;
219 int32_t id;
220};
221
93128a92 222#endif /* _LTTNG_KERNEL_H */
This page took 0.086397 seconds and 5 git commands to generate.