From 4f0e6215ab4c82553d4d881f3fb9865c6e1a464a Mon Sep 17 00:00:00 2001 From: David Smith Date: Wed, 11 Dec 2013 15:17:51 -0600 Subject: [PATCH] Fixed PR16312 by adding preadv syscall support. * tapset/linux/syscalls2.stp: Added preadv() probe support. * tapset/linux/nd_syscalls2.stp: Ditto. * testsuite/systemtap.syscall/readwrite.c: Added preadv() test. * testsuite/buildok/nd_syscalls2-detailed.stp: Added preadv probe test. * testsuite/buildok/syscalls2-detailed.stp: Ditto. --- tapset/linux/nd_syscalls2.stp | 50 +++++++++++++++++++++ tapset/linux/syscalls2.stp | 39 ++++++++++++++++ testsuite/buildok/nd_syscalls2-detailed.stp | 10 +++++ testsuite/buildok/syscalls2-detailed.stp | 10 +++++ testsuite/systemtap.syscall/readwrite.c | 18 ++++++-- 5 files changed, 123 insertions(+), 4 deletions(-) diff --git a/tapset/linux/nd_syscalls2.stp b/tapset/linux/nd_syscalls2.stp index 1f1b7742a..6ef348824 100644 --- a/tapset/linux/nd_syscalls2.stp +++ b/tapset/linux/nd_syscalls2.stp @@ -557,6 +557,56 @@ probe nd_syscall.pread.return = kprobe.function("sys_pread64").return ? retstr = returnstr(1) } +# preadv ____________________________________________________ +# +# SYSCALL_DEFINE5(preadv, unsigned long, fd, +# const struct iovec __user *, vec, +# unsigned long, vlen, unsigned long, pos_l, +# unsigned long, pos_h) +# COMPAT_SYSCALL_DEFINE5(pwritev, unsigned long, fd, +# const struct compat_iovec __user *,vec, +# unsigned long, vlen, u32, pos_low, u32, pos_high) +# +probe nd_syscall.preadv = __nd_syscall.preadv ?, __nd_syscall.compat_preadv ? +{ + name = "preadv" +} +probe __nd_syscall.preadv = kernel.function("sys_preadv") +{ + # fd = $fd + # vector_uaddr = $vec + # count = $vlen + # offset = ($pos_h << %{ BITS_PER_LONG %}) + $pos_l + # argstr = sprintf("%d, %p, %d, 0x%x", $fd, $vec, $vlen, + # ($pos_h << %{ BITS_PER_LONG %}) + $pos_l) + asmlinkage() + fd = int_arg(1) + vector_uaddr = pointer_arg(2) + count = int_arg(3) + offset = (ulong_arg(5) << %{ BITS_PER_LONG %}) + ulong_arg(4) + argstr = sprintf("%d, %p, %d, 0x%x", fd, vector_uaddr, count, offset) +} +probe __nd_syscall.compat_preadv = kernel.function("compat_sys_preadv") +{ + # fd = $fd + # vector_uaddr = $vec + # count = $vlen + # offset = ($pos_high << 32) + $pos_low + # argstr = sprintf("%d, %p, %d, 0x%x", $fd, $vec, $vlen, + # ($pos_high << 32) + $pos_low) + fd = int_arg(1) + vector_uaddr = pointer_arg(2) + count = int_arg(3) + offset = (u32_arg(5) << 32) + u32_arg(4) + argstr = sprintf("%d, %p, %d, 0x%x", fd, vector_uaddr, count, offset) +} +probe nd_syscall.preadv.return = kernel.function("sys_preadv").return ?, + kernel.function("compat_sys_preadv").return ? +{ + name = "preadv" + retstr = returnstr(1) +} + # pselect6 _____________________________________________________ # # long sys_pselect6(int n, fd_set __user *inp, fd_set __user *outp, diff --git a/tapset/linux/syscalls2.stp b/tapset/linux/syscalls2.stp index 120976cb0..2c72e1fa4 100644 --- a/tapset/linux/syscalls2.stp +++ b/tapset/linux/syscalls2.stp @@ -541,6 +541,45 @@ probe syscall.pread.return = kernel.function("sys_pread64").return retstr = return_str(1, $return) } +# preadv ____________________________________________________ +# +# SYSCALL_DEFINE5(preadv, unsigned long, fd, +# const struct iovec __user *, vec, +# unsigned long, vlen, unsigned long, pos_l, +# unsigned long, pos_h) +# COMPAT_SYSCALL_DEFINE5(pwritev, unsigned long, fd, +# const struct compat_iovec __user *,vec, +# unsigned long, vlen, u32, pos_low, u32, pos_high) +# +probe syscall.preadv = __syscall.preadv ?, __syscall.compat_preadv ? +{ + name = "preadv" +} +probe __syscall.preadv = kernel.function("sys_preadv") +{ + fd = $fd + vector_uaddr = $vec + count = $vlen + offset = ($pos_h << %{ BITS_PER_LONG %}) + $pos_l + argstr = sprintf("%d, %p, %d, 0x%x", $fd, $vec, $vlen, + ($pos_h << %{ BITS_PER_LONG %}) + $pos_l) +} +probe __syscall.compat_preadv = kernel.function("compat_sys_preadv") +{ + fd = $fd + vector_uaddr = $vec + count = $vlen + offset = ($pos_high << 32) + $pos_low + argstr = sprintf("%d, %p, %d, 0x%x", $fd, $vec, $vlen, + ($pos_high << 32) + $pos_low) +} +probe syscall.preadv.return = kernel.function("sys_preadv").return ?, + kernel.function("compat_sys_preadv").return ? +{ + name = "preadv" + retstr = return_str(1, $return) +} + # pselect6 _____________________________________________________ # # long sys_pselect6(int n, fd_set __user *inp, fd_set __user *outp, diff --git a/testsuite/buildok/nd_syscalls2-detailed.stp b/testsuite/buildok/nd_syscalls2-detailed.stp index 292656c78..93a8d9367 100755 --- a/testsuite/buildok/nd_syscalls2-detailed.stp +++ b/testsuite/buildok/nd_syscalls2-detailed.stp @@ -136,6 +136,16 @@ probe nd_syscall.pread.return printf("%s %s\n", name, retstr) } +probe nd_syscall.preadv ? +{ + printf("%s(%s)\n", name, argstr) + printf("%d %p %d %d\n", fd, vector_uaddr, count, offset) +} +probe nd_syscall.preadv.return ? +{ + printf("%s %s\n", name, retstr) +} + probe nd_syscall.pselect6 ?, nd_syscall.compat_pselect6 ?, nd_syscall.pselect7 ?, %( systemtap_v <= "1.3" %? diff --git a/testsuite/buildok/syscalls2-detailed.stp b/testsuite/buildok/syscalls2-detailed.stp index 866004004..ef6f192c1 100755 --- a/testsuite/buildok/syscalls2-detailed.stp +++ b/testsuite/buildok/syscalls2-detailed.stp @@ -133,6 +133,16 @@ probe syscall.pread.return printf("%s %s\n", name, retstr) } +probe syscall.preadv ? +{ + printf("%s(%s)\n", name, argstr) + printf("%d %p %d %d\n", fd, vector_uaddr, count, offset) +} +probe syscall.preadv.return ? +{ + printf("%s %s\n", name, retstr) +} + probe syscall.pselect6 ?, syscall.compat_pselect6 ?, syscall.pselect7 ?, %( systemtap_v <= "1.3" %? diff --git a/testsuite/systemtap.syscall/readwrite.c b/testsuite/systemtap.syscall/readwrite.c index 58fade405..3c7e6b63b 100644 --- a/testsuite/systemtap.syscall/readwrite.c +++ b/testsuite/systemtap.syscall/readwrite.c @@ -1,4 +1,4 @@ -/* COVERAGE: read write readv writev pwritev lseek llseek */ +/* COVERAGE: read write readv preadv writev pwritev lseek llseek */ #define _BSD_SOURCE #include #include @@ -45,8 +45,8 @@ int main() pwritev(fd, v, 3, 0); //staptest// pwritev (NNNN, XXXX, 3, 0x0) = 15 - pwritev(fd, v, 3, 0x10); - //staptest// pwritev (NNNN, XXXX, 3, 0x10) = 15 + pwritev(fd, v, 3, 0x100); + //staptest// pwritev (NNNN, XXXX, 3, 0x100) = 15 #endif lseek(fd, 0, SEEK_SET); @@ -56,7 +56,7 @@ int main() //staptest// lseek (NNNN, 1, SEEK_CUR) = 1 lseek(fd, -1, SEEK_END); - //staptest// lseek (NNNN, -1, SEEK_END) = 84 + //staptest// lseek (NNNN, -1, SEEK_END) = NNNN #ifdef SYS__llseek syscall(SYS__llseek, fd, 1, 0, &res, SEEK_SET); @@ -73,6 +73,7 @@ int main() #endif close (fd); + //staptest// close (NNNN) = 0 fd = open("foobar1",O_RDONLY); //staptest// open ("foobar1", O_RDONLY[[[[.O_LARGEFILE]]]]?) = NNNN @@ -95,7 +96,16 @@ int main() readv(fd, x, 3); //staptest// readv (NNNN, XXXX, 3) = 15 +#ifdef SYS_preadv + preadv(fd, x, 3, 0); + //staptest// preadv (NNNN, XXXX, 3, 0x0) = 15 + + preadv(fd, x, 3, 0x100); + //staptest// preadv (NNNN, XXXX, 3, 0x100) = 15 +#endif + close (fd); + //staptest// close (NNNN) = 0 return 0; } -- 2.43.5