Cleanup: Remove deprecated TODO file
[lttng-modules.git] / instrumentation / syscalls / lttng-syscalls-generate-headers.sh
old mode 100644 (file)
new mode 100755 (executable)
index f9746f5..df29abf
-#!/bin/sh
+#!/bin/bash
 
 # Generate system call probe description macros from syscall metadata dump file.
+# The resulting header will be written in the headers subdirectory, in a file name
+# based on the name of the input file.
+#
 # example usage:
 #
-# lttng-syscalls-generate-headers.sh integers 3.0.4 x86-64-syscalls-3.0.4
-# lttng-syscalls-generate-headers.sh pointers 3.0.4 x86-64-syscalls-3.0.4
+# lttng-syscalls-generate-headers.sh <type> <input_dir> <input_filename_in_dir> <bitness>
+# lttng-syscalls-generate-headers.sh integers 3.0.4 x86-64-syscalls 64
+# lttng-syscalls-generate-headers.sh pointers 3.0.4 x86-64-syscalls 64
 
 CLASS=$1
-INPUTDIR=$2
+VERSIONDIR=$2
 INPUTFILE=$3
-INPUT=${INPUTDIR}/${INPUTFILE}
-SRCFILE=gen.tmp.0
-TMPFILE=gen.tmp.1
+BITNESS=$4
+INPUT=${VERSIONDIR}/${INPUTFILE}
 HEADER=headers/${INPUTFILE}_${CLASS}.h
 
-cp ${INPUT} ${SRCFILE}
+if [ x"$VERSIONDIR" = x"" ]; then
+       echo "Error: Please specify input directory as second argument" >&2
+       exit 1
+fi
+
+if [ x"$INPUTFILE" = x"" ]; then
+       echo "Error: Please specify input file as third argument" >&2
+       exit 1
+fi
+
+if [ x"$BITNESS" != x"32" ] && [ x"$BITNESS" != x"64" ]; then
+       echo "Error: Please specify bitness as fourth argument (\"32\" or \"64\")" >&2
+       exit 1
+fi
+
+# Abort on error and undefined variable
+set -eu
+
+# Create temp files
+SRCFILE=$(mktemp)
+TMPFILE=$(mktemp)
+
+# Delete temp files on exit
+trap 'rm -f "${SRCFILE}" "${TMPFILE}"' EXIT
 
-#Cleanup
-perl -p -e 's/^\[.*\] //g' ${SRCFILE} > ${TMPFILE}
-mv ${TMPFILE} ${SRCFILE}
+cp "${INPUT}" "${SRCFILE}"
 
-perl -p -e 's/^syscall sys_([^ ]*)/syscall $1/g' ${SRCFILE} > ${TMPFILE}
-mv ${TMPFILE} ${SRCFILE}
+## Cleanup the input file
+# Remove the dmesg timestamp if present
+perl -pi -e 's/^\[.*\] //g' "${SRCFILE}"
+# Remove the 'sys_' prefix from syscall names
+perl -pi -e 's/^syscall sys_([^ ]*)/syscall $1/g' "${SRCFILE}"
+# Remove the user attribute from arguments
+sed -i 's/ __attribute__((user))//g' "${SRCFILE}"
 
 #Filter
 
 if [ "$CLASS" = integers ]; then
        #select integers and no-args.
        CLASSCAP=INTEGERS
-       grep -v "\\*\|cap_user_header_t" ${SRCFILE} > ${TMPFILE}
-       mv ${TMPFILE} ${SRCFILE}
-fi
-
-
-if [ "$CLASS" = pointers ]; then
+       grep -v "\\*\|cap_user_header_t" "${SRCFILE}" > "${TMPFILE}"
+       mv "${TMPFILE}" "${SRCFILE}"
+elif [ "$CLASS" = pointers ]; then
        #select system calls using pointers.
        CLASSCAP=POINTERS
