Commit | Line | Data |
---|---|---|
2879dbbc | 1 | #!/bin/bash |
5fee13fd MD |
2 | |
3 | # Generate system call probe description macros from syscall metadata dump file. | |
eafcf0ad | 4 | # The resulting header will be written in the headers subdirectory, in a file name |
2879dbbc | 5 | # based on the name of the input file. |
eafcf0ad | 6 | # |
5fee13fd | 7 | # example usage: |
25631135 | 8 | # |
6ae73da4 MJ |
9 | # lttng-syscalls-generate-headers.sh <type> <input_dir> <arch_name> <bitness> <output_dir> |
10 | # lttng-syscalls-generate-headers.sh integers 3.0.4 x86 64 ../../include/instrumentation/syscalls/ | |
11 | # lttng-syscalls-generate-headers.sh pointers 3.0.4 x86 64 ../../include/instrumentation/syscalls/ | |
5fee13fd | 12 | |
25631135 | 13 | CLASS=$1 |
6314c2d3 | 14 | VERSIONDIR=$2 |
6ae73da4 MJ |
15 | ARCH=$3 |
16 | BITNESS=$4 | |
17 | OUTPUTDIR=$5 | |
18 | ARCH_NAME="$ARCH-$BITNESS" | |
19 | INPUTFILE="$ARCH_NAME-syscalls" | |
5fee13fd | 20 | |
b03cf820 | 21 | if [ "$VERSIONDIR" = "" ]; then |
2879dbbc | 22 | echo "Error: Please specify input directory as second argument" >&2 |
94f9e233 MD |
23 | exit 1 |
24 | fi | |
25 | ||
b03cf820 | 26 | if [ "$INPUTFILE" = "" ]; then |
2879dbbc | 27 | echo "Error: Please specify input file as third argument" >&2 |
94f9e233 MD |
28 | exit 1 |
29 | fi | |
30 | ||
b03cf820 | 31 | if [ "$BITNESS" != "32" ] && [ "$BITNESS" != "64" ]; then |
2879dbbc | 32 | echo "Error: Please specify bitness as fourth argument (\"32\" or \"64\")" >&2 |
94f9e233 MD |
33 | exit 1 |
34 | fi | |
35 | ||
b03cf820 | 36 | if [ "$ARCH_NAME" = "" ]; then |
9497697f JG |
37 | echo "Error: Please specify the architecture name as fourth argument" >&2 |
38 | exit 1 | |
39 | fi | |
40 | ||
b03cf820 MJ |
41 | if [ "$OUTPUTDIR" = "" ]; then |
42 | echo "Error: Please specify output directory as fifth argument" >&2 | |
43 | exit 1 | |
44 | fi | |
45 | ||
2879dbbc MJ |
46 | # Abort on error and undefined variable |
47 | set -eu | |
5fee13fd | 48 | |
b03cf820 MJ |
49 | INPUT=${VERSIONDIR}/${INPUTFILE} |
50 | HEADER="${OUTPUTDIR}/${INPUTFILE}_${CLASS}.h" | |
51 | ||
2879dbbc MJ |
52 | # Create temp files |
53 | SRCFILE=$(mktemp) | |
54 | TMPFILE=$(mktemp) | |
5fee13fd | 55 | |
2879dbbc MJ |
56 | # Delete temp files on exit |
57 | trap 'rm -f "${SRCFILE}" "${TMPFILE}"' EXIT | |
58 | ||
59 | cp "${INPUT}" "${SRCFILE}" | |
60 | ||
61 | ## Cleanup the input file | |
62 | # Remove the dmesg timestamp if present | |
63 | perl -pi -e 's/^\[.*\] //g' "${SRCFILE}" | |
64 | # Remove the 'sys_' prefix from syscall names | |
65 | perl -pi -e 's/^syscall sys_([^ ]*)/syscall $1/g' "${SRCFILE}" | |
66 | # Remove the user attribute from arguments | |
67 | sed -i 's/ __attribute__((user))//g' "${SRCFILE}" | |
5fee13fd MD |
68 | |
69 | #Filter | |
70 | ||
25631135 MD |
71 | if [ "$CLASS" = integers ]; then |
72 | #select integers and no-args. | |
177b3692 | 73 | CLASSCAP=INTEGERS |
2879dbbc MJ |
74 | grep -v "\\*\|cap_user_header_t" "${SRCFILE}" > "${TMPFILE}" |
75 | mv "${TMPFILE}" "${SRCFILE}" | |
76 | elif [ "$CLASS" = pointers ]; then | |
25631135 | 77 | #select system calls using pointers. |
177b3692 | 78 | CLASSCAP=POINTERS |
2879dbbc MJ |
79 | grep "\\*\|cap_#user_header_t" "${SRCFILE}" > "${TMPFILE}" |
80 | mv "${TMPFILE}" "${SRCFILE}" | |
81 | else | |
82 | echo "Error: Please specify \"integers\" or \"pointers\" as first argument" >&2 | |
94f9e233 MD |
83 | exit 1 |
84 | fi | |
85 | ||
5fee13fd | 86 | |
b7cdc182 | 87 | echo "/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */ |
b03cf820 | 88 | /* SPDX-FileCopyrightText: $(date +%Y) EfficiOS Inc. */ |
2879dbbc MJ |
89 | |
90 | /* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */ | |
91 | ||
6314c2d3 MJ |
92 | /* Generated from ${INPUTFILE} ${VERSIONDIR} */ |
93 | ||
2879dbbc | 94 | #ifndef CREATE_SYSCALL_TABLE |
054f2ed3 | 95 | |
177b3692 MD |
96 | #if !defined(_TRACE_SYSCALLS_${CLASSCAP}_H) || defined(TRACE_HEADER_MULTI_READ) |
97 | #define _TRACE_SYSCALLS_${CLASSCAP}_H | |
5fee13fd | 98 | |
3b4aafcb | 99 | #include <lttng/tracepoint-event.h> |
5fee13fd | 100 | #include <linux/syscalls.h> |
1dc9d1cf | 101 | #include \"${INPUTFILE}_${CLASS}_override.h\" |
daaf627a | 102 | #include \"syscalls_${CLASS}_override.h\" |
2879dbbc | 103 | " > "${HEADER}" |
5fee13fd | 104 | |
25631135 MD |
105 | if [ "$CLASS" = integers ]; then |
106 | ||
2879dbbc | 107 | NRARGS=0 |
fc4f7161 | 108 | |
2879dbbc MJ |
109 | # shellcheck disable=SC2129 |
110 | printf \ | |
111 | '#ifdef SC_ENTER | |
112 | SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(syscalls_noargs, | |
113 | TP_FIELDS() | |
114 | ) | |
115 | ' >> "${HEADER}" | |
f7bdf4db | 116 | |
2879dbbc MJ |
117 | # shellcheck disable=SC2026 |
118 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \ | |
119 | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
177b3692 MD |
120 | 'types: \(([^)]*)\) '\ |
121 | 'args: \(([^)]*)\)/'\ | |
644d6e9c | 122 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 123 | 'SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(syscalls_noargs, $1)\n'\ |
2879dbbc | 124 | '#endif/g' >> "${HEADER}" |
f7bdf4db | 125 | |
2879dbbc | 126 | printf '#else /* #ifdef SC_ENTER */\n' >> "${HEADER}" |
fc4f7161 | 127 | |
2879dbbc MJ |
128 | # shellcheck disable=SC2026 |
129 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \ | |
130 | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
fc4f7161 MD |
131 | 'types: \(([^)]*)\) '\ |
132 | 'args: \(([^)]*)\)/'\ | |
644d6e9c | 133 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 134 | 'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\ |
fc4f7161 MD |
135 | ' TP_PROTO(sc_exit(long ret)),\n'\ |
136 | ' TP_ARGS(sc_exit(ret)),\n'\ | |
57ede728 | 137 | ' TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)))\n'\ |
fc4f7161 | 138 | ')\n'\ |
2879dbbc | 139 | '#endif/g' >> "${HEADER}" |
fc4f7161 | 140 | |
2879dbbc | 141 | printf '#endif /* else #ifdef SC_ENTER */\n' >> "${HEADER}" |
fc4f7161 | 142 | |
25631135 | 143 | fi |
5fee13fd | 144 | |
177b3692 | 145 | |
5fee13fd MD |
146 | # types: 4 |
147 | # args 5 | |
148 | ||
149 | NRARGS=1 | |
2879dbbc MJ |
150 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do |
151 | SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g') | |
6ae73da4 | 152 | ARG1=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 1) |
2879dbbc MJ |
153 | |
154 | echo Syscall: "${SC_NAME}" "${ARG1}" | |
155 | ||
156 | # shellcheck disable=SC2026 | |
157 | echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
177b3692 MD |
158 | 'types: \(([^)]*)\) '\ |
159 | 'args: \(([^)]*)\)/'\ | |
644d6e9c | 160 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 161 | 'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\ |
fc4f7161 MD |
162 | ' TP_PROTO(sc_exit(long ret,) $4 $5),\n'\ |
163 | ' TP_ARGS(sc_exit(ret,) $5),\n'\ | |
57ede728 | 164 | ' TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) '"${ARG1}"'(ctf_integer($4, $5, $5)))\n'\ |
1dc9d1cf | 165 | ')\n'\ |
2879dbbc MJ |
166 | '#endif/g' >> "${HEADER}" |
167 | done | |
5fee13fd MD |
168 | |
169 | # types: 4 5 | |
170 | # args 6 7 | |
171 | ||
172 | NRARGS=2 | |
2879dbbc MJ |
173 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do |
174 | SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g') | |
6ae73da4 MJ |
175 | ARG1=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 1) |
176 | ARG2=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 2) | |
2879dbbc MJ |
177 | |
178 | echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}" | |
179 | ||
180 | # shellcheck disable=SC2026 | |
181 | echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
177b3692 MD |
182 | 'types: \(([^,]*), ([^)]*)\) '\ |
183 | 'args: \(([^,]*), ([^)]*)\)/'\ | |
644d6e9c | 184 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 185 | 'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\ |
fc4f7161 MD |
186 | ' TP_PROTO(sc_exit(long ret,) $4 $6, $5 $7),\n'\ |
187 | ' TP_ARGS(sc_exit(ret,) $6, $7),\n'\ | |
57ede728 | 188 | ' TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) '"${ARG1}"'(ctf_integer($4, $6, $6)) '"${ARG2}"'(ctf_integer($5, $7, $7)))\n'\ |
1dc9d1cf | 189 | ')\n'\ |
2879dbbc MJ |
190 | '#endif/g' >> "${HEADER}" |
191 | done | |
5fee13fd MD |
192 | |
193 | # types: 4 5 6 | |
194 | # args 7 8 9 | |
195 | ||
196 | NRARGS=3 | |
2879dbbc MJ |
197 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do |
198 | SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g') | |
6ae73da4 MJ |
199 | ARG1=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 1) |
200 | ARG2=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 2) | |
201 | ARG3=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 3) | |
2879dbbc MJ |
202 | |
203 | echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}" "${ARG3}" | |
204 | ||
205 | # shellcheck disable=SC2026 | |
206 | echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
177b3692 MD |
207 | 'types: \(([^,]*), ([^,]*), ([^)]*)\) '\ |
208 | 'args: \(([^,]*), ([^,]*), ([^)]*)\)/'\ | |
644d6e9c | 209 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 210 | 'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\ |
fc4f7161 MD |
211 | ' TP_PROTO(sc_exit(long ret,) $4 $7, $5 $8, $6 $9),\n'\ |
212 | ' TP_ARGS(sc_exit(ret,) $7, $8, $9),\n'\ | |
57ede728 | 213 | ' TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) '"${ARG1}"'(ctf_integer($4, $7, $7)) '"${ARG2}"'(ctf_integer($5, $8, $8)) '"${ARG3}"'(ctf_integer($6, $9, $9)))\n'\ |
1dc9d1cf | 214 | ')\n'\ |
2879dbbc MJ |
215 | '#endif/g' >> "${HEADER}" |
216 | done | |
5fee13fd MD |
217 | |
218 | ||
219 | # types: 4 5 6 7 | |
220 | # args 8 9 10 11 | |
221 | ||
222 | NRARGS=4 | |
2879dbbc MJ |
223 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do |
224 | SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g') | |
6ae73da4 MJ |
225 | ARG1=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 1) |
226 | ARG2=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 2) | |
227 | ARG3=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 3) | |
228 | ARG4=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 4) | |
2879dbbc MJ |
229 | |
230 | echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}" "${ARG3}" "${ARG4}" | |
231 | ||
232 | # shellcheck disable=SC2026 | |
233 | echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
177b3692 MD |
234 | 'types: \(([^,]*), ([^,]*), ([^,]*), ([^)]*)\) '\ |
235 | 'args: \(([^,]*), ([^,]*), ([^,]*), ([^)]*)\)/'\ | |
644d6e9c | 236 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 237 | 'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\ |
fc4f7161 MD |
238 | ' TP_PROTO(sc_exit(long ret,) $4 $8, $5 $9, $6 $10, $7 $11),\n'\ |
239 | ' TP_ARGS(sc_exit(ret,) $8, $9, $10, $11),\n'\ | |
57ede728 | 240 | ' TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) '"${ARG1}"'(ctf_integer($4, $8, $8)) '"${ARG2}"'(ctf_integer($5, $9, $9)) '"${ARG3}"'(ctf_integer($6, $10, $10)) '"${ARG4}"'(ctf_integer($7, $11, $11)))\n'\ |
1dc9d1cf | 241 | ')\n'\ |
2879dbbc MJ |
242 | '#endif/g' >> "${HEADER}" |
243 | done | |
5fee13fd MD |
244 | |
245 | # types: 4 5 6 7 8 | |
246 | # args 9 10 11 12 13 | |
247 | ||
248 | NRARGS=5 | |
2879dbbc MJ |
249 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do |
250 | SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g') | |
6ae73da4 MJ |
251 | ARG1=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 1) |
252 | ARG2=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 2) | |
253 | ARG3=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 3) | |
254 | ARG4=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 4) | |
255 | ARG5=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 5) | |
2879dbbc MJ |
256 | |
257 | echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}" "${ARG3}" "${ARG4}" "${ARG5}" | |
258 | ||
259 | # shellcheck disable=SC2026 | |
260 | echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
177b3692 MD |
261 | 'types: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^)]*)\) '\ |
262 | 'args: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^)]*)\)/'\ | |
644d6e9c | 263 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 264 | 'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\ |
fc4f7161 MD |
265 | ' TP_PROTO(sc_exit(long ret,) $4 $9, $5 $10, $6 $11, $7 $12, $8 $13),\n'\ |
266 | ' TP_ARGS(sc_exit(ret,) $9, $10, $11, $12, $13),\n'\ | |
57ede728 | 267 | ' TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) '"${ARG1}"'(ctf_integer($4, $9, $9)) '"${ARG2}"'(ctf_integer($5, $10, $10)) '"${ARG3}"'(ctf_integer($6, $11, $11)) '"${ARG4}"'(ctf_integer($7, $12, $12)) '"${ARG5}"'(ctf_integer($8, $13, $13)))\n'\ |
1dc9d1cf | 268 | ')\n'\ |
2879dbbc MJ |
269 | '#endif/g' >> "${HEADER}" |
270 | done | |
5fee13fd MD |
271 | |
272 | ||
273 | # types: 4 5 6 7 8 9 | |
274 | # args 10 11 12 13 14 15 | |
275 | ||
276 | NRARGS=6 | |
2879dbbc MJ |
277 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do |
278 | SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g') | |
6ae73da4 MJ |
279 | ARG1=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 1) |
280 | ARG2=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 2) | |
281 | ARG3=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 3) | |
282 | ARG4=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 4) | |
283 | ARG5=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 5) | |
284 | ARG6=$(./lttng-get-syscall-inout.sh "${ARCH_NAME}" "${SC_NAME}" "$NRARGS" 6) | |
2879dbbc MJ |
285 | |
286 | echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}" "${ARG3}" "${ARG4}" "${ARG5}" "${ARG6}" | |
287 | ||
288 | # shellcheck disable=SC2026 | |
289 | echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
177b3692 MD |
290 | 'types: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^\)]*)\) '\ |
291 | 'args: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^\)]*)\)/'\ | |
644d6e9c | 292 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 293 | 'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\ |
fc4f7161 MD |
294 | ' TP_PROTO(sc_exit(long ret,) $4 $10, $5 $11, $6 $12, $7 $13, $8 $14, $9 $15),\n'\ |
295 | ' TP_ARGS(sc_exit(ret,) $10, $11, $12, $13, $14, $15),\n'\ | |
57ede728 | 296 | ' TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) '"${ARG1}"'(ctf_integer($4, $10, $10)) '"${ARG2}"'(ctf_integer($5, $11, $11)) '"${ARG3}"'(ctf_integer($6, $12, $12)) '"${ARG4}"'(ctf_integer($7, $13, $13)) '"${ARG5}"'(ctf_integer($8, $14, $14)) '"${ARG6}"'(ctf_integer($9, $15, $15)))\n'\ |
1dc9d1cf | 297 | ')\n'\ |
2879dbbc MJ |
298 | '#endif/g' >> "${HEADER}" |
299 | done | |
5fee13fd | 300 | |
9b6d7a0c MD |
301 | # Macro for tracing syscall table |
302 | ||
054f2ed3 | 303 | echo \ |
5fee13fd | 304 | " |
177b3692 | 305 | #endif /* _TRACE_SYSCALLS_${CLASSCAP}_H */ |
5fee13fd MD |
306 | |
307 | /* This part must be outside protection */ | |
3b4aafcb | 308 | #include <lttng/define_trace.h> |
054f2ed3 MD |
309 | |
310 | #else /* CREATE_SYSCALL_TABLE */ | |
054f2ed3 | 311 | |
cac8f1aa | 312 | #include \"${INPUTFILE}_${CLASS}_override.h\" |
daaf627a | 313 | #include \"syscalls_${CLASS}_override.h\" |
2879dbbc | 314 | " >> "${HEADER}" |
f7bdf4db MD |
315 | |
316 | NRARGS=0 | |
f7bdf4db | 317 | |
25631135 | 318 | if [ "$CLASS" = integers ]; then |
2879dbbc | 319 | #noargs |
fc4f7161 | 320 | |
2879dbbc MJ |
321 | # shellcheck disable=SC2129 |
322 | printf '#ifdef SC_ENTER\n' >> "${HEADER}" | |
fc4f7161 | 323 | |
2879dbbc MJ |
324 | # shellcheck disable=SC2026 |
325 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \ | |
326 | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\ | |
644d6e9c MD |
327 | '#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_$1\n'\ |
328 | 'TRACE_SYSCALL_TABLE\(syscalls_noargs, $1, $2, $3\)\n'\ | |
2879dbbc | 329 | '#endif/g' >> "${HEADER}" |
fc4f7161 | 330 | |
2879dbbc | 331 | printf '#else /* #ifdef SC_ENTER */\n' >> "${HEADER}" |
fc4f7161 | 332 | |
2879dbbc MJ |
333 | # shellcheck disable=SC2026 |
334 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \ | |
335 | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\ | |
644d6e9c MD |
336 | '#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_$1\n'\ |
337 | 'TRACE_SYSCALL_TABLE($1, $1, $2, $3)\n'\ | |
2879dbbc | 338 | '#endif/g' >> "${HEADER}" |
fc4f7161 | 339 | |
2879dbbc | 340 | printf '#endif /* else #ifdef SC_ENTER */\n' >> "${HEADER}" |
25631135 | 341 | fi |
f7bdf4db MD |
342 | |
343 | #others. | |
2879dbbc MJ |
344 | # shellcheck disable=SC2026 |
345 | grep -v "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \ | |
346 | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\ | |
644d6e9c MD |
347 | '#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_$1\n'\ |
348 | 'TRACE_SYSCALL_TABLE($1, $1, $2, $3)\n'\ | |
2879dbbc | 349 | '#endif/g' >> "${HEADER}" |
054f2ed3 | 350 | |
2879dbbc | 351 | printf '\n#endif /* CREATE_SYSCALL_TABLE */\n' >> "${HEADER}" |
5fee13fd | 352 | |
e374aaf1 MD |
353 | #fields names: ...char * type with *name* or *file* or *path* or *root* |
354 | # or *put_old* or *type* | |
2879dbbc MJ |
355 | perl -pi -e 's/ctf_integer\(([^,)]*char \*), ([^\)]*)(name|file|path|root|put_old|type)([^\)]*)\)/ctf_user_string($2$3$4)/g' \ |
356 | "${HEADER}" | |
d0b4f04b MD |
357 | |
358 | #prettify addresses heuristics. | |
359 | #field names with addr or ptr | |
2879dbbc MJ |
360 | perl -pi -e 's/ctf_integer\(([^,)]*), ([^,)]*addr|[^,)]*ptr)([^),]*)\)/ctf_integer_hex($1, $2$3, $2$3)/g' \ |
361 | "${HEADER}" | |
f4c4a6ae | 362 | |
d0b4f04b | 363 | #field types ending with '*' |
2879dbbc MJ |
364 | perl -pi -e 's/ctf_integer\(([^,)]*\*), ([^),]*)\)/ctf_integer_hex($1, $2, $2)/g' "${HEADER}" |
365 | ||
366 | # EOF |