3 # Generate system call probe description macros from syscall metadata dump file.
6 # lttng-syscalls-generate-headers.sh integers 3.0.4 x86-64-syscalls-3.0.4 64
7 # lttng-syscalls-generate-headers.sh pointers 3.0.4 x86-64-syscalls-3.0.4 64
13 INPUT
=${INPUTDIR}/${INPUTFILE}
16 HEADER
=headers
/${INPUTFILE}_
${CLASS}.h
18 cp ${INPUT} ${SRCFILE}
21 perl
-p -e 's/^\[.*\] //g' ${SRCFILE} > ${TMPFILE}
22 mv ${TMPFILE} ${SRCFILE}
24 perl
-p -e 's/^syscall sys_([^ ]*)/syscall $1/g' ${SRCFILE} > ${TMPFILE}
25 mv ${TMPFILE} ${SRCFILE}
29 if [ "$CLASS" = integers
]; then
30 #select integers and no-args.
32 grep -v "\\*\|cap_user_header_t" ${SRCFILE} > ${TMPFILE}
33 mv ${TMPFILE} ${SRCFILE}
37 if [ "$CLASS" = pointers
]; then
38 #select system calls using pointers.
40 grep "\\*\|cap_#user_header_t" ${SRCFILE} > ${TMPFILE}
41 mv ${TMPFILE} ${SRCFILE}
44 echo "/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */" > ${HEADER}
47 "#ifndef CREATE_SYSCALL_TABLE
49 #if !defined(_TRACE_SYSCALLS_${CLASSCAP}_H) || defined(TRACE_HEADER_MULTI_READ)
50 #define _TRACE_SYSCALLS_${CLASSCAP}_H
52 #include <linux/tracepoint.h>
53 #include <linux/syscalls.h>
54 #include \"${INPUTFILE}_${CLASS}_override.h\"
55 #include \"syscalls_${CLASS}_override.h\"
58 if [ "$CLASS" = integers
]; then
63 'SC_DECLARE_EVENT_CLASS_NOARGS(syscalls_noargs,\n'\
64 ' TP_STRUCT__entry(),\n'\
65 ' TP_fast_assign(),\n'\
70 grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
71 perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
72 'types: \(([^)]*)\) '\
74 '#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
75 'SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_$1)\n'\
77 ${TMPFILE} >> ${HEADER}
86 grep "^syscall
[^
]* nr
[^
]* nbargs
${NRARGS} " ${SRCFILE} > ${TMPFILE}
87 perl
-p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
88 'types: \(([^)]*)\) '\
90 '#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
91 'SC_TRACE_EVENT(sys_$1,\n'\
92 ' TP_PROTO($4 $5),\n'\
94 ' TP_STRUCT__entry(__field($4, $5)),\n'\
95 ' TP_fast_assign(tp_assign($4, $5, $5)),\n'\
99 ${TMPFILE} >> ${HEADER}
105 grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
106 perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
107 'types: \(([^,]*), ([^)]*)\) '\
108 'args: \(([^,]*), ([^)]*)\)/'\
109 '#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
110 'SC_TRACE_EVENT(sys_$1,\n'\
111 ' TP_PROTO($4 $6, $5 $7),\n'\
112 ' TP_ARGS($6, $7),\n'\
113 ' TP_STRUCT__entry(__field($4, $6) __field($5, $7)),\n'\
114 ' TP_fast_assign(tp_assign($4, $6, $6) tp_assign($5, $7, $7)),\n'\
118 ${TMPFILE} >> ${HEADER}
124 grep "^syscall
[^
]* nr
[^
]* nbargs
${NRARGS} " ${SRCFILE} > ${TMPFILE}
125 perl
-p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
126 'types: \(([^,]*), ([^,]*), ([^)]*)\) '\
127 'args: \(([^,]*), ([^,]*), ([^)]*)\)/'\
128 '#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
129 'SC_TRACE_EVENT(sys_$1,\n'\
130 ' TP_PROTO($4 $7, $5 $8, $6 $9),\n'\
131 ' TP_ARGS($7, $8, $9),\n'\
132 ' TP_STRUCT__entry(__field($4, $7) __field($5, $8) __field($6, $9)),\n'\
133 ' TP_fast_assign(tp_assign($4, $7, $7) tp_assign($5, $8, $8) tp_assign($6, $9, $9)),\n'\
137 ${TMPFILE} >> ${HEADER}
144 grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
145 perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
146 'types: \(([^,]*), ([^,]*), ([^,]*), ([^)]*)\) '\
147 'args: \(([^,]*), ([^,]*), ([^,]*), ([^)]*)\)/'\
148 '#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
149 'SC_TRACE_EVENT(sys_$1,\n'\
150 ' TP_PROTO($4 $8, $5 $9, $6 $10, $7 $11),\n'\
151 ' TP_ARGS($8, $9, $10, $11),\n'\
152 ' TP_STRUCT__entry(__field($4, $8) __field($5, $9) __field($6, $10) __field($7, $11)),\n'\
153 ' TP_fast_assign(tp_assign($4, $8, $8) tp_assign($5, $9, $9) tp_assign($6, $10, $10) tp_assign($7, $11, $11)),\n'\
157 ${TMPFILE} >> ${HEADER}
163 grep "^syscall
[^
]* nr
[^
]* nbargs
${NRARGS} " ${SRCFILE} > ${TMPFILE}
164 perl
-p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
165 'types: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^)]*)\) '\
166 'args: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^)]*)\)/'\
167 '#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
168 'SC_TRACE_EVENT(sys_$1,\n'\
169 ' TP_PROTO($4 $9, $5 $10, $6 $11, $7 $12, $8 $13),\n'\
170 ' TP_ARGS($9, $10, $11, $12, $13),\n'\
171 ' TP_STRUCT__entry(__field($4, $9) __field($5, $10) __field($6, $11) __field($7, $12) __field($8, $13)),\n'\
172 ' TP_fast_assign(tp_assign($4, $9, $9) tp_assign($5, $10, $10) tp_assign($6, $11, $11) tp_assign($7, $12, $12) tp_assign($8, $13, $13)),\n'\
176 ${TMPFILE} >> ${HEADER}
180 # args 10 11 12 13 14 15
183 grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
184 perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
185 'types: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^\)]*)\) '\
186 'args: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^\)]*)\)/'\
187 '#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
188 'SC_TRACE_EVENT(sys_$1,\n'\
189 ' TP_PROTO($4 $10, $5 $11, $6 $12, $7 $13, $8 $14, $9 $15),\n'\
190 ' TP_ARGS($10, $11, $12, $13, $14, $15),\n'\
191 ' TP_STRUCT__entry(__field($4, $10) __field($5, $11) __field($6, $12) __field($7, $13) __field($8, $14) __field($9, $15)),\n'\
192 ' TP_fast_assign(tp_assign($4, $10, $10) tp_assign($5, $11, $11) tp_assign($6, $12, $12) tp_assign($7, $13, $13) tp_assign($8, $14, $14) tp_assign($9, $15, $15)),\n'\
196 ${TMPFILE} >> ${HEADER}
198 # Macro for tracing syscall table
201 for NRARGS in $(seq 0 6); do
202 grep "^syscall
[^
]* nr
[^
]* nbargs
${NRARGS} " ${SRCFILE} >> ${TMPFILE}
207 #endif /* _TRACE_SYSCALLS_${CLASSCAP}_H */
209 /* This part must be outside protection */
210 #include \"../../../probes/define_trace.h\"
212 #else /* CREATE_SYSCALL_TABLE */
214 #include \"${INPUTFILE}_${CLASS}_override.h\"
215 #include \"syscalls_${CLASS}_override.h\"
220 if [ "$CLASS" = integers
]; then
222 grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
223 perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\
224 '#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_sys_$1\n'\
225 'TRACE_SYSCALL_TABLE\(syscalls_noargs, sys_$1, $2, $3\)\n'\
227 ${TMPFILE} >> ${HEADER}
231 grep -v "^syscall
[^
]* nr
[^
]* nbargs
${NRARGS} " ${SRCFILE} > ${TMPFILE}
232 perl
-p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\
233 '#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_sys_$1\n'\
234 'TRACE_SYSCALL_TABLE(sys_$1, sys_$1, $2, $3)\n'\
236 ${TMPFILE} >> ${HEADER}
240 #endif /* CREATE_SYSCALL_TABLE */
243 #fields names: ...char * type with *name* or *file* or *path* or *root*
244 # or *put_old* or *type*
245 cp -f ${HEADER} ${TMPFILE}
247 perl
-p -e 's/__field\(([^,)]*char \*), ([^\)]*)(name|file|path|root|put_old|type)([^\)]*)\)/__string_from_user($2$3$4, $2$3$4)/g'\
248 ${TMPFILE} >> ${HEADER}
249 cp -f ${HEADER} ${TMPFILE}
251 perl
-p -e 's/tp_assign\(([^,)]*char \*), ([^,]*)(name|file|path|root|put_old|type)([^,]*), ([^\)]*)\)/tp_copy_string_from_user($2$3$4, $5)/g'\
252 ${TMPFILE} >> ${HEADER}
254 #prettify addresses heuristics.
255 #field names with addr or ptr
256 cp -f ${HEADER} ${TMPFILE}
258 perl
-p -e 's/__field\(([^,)]*), ([^,)]*addr|[^,)]*ptr)([^),]*)\)/__field_hex($1, $2$3)/g'\
259 ${TMPFILE} >> ${HEADER}
261 #field types ending with '*'
262 cp -f ${HEADER} ${TMPFILE}
264 perl
-p -e 's/__field\(([^,)]*\*), ([^),]*)\)/__field_hex($1, $2)/g'\
265 ${TMPFILE} >> ${HEADER}
267 #strip the extra type information from tp_assign.
268 cp -f ${HEADER} ${TMPFILE}
270 perl
-p -e 's/tp_assign\(([^,)]*), ([^,]*), ([^\)]*)\)/tp_assign($2, $3)/g'\
271 ${TMPFILE} >> ${HEADER}
273 rm -f ${INPUTFILE}.tmp
This page took 0.038569 seconds and 5 git commands to generate.