]> sourceware.org Git - systemtap.git/commitdiff
Fixed PR16311 by adding/improving pwritev syscall support.
authorDavid Smith <dsmith@redhat.com>
Tue, 10 Dec 2013 23:14:51 +0000 (17:14 -0600)
committerDavid Smith <dsmith@redhat.com>
Tue, 10 Dec 2013 23:14:51 +0000 (17:14 -0600)
* tapset/linux/syscalls2.stp: Improved syscall.pwritev probe support,
  fixed offset calculations.
* tapset/linux/nd_syscalls2.stp: Added 'nd_syscall.pwritev' and
  'nd_syscall.pwritev.return' probes.
* testsuite/buildok/syscalls2-detailed.stp: Added pwritev probe test.
* testsuite/buildok/nd_syscalls2-detailed.stp: Ditto.
* testsuite/systemtap.syscall/readwrite.c: Aded pwritev() test.

tapset/linux/nd_syscalls2.stp
tapset/linux/syscalls2.stp
testsuite/buildok/nd_syscalls2-detailed.stp
testsuite/buildok/syscalls2-detailed.stp
testsuite/systemtap.syscall/readwrite.c

index 04779edf580037b4e5acd411390ec13b2388fdd0..1f1b7742a253ea3d82c85d3044fb7742ffc656c0 100644 (file)
@@ -737,6 +737,56 @@ probe nd_syscall.pwrite32.return = kprobe.function("sys32_pwrite64").return ?
        retstr = returnstr(1)
 }
 
+# pwritev ___________________________________________________
+#
+# sys_pwritev(unsigned long fd, const struct iovec __user * vec,
+#             unsigned long vlen, unsigned long pos_l, unsigned long pos_h)
+# compat_sys_pwritev(unsigned long fd, const struct compat_iovec __user *vec,
+#                    unsigned long vlen, u32 pos_low, u32 pos_high)
+#
+probe nd_syscall.pwritev = __nd_syscall.pwritev ?,
+                          __nd_syscall.compat_pwritev ?
+{
+       name = "pwritev"
+}
+probe __nd_syscall.pwritev = kprobe.function("sys_pwritev").call
+{
+       // 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_pwritev = kprobe.function("compat_sys_pwritev").call
+{
+       // 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)
+       asmlinkage()
+       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.pwritev.return =
+       kprobe.function("sys_pwritev").return ?,
+       kprobe.function("compat_sys_pwritev").return ?
+{
+       name = "pwritev"
+       retstr = returnstr(1)
+}
+
 # quotactl ___________________________________________________
 #
 # long sys_quotactl(unsigned int cmd,
index 7ff23f5bd8f5bc309b4987f491a1f18a6458410c..120976cb06c6dc49bf683fc0d34a492ce762f232 100644 (file)
@@ -682,32 +682,37 @@ probe syscall.pwrite32.return = kernel.function("sys32_pwrite64").return ?
        retstr = return_str(1, $return)
 }
 
+# pwritev ___________________________________________________
+#
+# sys_pwritev(unsigned long fd, const struct iovec __user * vec,
+#             unsigned long vlen, unsigned long pos_l, unsigned long pos_h)
 # compat_sys_pwritev(unsigned long fd, const struct compat_iovec __user *vec,
 #                    unsigned long vlen, u32 pos_low, u32 pos_high)
-probe syscall.pwritev = kernel.function("compat_sys_pwritev").call ?
+#
+probe syscall.pwritev = __syscall.pwritev ?, __syscall.compat_pwritev ?
 {
        name = "pwritev"
+}
+probe __syscall.pwritev = kernel.function("sys_pwritev").call
+{
+       fd = $fd
        vector_uaddr = $vec
        count = $vlen
-       fd = $fd
-       offset = ($pos_high << 32) + $pos_low
-       argstr = sprintf("%d, %p, %d %d", $fd, $vec, $vlen,
-                 ($pos_high << 32) + $pos_low)
+       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)
 }
-# sys_pwritev(unsigned long fd, const struct iovec __user * vec,
-#             unsigned long vlen, unsigned long pos_l, unsigned long pos_h)
-probe syscall.pwritev = kernel.function("sys_pwritev").call
+probe __syscall.compat_pwritev = kernel.function("compat_sys_pwritev").call
 {
-       name = "pwritev"
+       fd = $fd
        vector_uaddr = $vec
        count = $vlen
-       fd = $fd
-       offset = ($pos_h << 32) + $pos_l
-       argstr = sprintf("%d, %p, %d %d", $fd, $vec, $vlen,
-                 ($pos_h << 32) + $pos_l)
+       offset = ($pos_high << 32) + $pos_low
+       argstr = sprintf("%d, %p, %d, 0x%x", $fd, $vec, $vlen,
+                        ($pos_high << 32) + $pos_low)
 }
-probe syscall.pwritev.return = kernel.function("compat_sys_pwritev").return ?,
-                              kernel.function("sys_writev").return
+probe syscall.pwritev.return = kernel.function("sys_pwritev").return ?,
+                              kernel.function("compat_sys_pwritev").return ?
 {
        name = "pwritev"
        retstr = return_str(1, $return)
index f5d87d73cd4baccc08649cdb90058ed375d5a3d8..292656c7826273574b9b7afb635773b673a03930 100755 (executable)
@@ -172,6 +172,16 @@ probe nd_syscall.pwrite.return, nd_syscall.pwrite32.return ?
        printf("%s %s\n", name, retstr)
 }
 
+probe syscall.pwritev ?
+{
+       printf("%s(%s)\n", name, argstr)
+       printf("%d %p %d %d\n", fd, vector_uaddr, count, offset)
+}
+probe syscall.pwritev.return ?
+{
+       printf("%s %s\n", name, retstr)
+}
+
 probe nd_syscall.quotactl
 {
        printf("%s(%s)\n", name, argstr)
index b25ddc65b129b6da5a3043b3c1485d13bf631bc3..86600400460664c6042bf0e91fded2a9848b82e4 100755 (executable)
@@ -169,6 +169,16 @@ probe syscall.pwrite.return, syscall.pwrite32.return ?
        printf("%s %s\n", name, retstr)
 }
 
+probe syscall.pwritev ?
+{
+       printf("%s(%s)\n", name, argstr)
+       printf("%d %p %d %d\n", fd, vector_uaddr, count, offset)
+}
+probe syscall.pwritev.return ?
+{
+       printf("%s %s\n", name, retstr)
+}
+
 probe syscall.quotactl
 {
        printf("%s(%s)\n", name, argstr)
index d966c0a8b417d5ba88ec4d984d7f85ecaca505e5..58fade405516bd234715c73656955049acb8de72 100644 (file)
@@ -1,4 +1,5 @@
-/* COVERAGE: read write readv writev lseek llseek */
+/* COVERAGE: read write readv writev pwritev lseek llseek */
+#define _BSD_SOURCE
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -40,6 +41,14 @@ int main()
   writev(fd, v, 3);
   //staptest// writev (NNNN, XXXX, 3) = 15
 
+#ifdef SYS_pwritev
+  pwritev(fd, v, 3, 0);
+  //staptest// pwritev (NNNN, XXXX, 3, 0x0) = 15
+
+  pwritev(fd, v, 3, 0x10);
+  //staptest// pwritev (NNNN, XXXX, 3, 0x10) = 15
+#endif
+
   lseek(fd, 0, SEEK_SET);
   //staptest// lseek (NNNN, 0, SEEK_SET) = 0
 
This page took 0.042644 seconds and 5 git commands to generate.