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