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