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> |
6314c2d3 MJ |
10 | # lttng-syscalls-generate-headers.sh integers 3.0.4 x86-64-syscalls 64 |
11 | # lttng-syscalls-generate-headers.sh pointers 3.0.4 x86-64-syscalls 64 | |
5fee13fd | 12 | |
25631135 | 13 | CLASS=$1 |
6314c2d3 | 14 | VERSIONDIR=$2 |
25631135 | 15 | INPUTFILE=$3 |
daaf627a | 16 | BITNESS=$4 |
6314c2d3 | 17 | INPUT=${VERSIONDIR}/${INPUTFILE} |
177b3692 | 18 | HEADER=headers/${INPUTFILE}_${CLASS}.h |
5fee13fd | 19 | |
6314c2d3 | 20 | if [ x"$VERSIONDIR" = 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 | |
b7cdc182 | 73 | echo "/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */ |
2879dbbc MJ |
74 | |
75 | /* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */ | |
76 | ||
6314c2d3 MJ |
77 | /* Generated from ${INPUTFILE} ${VERSIONDIR} */ |
78 | ||
2879dbbc | 79 | #ifndef CREATE_SYSCALL_TABLE |
054f2ed3 | 80 | |
177b3692 MD |
81 | #if !defined(_TRACE_SYSCALLS_${CLASSCAP}_H) || defined(TRACE_HEADER_MULTI_READ) |
82 | #define _TRACE_SYSCALLS_${CLASSCAP}_H | |
5fee13fd | 83 | |
3b4aafcb | 84 | #include <lttng/tracepoint-event.h> |
5fee13fd | 85 | #include <linux/syscalls.h> |
1dc9d1cf | 86 | #include \"${INPUTFILE}_${CLASS}_override.h\" |
daaf627a | 87 | #include \"syscalls_${CLASS}_override.h\" |
2879dbbc | 88 | " > "${HEADER}" |
5fee13fd | 89 | |
25631135 MD |
90 | if [ "$CLASS" = integers ]; then |
91 | ||
2879dbbc | 92 | NRARGS=0 |
fc4f7161 | 93 | |
2879dbbc MJ |
94 | # shellcheck disable=SC2129 |
95 | printf \ | |
96 | '#ifdef SC_ENTER | |
97 | SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(syscalls_noargs, | |
98 | TP_FIELDS() | |
99 | ) | |
100 | ' >> "${HEADER}" | |
f7bdf4db | 101 | |
2879dbbc MJ |
102 | # shellcheck disable=SC2026 |
103 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \ | |
104 | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
177b3692 MD |
105 | 'types: \(([^)]*)\) '\ |
106 | 'args: \(([^)]*)\)/'\ | |
644d6e9c | 107 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 108 | 'SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(syscalls_noargs, $1)\n'\ |
2879dbbc | 109 | '#endif/g' >> "${HEADER}" |
f7bdf4db | 110 | |
2879dbbc | 111 | printf '#else /* #ifdef SC_ENTER */\n' >> "${HEADER}" |
fc4f7161 | 112 | |
2879dbbc MJ |
113 | # shellcheck disable=SC2026 |
114 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \ | |
115 | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
fc4f7161 MD |
116 | 'types: \(([^)]*)\) '\ |
117 | 'args: \(([^)]*)\)/'\ | |
644d6e9c | 118 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 119 | 'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\ |
fc4f7161 MD |
120 | ' TP_PROTO(sc_exit(long ret)),\n'\ |
121 | ' TP_ARGS(sc_exit(ret)),\n'\ | |
57ede728 | 122 | ' TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)))\n'\ |
fc4f7161 | 123 | ')\n'\ |
2879dbbc | 124 | '#endif/g' >> "${HEADER}" |
fc4f7161 | 125 | |
2879dbbc | 126 | printf '#endif /* else #ifdef SC_ENTER */\n' >> "${HEADER}" |
fc4f7161 | 127 | |
25631135 | 128 | fi |
5fee13fd | 129 | |
177b3692 | 130 | |
5fee13fd MD |
131 | # types: 4 |
132 | # args 5 | |
133 | ||
134 | NRARGS=1 | |
2879dbbc MJ |
135 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do |
136 | SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g') | |
137 | ARG1=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 1) | |
138 | ||
139 | echo Syscall: "${SC_NAME}" "${ARG1}" | |
140 | ||
141 | # shellcheck disable=SC2026 | |
142 | echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
177b3692 MD |
143 | 'types: \(([^)]*)\) '\ |
144 | 'args: \(([^)]*)\)/'\ | |
644d6e9c | 145 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 146 | 'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\ |
fc4f7161 MD |
147 | ' TP_PROTO(sc_exit(long ret,) $4 $5),\n'\ |
148 | ' TP_ARGS(sc_exit(ret,) $5),\n'\ | |
57ede728 | 149 | ' TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) '"${ARG1}"'(ctf_integer($4, $5, $5)))\n'\ |
1dc9d1cf | 150 | ')\n'\ |
2879dbbc MJ |
151 | '#endif/g' >> "${HEADER}" |
152 | done | |
5fee13fd MD |
153 | |
154 | # types: 4 5 | |
155 | # args 6 7 | |
156 | ||
157 | NRARGS=2 | |
2879dbbc MJ |
158 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do |
159 | SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g') | |
160 | ARG1=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 1) | |
161 | ARG2=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 2) | |
162 | ||
163 | echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}" | |
164 | ||
165 | # shellcheck disable=SC2026 | |
166 | echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
177b3692 MD |
167 | 'types: \(([^,]*), ([^)]*)\) '\ |
168 | 'args: \(([^,]*), ([^)]*)\)/'\ | |
644d6e9c | 169 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 170 | 'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\ |
fc4f7161 MD |
171 | ' TP_PROTO(sc_exit(long ret,) $4 $6, $5 $7),\n'\ |
172 | ' TP_ARGS(sc_exit(ret,) $6, $7),\n'\ | |
57ede728 | 173 | ' TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) '"${ARG1}"'(ctf_integer($4, $6, $6)) '"${ARG2}"'(ctf_integer($5, $7, $7)))\n'\ |
1dc9d1cf | 174 | ')\n'\ |
2879dbbc MJ |
175 | '#endif/g' >> "${HEADER}" |
176 | done | |
5fee13fd MD |
177 | |
178 | # types: 4 5 6 | |
179 | # args 7 8 9 | |
180 | ||
181 | NRARGS=3 | |
2879dbbc MJ |
182 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do |
183 | SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g') | |
184 | ARG1=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 1) | |
185 | ARG2=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 2) | |
186 | ARG3=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 3) | |
187 | ||
188 | echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}" "${ARG3}" | |
189 | ||
190 | # shellcheck disable=SC2026 | |
191 | echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
177b3692 MD |
192 | 'types: \(([^,]*), ([^,]*), ([^)]*)\) '\ |
193 | 'args: \(([^,]*), ([^,]*), ([^)]*)\)/'\ | |
644d6e9c | 194 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 195 | 'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\ |
fc4f7161 MD |
196 | ' TP_PROTO(sc_exit(long ret,) $4 $7, $5 $8, $6 $9),\n'\ |
197 | ' TP_ARGS(sc_exit(ret,) $7, $8, $9),\n'\ | |
57ede728 | 198 | ' 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 | 199 | ')\n'\ |
2879dbbc MJ |
200 | '#endif/g' >> "${HEADER}" |
201 | done | |
5fee13fd MD |
202 | |
203 | ||
204 | # types: 4 5 6 7 | |
205 | # args 8 9 10 11 | |
206 | ||
207 | NRARGS=4 | |
2879dbbc MJ |
208 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do |
209 | SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g') | |
210 | ARG1=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 1) | |
211 | ARG2=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 2) | |
212 | ARG3=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 3) | |
213 | ARG4=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 4) | |
214 | ||
215 | echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}" "${ARG3}" "${ARG4}" | |
216 | ||
217 | # shellcheck disable=SC2026 | |
218 | echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
177b3692 MD |
219 | 'types: \(([^,]*), ([^,]*), ([^,]*), ([^)]*)\) '\ |
220 | 'args: \(([^,]*), ([^,]*), ([^,]*), ([^)]*)\)/'\ | |
644d6e9c | 221 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 222 | 'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\ |
fc4f7161 MD |
223 | ' TP_PROTO(sc_exit(long ret,) $4 $8, $5 $9, $6 $10, $7 $11),\n'\ |
224 | ' TP_ARGS(sc_exit(ret,) $8, $9, $10, $11),\n'\ | |
57ede728 | 225 | ' 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 | 226 | ')\n'\ |
2879dbbc MJ |
227 | '#endif/g' >> "${HEADER}" |
228 | done | |
5fee13fd MD |
229 | |
230 | # types: 4 5 6 7 8 | |
231 | # args 9 10 11 12 13 | |
232 | ||
233 | NRARGS=5 | |
2879dbbc MJ |
234 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do |
235 | SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g') | |
236 | ARG1=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 1) | |
237 | ARG2=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 2) | |
238 | ARG3=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 3) | |
239 | ARG4=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 4) | |
240 | ARG5=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 5) | |
241 | ||
242 | echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}" "${ARG3}" "${ARG4}" "${ARG5}" | |
243 | ||
244 | # shellcheck disable=SC2026 | |
245 | echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
177b3692 MD |
246 | 'types: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^)]*)\) '\ |
247 | 'args: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^)]*)\)/'\ | |
644d6e9c | 248 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 249 | 'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\ |
fc4f7161 MD |
250 | ' TP_PROTO(sc_exit(long ret,) $4 $9, $5 $10, $6 $11, $7 $12, $8 $13),\n'\ |
251 | ' TP_ARGS(sc_exit(ret,) $9, $10, $11, $12, $13),\n'\ | |
57ede728 | 252 | ' 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 | 253 | ')\n'\ |
2879dbbc MJ |
254 | '#endif/g' >> "${HEADER}" |
255 | done | |
5fee13fd MD |
256 | |
257 | ||
258 | # types: 4 5 6 7 8 9 | |
259 | # args 10 11 12 13 14 15 | |
260 | ||
261 | NRARGS=6 | |
2879dbbc MJ |
262 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do |
263 | SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g') | |
264 | ARG1=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 1) | |
265 | ARG2=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 2) | |
266 | ARG3=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 3) | |
267 | ARG4=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 4) | |
268 | ARG5=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 5) | |
269 | ARG6=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 6) | |
270 | ||
271 | echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}" "${ARG3}" "${ARG4}" "${ARG5}" "${ARG6}" | |
272 | ||
273 | # shellcheck disable=SC2026 | |
274 | echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ | |
177b3692 MD |
275 | 'types: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^\)]*)\) '\ |
276 | 'args: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^\)]*)\)/'\ | |
644d6e9c | 277 | '#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\ |
cb3ef14c | 278 | 'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\ |
fc4f7161 MD |
279 | ' TP_PROTO(sc_exit(long ret,) $4 $10, $5 $11, $6 $12, $7 $13, $8 $14, $9 $15),\n'\ |
280 | ' TP_ARGS(sc_exit(ret,) $10, $11, $12, $13, $14, $15),\n'\ | |
57ede728 | 281 | ' 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 | 282 | ')\n'\ |
2879dbbc MJ |
283 | '#endif/g' >> "${HEADER}" |
284 | done | |
5fee13fd | 285 | |
9b6d7a0c MD |
286 | # Macro for tracing syscall table |
287 | ||
054f2ed3 | 288 | echo \ |
5fee13fd | 289 | " |
177b3692 | 290 | #endif /* _TRACE_SYSCALLS_${CLASSCAP}_H */ |
5fee13fd MD |
291 | |
292 | /* This part must be outside protection */ | |
3b4aafcb | 293 | #include <lttng/define_trace.h> |
054f2ed3 MD |
294 | |
295 | #else /* CREATE_SYSCALL_TABLE */ | |
054f2ed3 | 296 | |
cac8f1aa | 297 | #include \"${INPUTFILE}_${CLASS}_override.h\" |
daaf627a | 298 | #include \"syscalls_${CLASS}_override.h\" |
2879dbbc | 299 | " >> "${HEADER}" |
f7bdf4db MD |
300 | |
301 | NRARGS=0 | |
f7bdf4db | 302 | |
25631135 | 303 | if [ "$CLASS" = integers ]; then |
2879dbbc | 304 | #noargs |
fc4f7161 | 305 | |
2879dbbc MJ |
306 | # shellcheck disable=SC2129 |
307 | printf '#ifdef SC_ENTER\n' >> "${HEADER}" | |
fc4f7161 | 308 | |
2879dbbc MJ |
309 | # shellcheck disable=SC2026 |
310 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \ | |
311 | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\ | |
644d6e9c MD |
312 | '#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_$1\n'\ |
313 | 'TRACE_SYSCALL_TABLE\(syscalls_noargs, $1, $2, $3\)\n'\ | |
2879dbbc | 314 | '#endif/g' >> "${HEADER}" |
fc4f7161 | 315 | |
2879dbbc | 316 | printf '#else /* #ifdef SC_ENTER */\n' >> "${HEADER}" |
fc4f7161 | 317 | |
2879dbbc MJ |
318 | # shellcheck disable=SC2026 |
319 | grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \ | |
320 | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\ | |
644d6e9c MD |
321 | '#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_$1\n'\ |
322 | 'TRACE_SYSCALL_TABLE($1, $1, $2, $3)\n'\ | |
2879dbbc | 323 | '#endif/g' >> "${HEADER}" |
fc4f7161 | 324 | |
2879dbbc | 325 | printf '#endif /* else #ifdef SC_ENTER */\n' >> "${HEADER}" |
25631135 | 326 | fi |
f7bdf4db MD |
327 | |
328 | #others. | |
2879dbbc MJ |
329 | # shellcheck disable=SC2026 |
330 | grep -v "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \ | |
331 | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\ | |
644d6e9c MD |
332 | '#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_$1\n'\ |
333 | 'TRACE_SYSCALL_TABLE($1, $1, $2, $3)\n'\ | |
2879dbbc | 334 | '#endif/g' >> "${HEADER}" |
054f2ed3 | 335 | |
2879dbbc | 336 | printf '\n#endif /* CREATE_SYSCALL_TABLE */\n' >> "${HEADER}" |
5fee13fd | 337 | |
e374aaf1 MD |
338 | #fields names: ...char * type with *name* or *file* or *path* or *root* |
339 | # or *put_old* or *type* | |
2879dbbc MJ |
340 | perl -pi -e 's/ctf_integer\(([^,)]*char \*), ([^\)]*)(name|file|path|root|put_old|type)([^\)]*)\)/ctf_user_string($2$3$4)/g' \ |
341 | "${HEADER}" | |
d0b4f04b MD |
342 | |
343 | #prettify addresses heuristics. | |
344 | #field names with addr or ptr | |
2879dbbc MJ |
345 | perl -pi -e 's/ctf_integer\(([^,)]*), ([^,)]*addr|[^,)]*ptr)([^),]*)\)/ctf_integer_hex($1, $2$3, $2$3)/g' \ |
346 | "${HEADER}" | |
f4c4a6ae | 347 | |
d0b4f04b | 348 | #field types ending with '*' |
2879dbbc MJ |
349 | perl -pi -e 's/ctf_integer\(([^,)]*\*), ([^),]*)\)/ctf_integer_hex($1, $2, $2)/g' "${HEADER}" |
350 | ||
351 | # EOF |