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