NRARGS=0
+printf \
+'#ifdef SC_ENTER\n'\
+ >> ${HEADER}
+
printf \
'SC_DECLARE_EVENT_CLASS_NOARGS(syscalls_noargs,\n'\
' TP_STRUCT__entry(),\n'\
'#endif/g'\
${TMPFILE} >> ${HEADER}
+printf \
+'#else /* #ifdef SC_ENTER */\n'\
+ >> ${HEADER}
+
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
+perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+'types: \(([^)]*)\) '\
+'args: \(([^)]*)\)/'\
+'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
+'SC_TRACE_EVENT(sys_$1,\n'\
+' TP_PROTO(sc_exit(long ret)),\n'\
+' TP_ARGS(sc_exit(ret)),\n'\
+' TP_STRUCT__entry(sc_exit(__field(long, ret))),\n'\
+' TP_fast_assign(sc_exit(tp_assign(long, ret, ret))),\n'\
+' TP_printk()\n'\
+')\n'\
+'#endif/g'\
+ ${TMPFILE} >> ${HEADER}
+
+printf \
+'#endif /* else #ifdef SC_ENTER */\n'\
+ >> ${HEADER}
+
fi
'args: \(([^)]*)\)/'\
'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
'SC_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($4, $5, $5)),\n'\
+' TP_PROTO(sc_exit(long ret,) $4 $5),\n'\
+' TP_ARGS(sc_exit(ret,) $5),\n'\
+' TP_STRUCT__entry(sc_exit(__field(long, ret)) __field($4, $5)),\n'\
+' TP_fast_assign(sc_exit(tp_assign(long, ret, ret)) tp_assign($4, $5, $5)),\n'\
' TP_printk()\n'\
')\n'\
'#endif/g'\
'args: \(([^,]*), ([^)]*)\)/'\
'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
'SC_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($4, $6, $6) tp_assign($5, $7, $7)),\n'\
+' TP_PROTO(sc_exit(long ret,) $4 $6, $5 $7),\n'\
+' TP_ARGS(sc_exit(ret,) $6, $7),\n'\
+' TP_STRUCT__entry(sc_exit(__field(long, ret)) __field($4, $6) __field($5, $7)),\n'\
+' TP_fast_assign(sc_exit(tp_assign(long, ret, ret)) tp_assign($4, $6, $6) tp_assign($5, $7, $7)),\n'\
' TP_printk()\n'\
')\n'\
'#endif/g'\
'args: \(([^,]*), ([^,]*), ([^)]*)\)/'\
'#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'\
-' TP_STRUCT__entry(__field($4, $7) __field($5, $8) __field($6, $9)),\n'\
-' TP_fast_assign(tp_assign($4, $7, $7) tp_assign($5, $8, $8) tp_assign($6, $9, $9)),\n'\
+' TP_PROTO(sc_exit(long ret,) $4 $7, $5 $8, $6 $9),\n'\
+' TP_ARGS(sc_exit(ret,) $7, $8, $9),\n'\
+' TP_STRUCT__entry(sc_exit(__field(long, ret)) __field($4, $7) __field($5, $8) __field($6, $9)),\n'\
+' TP_fast_assign(sc_exit(tp_assign(long, ret, ret)) tp_assign($4, $7, $7) tp_assign($5, $8, $8) tp_assign($6, $9, $9)),\n'\
' TP_printk()\n'\
')\n'\
'#endif/g'\
'args: \(([^,]*), ([^,]*), ([^,]*), ([^)]*)\)/'\
'#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'\
-' TP_STRUCT__entry(__field($4, $8) __field($5, $9) __field($6, $10) __field($7, $11)),\n'\
-' TP_fast_assign(tp_assign($4, $8, $8) tp_assign($5, $9, $9) tp_assign($6, $10, $10) tp_assign($7, $11, $11)),\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_STRUCT__entry(sc_exit(__field(long, ret)) __field($4, $8) __field($5, $9) __field($6, $10) __field($7, $11)),\n'\
+' TP_fast_assign(sc_exit(tp_assign(long, ret, ret)) tp_assign($4, $8, $8) tp_assign($5, $9, $9) tp_assign($6, $10, $10) tp_assign($7, $11, $11)),\n'\
' TP_printk()\n'\
')\n'\
'#endif/g'\
'args: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^)]*)\)/'\
'#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'\
-' TP_STRUCT__entry(__field($4, $9) __field($5, $10) __field($6, $11) __field($7, $12) __field($8, $13)),\n'\
-' 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'\
+' 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_STRUCT__entry(sc_exit(__field(long, ret)) __field($4, $9) __field($5, $10) __field($6, $11) __field($7, $12) __field($8, $13)),\n'\
+' TP_fast_assign(sc_exit(tp_assign(long, ret, ret)) 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'\
' TP_printk()\n'\
')\n'\
'#endif/g'\
'args: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^\)]*)\)/'\
'#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'\
-' 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($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'\
+' 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_STRUCT__entry(sc_exit(__field(long, ret)) __field($4, $10) __field($5, $11) __field($6, $12) __field($7, $13) __field($8, $14) __field($9, $15)),\n'\
+' TP_fast_assign(sc_exit(tp_assign(long, ret, ret)) 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'\
' TP_printk()\n'\
')\n'\
'#endif/g'\
if [ "$CLASS" = integers ]; then
#noargs
+
+printf \
+'#ifdef SC_ENTER\n'\
+ >> ${HEADER}
+
grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\
'#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_sys_$1\n'\
'TRACE_SYSCALL_TABLE\(syscalls_noargs, sys_$1, $2, $3\)\n'\
'#endif/g'\
${TMPFILE} >> ${HEADER}
+
+printf \
+'#else /* #ifdef SC_ENTER */\n'\
+ >> ${HEADER}
+
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
+perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\
+'#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_sys_$1\n'\
+'TRACE_SYSCALL_TABLE(sys_$1, sys_$1, $2, $3)\n'\
+'#endif/g'\
+ ${TMPFILE} >> ${HEADER}
+
+printf \
+'#endif /* else #ifdef SC_ENTER */\n'\
+ >> ${HEADER}
+
fi
#others.
#include "instrumentation/syscalls/headers/syscalls_unknown.h"
#undef TRACE_SYSTEM
+#define SC_ENTER
+
+#undef SC_EXIT_PROTO
+#define SC_EXIT_PROTO(...)
+#undef SC_EXIT_ARGS
+#define SC_EXIT_ARGS(...)
+#undef sc_exit
+#define sc_exit(...)
/* Hijack probe callback for system call enter */
#undef TP_PROBE_CB
#undef _TRACE_SYSCALLS_integers_H
#undef _TRACE_SYSCALLS_pointers_H
+#undef SC_ENTER
+
+#define SC_EXIT
+
+#undef SC_EXIT_PROTO
+#define SC_EXIT_PROTO(...) __VA_ARGS__
+#undef SC_EXIT_ARGS
+#define SC_EXIT_ARGS(...) __VA_ARGS__
+#undef sc_exit
+#define sc_exit(...) __VA_ARGS__
/* Hijack probe callback for system call exit */
#define TP_PROBE_CB(_template) &syscall_exit_probe
#undef _TRACE_SYSCALLS_integers_H
#undef _TRACE_SYSCALLS_pointers_H
+#undef SC_EXIT
#undef TP_MODULE_NOINIT
#undef LTTNG_PACKAGE_BUILD
#define CREATE_SYSCALL_TABLE
+#define SC_ENTER
+
+#undef sc_exit
+#define sc_exit(...)
+
#undef TRACE_SYSCALL_TABLE
#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs) \
[ _nr ] = { \
#include "instrumentation/syscalls/headers/compat_syscalls_pointers.h"
};
+#undef SC_ENTER
+
+#define SC_EXIT
+
+#undef sc_exit
+#define sc_exit(...) __VA_ARGS__
+
#undef TRACE_SYSCALL_TABLE
#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs) \
[ _nr ] = { \
#include "instrumentation/syscalls/headers/compat_syscalls_pointers.h"
};
+#undef SC_EXIT
+
#undef CREATE_SYSCALL_TABLE
struct lttng_syscall_filter {
switch (entry->nrargs) {
case 0:
{
- void (*fptr)(void *__data) = entry->func;
+ void (*fptr)(void *__data, long ret) = entry->func;
- fptr(event);
+ fptr(event, ret);
break;
}
case 1:
{
void (*fptr)(void *__data,
+ long ret,
unsigned long arg0) = entry->func;
unsigned long args[1];
syscall_get_arguments(current, regs, 0, entry->nrargs, args);
- fptr(event, args[0]);
+ fptr(event, ret, args[0]);
break;
}
case 2:
{
void (*fptr)(void *__data,
+ long ret,
unsigned long arg0,
unsigned long arg1) = entry->func;
unsigned long args[2];
syscall_get_arguments(current, regs, 0, entry->nrargs, args);
- fptr(event, args[0], args[1]);
+ fptr(event, ret, args[0], args[1]);
break;
}
case 3:
{
void (*fptr)(void *__data,
+ long ret,
unsigned long arg0,
unsigned long arg1,
unsigned long arg2) = entry->func;
unsigned long args[3];
syscall_get_arguments(current, regs, 0, entry->nrargs, args);
- fptr(event, args[0], args[1], args[2]);
+ fptr(event, ret, args[0], args[1], args[2]);
break;
}
case 4:
{
void (*fptr)(void *__data,
+ long ret,
unsigned long arg0,
unsigned long arg1,
unsigned long arg2,
unsigned long args[4];
syscall_get_arguments(current, regs, 0, entry->nrargs, args);
- fptr(event, args[0], args[1], args[2], args[3]);
+ fptr(event, ret, args[0], args[1], args[2], args[3]);
break;
}
case 5:
{
void (*fptr)(void *__data,
+ long ret,
unsigned long arg0,
unsigned long arg1,
unsigned long arg2,
unsigned long args[5];
syscall_get_arguments(current, regs, 0, entry->nrargs, args);
- fptr(event, args[0], args[1], args[2], args[3], args[4]);
+ fptr(event, ret, args[0], args[1], args[2], args[3], args[4]);
break;
}
case 6:
{
void (*fptr)(void *__data,
+ long ret,
unsigned long arg0,
unsigned long arg1,
unsigned long arg2,
unsigned long args[6];
syscall_get_arguments(current, regs, 0, entry->nrargs, args);
- fptr(event, args[0], args[1], args[2],
+ fptr(event, ret, args[0], args[1], args[2],
args[3], args[4], args[5]);
break;
}