From bf4b8ae2b55776433785ee77c5a3985b63364a87 Mon Sep 17 00:00:00 2001 From: Przemyslaw Pawelczyk Date: Fri, 22 May 2009 13:58:27 +0200 Subject: Unify formatting of nd_syscalls.stp. Rules were already specified in commit c0c1ccc6. Signed-off-by: Josh Stone --- tapset/nd_syscalls.stp | 213 ++++++++++++++++++++++++------------------------- 1 file changed, 103 insertions(+), 110 deletions(-) diff --git a/tapset/nd_syscalls.stp b/tapset/nd_syscalls.stp index 32c3640e..b7172c0c 100644 --- a/tapset/nd_syscalls.stp +++ b/tapset/nd_syscalls.stp @@ -27,7 +27,7 @@ * braces are decoded structs. * * retstr - a string containing the return value in an easy-to-read format. -* Set in return probes only. +* Set in return probes only. */ @@ -106,7 +106,7 @@ probe nd_syscall.add_key = kprobe.function("sys_add_key") ? // payload_uaddr = $_payload // plen = $plen // ringid = $ringid - // argstr = sprintf("%s, %s, %s, %d, %d", + // argstr = sprintf("%s, %s, %s, %d, %d", // user_string_quoted($_type), // user_string_quoted($_description), // text_strn(user_string($_payload), syscall_string_trunc, 1), @@ -117,11 +117,11 @@ probe nd_syscall.add_key = kprobe.function("sys_add_key") ? payload_uaddr = pointer_arg(3) plen = ulong_arg(4) ringid = int_arg(5) - argstr = sprintf("%s, %s, %s, %d, %d", - user_string_quoted(type_uaddr), - user_string_quoted(description_uaddr), - text_strn(user_string(payload_uaddr), syscall_string_trunc, 1), - plen, ringid) + argstr = sprintf("%s, %s, %s, %d, %d", + user_string_quoted(type_uaddr), + user_string_quoted(description_uaddr), + text_strn(user_string(payload_uaddr), syscall_string_trunc, 1), + plen, ringid) } probe nd_syscall.add_key.return = kprobe.function("sys_add_key").return ? { @@ -200,14 +200,14 @@ probe nd_syscall.bdflush = kprobe.function("sys_bdflush") ? name = "bdflush" // func = $func // data = $data - // if (($func>=2)&&($func%2==0)) + // if (($func >= 2) && ($func % 2 == 0)) // data_str = sprintf("%p", $data) // else // data_str = sprintf("%d", $data) asmlinkage() func = int_arg(1) data = long_arg(2) - if ((func>=2)&&(func%2==0)) + if ((func >= 2) && (func % 2 == 0)) data_str = sprintf("%p", data) else data_str = sprintf("%d", data) @@ -361,12 +361,12 @@ probe nd_syscall.chown = kprobe.function("sys_chown") // path = user_string($filename) // owner = __int32($user) // group = __int32($group) - // argstr = sprintf("%s, %d, %d", user_string_quoted($filename), owner, group) + // argstr = sprintf("%s, %d, %d", user_string_quoted($filename), owner, group) asmlinkage() path = user_string(pointer_arg(1)) owner = __int32(uint_arg(2)) group = __int32(uint_arg(3)) - argstr = sprintf("%s, %d, %d", user_string_quoted(pointer_arg(1)), owner, group) + argstr = sprintf("%s, %d, %d", user_string_quoted(pointer_arg(1)), owner, group) } probe nd_syscall.chown.return = kprobe.function("sys_chown").return { @@ -374,7 +374,7 @@ probe nd_syscall.chown.return = kprobe.function("sys_chown").return retstr = returnstr(1) } # chown16 ___________________________________________________ -# long sys_chown16(const char __user * filename, old_uid_t user, +# long sys_chown16(const char __user * filename, old_uid_t user, # old_gid_t group) # probe nd_syscall.chown16 = kprobe.function("sys_chown16") ? @@ -416,7 +416,7 @@ probe nd_syscall.chroot.return = kprobe.function("sys_chroot").return # clock_getres _______________________________________________ # long sys_clock_getres(clockid_t which_clock, struct timespec __user *tp) # long compat_clock_getres(clockid_t which_clock, struct compat_timespec __user *tp) -# +# probe nd_syscall.clock_getres = kprobe.function("sys_clock_getres"), kprobe.function("compat_clock_getres") ? { @@ -480,7 +480,7 @@ probe nd_syscall.clock_nanosleep = kprobe.function("sys_clock_nanosleep") else flag_str = sprintf("0x%x", flags) argstr = sprintf("%s, %s, %s, %p", _get_wc_str(int_arg(1)), flag_str, - _struct_timespec_u(pointer_arg(3), 1), pointer_arg(4)) + _struct_timespec_u(pointer_arg(3), 1), pointer_arg(4)) } probe nd_syscall.clock_nanosleep.return = kprobe.function("sys_clock_nanosleep").return { @@ -510,8 +510,8 @@ probe nd_syscall.compat_clock_nanosleep = kprobe.function("compat_clock_nanoslee else flag_str = sprintf("0x%x", flags) argstr = sprintf("%s, %s, %s, %p", _get_wc_str(int_arg(1)), flag_str, - _struct_compat_timespec_u(pointer_arg(3), 1), - pointer_arg(4)) + _struct_compat_timespec_u(pointer_arg(3), 1), + pointer_arg(4)) } probe nd_syscall.compat_clock_nanosleep.return = kprobe.function("compat_clock_nanosleep").return ?, kprobe.function("compat_sys_clock_nanosleep").return ? @@ -892,7 +892,7 @@ probe nd_syscall.fadvise64_64 = kprobe.function("sys_fadvise64_64") advice = int_arg(4) argstr = sprintf("%d, %d, %d, %s", fd, offset, len, _fadvice_advice_str(advice)) } -probe nd_syscall.fadvise64_64.return = kprobe.function("sys_fadvise64_64").return +probe nd_syscall.fadvise64_64.return = kprobe.function("sys_fadvise64_64").return { name = "fadvise64_64" retstr = returnstr(1) @@ -930,7 +930,7 @@ probe nd_syscall.fadvise64_64 = kprobe.function("sys_fadvise64_64") advice = 0 argstr = "" } -probe nd_syscall.fadvise64_64.return = kprobe.function("sys_fadvise64_64").return +probe nd_syscall.fadvise64_64.return = kprobe.function("sys_fadvise64_64").return { name = "fadvise64_64" retstr = returnstr(1) @@ -980,12 +980,12 @@ probe nd_syscall.fchown = kprobe.function("sys_fchown") // fd = $fd // owner = __int32($user) // group = __int32($group) - // argstr = sprintf("%d, %d, %d", $fd, owner, group) + // argstr = sprintf("%d, %d, %d", $fd, owner, group) asmlinkage() fd = int_arg(1) owner = __int32(uint_arg(2)) group = __int32(uint_arg(3)) - argstr = sprintf("%d, %d, %d", fd, owner, group) + argstr = sprintf("%d, %d, %d", fd, owner, group) } probe nd_syscall.fchown.return = kprobe.function("sys_fchown").return { @@ -1125,7 +1125,8 @@ probe nd_syscall.flock.return = kprobe.function("sys_flock").return retstr = returnstr(1) } -function __is_user_regs:long (regs:long) %{ /* pure */ +function __is_user_regs:long (regs:long) /* pure */ +%{ struct pt_regs * regs = (void *)((unsigned long)THIS->regs); /* copied from asm/ptrace.h */ #if defined(__i386__) @@ -1181,7 +1182,7 @@ probe nd_syscall.fork = kprobe.function("do_fork") if (!__is_user_regs(regs)) { name = "fork_kernel_thread" - argstr = __fork_flags(clone_flags) + argstr = __fork_flags(clone_flags) } else if (clone_flags & 17) name = "fork" else if (clone_flags & 0x4000) @@ -1258,7 +1259,7 @@ probe nd_syscall.fsetxattr.return = kprobe.function("sys_fsetxattr").return # struct oldabi_stat64 __user * statbuf) # long compat_sys_newfstat(unsigned int fd, struct compat_stat __user * statbuf) # -probe nd_syscall.fstat = kprobe.function("sys_fstat") ?, +probe nd_syscall.fstat = kprobe.function("sys_fstat") ?, kprobe.function("sys_fstat64") ?, kprobe.function("sys32_fstat64") ?, kprobe.function("sys_newfstat") ?, @@ -1290,7 +1291,7 @@ probe nd_syscall.fstat.return = kprobe.function("sys_fstat").return ?, # long sys_newfstatat(int dfd, char __user *filename, struct stat __user *statbuf, int flag) # long sys_fstatat64(int dfd, char __user *filename, struct stat64 __user *statbuf, int flag) # long compat_sys_newfstatat(unsigned int dfd, char __user *filename, struct compat_stat __user *statbuf, int flag) -probe nd_syscall.fstatat = kprobe.function("sys_fstatat64") ?, +probe nd_syscall.fstatat = kprobe.function("sys_fstatat64") ?, kprobe.function("sys_newfstatat") ?, kprobe.function("compat_sys_newfstatat") ?, kprobe.function("sys32_fstatat64") ? @@ -1306,7 +1307,7 @@ probe nd_syscall.fstatat = kprobe.function("sys_fstatat64") ?, buf_uaddr = pointer_arg(3) argstr = sprintf("%s, %s, %p, %s", _dfd_str(dirfd), user_string_quoted(pointer_arg(2)), buf_uaddr, _at_flag_str(int_arg(4))) } -probe nd_syscall.fstatat.return = kprobe.function("sys_fstatat64").return ?, +probe nd_syscall.fstatat.return = kprobe.function("sys_fstatat64").return ?, kprobe.function("sys_newfstatat").return ?, kprobe.function("compat_sys_newfstatat").return ?, kprobe.function("sys32_fstatat64").return ? @@ -1435,11 +1436,11 @@ probe nd_syscall.futex = kprobe.function("sys_futex") ? // uaddr2_uaddr = $uaddr2 // val3 = $val3 // if (op == 0) - // argstr = sprintf("%p, %s, %d, %s", $uaddr, _futex_op_str($op), - // $val, _struct_timespec_u($utime, 1)) + // argstr = sprintf("%p, %s, %d, %s", $uaddr, _futex_op_str($op), + // $val, _struct_timespec_u($utime, 1)) // else - // argstr = sprintf("%p, %s, %d", $uaddr, _futex_op_str($op), - // $val) + // argstr = sprintf("%p, %s, %d", $uaddr, _futex_op_str($op), + // $val) asmlinkage() futex_uaddr = pointer_arg(1) op = int_arg(2) @@ -1450,10 +1451,10 @@ probe nd_syscall.futex = kprobe.function("sys_futex") ? if (op == 0) argstr = sprintf("%p, %s, %d, %s", futex_uaddr, _futex_op_str(op), val, - _struct_timespec_u(utime_uaddr, 1)) + _struct_timespec_u(utime_uaddr, 1)) else argstr = sprintf("%p, %s, %d", futex_uaddr, - _futex_op_str(op), val) + _futex_op_str(op), val) } probe nd_syscall.futex.return = kprobe.function("sys_futex").return ? { @@ -1470,11 +1471,11 @@ probe nd_syscall.compat_futex = kprobe.function("compat_sys_futex") ? // uaddr2_uaddr = $uaddr2 // val3 = $val3 // if (op == 0) - // argstr = sprintf("%p, %s, %d, %s", $uaddr, _futex_op_str($op), - // $val, _struct_compat_timespec_u($utime, 1)) + // argstr = sprintf("%p, %s, %d, %s", $uaddr, _futex_op_str($op), + // $val, _struct_compat_timespec_u($utime, 1)) // else - // argstr = sprintf("%p, %s, %d", $uaddr, _futex_op_str($op), - // $val) + // argstr = sprintf("%p, %s, %d", $uaddr, _futex_op_str($op), + // $val) asmlinkage() futex_uaddr = pointer_arg(1) op = int_arg(2) @@ -1485,10 +1486,10 @@ probe nd_syscall.compat_futex = kprobe.function("compat_sys_futex") ? if (op == 0) argstr = sprintf("%p, %s, %d, %s", futex_uaddr, _futex_op_str(op), val, - _struct_compat_timespec_u(utime_uaddr, 1)) + _struct_compat_timespec_u(utime_uaddr, 1)) else argstr = sprintf("%p, %s, %d", futex_uaddr, - _futex_op_str(op), val) + _futex_op_str(op), val) } probe nd_syscall.compat_futex.return = kprobe.function("compat_sys_futex").return ? { @@ -1509,14 +1510,14 @@ probe nd_syscall.futimesat = kprobe.function("sys_futimesat") ? // filename_uaddr = $filename // filename = user_string($filename) // tvp_uaddr = $utimes - // argstr = sprintf("%s, %s, %s", _dfd_str($dfd), user_string_quoted($filename), + // argstr = sprintf("%s, %s, %s", _dfd_str($dfd), user_string_quoted($filename), // _struct_timeval_u($utimes, 2)) asmlinkage() dirfd = int_arg(1) filename_uaddr = pointer_arg(2) filename = user_string(filename_uaddr) tvp_uaddr = pointer_arg(3) - argstr = sprintf("%s, %s, %s", _dfd_str(dirfd), user_string_quoted(filename_uaddr), + argstr = sprintf("%s, %s, %s", _dfd_str(dirfd), user_string_quoted(filename_uaddr), _struct_timeval_u(tvp_uaddr, 2)) } probe nd_syscall.compat_futimesat = kprobe.function("compat_sys_futimesat") ? @@ -1526,14 +1527,14 @@ probe nd_syscall.compat_futimesat = kprobe.function("compat_sys_futimesat") ? // filename_uaddr = $filename // filename = user_string($filename) // tvp_uaddr = $utimes - // argstr = sprintf("%s, %s, %s", _dfd_str($dfd), user_string_quoted($filename), + // argstr = sprintf("%s, %s, %s", _dfd_str($dfd), user_string_quoted($filename), // _struct_timeval_u($utimes, 2)) asmlinkage() dirfd = uint_arg(1) filename_uaddr = pointer_arg(2) filename = user_string(pointer_arg(2)) tvp_uaddr = pointer_arg(3) - argstr = sprintf("%s, %s, %s", _dfd_str(uint_arg(1)), user_string_quoted(pointer_arg(2)), + argstr = sprintf("%s, %s, %s", _dfd_str(uint_arg(1)), user_string_quoted(pointer_arg(2)), _struct_compat_timeval_u(pointer_arg(3), 2)) } probe nd_syscall.futimesat.return = kprobe.function("sys_futimesat").return ? @@ -1641,7 +1642,7 @@ probe nd_syscall.geteuid.return = kprobe.function("sys_geteuid16").return ?, # probe nd_syscall.getgid = kprobe.function("sys_getgid16") ?, kprobe.function("sys32_getgid16") ?, - kprobe.function("sys_getgid") + kprobe.function("sys_getgid") { name = "getgid" argstr = "" @@ -1706,11 +1707,11 @@ probe nd_syscall.getitimer = kprobe.function("sys_getitimer") name = "getitimer" // which = $which // value_uaddr = $value - // argstr = sprintf("%s, %p", _itimer_which_str($which), $value) + // argstr = sprintf("%s, %p", _itimer_which_str($which), $value) asmlinkage() which = int_arg(1) value_uaddr = pointer_arg(2) - argstr = sprintf("%s, %p", _itimer_which_str(which), value_uaddr ) + argstr = sprintf("%s, %p", _itimer_which_str(which), value_uaddr) } probe nd_syscall.getitimer.return = kprobe.function("sys_getitimer").return { @@ -1723,11 +1724,11 @@ probe nd_syscall.compat_getitimer = kprobe.function("compat_sys_getitimer") ? name = "getitimer" // which = $which // value_uaddr = $it - // argstr = sprintf("%s, %p", _itimer_which_str($which), $it) + // argstr = sprintf("%s, %p", _itimer_which_str($which), $it) asmlinkage() which = int_arg(1) value_uaddr = pointer_arg(2) - argstr = sprintf("%s, %p", _itimer_which_str(which), value_uaddr) + argstr = sprintf("%s, %p", _itimer_which_str(which), value_uaddr) } probe nd_syscall.compat_getitimer.return = kprobe.function("compat_sys_getitimer").return ? { @@ -1764,7 +1765,7 @@ probe nd_syscall.get_mempolicy = kprobe.function("sys_get_mempolicy") ?, addr = ulong_arg(4) flags = ulong_arg(5) argstr = sprintf("%p, %p, %d, %p, 0x%x", policy_uaddr, - nmask_uaddr, maxnode, addr, flags) + nmask_uaddr, maxnode, addr, flags) } probe nd_syscall.get_mempolicy.return = kprobe.function("sys_get_mempolicy").return ?, kprobe.function("compat_sys_get_mempolicy").return ? @@ -1877,7 +1878,7 @@ probe nd_syscall.getpriority.return = kprobe.function("sys_getpriority").return # old_uid_t __user *egid, # old_uid_t __user *sgid) probe nd_syscall.getresgid = kprobe.function("sys_getresgid16") ?, - kprobe.function("sys_getresgid") + kprobe.function("sys_getresgid") { name = "getresgid" // rgid_uaddr = $rgid @@ -1898,7 +1899,7 @@ probe nd_syscall.getresgid.return = kprobe.function("sys_getresgid16").return ?, } # getresuid __________________________________________________ -# long sys_getresuid(uid_t __user *ruid, +# long sys_getresuid(uid_t __user *ruid, # uid_t __user *euid, # uid_t __user *suid) probe nd_syscall.getresuid = kprobe.function("sys_getresuid16") ?, @@ -1916,7 +1917,7 @@ probe nd_syscall.getresuid = kprobe.function("sys_getresuid16") ?, argstr = sprintf("%p, %p, %p", ruid_uaddr, euid_uaddr, suid_uaddr) } probe nd_syscall.getresuid.return = kprobe.function("sys_getresuid16").return ?, - kprobe.function("sys_getresuid").return + kprobe.function("sys_getresuid").return { name = "getresuid" retstr = returnstr(1) @@ -1953,27 +1954,19 @@ probe nd_syscall.getrusage = kprobe.function("sys_getrusage") { name = "getrusage" // who = $who - // if($who==-2) - // { + // if ($who == -2) { // # RUSAGE_BOTH is not valid argument for sys_getrusage // who_str = sprintf("UNKNOWN VALUE: %d", $who) - // } - // else - // { + // } else // who_str = _rusage_who_str($who) - // } // usage_uaddr = $ru asmlinkage() who = int_arg(1) - if(who==-2) - { + if (who == -2) { # RUSAGE_BOTH is not valid argument for sys_getrusage who_str = sprintf("UNKNOWN VALUE: %d", who) - } - else - { + } else who_str = _rusage_who_str(who) - } usage_uaddr = pointer_arg(2) argstr = sprintf("%s, %p", who_str, usage_uaddr) } @@ -2051,10 +2044,10 @@ probe nd_syscall.getsockopt = kprobe.function("sys_getsockopt") ?, optval_uaddr = pointer_arg(4) optlen_uaddr = pointer_arg(5) argstr = sprintf("%d, %s, %s, %p, %p", fd, _sockopt_level_str(level), - _sockopt_optname_str(optname), optval_uaddr, optlen_uaddr) + _sockopt_optname_str(optname), optval_uaddr, optlen_uaddr) } probe nd_syscall.getsockopt.return = kprobe.function("sys_getsockopt").return ?, - kprobe.function("compat_sys_getsockopt").return ? + kprobe.function("compat_sys_getsockopt").return ? { name = "getsockopt" retstr = returnstr(1) @@ -2076,7 +2069,7 @@ probe nd_syscall.gettid.return = kprobe.function("sys_gettid").return # gettimeofday _______________________________________________ # long sys_gettimeofday(struct timeval __user *tv, # struct timezone __user *tz) -# long sys32_gettimeofday(struct compat_timeval __user *tv, +# long sys32_gettimeofday(struct compat_timeval __user *tv, # struct timezone __user *tz) # long compat_sys_gettimeofday(struct compat_timeval __user *tv, # struct timezone __user *tz) @@ -2136,11 +2129,11 @@ probe nd_syscall.getxattr = kprobe.function("sys_getxattr") // name2 = user_string($name) // value_uaddr = $value // size = $size - // argstr = sprintf("%s, %s, %p, %d", + // argstr = sprintf("%s, %s, %p, %d", // %( kernel_v >= "2.6.27" %? - // user_string_quoted($pathname), + // user_string_quoted($pathname), // %: - // user_string_quoted($path), + // user_string_quoted($path), // %) // user_string_quoted($name), // value_uaddr, size) @@ -2150,8 +2143,8 @@ probe nd_syscall.getxattr = kprobe.function("sys_getxattr") name2 = user_string(pointer_arg(2)) value_uaddr = pointer_arg(3) size = ulong_arg(4) - argstr = sprintf("%s, %s, %p, %d", - user_string_quoted(path), + argstr = sprintf("%s, %s, %p, %d", + user_string_quoted(path), user_string_quoted(pointer_arg(2)), value_uaddr, size) } @@ -2380,7 +2373,7 @@ probe nd_syscall.ioperm.return = kprobe.function("sys_ioperm").return ? # io_setup ___________________________________________________ # long sys_io_setup(unsigned nr_events, aio_context_t __user *ctxp) -# +# probe nd_syscall.io_setup = kprobe.function("sys_io_setup") { name = "io_setup" @@ -2601,7 +2594,7 @@ probe nd_syscall.lchown.return = kprobe.function("sys_lchown").return } # lchown16 ___________________________________________________ -# long sys_lchown16(const char __user * filename, old_uid_t user, +# long sys_lchown16(const char __user * filename, old_uid_t user, # old_gid_t group) # probe nd_syscall.lchown16 = kprobe.function("sys_lchown16") ? @@ -2640,11 +2633,11 @@ probe nd_syscall.lgetxattr = kprobe.function("sys_lgetxattr") // name2 = user_string($name) // value_uaddr = $value // size = $size - // argstr = sprintf("%s, %s, %p, %d", + // argstr = sprintf("%s, %s, %p, %d", // %( kernel_v >= "2.6.27" %? - // user_string_quoted($pathname), + // user_string_quoted($pathname), // %: - // user_string_quoted($path), + // user_string_quoted($path), // %) // user_string_quoted($name), // value_uaddr, size) @@ -2654,8 +2647,8 @@ probe nd_syscall.lgetxattr = kprobe.function("sys_lgetxattr") name2 = user_string(pointer_arg(2)) value_uaddr = pointer_arg(3) size = ulong_arg(4) - argstr = sprintf("%s, %s, %p, %d", - user_string_quoted(pointer_arg(1)), + argstr = sprintf("%s, %s, %p, %d", + user_string_quoted(pointer_arg(1)), user_string_quoted(pointer_arg(2)), value_uaddr, size) } @@ -2672,14 +2665,14 @@ probe nd_syscall.link = kprobe.function("sys_link") name = "link" // oldpath = user_string($oldname) // newpath = user_string($newname) - // argstr = sprintf("%s, %s", - // user_string_quoted($oldname), + // argstr = sprintf("%s, %s", + // user_string_quoted($oldname), // user_string_quoted($newname)) asmlinkage() oldpath = user_string(pointer_arg(1)) newpath = user_string(pointer_arg(2)) - argstr = sprintf("%s, %s", - user_string_quoted(pointer_arg(1)), + argstr = sprintf("%s, %s", + user_string_quoted(pointer_arg(1)), user_string_quoted(pointer_arg(2))) } probe nd_syscall.link.return = kprobe.function("sys_link").return @@ -2695,11 +2688,11 @@ probe nd_syscall.listen = kprobe.function("sys_listen") ? name = "listen" // sockfd = $fd // backlog = $backlog - // argstr = sprintf("%d, %d", $fd, $backlog) + // argstr = sprintf("%d, %d", $fd, $backlog) asmlinkage() sockfd = int_arg(1) backlog = int_arg(2) - argstr = sprintf("%d, %d", sockfd, backlog) + argstr = sprintf("%d, %d", sockfd, backlog) } probe nd_syscall.listen.return = kprobe.function("sys_listen").return ? { @@ -2833,11 +2826,11 @@ probe nd_syscall.lremovexattr = kprobe.function("sys_lremovexattr") // %( kernel_v >= "2.6.27" %? // path_uaddr = $pathname // path = user_string($pathname) - // argstr = sprintf("%s, %s", user_string_quoted($pathname), user_string_quoted($name)) + // argstr = sprintf("%s, %s", user_string_quoted($pathname), user_string_quoted($name)) // %: // path_uaddr = $path // path = user_string($path) - // argstr = sprintf("%s, %s", user_string_quoted($path), user_string_quoted($name)) + // argstr = sprintf("%s, %s", user_string_quoted($path), user_string_quoted($name)) // %) asmlinkage() path_uaddr = pointer_arg(1) @@ -2898,11 +2891,11 @@ probe nd_syscall.lsetxattr = kprobe.function("sys_lsetxattr") // value_uaddr = $value // size = $size // flags = $flags - // argstr = sprintf("%s, %s, %p, %d, %d", + // argstr = sprintf("%s, %s, %p, %d, %d", // %( kernel_v >= "2.6.27" %? - // user_string_quoted($pathname), + // user_string_quoted($pathname), // %: - // user_string_quoted($path), + // user_string_quoted($path), // %) // user_string_quoted($name), // value_uaddr, $size, $flags) @@ -2914,10 +2907,10 @@ probe nd_syscall.lsetxattr = kprobe.function("sys_lsetxattr") value_uaddr = pointer_arg(3) size = ulong_arg(4) flags = int_arg(5) - argstr = sprintf("%s, %s, %p, %d, %d", - user_string_quoted(path_uaddr), - user_string_quoted(name_uaddr), - value_uaddr, size, flags) + argstr = sprintf("%s, %s, %p, %d, %d", + user_string_quoted(path_uaddr), + user_string_quoted(name_uaddr), + value_uaddr, size, flags) } probe nd_syscall.lsetxattr.return = kprobe.function("sys_lsetxattr").return { @@ -2944,11 +2937,11 @@ probe nd_syscall.lstat = kprobe.function("sys_lstat") ?, name = "lstat" // path = user_string($filename) // buf_uaddr = $statbuf - // argstr = sprintf("%s, %p", user_string_quoted($filename), $statbuf) + // argstr = sprintf("%s, %p", user_string_quoted($filename), $statbuf) asmlinkage() path = user_string(pointer_arg(1)) buf_uaddr = pointer_arg(2) - argstr = sprintf("%s, %p", user_string_quoted(pointer_arg(1)), buf_uaddr) + argstr = sprintf("%s, %p", user_string_quoted(pointer_arg(1)), buf_uaddr) } probe nd_syscall.lstat.return = kprobe.function("sys_lstat").return ?, kprobe.function("sys_newlstat").return ?, @@ -2956,7 +2949,7 @@ probe nd_syscall.lstat.return = kprobe.function("sys_lstat").return ?, kprobe.function("sys32_lstat64").return ?, kprobe.function("sys_lstat64").return ?, kprobe.function("sys_oabi_lstat64").return ? -{ +{ name = "lstat" retstr = returnstr(1) } @@ -3020,7 +3013,7 @@ probe nd_syscall.mbind = kprobe.function("sys_mbind") ?, maxnode = ulong_arg(5) flags = uint_arg(6) argstr = sprintf("%d, %d, %d, %p, %d, 0x%x", start, len, mode, - nmask_uaddr, maxnode, flags) + nmask_uaddr, maxnode, flags) } probe nd_syscall.mbind.return = kprobe.function("sys_mbind").return ?, kprobe.function("compat_sys_mbind").return ? @@ -3228,10 +3221,10 @@ probe nd_syscall.move_pages.return = kprobe.function("sys_move_pages").return ?, # char __user * type, # unsigned long flags, # void __user * data) -# long compat_sys_mount(char __user * dev_name, +# long compat_sys_mount(char __user * dev_name, # char __user * dir_name, -# char __user * type, -# unsigned long flags, +# char __user * type, +# unsigned long flags, # void __user * data) probe nd_syscall.mount = kprobe.function("sys_mount"), kprobe.function("compat_sys_mount") ? @@ -3243,10 +3236,10 @@ probe nd_syscall.mount = kprobe.function("sys_mount"), // mountflags = $flags // mountflags_str = _mountflags_str($flags) // data = text_strn(user_string($data), syscall_string_trunc, 1) - // argstr = sprintf("%s, %s, %s, %s, %s", - // user_string_quoted($dev_name), - // user_string_quoted($dir_name), - // user_string_quoted($type), + // argstr = sprintf("%s, %s, %s, %s, %s", + // user_string_quoted($dev_name), + // user_string_quoted($dir_name), + // user_string_quoted($type), // mountflags_str, data) asmlinkage() source = user_string(pointer_arg(1)) @@ -3255,13 +3248,13 @@ probe nd_syscall.mount = kprobe.function("sys_mount"), mountflags = ulong_arg(4) mountflags_str = _mountflags_str(mountflags) data = text_strn(user_string(pointer_arg(5)), syscall_string_trunc, 1) - argstr = sprintf("%s, %s, %s, %s, %s", - user_string_quoted(pointer_arg(1)), - user_string_quoted(pointer_arg(2)), - user_string_quoted(pointer_arg(3)), + argstr = sprintf("%s, %s, %s, %s, %s", + user_string_quoted(pointer_arg(1)), + user_string_quoted(pointer_arg(2)), + user_string_quoted(pointer_arg(3)), mountflags_str, data) } -probe nd_syscall.mount.return = kprobe.function("sys_mount").return, +probe nd_syscall.mount.return = kprobe.function("sys_mount").return, kprobe.function("compat_sys_mount").return ? { name = "mount" @@ -3416,7 +3409,7 @@ probe nd_syscall.mq_timedreceive = kprobe.function("sys_mq_timedreceive") ?, msg_prio_uaddr = pointer_arg(4) abs_timeout_uaddr = pointer_arg(5) argstr = sprintf("%d, %p, %d, %p, %p", mqdes, msg_ptr_uaddr, msg_len, - msg_prio_uaddr, abs_timeout_uaddr) + msg_prio_uaddr, abs_timeout_uaddr) } probe nd_syscall.mq_timedreceive.return = kprobe.function("sys_mq_timedreceive").return ?, kprobe.function("compat_sys_mq_timedreceive").return ? @@ -3454,7 +3447,7 @@ probe nd_syscall.mq_timedsend = kprobe.function("sys_mq_timedsend") ?, msg_prio = uint_arg(4) abs_timeout_uaddr = pointer_arg(5) argstr = sprintf("%d, %p, %d, %d, %p", mqdes, msg_ptr_uaddr, msg_len, - msg_prio, abs_timeout_uaddr) + msg_prio, abs_timeout_uaddr) } probe nd_syscall.mq_timedsend.return = kprobe.function("sys_mq_timedsend").return ?, kprobe.function("compat_sys_mq_timedsend").return ? -- cgit From 8b09a1a4620cd8eac7d6df65bda799f5d4bcfe2b Mon Sep 17 00:00:00 2001 From: Przemyslaw Pawelczyk Date: Fri, 22 May 2009 16:31:15 +0200 Subject: Remove return probes for exit[_group] in nd_syscalls.stp. Analogue of commit 39a8b0bc. Signed-off-by: Josh Stone --- tapset/nd_syscalls.stp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tapset/nd_syscalls.stp b/tapset/nd_syscalls.stp index b7172c0c..aa6ad694 100644 --- a/tapset/nd_syscalls.stp +++ b/tapset/nd_syscalls.stp @@ -832,7 +832,8 @@ probe nd_syscall.exit = kprobe.function("do_exit") status = int_arg(1) argstr = sprint(status) } -probe nd_syscall.exit.return = end {} +# sys_exit() never returns, and is blacklisted for return probes, +# so no alias here. See bz6588. # exit_group _________________________________________________ # void sys_exit_group(int error_code) @@ -846,8 +847,8 @@ probe nd_syscall.exit_group = kprobe.function("sys_exit_group") status = int_arg(1) argstr = sprint(status) } - -probe nd_syscall.exit_group.return = end {} +# sys_exit_group() never returns, and is blacklisted for return probes, +# so no alias here. See bz6588. %(arch != "x86_64" %? # fadvise64 __________________________________________________ -- cgit From edd119a6daa564ffc7ba8db9bc2927929ea7e25e Mon Sep 17 00:00:00 2001 From: Przemyslaw Pawelczyk Date: Fri, 22 May 2009 17:15:21 +0200 Subject: Add missing probe points in nd_syscalls.stp. Add probe points for faccessat, fchmodat, fchownat, linkat and mknodat. Analogue of commits: a3d153e5, 335972be, 46e2c2c1, c815c982, dac6e242 and bad69f1d. Signed-off-by: Josh Stone --- tapset/nd_syscalls.stp | 154 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/tapset/nd_syscalls.stp b/tapset/nd_syscalls.stp index aa6ad694..fef79a0c 100644 --- a/tapset/nd_syscalls.stp +++ b/tapset/nd_syscalls.stp @@ -850,6 +850,32 @@ probe nd_syscall.exit_group = kprobe.function("sys_exit_group") # sys_exit_group() never returns, and is blacklisted for return probes, # so no alias here. See bz6588. +# faccessat __________________________________________________ +# new function with 2.6.16 +# long sys_faccessat(int dfd, const char __user *filename, int mode) +probe nd_syscall.faccessat = kprobe.function("sys_faccessat") ? +{ + name = "faccessat" + // dirfd = $dfd + // dirfd_str = _dfd_str($dfd) + // pathname = user_string($filename) + // mode = $mode + // mode_str = _access_mode_str($mode) + // argstr = sprintf("%s, %s, %s", dirfd_str, user_string_quoted($filename), mode_str) + asmlinkage() + dirfd = int_arg(1) + dirfd_str = _dfd_str(dirfd) + pathname = user_string(pointer_arg(2)) + mode = int_arg(3) + mode_str = _access_mode_str(mode) + argstr = sprintf("%s, %s, %s", dirfd_str, user_string_quoted(pointer_arg(2)), mode_str) +} +probe nd_syscall.faccessat.return = kprobe.function("sys_faccessat").return ? +{ + name = "faccessat" + retstr = returnstr(1) +} + %(arch != "x86_64" %? # fadvise64 __________________________________________________ # long sys_fadvise64(int fd, loff_t offset, size_t len, int advice) @@ -973,6 +999,31 @@ probe nd_syscall.fchmod.return = kprobe.function("sys_fchmod").return retstr = returnstr(1) } +# fchmodat ___________________________________________________ +# new function with 2.6.16 +# long sys_fchmodat(int dfd, const char __user *filename, +# mode_t mode) +probe nd_syscall.fchmodat = kprobe.function("sys_fchmodat") ? +{ + name = "fchmodat" + // dirfd = $dfd + // dirfd_str = _dfd_str($dfd) + // pathname = user_string($filename) + // mode = $mode + // argstr = sprintf("%s, %s, %#o", dirfd_str, user_string_quoted($filename), $mode) + asmlinkage() + dirfd = int_arg(1) + dirfd_str = _dfd_str(dirfd) + pathname = user_string(pointer_arg(2)) + mode = uint_arg(3) + argstr = sprintf("%s, %s, %#o", dirfd_str, user_string_quoted(pointer_arg(2)), mode) +} +probe nd_syscall.fchmodat.return = kprobe.function("sys_fchmodat").return ? +{ + name = "fchmodat" + retstr = returnstr(1) +} + # fchown _____________________________________________________ # long sys_fchown(unsigned int fd, uid_t user, gid_t group) probe nd_syscall.fchown = kprobe.function("sys_fchown") @@ -1015,6 +1066,39 @@ probe nd_syscall.fchown16.return = kprobe.function("sys_fchown16").return ? retstr = returnstr(1) } +# fchownat ___________________________________________________ +# new function with 2.6.16 +# long sys_fchownat(int dfd, const char __user *filename, +# uid_t user, gid_t group, int flag) +probe nd_syscall.fchownat = kprobe.function("sys_fchownat") ? +{ + name = "fchownat" + // dirfd = $dfd + // dirfd_str = _dfd_str($dfd) + // pathname = user_string($filename) + // owner = __int32($user) + // group = __int32($group) + // flags = $flag + // flags_str = _at_flag_str($flag) + // argstr = sprintf("%s, %s, %d, %d, %s", + // dirfd_str, user_string_quoted($filename), owner, group, flags_str) + asmlinkage() + dirfd = int_arg(1) + dirfd_str = _dfd_str(dirfd) + pathname = user_string(pointer_arg(2)) + owner = __int32(uint_arg(3)) + group = __int32(uint_arg(4)) + flags = int_arg(5) + flags_str = _at_flag_str(flags) + argstr = sprintf("%s, %s, %d, %d, %s", + dirfd_str, user_string_quoted(pointer_arg(2)), owner, group, flags_str) +} +probe nd_syscall.fchownat.return = kprobe.function("sys_fchownat").return ? +{ + name = "fchownat" + retstr = returnstr(1) +} + # fcntl ______________________________________________________ # long sys_fcntl(int fd, unsigned int cmd, unsigned long arg) # long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg) @@ -2682,6 +2766,45 @@ probe nd_syscall.link.return = kprobe.function("sys_link").return retstr = returnstr(1) } +# linkat _____________________________________________________ +# new function with 2.6.16 +# long sys_linkat(int olddfd, const char __user *oldname, +# int newdfd, const char __user *newname, int flags) +probe nd_syscall.linkat = kprobe.function("sys_linkat") ? +{ + name = "linkat" + // olddirfd = $olddfd + // olddirfd_str = _dfd_str($olddfd) + // oldpath = user_string($oldname) + // newdirfd = $newdfd + // newdirfd_str = _dfd_str($newdfd) + // newpath = user_string($newname) + // flags = $flags + // flags_str = _at_flag_str($flags) + // argstr = sprintf("%s, %s, %s, %s, %s", + // olddirfd_str, user_string_quoted($oldname), + // newdirfd_str, user_string_quoted($newname), + // flags_str) + asmlinkage() + olddirfd = int_arg(1) + olddirfd_str = _dfd_str(olddirfd) + oldpath = user_string(pointer_arg(2)) + newdirfd = int_arg(3) + newdirfd_str = _dfd_str(newdirfd) + newpath = user_string(pointer_arg(4)) + flags = int_arg(5) + flags_str = _at_flag_str(flags) + argstr = sprintf("%s, %s, %s, %s, %s", + olddirfd_str, user_string_quoted(pointer_arg(2)), + newdirfd_str, user_string_quoted(pointer_arg(4)), + flags_str) +} +probe nd_syscall.linkat.return = kprobe.function("sys_linkat").return ? +{ + name = "linkat" + retstr = returnstr(1) +} + # listen _____________________________________________________ # long sys_listen(int fd, int backlog) probe nd_syscall.listen = kprobe.function("sys_listen") ? @@ -3127,6 +3250,37 @@ probe nd_syscall.mknod.return = kprobe.function("sys_mknod").return retstr = returnstr(1) } +# mknodat ____________________________________________________ +# new function with 2.6.16 +# long sys_mknodat(int dfd, const char __user *filename, +# int mode, unsigned dev) +probe nd_syscall.mknodat = kprobe.function("sys_mknodat") ? +{ + name = "mknodat" + // dirfd = $dfd + // dirfd_str = _dfd_str($dfd) + // pathname = user_string($filename) + // mode = $mode + // mode_str = _mknod_mode_str($mode) + // dev = $dev + // argstr = sprintf("%s, %s, %s, %p", + // dirfd_str, user_string_quoted($filename), mode_str, $dev) + asmlinkage() + dirfd = int_arg(1) + dirfd_str = _dfd_str(dirfd) + pathname = user_string(pointer_arg(2)) + mode = int_arg(3) + mode_str = _mknod_mode_str(mode) + dev = uint_arg(4) + argstr = sprintf("%s, %s, %s, %p", + dirfd_str, user_string_quoted(pointer_arg(2)), mode_str, dev) +} +probe nd_syscall.mknodat.return = kprobe.function("sys_mknodat").return ? +{ + name = "mknodat" + retstr = returnstr(1) +} + # mlock ______________________________________________________ # # long sys_mlock(unsigned long start, size_t len) -- cgit From efd032a83a3e5254988a49ed52cdab85c19ce762 Mon Sep 17 00:00:00 2001 From: Przemyslaw Pawelczyk Date: Fri, 22 May 2009 20:05:43 +0200 Subject: Uncomment 'name' variable in nd_syscall.lseek probe point. Signed-off-by: Josh Stone --- tapset/nd_syscalls.stp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tapset/nd_syscalls.stp b/tapset/nd_syscalls.stp index fef79a0c..97374d9f 100644 --- a/tapset/nd_syscalls.stp +++ b/tapset/nd_syscalls.stp @@ -2973,7 +2973,7 @@ probe nd_syscall.lremovexattr.return = kprobe.function("sys_lremovexattr").retur # off_t sys_lseek(unsigned int fd, off_t offset, unsigned int origin) probe nd_syscall.lseek = kprobe.function("sys_lseek") { - // name = "lseek" + name = "lseek" // fildes = $fd // # offset = __int32($offset) // offset = $offset -- cgit From 29d0edebd429185b88ff9c476eb4fba4396b5f63 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 22 May 2009 14:57:33 -0700 Subject: Use embedded-C for empty functions The functions asmlinkage() and fastcall() are used to help access syscall parameters on i686. All other archs don't need this, but they still define empty functions to shield the callers from arch details. However, stap issues warnings for empty script-level functions. This patch changes them to "%{ /* pure */ %}" so there's no complaint, and they will still get optimized away. --- tapset/ppc64/registers.stp | 6 ++---- tapset/s390x/registers.stp | 6 ++---- tapset/x86_64/registers.stp | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/tapset/ppc64/registers.stp b/tapset/ppc64/registers.stp index e5decd81..c8713e5a 100644 --- a/tapset/ppc64/registers.stp +++ b/tapset/ppc64/registers.stp @@ -210,11 +210,9 @@ function u64_arg:long (argnum:long) { return ulonglong_arg(argnum) } -function asmlinkage() { -} +function asmlinkage() %{ /* pure */ %} -function fastcall() { -} +function fastcall() %{ /* pure */ %} function regparm() %{ snprintf(CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer), diff --git a/tapset/s390x/registers.stp b/tapset/s390x/registers.stp index 37218d14..79482b73 100644 --- a/tapset/s390x/registers.stp +++ b/tapset/s390x/registers.stp @@ -210,11 +210,9 @@ function u64_arg:long (argnum:long) { return ulonglong_arg(argnum) } -function asmlinkage() { -} +function asmlinkage() %{ /* pure */ %} -function fastcall() { -} +function fastcall() %{ /* pure */ %} function regparm() %{ snprintf(CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer), diff --git a/tapset/x86_64/registers.stp b/tapset/x86_64/registers.stp index 2e21f3eb..48ba3119 100644 --- a/tapset/x86_64/registers.stp +++ b/tapset/x86_64/registers.stp @@ -235,11 +235,9 @@ function u64_arg:long (argnum:long) { return ulonglong_arg(argnum) } -function asmlinkage() { -} +function asmlinkage() %{ /* pure */ %} -function fastcall() { -} +function fastcall() %{ /* pure */ %} function regparm(n:long) %{ if (_stp_probing_32bit_app(CONTEXT->regs) && -- cgit From dec6cf8fd4da55ac0fd4c711b3eebc48ee9eda75 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 22 May 2009 15:27:56 -0700 Subject: Move the "pure" tag into the body of __is_user_regs The "/* pure */" tag has no effect unless it is within the embedded-C body of a function. In this instance, they were accidentally moved out during the syscall cleanups. --- tapset/nd_syscalls.stp | 3 ++- tapset/syscalls.stp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tapset/nd_syscalls.stp b/tapset/nd_syscalls.stp index 97374d9f..af145394 100644 --- a/tapset/nd_syscalls.stp +++ b/tapset/nd_syscalls.stp @@ -1210,8 +1210,9 @@ probe nd_syscall.flock.return = kprobe.function("sys_flock").return retstr = returnstr(1) } -function __is_user_regs:long (regs:long) /* pure */ +function __is_user_regs:long (regs:long) %{ + /* pure */ struct pt_regs * regs = (void *)((unsigned long)THIS->regs); /* copied from asm/ptrace.h */ #if defined(__i386__) diff --git a/tapset/syscalls.stp b/tapset/syscalls.stp index 3a34c91b..0886deeb 100644 --- a/tapset/syscalls.stp +++ b/tapset/syscalls.stp @@ -1060,8 +1060,9 @@ probe syscall.flock.return = kernel.function("SyS_flock").return !, retstr = returnstr(1) } -function __is_user_regs:long (regs:long) /* pure */ +function __is_user_regs:long (regs:long) %{ + /* pure */ struct pt_regs * regs = (void *)((unsigned long)THIS->regs); /* copied from asm/ptrace.h */ #if defined(__i386__) -- cgit From b350f56b13f4e5acd5744cd71e4b26343aae8e6b Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 22 May 2009 18:01:18 -0700 Subject: PR10190: Suppress warnings for optional kprobes When a kernel.function or kprobe.function fails in registration, we usually print a WARNING and move on. With this patch, kprobes that have the optional '?' flag will not print any WARNING. --- tapsets.cxx | 17 +++++++++++++---- testsuite/systemtap.base/badkprobe.exp | 15 ++++++++++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/tapsets.cxx b/tapsets.cxx index a9ef2487..5335ea9c 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -3103,6 +3103,7 @@ dwarf_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "static struct stap_dwarf_probe {"; s.op->newline(1) << "const unsigned return_p:1;"; s.op->newline() << "const unsigned maxactive_p:1;"; + s.op->newline() << "const unsigned optional_p:1;"; s.op->newline() << "unsigned registered_p:1;"; s.op->newline() << "const unsigned short maxactive_val;"; @@ -3163,6 +3164,8 @@ dwarf_derived_probe_group::emit_module_decls (systemtap_session& s) assert (p->maxactive_val >= 0 && p->maxactive_val <= USHRT_MAX); s.op->line() << " .maxactive_val=" << p->maxactive_val << ","; } + if (p->locations[0]->optional) + s.op->line() << " .optional_p=1,"; s.op->line() << " .address=(unsigned long)0x" << hex << p->addr << dec << "ULL,"; s.op->line() << " .module=\"" << p->module << "\","; s.op->line() << " .section=\"" << p->section << "\","; @@ -3266,8 +3269,9 @@ dwarf_derived_probe_group::emit_module_init (systemtap_session& s) s.op->newline(-1) << "}"; s.op->newline() << "if (rc) {"; // PR6749: tolerate a failed register_*probe. s.op->newline(1) << "sdp->registered_p = 0;"; - s.op->newline() << "_stp_warn (\"probe %s registration error (rc %d)\", probe_point, rc);"; - s.op->newline() << "rc = 0;"; // continue with other probes + s.op->newline() << "if (!sdp->optional_p)"; + s.op->newline(1) << "_stp_warn (\"probe %s registration error (rc %d)\", probe_point, rc);"; + s.op->newline(-1) << "rc = 0;"; // continue with other probes // XXX: shall we increment numskipped? s.op->newline(-1) << "}"; @@ -4611,6 +4615,7 @@ kprobe_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "static struct stap_dwarfless_probe {"; s.op->newline(1) << "const unsigned return_p:1;"; s.op->newline() << "const unsigned maxactive_p:1;"; + s.op->newline() << "const unsigned optional_p:1;"; s.op->newline() << "unsigned registered_p:1;"; s.op->newline() << "const unsigned short maxactive_val;"; @@ -4657,6 +4662,9 @@ kprobe_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->line() << " .maxactive_val=" << p->maxactive_val << ","; } + if (p->locations[0]->optional) + s.op->line() << " .optional_p=1,"; + if (p->has_statement) s.op->line() << " .address=(unsigned long)0x" << hex << p->addr << dec << "ULL,"; else @@ -4766,8 +4774,9 @@ kprobe_derived_probe_group::emit_module_init (systemtap_session& s) s.op->newline(-1) << "}"; s.op->newline() << "if (rc) {"; // PR6749: tolerate a failed register_*probe. s.op->newline(1) << "sdp->registered_p = 0;"; - s.op->newline() << "_stp_warn (\"probe %s registration error (rc %d)\", probe_point, rc);"; - s.op->newline() << "rc = 0;"; // continue with other probes + s.op->newline() << "if (!sdp->optional_p)"; + s.op->newline(1) << "_stp_warn (\"probe %s registration error (rc %d)\", probe_point, rc);"; + s.op->newline(-1) << "rc = 0;"; // continue with other probes // XXX: shall we increment numskipped? s.op->newline(-1) << "}"; diff --git a/testsuite/systemtap.base/badkprobe.exp b/testsuite/systemtap.base/badkprobe.exp index c0815fbe..96ad5a3b 100644 --- a/testsuite/systemtap.base/badkprobe.exp +++ b/testsuite/systemtap.base/badkprobe.exp @@ -19,7 +19,20 @@ foreach bk $bad_kprobes { spawn stap -g -w -e "$script" "$bk" expect { -timeout 60 - -re "^WARNING: probe .*registration error.*\r\ncleanup ok" { pass $test } + -re "^WARNING: probe .*registration error.*\r\ncleanup ok\r\n" { pass $test } + eof { fail "$test (eof)" } + timeout { fail "$test (timeout)" } + } + catch {close} + catch {wait} +} + +foreach bk $bad_kprobes { + set test "bad optional kprobe registration: $bk" + spawn stap -g -w -e "$script" "$bk ?" + expect { + -timeout 60 + -re "^cleanup ok\r\n" { pass $test } eof { fail "$test (eof)" } timeout { fail "$test (timeout)" } } -- cgit From c9116e9980ad6e417697737f8d54a4a625811245 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 22 May 2009 19:55:50 -0700 Subject: Fix another kernel/kprobe.function conflict Both kernel.function and kprobe.function were defining a global array stap_unreg_kprobes to use in bulk kprobes unregistration. The compiler allowed the duplicate definition as long as they were the same size, as it was when exercised in buildok/thirtyone. kprobe.function now uses a separate stap_unreg_kprobes2, and the testcase is modified to produce an imbalanced number of probes. --- tapsets.cxx | 14 +++++++------- testsuite/buildok/thirtyone.stp | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tapsets.cxx b/tapsets.cxx index 5335ea9c..e88928dc 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -4599,7 +4599,7 @@ kprobe_derived_probe_group::emit_module_decls (systemtap_session& s) // Emit an array of kprobe/kretprobe pointers s.op->newline() << "#if defined(STAPCONF_UNREGISTER_KPROBES)"; - s.op->newline() << "static void * stap_unreg_kprobes[" << probes_by_module.size() << "];"; + s.op->newline() << "static void * stap_unreg_kprobes2[" << probes_by_module.size() << "];"; s.op->newline() << "#endif"; // Emit the actual probe list. @@ -4795,27 +4795,27 @@ kprobe_derived_probe_group::emit_module_exit (systemtap_session& s) s.op->newline() << "struct stap_dwarfless_kprobe *kp = & stap_dwarfless_kprobes[i];"; s.op->newline() << "if (! sdp->registered_p) continue;"; s.op->newline() << "if (!sdp->return_p)"; - s.op->newline(1) << "stap_unreg_kprobes[j++] = &kp->u.kp;"; + s.op->newline(1) << "stap_unreg_kprobes2[j++] = &kp->u.kp;"; s.op->newline(-2) << "}"; - s.op->newline() << "unregister_kprobes((struct kprobe **)stap_unreg_kprobes, j);"; + s.op->newline() << "unregister_kprobes((struct kprobe **)stap_unreg_kprobes2, j);"; s.op->newline() << "j = 0;"; s.op->newline() << "for (i=0; i<" << probes_by_module.size() << "; i++) {"; s.op->newline(1) << "struct stap_dwarfless_probe *sdp = & stap_dwarfless_probes[i];"; s.op->newline() << "struct stap_dwarfless_kprobe *kp = & stap_dwarfless_kprobes[i];"; s.op->newline() << "if (! sdp->registered_p) continue;"; s.op->newline() << "if (sdp->return_p)"; - s.op->newline(1) << "stap_unreg_kprobes[j++] = &kp->u.krp;"; + s.op->newline(1) << "stap_unreg_kprobes2[j++] = &kp->u.krp;"; s.op->newline(-2) << "}"; - s.op->newline() << "unregister_kretprobes((struct kretprobe **)stap_unreg_kprobes, j);"; + s.op->newline() << "unregister_kretprobes((struct kretprobe **)stap_unreg_kprobes2, j);"; s.op->newline() << "#ifdef __ia64__"; s.op->newline() << "j = 0;"; s.op->newline() << "for (i=0; i<" << probes_by_module.size() << "; i++) {"; s.op->newline(1) << "struct stap_dwarfless_probe *sdp = & stap_dwarfless_probes[i];"; s.op->newline() << "struct stap_dwarfless_kprobe *kp = & stap_dwarfless_kprobes[i];"; s.op->newline() << "if (! sdp->registered_p) continue;"; - s.op->newline() << "stap_unreg_kprobes[j++] = &kp->dummy;"; + s.op->newline() << "stap_unreg_kprobes2[j++] = &kp->dummy;"; s.op->newline(-1) << "}"; - s.op->newline() << "unregister_kprobes((struct kprobe **)stap_unreg_kprobes, j);"; + s.op->newline() << "unregister_kprobes((struct kprobe **)stap_unreg_kprobes2, j);"; s.op->newline() << "#endif"; s.op->newline() << "#endif"; diff --git a/testsuite/buildok/thirtyone.stp b/testsuite/buildok/thirtyone.stp index 8a97d84f..5f2f2da6 100755 --- a/testsuite/buildok/thirtyone.stp +++ b/testsuite/buildok/thirtyone.stp @@ -1,4 +1,5 @@ #! stap -p4 +probe kprobe.function("sys_stat") {} probe kprobe.function("sys_open") {} probe kernel.function("sys_close") {} -- cgit