diff options
-rw-r--r-- | tapset/aux_syscalls.stp | 23 | ||||
-rw-r--r-- | tapset/syscalls.stp | 23 | ||||
-rw-r--r-- | testsuite/systemtap.syscall/eventfd.c | 21 |
3 files changed, 61 insertions, 6 deletions
diff --git a/tapset/aux_syscalls.stp b/tapset/aux_syscalls.stp index 15a70484..5377bafd 100644 --- a/tapset/aux_syscalls.stp +++ b/tapset/aux_syscalls.stp @@ -1645,6 +1645,29 @@ function _epoll_create1_flag_str:string(f:long) #endif %} +%{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) +#include <linux/eventfd.h> +#endif +%} +function _eventfd2_flag_str:string(f:long) +%{ /* pure */ + long flags = THIS->f; + char *str = THIS->__retvalue; + int len; + +#if defined(EFD_CLOEXEC) && defined(EFD_NONBLOCK) + if (flags & EFD_NONBLOCK) + strlcat(str, "EFD_NONBLOCK|", MAXSTRINGLEN); + if (flags & EFD_CLOEXEC) + strlcat(str, "EFD_CLOEXEC|", MAXSTRINGLEN); +#endif + + len = strlen(str); + if (len) + str[strlen(str)-1] = 0; +%} + function _dup3_flag_str:string(f:long) %{ /* pure */ #ifdef O_CLOEXEC diff --git a/tapset/syscalls.stp b/tapset/syscalls.stp index 90cdbd0e..86f81abf 100644 --- a/tapset/syscalls.stp +++ b/tapset/syscalls.stp @@ -733,17 +733,28 @@ probe syscall.epoll_wait.return = kernel.function("compat_sys_epoll_wait").retur # eventfd _____________________________________________________ # long sys_eventfd(unsigned int count) -# -probe syscall.eventfd = kernel.function("SyS_eventfd").call !, +# SYSCALL_DEFINE2(eventfd2, unsigned int, count, int, flags) +probe syscall.eventfd = kernel.function("SyS_eventfd2").call !, + kernel.function("sys_eventfd2").call !, + kernel.function("SyS_eventfd").call !, kernel.function("sys_eventfd").call ? { - name = "eventfd" - argstr = sprint($count) + flags = @defined($flags) ? $flags : 0 + if (flags == 0) { + name = "eventfd" + argstr = sprint($count) + } else { + name = "eventfd2" + argstr = sprintf("%d, %s", $count, _eventfd2_flag_str(flags)) + } } -probe syscall.eventfd.return = kernel.function("SyS_eventfd").return !, +probe syscall.eventfd.return = kernel.function("SyS_eventfd2").return !, + kernel.function("sys_eventfd2").return !, + kernel.function("SyS_eventfd").return !, kernel.function("sys_eventfd").return ? { - name = "eventfd" + flags = @defined($flags) ? $flags : 0 + name = flags == 0 ? "eventfd" : "eventfd2" retstr = returnstr(1) } diff --git a/testsuite/systemtap.syscall/eventfd.c b/testsuite/systemtap.syscall/eventfd.c new file mode 100644 index 00000000..f204ddeb --- /dev/null +++ b/testsuite/systemtap.syscall/eventfd.c @@ -0,0 +1,21 @@ +/* COVERAGE: eventfd eventfd2 */ +#include <sys/eventfd.h> + +int main() +{ + int fd = eventfd(0, 0); + //staptest// eventfd (0) = NNNN + +#ifdef EFD_NONBLOCK + fd = eventfd(1, EFD_NONBLOCK); + //staptest// eventfd2 (1, EFD_NONBLOCK) = NNNN + + fd = eventfd(2, EFD_CLOEXEC); + //staptest// eventfd2 (2, EFD_CLOEXEC) = NNNN + + fd = eventfd(3, EFD_NONBLOCK|EFD_CLOEXEC); + //staptest// eventfd2 (3, EFD_NONBLOCK|EFD_CLOEXEC) = NNNN +#endif + + return 0; +} |