From f087c78931c083842a00b54ca7dc9b64a92ac69c Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 29 Apr 2014 12:25:51 -0500 Subject: [PATCH] PR16716 partial fix: Fix types in syscall.sysfs. * tapset/linux/syscalls2.stp: Fixed types in syscall.sysfs. Improved output formatting. * tapset/linux/syscalls2.stp: Improved output formatting in nd_syscall.sysfs. * testsuite/systemtap.syscall/sysfs.c: New test case. --- tapset/linux/nd_syscalls2.stp | 6 ++++-- tapset/linux/syscalls2.stp | 13 ++++++++----- testsuite/systemtap.syscall/sysfs.c | 30 +++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 testsuite/systemtap.syscall/sysfs.c diff --git a/tapset/linux/nd_syscalls2.stp b/tapset/linux/nd_syscalls2.stp index ad598fd86..2c41458ec 100644 --- a/tapset/linux/nd_syscalls2.stp +++ b/tapset/linux/nd_syscalls2.stp @@ -3549,11 +3549,13 @@ probe nd_syscall.sysfs = kprobe.function("sys_sysfs") ? arg1 = ulong_arg(2) arg2 = ulong_arg(3) if (option == 1) - argstr = sprintf("%d, %s, %d", option, user_string_quoted(arg1), arg2) + argstr = sprintf("%d, %s", option, user_string_quoted(arg1)) else if (option == 2) argstr = sprintf("%d, %d, %p", option, arg1, arg2) + else if (option == 3) + argstr = sprintf("%d", option) else - argstr = sprintf("%d, %d, %d", option, arg1, arg2) + argstr = sprintf("%d, 0x%x, 0x%x", option, arg1, arg2) } probe nd_syscall.sysfs.return = kprobe.function("sys_sysfs").return ? { diff --git a/tapset/linux/syscalls2.stp b/tapset/linux/syscalls2.stp index a6752cd82..612463018 100644 --- a/tapset/linux/syscalls2.stp +++ b/tapset/linux/syscalls2.stp @@ -3435,23 +3435,26 @@ probe syscall.sysctl.return = kernel.function("compat_sys_sysctl").return ?, probe syscall.sysfs = kernel.function("sys_sysfs").call { name = "sysfs" - option = $option + option = __int32($option) arg1 = $arg1 arg2 = $arg2 if (option == 1) - argstr = sprintf("%d, %s, %d", $option, user_string_quoted($arg1), $arg2) + argstr = sprintf("%d, %s", __int32($option), + user_string_quoted($arg1)) else if (option == 2) - argstr = sprintf("%d, %d, %p", $option, $arg1, $arg2) + argstr = sprintf("%d, %d, %p", __int32($option), $arg1, $arg2) else if (option == 3) - argstr = sprintf("%d, %d, %d", $option, $arg1, $arg2) + argstr = sprintf("%d", __int32($option)) else - argstr = sprintf("%d, %d, %d", $option, $arg1, $arg2) + argstr = sprintf("%d, 0x%x, 0x%x", __int32($option), $arg1, + $arg2) } probe syscall.sysfs.return = kernel.function("sys_sysfs").return { name = "sysfs" retstr = return_str(1, $return) } + # sysinfo ____________________________________________________ # # long sys_sysinfo(struct sysinfo __user *info) diff --git a/testsuite/systemtap.syscall/sysfs.c b/testsuite/systemtap.syscall/sysfs.c new file mode 100644 index 000000000..8addae26f --- /dev/null +++ b/testsuite/systemtap.syscall/sysfs.c @@ -0,0 +1,30 @@ +/* COVERAGE: sysfs */ + +#include +#include +#include + +int main() +{ +#ifdef SYS_sysfs + char buf[1024]; + + int idx = syscall(SYS_sysfs, 1, "proc"); + //staptest// sysfs (1, "proc") = NNNN + + syscall(SYS_sysfs, 2, idx, buf); + //staptest// sysfs (2, NNNN, XXXX) = 0 + + syscall(SYS_sysfs, 3); + //staptest// sysfs (3) = NNNN + + syscall(SYS_sysfs, -1, 0, buf); + //staptest// sysfs (-1, 0x0, XXXX) = -NNNN (EINVAL) + + syscall(SYS_sysfs, 4, -1, buf); + //staptest// sysfs (4, 0x[f]+, XXXX) = -NNNN (EINVAL) + + syscall(SYS_sysfs, 2, idx, (char *)-1); + //staptest// sysfs (2, NNNN, 0x[f]+) = -NNNN (EFAULT) +#endif +} -- 2.43.5