Cleanup: Rename abstract types to lttng_kernel_type
[lttng-modules.git] / include / instrumentation / syscalls / headers / syscalls_integers_override.h
CommitLineData
b7cdc182 1/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
6314c2d3 2
7e42c4ec
MD
3#ifndef CREATE_SYSCALL_TABLE
4
3cf55950
FD
5/*
6 * The `flags` argument of the mmap syscall is split in two parts:
7 * - The type of mapping is described by the four least significant bits of the 4
8 * bytes integer,
9 * - The options on the mapping are described by the remaining 28 most
10 * significant bits.
11 */
12#define MAPPING_TYPE_RESERVED_BITS 4
13#define LTTNG_MMAP_FLAGS_TO_CTF(x) ((x) >> MAPPING_TYPE_RESERVED_BITS)
14
15/*
16 * Enumeration of the mmap flags, as described in the 'mmap'
17 * system call man page.
18 */
19SC_LTTNG_TRACEPOINT_ENUM(lttng_mmap_protection,
20 TP_ENUM_VALUES(
21 ctf_enum_value("PROT_EXEC", PROT_EXEC)
22 ctf_enum_value("PROT_READ", PROT_READ)
23 ctf_enum_value("PROT_WRITE", PROT_WRITE)
24 ctf_enum_value("PROT_NONE", PROT_NONE)
25 )
26)
27
28SC_LTTNG_TRACEPOINT_ENUM(lttng_mmap_flags_mapping_type,
29 TP_ENUM_VALUES(
30 ctf_enum_value("MAP_SHARED", MAP_SHARED)
31 ctf_enum_value("MAP_PRIVATE", MAP_PRIVATE)
5f4c791e 32#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0))
3cf55950 33 ctf_enum_value("MAP_SHARED_VALIDATE", MAP_SHARED_VALIDATE)
5f4c791e 34#endif /* (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0)) */
3cf55950
FD
35 )
36)
37
38/*
39 * Shift the values of the options so we can read them from the `flags` integer
40 * directly.
41 */
42SC_LTTNG_TRACEPOINT_ENUM(lttng_mmap_flags_options,
43 TP_ENUM_VALUES(
44 ctf_enum_value("<none>", 0)
1203baa4
FD
45
46#if defined (MAP_32BIT) && MAP_32BIT != 0
3cf55950 47 ctf_enum_value("MAP_32BIT", LTTNG_MMAP_FLAGS_TO_CTF(MAP_32BIT))
1203baa4
FD
48#endif /* defined (MAP_32BIT) && MAP_32BIT != 0 */
49
3cf55950
FD
50 ctf_enum_value("MAP_ANONYMOUS", LTTNG_MMAP_FLAGS_TO_CTF(MAP_ANONYMOUS))
51 ctf_enum_value("MAP_DENYWRITE", LTTNG_MMAP_FLAGS_TO_CTF(MAP_DENYWRITE))
52 ctf_enum_value("MAP_EXECUTABLE", LTTNG_MMAP_FLAGS_TO_CTF(MAP_EXECUTABLE))
53 ctf_enum_value("MAP_FIXED", LTTNG_MMAP_FLAGS_TO_CTF(MAP_FIXED))
1203baa4 54
5f4c791e 55#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,17,0))
3cf55950 56 ctf_enum_value("MAP_FIXED_NOREPLACE", LTTNG_MMAP_FLAGS_TO_CTF(MAP_FIXED_NOREPLACE))
5f4c791e 57#endif /* (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,17,0)) */
1203baa4 58
3cf55950
FD
59 ctf_enum_value("MAP_GROWSDOWN", LTTNG_MMAP_FLAGS_TO_CTF(MAP_GROWSDOWN))
60 ctf_enum_value("MAP_HUGETLB", LTTNG_MMAP_FLAGS_TO_CTF(MAP_HUGETLB))
1203baa4 61
5f4c791e 62#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0))
1203baa4
FD
63
64#if defined (MAP_HUGE_2MB) && MAP_HUGE_2MB != 0
65 ctf_enum_value("MAP_HUGE_2MB", LTTNG_MMAP_FLAGS_TO_CTF(MAP_HUGE_2MB))
66#endif /* defined (MAP_HUGE_2MB) && MAP_HUGE_2MB != 0 */
67
68#if defined (MAP_HUGE_1GB) && MAP_HUGE_1GB != 0
69 ctf_enum_value("MAP_HUGE_1GB", LTTNG_MMAP_FLAGS_TO_CTF(MAP_HUGE_1GB))
70#endif /* defined (MAP_HUGE_1GB) && MAP_HUGE_1GB != 0 */
71
5f4c791e 72#endif /* (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,8,0)) */
1203baa4 73
3cf55950
FD
74 ctf_enum_value("MAP_LOCKED", LTTNG_MMAP_FLAGS_TO_CTF(MAP_LOCKED))
75 ctf_enum_value("MAP_NONBLOCK", LTTNG_MMAP_FLAGS_TO_CTF(MAP_NONBLOCK))
76 ctf_enum_value("MAP_NORESERVE", LTTNG_MMAP_FLAGS_TO_CTF(MAP_NORESERVE))
77 ctf_enum_value("MAP_POPULATE", LTTNG_MMAP_FLAGS_TO_CTF(MAP_POPULATE))
78 ctf_enum_value("MAP_STACK", LTTNG_MMAP_FLAGS_TO_CTF(MAP_STACK))
1203baa4 79
5f4c791e 80#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0))
3cf55950 81 ctf_enum_value("MAP_SYNC", LTTNG_MMAP_FLAGS_TO_CTF(MAP_SYNC))
5f4c791e 82#endif /* (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0)) */
1203baa4
FD
83
84#if defined (MAP_UNINITIALIZED) && MAP_UNINITIALIZED != 0
3cf55950 85 ctf_enum_value("MAP_UNINITIALIZED", LTTNG_MMAP_FLAGS_TO_CTF(MAP_UNINITIALIZED))
1203baa4 86#endif /* defined (MAP_UNINITIALIZED) && MAP_UNINITIALIZED != 0 */
3cf55950
FD
87 )
88)
89
90#define LTTNG_MMAP_FLAGS_TYPE \
91{ \
92 .name = "type", \
93 .type = { \
12bb2edb 94 .type = lttng_kernel_type_enum_nestable, \
3cf55950
FD
95 .u = { \
96 .enum_nestable = { \
97 .desc = &__enum_lttng_mmap_flags_mapping_type, \
98 .container_type = __LTTNG_COMPOUND_LITERAL( \
99 struct lttng_type, __type_integer(uint32_t, \
100 4, 1, -1, __BYTE_ORDER, 16, none)), \
101 }, \
102 }, \
103 }, \
104}
105
106#define LTTNG_MMAP_FLAGS_OPTIONS \
107{ \
108 .name = "options", \
109 .type = { \
12bb2edb 110 .type = lttng_kernel_type_enum_nestable, \
3cf55950
FD
111 .u = { \
112 .enum_nestable = { \
113 .desc = &__enum_lttng_mmap_flags_options, \
114 .container_type = __LTTNG_COMPOUND_LITERAL( \
115 struct lttng_type, __type_integer(uint32_t, \
116 28, 1, -1, __BYTE_ORDER, 16, none)),\
117 }, \
118 }, \
119 }, \
120}
121
122#if (__BYTE_ORDER == __LITTLE_ENDIAN)
123#define LTTNG_MMAP_FLAGS \
124 [0] = LTTNG_MMAP_FLAGS_TYPE, \
125 [1] = LTTNG_MMAP_FLAGS_OPTIONS,
126
127#else
128#define LTTNG_MMAP_FLAGS \
129 [0] = LTTNG_MMAP_FLAGS_OPTIONS, \
130 [1] = LTTNG_MMAP_FLAGS_TYPE,
131#endif
132
133/*
134 * Use a custom field here so that tracer writes a single integer and the
135 * work of splitting it up in two fields is left to the trace reader.
136 */
769ad370
MD
137#define OVERRIDE_32_mmap
138#define OVERRIDE_64_mmap
cb3ef14c 139SC_LTTNG_TRACEPOINT_EVENT(mmap,
769ad370
MD
140 TP_PROTO(sc_exit(unsigned long ret,)
141 unsigned long addr, unsigned long len,
142 unsigned long prot, unsigned long flags,
143 unsigned long fd, unsigned long off),
e17f92ba 144 TP_ARGS(sc_exit(ret,) addr, len, prot, flags, fd, off),
769ad370 145 TP_FIELDS(sc_exit(ctf_integer_hex(unsigned long, ret, ret))
57ede728
MD
146 sc_in(ctf_integer_hex(unsigned long, addr, addr))
147 sc_in(ctf_integer(size_t, len, len))
3cf55950
FD
148 sc_in(ctf_enum(lttng_mmap_protection, int, prot, prot))
149 sc_in(
150 ctf_custom_field(
151 ctf_custom_type(
152 {
12bb2edb 153 .type = lttng_kernel_type_struct_nestable,
3cf55950
FD
154 .u.struct_nestable.nr_fields = 2,
155 .u.struct_nestable.fields =
156 __LTTNG_COMPOUND_LITERAL(struct lttng_event_field,
157 LTTNG_MMAP_FLAGS
158 ),
159 .u.struct_nestable.alignment = lttng_alignof(uint32_t) * CHAR_BIT,
160 }
161 ),
162 flags,
163 ctf_custom_code(
164 ctf_integer_type(uint32_t, flags)
165 )
166 )
167 )
57ede728
MD
168 sc_in(ctf_integer(int, fd, fd))
169 sc_in(ctf_integer(off_t, offset, off))
170 )
7e42c4ec
MD
171)
172
c1c07d68
GB
173/*
174 * Enumeration of the open flags, as described in the 'open'
175 * system call man page.
176 */
177SC_LTTNG_TRACEPOINT_ENUM(lttng_fcntl_cmd_flags,
178 TP_ENUM_VALUES(
179 ctf_enum_value("F_DUPFD", F_DUPFD)
180 ctf_enum_value("F_GETFD", F_GETFD)
181 ctf_enum_value("F_SETFD", F_SETFD)
182 ctf_enum_value("F_GETFL", F_GETFL)
183 ctf_enum_value("F_SETFL", F_SETFL)
184 ctf_enum_value("F_GETLK", F_GETLK)
185 ctf_enum_value("F_SETLK", F_SETLK)
186 ctf_enum_value("F_SETLKW", F_SETLKW)
187 ctf_enum_value("F_SETOWN", F_SETOWN)
188 ctf_enum_value("F_GETOWN", F_GETOWN)
189 ctf_enum_value("F_SETSIG", F_SETSIG)
190 ctf_enum_value("F_GETSIG", F_GETSIG)
f25545b1 191#if !defined(CONFIG_64BIT) || defined(CONFIG_COMPAT)
c1c07d68
GB
192 ctf_enum_value("F_GETLK64", F_GETLK64)
193 ctf_enum_value("F_SETLK64", F_SETLK64)
194 ctf_enum_value("F_SETLKW64", F_SETLKW64)
f25545b1 195#endif /* #if !defined(CONFIG_64BIT) || defined(CONFIG_COMPAT) */
c1c07d68
GB
196 ctf_enum_value("F_SETOWN_EX", F_SETOWN_EX)
197 ctf_enum_value("F_GETOWN_EX", F_GETOWN_EX)
5f4c791e 198#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,6,0))
c1c07d68 199 ctf_enum_value("F_GETOWNER_UIDS", F_GETOWNER_UIDS)
5f4c791e
MJ
200#endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,6,0)) */
201#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,15,0))
c1c07d68
GB
202 ctf_enum_value("F_OFD_GETLK", F_OFD_GETLK)
203 ctf_enum_value("F_OFD_SETLK", F_OFD_SETLK)
204 ctf_enum_value("F_OFD_SETLKW", F_OFD_SETLKW)
5f4c791e 205#endif /* (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,15,0)) */
c1c07d68
GB
206 ctf_enum_value("F_SETLEASE", F_SETLEASE)
207 ctf_enum_value("F_GETLEASE", F_GETLEASE)
208 ctf_enum_value("F_NOTIFY", F_NOTIFY)
209 ctf_enum_value("F_CANCELLK", F_CANCELLK)
210 ctf_enum_value("F_DUPFD_CLOEXEC", F_DUPFD_CLOEXEC)
211 ctf_enum_value("F_SETPIPE_SZ", F_SETPIPE_SZ)
212 ctf_enum_value("F_GETPIPE_SZ", F_GETPIPE_SZ)
5f4c791e 213#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,17,0))
c1c07d68
GB
214 ctf_enum_value("F_ADD_SEALS", F_ADD_SEALS)
215 ctf_enum_value("F_GET_SEALS", F_GET_SEALS)
5f4c791e
MJ
216#endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,17,0)) */
217#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,14,0))
c1c07d68
GB
218 ctf_enum_value("F_GET_RW_HINT", F_GET_RW_HINT)
219 ctf_enum_value("F_SET_RW_HINT", F_SET_RW_HINT)
220 ctf_enum_value("F_GET_FILE_RW_HINT", F_GET_FILE_RW_HINT)
221 ctf_enum_value("F_SET_FILE_RW_HINT", F_SET_FILE_RW_HINT)
5f4c791e 222#endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,14,0)) */
c1c07d68
GB
223 )
224)
225
226#define OVERRIDE_32_fcntl
227#define OVERRIDE_64_fcntl
228SC_LTTNG_TRACEPOINT_EVENT(fcntl,
229 TP_PROTO(sc_exit(long ret,) unsigned int fd, unsigned int cmd, unsigned long arg),
230 TP_ARGS(sc_exit(ret,) fd, cmd, arg),
231 TP_FIELDS(
232 sc_exit(ctf_integer(long, ret, ret))
233 sc_in(ctf_integer(unsigned int, fd, fd))
234 sc_in(ctf_enum(lttng_fcntl_cmd_flags, unsigned int, cmd, cmd))
235 sc_inout(ctf_integer(unsigned long, arg, arg)))
236)
237
7e42c4ec 238#endif /* CREATE_SYSCALL_TABLE */
This page took 0.053093 seconds and 4 git commands to generate.