X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;ds=sidebyside;f=instrumentation%2Fsyscalls%2Flttng-syscalls-generate-headers.sh;h=a0ae0f2a2405ce30c7b2971fc3c92df5ae7aea50;hb=5b7ac358ff8a054b10f1e6c4ed6ea45820d9ced2;hp=5fb1f8faf22fc23d607c63a8913fc66f13e41bb4;hpb=7e42c4ec17806634672405848eaacc4815840281;p=lttng-modules.git diff --git a/instrumentation/syscalls/lttng-syscalls-generate-headers.sh b/instrumentation/syscalls/lttng-syscalls-generate-headers.sh old mode 100644 new mode 100755 index 5fb1f8fa..a0ae0f2a --- a/instrumentation/syscalls/lttng-syscalls-generate-headers.sh +++ b/instrumentation/syscalls/lttng-syscalls-generate-headers.sh @@ -1,19 +1,39 @@ #!/bin/sh # 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 +# lttng-syscalls-generate-headers.sh integers 3.0.4 x86-64-syscalls-3.0.4 64 +# lttng-syscalls-generate-headers.sh pointers 3.0.4 x86-64-syscalls-3.0.4 64 CLASS=$1 INPUTDIR=$2 INPUTFILE=$3 +BITNESS=$4 INPUT=${INPUTDIR}/${INPUTFILE} SRCFILE=gen.tmp.0 TMPFILE=gen.tmp.1 HEADER=headers/${INPUTFILE}_${CLASS}.h +if [ x"$INPUTDIR" = x"" ]; then + echo "Error: Please specify input directory as second argument" + exit 1 +fi + +if [ x"$INPUTFILE" = x"" ]; then + echo "Error: Please specify input file as third argument" + exit 1 +fi + +if [ x"$BITNESS" != x"32" ] && [ x"$BITNESS" != x"64" ]; then + echo "Error: Please specify bitness as fourth argument (\"32\" or \"64\")" + exit 1 +fi + cp ${INPUT} ${SRCFILE} #Cleanup @@ -40,6 +60,12 @@ if [ "$CLASS" = pointers ]; then mv ${TMPFILE} ${SRCFILE} fi +if [ x"$CLASSCAP" = x"" ]; then + echo "Error: Please specify \"integers\" or \"pointers\" as first argument" + rm -f ${SRCFILE} + exit 1 +fi + echo "/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */" > ${HEADER} echo \ @@ -51,25 +77,26 @@ echo \ #include #include #include \"${INPUTFILE}_${CLASS}_override.h\" +#include \"syscalls_${CLASS}_override.h\" " >> ${HEADER} if [ "$CLASS" = integers ]; then NRARGS=0 -echo \ +printf \ 'SC_DECLARE_EVENT_CLASS_NOARGS(syscalls_noargs,\n'\ ' TP_STRUCT__entry(),\n'\ ' TP_fast_assign(),\n'\ ' TP_printk()\n'\ -')'\ +')\n'\ >> ${HEADER} grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE} perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ 'types: \(([^)]*)\) '\ 'args: \(([^)]*)\)/'\ -'#ifndef OVERRIDE_sys_$1\n'\ +'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\ 'SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_$1)\n'\ '#endif/g'\ ${TMPFILE} >> ${HEADER} @@ -85,7 +112,7 @@ grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE} perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ 'types: \(([^)]*)\) '\ 'args: \(([^)]*)\)/'\ -'#ifndef OVERRIDE_sys_$1\n'\ +'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\ 'SC_TRACE_EVENT(sys_$1,\n'\ ' TP_PROTO($4 $5),\n'\ ' TP_ARGS($5),\n'\ @@ -104,7 +131,7 @@ grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE} perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ 'types: \(([^,]*), ([^)]*)\) '\ 'args: \(([^,]*), ([^)]*)\)/'\ -'#ifndef OVERRIDE_sys_$1\n'\ +'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\ 'SC_TRACE_EVENT(sys_$1,\n'\ ' TP_PROTO($4 $6, $5 $7),\n'\ ' TP_ARGS($6, $7),\n'\ @@ -123,7 +150,7 @@ grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE} perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ 'types: \(([^,]*), ([^,]*), ([^)]*)\) '\ 'args: \(([^,]*), ([^,]*), ([^)]*)\)/'\ -'#ifndef OVERRIDE_sys_$1\n'\ +'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\ 'SC_TRACE_EVENT(sys_$1,\n'\ ' TP_PROTO($4 $7, $5 $8, $6 $9),\n'\ ' TP_ARGS($7, $8, $9),\n'\ @@ -143,7 +170,7 @@ grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE} perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ 'types: \(([^,]*), ([^,]*), ([^,]*), ([^)]*)\) '\ 'args: \(([^,]*), ([^,]*), ([^,]*), ([^)]*)\)/'\ -'#ifndef OVERRIDE_sys_$1\n'\ +'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\ 'SC_TRACE_EVENT(sys_$1,\n'\ ' TP_PROTO($4 $8, $5 $9, $6 $10, $7 $11),\n'\ ' TP_ARGS($8, $9, $10, $11),\n'\ @@ -162,7 +189,7 @@ grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE} perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ 'types: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^)]*)\) '\ 'args: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^)]*)\)/'\ -'#ifndef OVERRIDE_sys_$1\n'\ +'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\ 'SC_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'\ @@ -182,7 +209,7 @@ grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE} perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ 'types: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^\)]*)\) '\ 'args: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^\)]*)\)/'\ -'#ifndef OVERRIDE_sys_$1\n'\ +'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\ 'SC_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'\ @@ -195,11 +222,6 @@ perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ # 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 */ @@ -210,6 +232,7 @@ echo \ #else /* CREATE_SYSCALL_TABLE */ #include \"${INPUTFILE}_${CLASS}_override.h\" +#include \"syscalls_${CLASS}_override.h\" " >> ${HEADER} NRARGS=0 @@ -218,7 +241,7 @@ if [ "$CLASS" = integers ]; then #noargs grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE} perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\ -'#ifndef OVERRIDE_TABLE_sys_$1\n'\ +'#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_sys_$1\n'\ 'TRACE_SYSCALL_TABLE\(syscalls_noargs, sys_$1, $2, $3\)\n'\ '#endif/g'\ ${TMPFILE} >> ${HEADER} @@ -227,7 +250,7 @@ fi #others. grep -v "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE} perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\ -'#ifndef OVERRIDE_TABLE_sys_$1\n'\ +'#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_sys_$1\n'\ 'TRACE_SYSCALL_TABLE(sys_$1, sys_$1, $2, $3)\n'\ '#endif/g'\ ${TMPFILE} >> ${HEADER} @@ -237,14 +260,15 @@ echo -n \ #endif /* CREATE_SYSCALL_TABLE */ " >> ${HEADER} -#fields names: ...char * type with *name* or *file* or *path* or *root* or *put_old* +#fields names: ...char * type with *name* or *file* or *path* or *root* +# or *put_old* or *type* cp -f ${HEADER} ${TMPFILE} rm -f ${HEADER} -perl -p -e 's/__field\(([^,)]*char \*), ([^\)]*)(name|file|path|root|put_old)([^\)]*)\)/__string($2$3$4, $2$3$4)/g'\ +perl -p -e 's/__field\(([^,)]*char \*), ([^\)]*)(name|file|path|root|put_old|type)([^\)]*)\)/__string_from_user($2$3$4, $2$3$4)/g'\ ${TMPFILE} >> ${HEADER} cp -f ${HEADER} ${TMPFILE} rm -f ${HEADER} -perl -p -e 's/tp_assign\(([^,)]*char \*), ([^,]*)(name|file|path|root|put_old)([^,]*), ([^\)]*)\)/tp_copy_string_from_user($2$3$4, $5)/g'\ +perl -p -e 's/tp_assign\(([^,)]*char \*), ([^,]*)(name|file|path|root|put_old|type)([^,]*), ([^\)]*)\)/tp_copy_string_from_user($2$3$4, $5)/g'\ ${TMPFILE} >> ${HEADER} #prettify addresses heuristics.