-       grep "\\*\|cap_#user_header_t" ${SRCFILE} > ${TMPFILE}
-       mv ${TMPFILE} ${SRCFILE}
+       grep "\\*\|cap_#user_header_t" "${SRCFILE}" > "${TMPFILE}"
+       mv "${TMPFILE}" "${SRCFILE}"
+else
+       echo "Error: Please specify \"integers\" or \"pointers\" as first argument" >&2
+       exit 1
 fi
 
-echo "/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */" > ${HEADER}
 
-echo \
-"#ifndef CREATE_SYSCALL_TABLE
+echo "/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
+
+/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
+
+/* Generated from ${INPUTFILE} ${VERSIONDIR} */
 
-#undef TRACE_SYSTEM
-#define TRACE_SYSTEM syscalls_${CLASS}
+#ifndef CREATE_SYSCALL_TABLE
 
 #if !defined(_TRACE_SYSCALLS_${CLASSCAP}_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_SYSCALLS_${CLASSCAP}_H
 
-#include <linux/tracepoint.h>
+#include <lttng/tracepoint-event.h>
 #include <linux/syscalls.h>
-" >> ${HEADER}
+#include \"${INPUTFILE}_${CLASS}_override.h\"
+#include \"syscalls_${CLASS}_override.h\"
+" > "${HEADER}"
 
 if [ "$CLASS" = integers ]; then
 
-NRARGS=0
+       NRARGS=0
 
-echo \
-'DECLARE_EVENT_CLASS_NOARGS(syscalls_noargs,\n'\
-'      TP_STRUCT__entry(),\n'\
-'      TP_fast_assign(),\n'\
-'      TP_printk()\n'\
-')'\
-       >> ${HEADER}
-
-grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
-perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+       # shellcheck disable=SC2129
+       printf \
+'#ifdef SC_ENTER
+SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(syscalls_noargs,
+       TP_FIELDS()
+)
+' >> "${HEADER}"
+
+       # shellcheck disable=SC2026
+       grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \
+               perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
 'types: \(([^)]*)\) '\
 'args: \(([^)]*)\)/'\
-'DEFINE_EVENT_NOARGS(syscalls_noargs, sys_$1)'\
-'/g'\
-       ${TMPFILE} >> ${HEADER}
+'#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\
+'SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(syscalls_noargs, $1)\n'\
+'#endif/g' >> "${HEADER}"
+
+       printf '#else /* #ifdef SC_ENTER */\n' >> "${HEADER}"
+
+       # shellcheck disable=SC2026
+       grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \
+               perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+'types: \(([^)]*)\) '\
+'args: \(([^)]*)\)/'\
+'#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\
+'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\
+'      TP_PROTO(sc_exit(long ret)),\n'\
+'      TP_ARGS(sc_exit(ret)),\n'\
+'      TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)))\n'\
+')\n'\
+'#endif/g' >> "${HEADER}"
+
+       printf '#endif /* else #ifdef SC_ENTER */\n' >> "${HEADER}"
 
 fi
 
@@ -82,160 +132,220 @@ fi
 # args   5
 
 NRARGS=1
-grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
-perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do
+       SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g')
+       ARG1=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 1)
+
+       echo Syscall: "${SC_NAME}" "${ARG1}"
+
+       # shellcheck disable=SC2026
+       echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
 'types: \(([^)]*)\) '\
 'args: \(([^)]*)\)/'\
-'TRACE_EVENT(sys_$1,\n'\
-'      TP_PROTO($4 $5),\n'\
-'      TP_ARGS($5),\n'\
-'      TP_STRUCT__entry(__field($4, $5)),\n'\
-'      TP_fast_assign(tp_assign($5, $5)),\n'\
-'      TP_printk()\n'\
-')/g'\
-       ${TMPFILE} >> ${HEADER}
+'#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\
+'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\
+'      TP_PROTO(sc_exit(long ret,) $4 $5),\n'\
+'      TP_ARGS(sc_exit(ret,) $5),\n'\
+'      TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) '"${ARG1}"'(ctf_integer($4, $5, $5)))\n'\
+')\n'\
+'#endif/g' >> "${HEADER}"
+done
 
 # types: 4 5
 # args   6 7
 
 NRARGS=2
-grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
-perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do
+       SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g')
+       ARG1=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 1)
+       ARG2=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 2)
+
+       echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}"
+
+       # shellcheck disable=SC2026
+       echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
 'types: \(([^,]*), ([^)]*)\) '\
 'args: \(([^,]*), ([^)]*)\)/'\
-'TRACE_EVENT(sys_$1,\n'\
-'      TP_PROTO($4 $6, $5 $7),\n'\
-'      TP_ARGS($6, $7),\n'\
-'      TP_STRUCT__entry(__field($4, $6) __field($5, $7)),\n'\
-'      TP_fast_assign(tp_assign($6, $6) tp_assign($7, $7)),\n'\
-'      TP_printk()\n'\
-')/g'\
-       ${TMPFILE} >> ${HEADER}
+'#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\
+'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\
+'      TP_PROTO(sc_exit(long ret,) $4 $6, $5 $7),\n'\
+'      TP_ARGS(sc_exit(ret,) $6, $7),\n'\
+'      TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) '"${ARG1}"'(ctf_integer($4, $6, $6)) '"${ARG2}"'(ctf_integer($5, $7, $7)))\n'\
+')\n'\
+'#endif/g' >> "${HEADER}"
+done
 
 # types: 4 5 6
 # args   7 8 9
 
 NRARGS=3
-grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
-perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do
+       SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g')
+       ARG1=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 1)
+       ARG2=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 2)
+       ARG3=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 3)
+
+       echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}" "${ARG3}"
+
+       # shellcheck disable=SC2026
+       echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
 'types: \(([^,]*), ([^,]*), ([^)]*)\) '\
 'args: \(([^,]*), ([^,]*), ([^)]*)\)/'\
-'TRACE_EVENT(sys_$1,\n'\
-'      TP_PROTO($4 $7, $5 $8, $6 $9),\n'\
-'      TP_ARGS($7, $8, $9),\n'\
-'      TP_STRUCT__entry(__field($4, $7) __field($5, $8) __field($6, $9)),\n'\
-'      TP_fast_assign(tp_assign($7, $7) tp_assign($8, $8) tp_assign($9, $9)),\n'\
-'      TP_printk()\n'\
-')/g'\
-       ${TMPFILE} >> ${HEADER}
+'#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\
+'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\
+'      TP_PROTO(sc_exit(long ret,) $4 $7, $5 $8, $6 $9),\n'\
+'      TP_ARGS(sc_exit(ret,) $7, $8, $9),\n'\
+'      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'\
+')\n'\
+'#endif/g' >> "${HEADER}"
+done
 
 
 # types: 4 5  6  7
 # args   8 9 10 11
 
 NRARGS=4
-grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
-perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do
+       SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g')
+       ARG1=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 1)
+       ARG2=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 2)
+       ARG3=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 3)
+       ARG4=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 4)
+
+       echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}" "${ARG3}" "${ARG4}"
+
+       # shellcheck disable=SC2026
+       echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
 'types: \(([^,]*), ([^,]*), ([^,]*), ([^)]*)\) '\
 'args: \(([^,]*), ([^,]*), ([^,]*), ([^)]*)\)/'\
-'TRACE_EVENT(sys_$1,\n'\
-'      TP_PROTO($4 $8, $5 $9, $6 $10, $7 $11),\n'\
-'      TP_ARGS($8, $9, $10, $11),\n'\
-'      TP_STRUCT__entry(__field($4, $8) __field($5, $9) __field($6, $10) __field($7, $11)),\n'\
-'      TP_fast_assign(tp_assign($8, $8) tp_assign($9, $9) tp_assign($10, $10) tp_assign($11, $11)),\n'\
-'      TP_printk()\n'\
-')/g'\
-       ${TMPFILE} >> ${HEADER}
+'#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\
+'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\
+'      TP_PROTO(sc_exit(long ret,) $4 $8, $5 $9, $6 $10, $7 $11),\n'\
+'      TP_ARGS(sc_exit(ret,) $8, $9, $10, $11),\n'\
+'      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'\
+')\n'\
+'#endif/g' >> "${HEADER}"
+done
 
 # types: 4  5  6  7  8
 # args   9 10 11 12 13
 
 NRARGS=5
-grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
-perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do
+       SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g')
+       ARG1=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 1)
+       ARG2=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 2)
+       ARG3=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 3)
+       ARG4=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 4)
+       ARG5=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 5)
+
+       echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}" "${ARG3}" "${ARG4}" "${ARG5}"
+
+       # shellcheck disable=SC2026
+       echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
 'types: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^)]*)\) '\
 'args: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^)]*)\)/'\
-'TRACE_EVENT(sys_$1,\n'\
-'      TP_PROTO($4 $9, $5 $10, $6 $11, $7 $12, $8 $13),\n'\
-'      TP_ARGS($9, $10, $11, $12, $13),\n'\
-'      TP_STRUCT__entry(__field($4, $9) __field($5, $10) __field($6, $11) __field($7, $12) __field($8, $13)),\n'\
-'      TP_fast_assign(tp_assign($9, $9) tp_assign($10, $10) tp_assign($11, $11) tp_assign($12, $12) tp_assign($13, $13)),\n'\
-'      TP_printk()\n'\
-')/g'\
-       ${TMPFILE} >> ${HEADER}
+'#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\
+'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\
+'      TP_PROTO(sc_exit(long ret,) $4 $9, $5 $10, $6 $11, $7 $12, $8 $13),\n'\
+'      TP_ARGS(sc_exit(ret,) $9, $10, $11, $12, $13),\n'\
+'      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'\
+')\n'\
+'#endif/g' >> "${HEADER}"
+done
 
 
 # types: 4   5  6  7  8  9
 # args   10 11 12 13 14 15
 
 NRARGS=6
-grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
-perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | while read -r LINE; do
+       SC_NAME=$(echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) .*/$1/g')
+       ARG1=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 1)
+       ARG2=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 2)
+       ARG3=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 3)
+       ARG4=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 4)
+       ARG5=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 5)
+       ARG6=$(./lttng-get-syscall-inout.sh table-syscall-inout.txt "${SC_NAME}" 6)
+
+       echo Syscall: "${SC_NAME}" "${ARG1}" "${ARG2}" "${ARG3}" "${ARG4}" "${ARG5}" "${ARG6}"
+
+       # shellcheck disable=SC2026
+       echo "${LINE}" | perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
 'types: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^\)]*)\) '\
 'args: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^\)]*)\)/'\
-'TRACE_EVENT(sys_$1,\n'\
-'      TP_PROTO($4 $10, $5 $11, $6 $12, $7 $13, $8 $14, $9 $15),\n'\
-'      TP_ARGS($10, $11, $12, $13, $14, $15),\n'\
-'      TP_STRUCT__entry(__field($4, $10) __field($5, $11) __field($6, $12) __field($7, $13) __field($8, $14) __field($9, $15)),\n'\
-'      TP_fast_assign(tp_assign($10, $10) tp_assign($11, $11) tp_assign($12, $12) tp_assign($13, $13) tp_assign($14, $14) tp_assign($15, $15)),\n'\
-'      TP_printk()\n'\
-')/g'\
-       ${TMPFILE} >> ${HEADER}
+'#ifndef OVERRIDE_'"${BITNESS}"'_$1\n'\
+'SC_LTTNG_TRACEPOINT_EVENT($1,\n'\
+'      TP_PROTO(sc_exit(long ret,) $4 $10, $5 $11, $6 $12, $7 $13, $8 $14, $9 $15),\n'\
+'      TP_ARGS(sc_exit(ret,) $10, $11, $12, $13, $14, $15),\n'\
+'      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'\
+')\n'\
+'#endif/g' >> "${HEADER}"
+done
 
 # Macro for tracing syscall table
 
