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