From: Mathieu Desnoyers Date: Sun, 20 Jul 2014 03:33:18 +0000 (-0400) Subject: Extract system call exit return value X-Git-Tag: v2.6.0-rc1~49 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=fc4f71617faa8894d4a32a1e40e10aa74647a949;p=lttng-modules.git Extract system call exit return value Signed-off-by: Mathieu Desnoyers --- diff --git a/instrumentation/syscalls/lttng-syscalls-generate-headers.sh b/instrumentation/syscalls/lttng-syscalls-generate-headers.sh index a0ae0f2a..557fa3e0 100755 --- a/instrumentation/syscalls/lttng-syscalls-generate-headers.sh +++ b/instrumentation/syscalls/lttng-syscalls-generate-headers.sh @@ -84,6 +84,10 @@ if [ "$CLASS" = integers ]; then NRARGS=0 +printf \ +'#ifdef SC_ENTER\n'\ + >> ${HEADER} + printf \ 'SC_DECLARE_EVENT_CLASS_NOARGS(syscalls_noargs,\n'\ ' TP_STRUCT__entry(),\n'\ @@ -101,6 +105,29 @@ perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ '#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 @@ -114,10 +141,10 @@ perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ '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'\ @@ -133,10 +160,10 @@ perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ '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'\ @@ -152,10 +179,10 @@ perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ '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'\ @@ -172,10 +199,10 @@ perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ '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'\ @@ -191,10 +218,10 @@ perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ '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'\ @@ -211,10 +238,10 @@ perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\ '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'\ @@ -239,12 +266,33 @@ NRARGS=0 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. diff --git a/lttng-syscalls.c b/lttng-syscalls.c index 60c5fd99..029c806b 100644 --- a/lttng-syscalls.c +++ b/lttng-syscalls.c @@ -92,6 +92,14 @@ struct mmap_arg_struct; #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 @@ -152,6 +160,16 @@ struct mmap_arg_struct; #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 @@ -210,6 +228,7 @@ struct mmap_arg_struct; #undef _TRACE_SYSCALLS_integers_H #undef _TRACE_SYSCALLS_pointers_H +#undef SC_EXIT #undef TP_MODULE_NOINIT #undef LTTNG_PACKAGE_BUILD @@ -224,6 +243,11 @@ struct trace_syscall_entry { #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 ] = { \ @@ -254,6 +278,13 @@ const struct trace_syscall_entry compat_sc_table[] = { #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 ] = { \ @@ -284,6 +315,8 @@ const struct trace_syscall_entry compat_sc_exit_table[] = { #include "instrumentation/syscalls/headers/compat_syscalls_pointers.h" }; +#undef SC_EXIT + #undef CREATE_SYSCALL_TABLE struct lttng_syscall_filter { @@ -511,47 +544,51 @@ void syscall_exit_probe(void *__data, struct pt_regs *regs, long ret) 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, @@ -559,12 +596,13 @@ void syscall_exit_probe(void *__data, struct pt_regs *regs, long ret) 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, @@ -573,12 +611,13 @@ void syscall_exit_probe(void *__data, struct pt_regs *regs, long ret) 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, @@ -588,7 +627,7 @@ void syscall_exit_probe(void *__data, struct pt_regs *regs, long ret) 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; }