-rm -f ${TMPFILE}
-for NRARGS in $(seq 0 6); do
-       grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} >> ${TMPFILE}
-done
-
 echo \
 "
 #endif /*  _TRACE_SYSCALLS_${CLASSCAP}_H */
 
 /* This part must be outside protection */
-#include \"../../../probes/define_trace.h\"
+#include <lttng/define_trace.h>
 
 #else /* CREATE_SYSCALL_TABLE */
-" >> ${HEADER}
 
+#include \"${INPUTFILE}_${CLASS}_override.h\"
+#include \"syscalls_${CLASS}_override.h\"
+" >> "${HEADER}"
 
 NRARGS=0
 
 if [ "$CLASS" = integers ]; then
-#noargs
-grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
-perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\
-'TRACE_SYSCALL_TABLE\(syscalls_noargs, sys_$1, $2, $3\)/g'\
-       ${TMPFILE} >> ${HEADER}
+       #noargs
+
+       # shellcheck disable=SC2129
+       printf '#ifdef SC_ENTER\n' >> "${HEADER}"
+
+       # shellcheck disable=SC2026
+       grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \
+               perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\
+'#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_$1\n'\
+'TRACE_SYSCALL_TABLE\(syscalls_noargs, $1, $2, $3\)\n'\
+'#endif/g' >> "${HEADER}"
+
+       printf '#else /* #ifdef SC_ENTER */\n' >> "${HEADER}"
+
+       # shellcheck disable=SC2026
+       grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \
+               perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\
+'#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_$1\n'\
+'TRACE_SYSCALL_TABLE($1, $1, $2, $3)\n'\
+'#endif/g' >> "${HEADER}"
+
+       printf '#endif /* else #ifdef SC_ENTER */\n' >> "${HEADER}"
 fi
 
 #others.
-grep -v "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
-perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\
-'TRACE_SYSCALL_TABLE(sys_$1, sys_$1, $2, $3)/g'\
-       ${TMPFILE} >> ${HEADER}
+# shellcheck disable=SC2026
+grep -v "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " "${SRCFILE}" | \
+       perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\
+'#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_$1\n'\
+'TRACE_SYSCALL_TABLE($1, $1, $2, $3)\n'\
+'#endif/g' >> "${HEADER}"
 
-echo -n \
-"
-#endif /* CREATE_SYSCALL_TABLE */
-" >> ${HEADER}
+printf '\n#endif /* CREATE_SYSCALL_TABLE */\n' >> "${HEADER}"
 
-#prettify addresses heuristics.
-cp -f ${HEADER} ${TMPFILE}
-rm -f ${HEADER}
+#fields names: ...char * type with *name* or *file* or *path* or *root*
+# or *put_old* or *type*
+perl -pi -e 's/ctf_integer\(([^,)]*char \*), ([^\)]*)(name|file|path|root|put_old|type)([^\)]*)\)/ctf_user_string($2$3$4)/g' \
+       "${HEADER}"
 
+#prettify addresses heuristics.
 #field names with addr or ptr
-perl -p -e 's/__field\(([^,)]*), ([^a,)]*addr|[^p,)]*ptr)([^),]*)\)/__field_hex($1, $2$3)/g'\
-       ${TMPFILE} >> ${HEADER}
-
-cp -f ${HEADER} ${TMPFILE}
-rm -f ${HEADER}
+perl -pi -e 's/ctf_integer\(([^,)]*), ([^,)]*addr|[^,)]*ptr)([^),]*)\)/ctf_integer_hex($1, $2$3, $2$3)/g' \
+       "${HEADER}"
 
 #field types ending with '*'
-perl -p -e 's/__field\(([^,)]*\*), ([^),]*)\)/__field_hex($1, $2)/g'\
-       ${TMPFILE} >> ${HEADER}
+perl -pi -e 's/ctf_integer\(([^,)]*\*), ([^),]*)\)/ctf_integer_hex($1, $2, $2)/g' "${HEADER}"
 
-rm -f ${INPUTFILE}.tmp
-rm -f ${TMPFILE}
-rm -f ${SRCFILE}
+# EOF
This page took 0.029429 seconds and 4 git commands to generate.