Fix: system call instrumentation overrides
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 25 Feb 2016 15:46:54 +0000 (10:46 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 7 Mar 2016 23:34:05 +0000 (18:34 -0500)
* All architectures

- For mmap, print the "ret" value as an hexadecimal integer (rather than
  base 10), which better suits a pointer.
- Add missing "clone" override define, which ensures the clone
  system call override is used rather than leaving it as an
  "unknown" system call.

* ARM32

- Add missing output return values to arm_fadvise64_64,
  sync_file_range2.
- Handle the 64-bit parameters of both arm_fadvise64_64 and
  sync_file_range2 correctly on arm32, on big and little endian builds.
- Move the mmap2 system call instrumentation from "pointers" to
  "integers" override header, and add the missing return value
  (sc_exit).

* PPC32

- Add sync_file_range2 system call instrumentation. Handle the
  64-bit parameters on big and little endian builds.
- Move the mmap2 system call instrumentation from "pointers" to
  "integers" override header, and add the missing return value
  (sc_exit).

* PPC64 compat

- Include compatibility (ppc32) header in ppc64 build to trace compat
  system calls on PPC64 big endian.

* x86-32

- Add mmap2 system call instrumentation override.
- Add sync_file_range instrumentation override, correctly combining
  the low/high parts of offset and nbytes into 64-bit fields.

Tested-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_integers_override.h
instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers_override.h
instrumentation/syscalls/headers/compat_syscalls_integers.h
instrumentation/syscalls/headers/compat_syscalls_pointers.h
instrumentation/syscalls/headers/powerpc-32-syscalls-3.0.34_integers_override.h
instrumentation/syscalls/headers/powerpc-32-syscalls-3.0.34_pointers_override.h
instrumentation/syscalls/headers/syscalls_integers_override.h
instrumentation/syscalls/headers/syscalls_pointers_override.h
instrumentation/syscalls/headers/x86-32-syscalls-3.1.0-rc6_integers_override.h

index 79efa547cb17dacfe8aef81a8fc9f3a40745e7ea..7696664414bb3c329710bd3f2bf289ecdfaed550 100644 (file)
@@ -1,29 +1,97 @@
 
 
-#define OVERRIDE_TABLE_32_arm_fadvise64_64
-#define OVERRIDE_TABLE_32_sync_file_range2
-
 #ifndef CREATE_SYSCALL_TABLE
 
+#if (__BYTE_ORDER == __LITTLE_ENDIAN)
+
+#define OVERRIDE_32_arm_fadvise64_64
+SC_LTTNG_TRACEPOINT_EVENT(arm_fadvise64_64,
+       TP_PROTO(sc_exit(long ret,) int fd, int advice,
+               int32_t offset_low, int32_t offset_high,
+               int32_t len_low, int32_t len_high),
+       TP_ARGS(sc_exit(ret,) fd, advice, offset_low, offset_high,
+               len_low, len_high),
+       TP_FIELDS(sc_exit(ctf_integer(long, ret, ret))
+               sc_in(ctf_integer(int, fd, fd))
+               sc_in(ctf_integer(int, advice, advice))
+               sc_in(ctf_integer(loff_t, offset,
+                       ((loff_t) offset_high << 32) | offset_low))
+               sc_in(ctf_integer(loff_t, len,
+                       ((loff_t) len_high << 32) | len_low))
+       )
+)
+
+#define OVERRIDE_32_sync_file_range2
+SC_LTTNG_TRACEPOINT_EVENT(sync_file_range2,
+       TP_PROTO(sc_exit(long ret,) int fd,
+               unsigned int flags,
+               int32_t offset_low, int32_t offset_high,
+               int32_t nbytes_low, int32_t nbytes_high),
+       TP_ARGS(sc_exit(ret,) fd, flags, offset_low, offset_high,
+               nbytes_low, nbytes_high),
+       TP_FIELDS(sc_exit(ctf_integer(long, ret, ret))
+               sc_in(ctf_integer(int, fd, fd))
+               sc_in(ctf_integer(unsigned int, flags, flags))
+               sc_in(ctf_integer(loff_t, offset,
+                       ((loff_t) offset_high << 32) | offset_low))
+               sc_in(ctf_integer(loff_t, nbytes,
+                       ((loff_t) nbytes_high << 32) | nbytes_low))
+       )
+)
+
+#else  /* __BIG_ENDIAN */
+
+#define OVERRIDE_32_arm_fadvise64_64
 SC_LTTNG_TRACEPOINT_EVENT(arm_fadvise64_64,
-       TP_PROTO(int fd, int advice, loff_t offset, loff_t len),
-       TP_ARGS(fd, advice, offset, len),
-       TP_FIELDS(
-               ctf_integer_hex(int, fd, fd)
-               ctf_integer_hex(int, advice, advice)
-               ctf_integer_hex(loff_t, offset, offset)
-               ctf_integer_hex(loff_t, len, len)
+       TP_PROTO(sc_exit(long ret,) int fd, int advice,
+               int32_t offset_high, int32_t offset_low,
+               int32_t len_high, int32_t len_low),
+       TP_ARGS(sc_exit(ret,) fd, advice, offset_high, offset_low,
+               len_high, len_low),
+       TP_FIELDS(sc_exit(ctf_integer(long, ret, ret))
+               sc_in(ctf_integer(int, fd, fd))
+               sc_in(ctf_integer(int, advice, advice))
+               sc_in(ctf_integer(loff_t, offset,
+                       ((loff_t) offset_high << 32) | offset_low))
+               sc_in(ctf_integer(loff_t, len,
+                       ((loff_t) len_high << 32) | len_low))
        )
 )
 
+#define OVERRIDE_32_sync_file_range2
 SC_LTTNG_TRACEPOINT_EVENT(sync_file_range2,
-       TP_PROTO(int fd, loff_t offset, loff_t nbytes, unsigned int flags),
-       TP_ARGS(fd, offset, nbytes, flags),
-       TP_FIELDS(
-               ctf_integer_hex(int, fd, fd)
-               ctf_integer_hex(loff_t, offset, offset)
-               ctf_integer_hex(loff_t, nbytes, nbytes)
-               ctf_integer_hex(unsigned int, flags, flags)
+       TP_PROTO(sc_exit(long ret,) int fd,
+               unsigned int flags,
+               int32_t offset_high, int32_t offset_low,
+               int32_t nbytes_high, int32_t nbytes_low),
+       TP_ARGS(sc_exit(ret,) fd, flags, offset_high, offset_low,
+               nbytes_high, nbytes_low),
+       TP_FIELDS(sc_exit(ctf_integer(long, ret, ret))
+               sc_in(ctf_integer(int, fd, fd))
+               sc_in(ctf_integer(unsigned int, flags, flags))
+               sc_in(ctf_integer(loff_t, offset,
+                       ((loff_t) offset_high << 32) | offset_low))
+               sc_in(ctf_integer(loff_t, nbytes,
+                       ((loff_t) nbytes_high << 32) | nbytes_low))
+       )
+)
+
+#endif
+
+#define OVERRIDE_32_mmap2
+SC_LTTNG_TRACEPOINT_EVENT(mmap2,
+       TP_PROTO(sc_exit(unsigned long ret,)
+               unsigned long addr, unsigned long len,
+               unsigned long prot, unsigned long flags,
+               unsigned long fd, unsigned long pgoff),
+       TP_ARGS(sc_exit(ret,) addr, len, prot, flags, fd, pgoff),
+       TP_FIELDS(sc_exit(ctf_integer_hex(unsigned long, ret, ret))
+               sc_in(ctf_integer_hex(unsigned long, addr, addr))
+               sc_in(ctf_integer(size_t, len, len))
+               sc_in(ctf_integer(int, prot, prot))
+               sc_in(ctf_integer(int, flags, flags))
+               sc_in(ctf_integer(int, fd, fd))
+               sc_in(ctf_integer(off_t, pgoff, pgoff))
        )
 )
 
@@ -31,11 +99,12 @@ SC_LTTNG_TRACEPOINT_EVENT(sync_file_range2,
 
 #define OVERRIDE_TABLE_32_mmap
 TRACE_SYSCALL_TABLE(mmap, mmap, 90, 6)
-
+#define OVERRIDE_TABLE_32_mmap2
+TRACE_SYSCALL_TABLE(mmap2, mmap2, 192, 6)
 #define OVERRIDE_TABLE_32_arm_fadvise64_64
-TRACE_SYSCALL_TABLE(arm_fadvise64_64, arm_fadvise64_64, 270, 4)
+TRACE_SYSCALL_TABLE(arm_fadvise64_64, arm_fadvise64_64, 270, 6)
 #define OVERRIDE_TABLE_32_sync_file_range2
-TRACE_SYSCALL_TABLE(sync_file_range2, sync_file_range2, 341, 4)
+TRACE_SYSCALL_TABLE(sync_file_range2, sync_file_range2, 341, 6)
 
 #endif /* CREATE_SYSCALL_TABLE */
 
index b27eedbcbacf8961de025ade1e0b25eb97144176..421df1fa5b56e6230f89feb30eba9739c1cfd839 100644 (file)
@@ -4,20 +4,6 @@
 
 #ifndef CREATE_SYSCALL_TABLE
 
-SC_LTTNG_TRACEPOINT_EVENT(mmap2,
-       TP_PROTO(void *addr, size_t len, int prot,
-                 int flags, int fd, off_t pgoff),
-       TP_ARGS(addr, len, prot, flags, fd, pgoff),
-       TP_FIELDS(
-               ctf_integer_hex(void *, addr, addr)
-               ctf_integer(size_t, len, len)
-               ctf_integer(int, prot, prot)
-               ctf_integer(int, flags, flags)
-               ctf_integer(int, fd, fd)
-               ctf_integer(off_t, pgoff, pgoff)
-       )
-)
-
 #define OVERRIDE_32_pipe
 SC_LTTNG_TRACEPOINT_EVENT(pipe,
        TP_PROTO(sc_exit(long ret,) int * fildes),
@@ -33,8 +19,6 @@ SC_LTTNG_TRACEPOINT_EVENT(pipe,
 TRACE_SYSCALL_TABLE(execve, execve, 11, 3)
 #define OVERRIDE_TABLE_32_clone
 TRACE_SYSCALL_TABLE(clone, clone, 120, 5)
-#define OVERRIDE_TABLE_32_mmap2
-TRACE_SYSCALL_TABLE(mmap2, mmap2, 192, 6)
 
 #endif /* CREATE_SYSCALL_TABLE */
 
index dabc4bf731e51be4adadb02b94433fef5fb91f52..ff07aa5a836bcbfaf389c59ec19e10a8f57c3f6a 100644 (file)
@@ -1,3 +1,7 @@
 #ifdef CONFIG_X86_64
 #include "x86-32-syscalls-3.1.0-rc6_integers.h"
 #endif
+
+#ifdef CONFIG_PPC64
+#include "powerpc-32-syscalls-3.0.34_integers.h"
+#endif
index a84423c7e5da2f5234a76ad1b7c66c67565b4b86..cc52f30cd14a1f1db028314bab595f23eabe174d 100644 (file)
@@ -1,3 +1,7 @@
 #ifdef CONFIG_X86_64
 #include "x86-32-syscalls-3.1.0-rc6_pointers.h"
 #endif
+
+#ifdef CONFIG_PPC64
+#include "powerpc-32-syscalls-3.0.34_pointers.h"
+#endif
index c0aabbbc0ecd879fc125b113b5b9990b35b7dbca..a41be136b954f8785c116e9d833455fb606bd0f6 100644 (file)
@@ -1,9 +1,72 @@
 #ifndef CREATE_SYSCALL_TABLE
 
+#define OVERRIDE_32_mmap2
+SC_LTTNG_TRACEPOINT_EVENT(mmap2,
+       TP_PROTO(sc_exit(unsigned long ret,)
+               unsigned long addr, unsigned long len,
+               unsigned long prot, unsigned long flags,
+               unsigned long fd, unsigned long pgoff),
+       TP_ARGS(sc_exit(ret,) addr, len, prot, flags, fd, pgoff),
+       TP_FIELDS(sc_exit(ctf_integer_hex(unsigned long, ret, ret))
+               sc_in(ctf_integer_hex(unsigned long, addr, addr))
+               sc_in(ctf_integer(size_t, len, len))
+               sc_in(ctf_integer(int, prot, prot))
+               sc_in(ctf_integer(int, flags, flags))
+               sc_in(ctf_integer(int, fd, fd))
+               sc_in(ctf_integer(off_t, pgoff, pgoff))
+       )
+)
+
+#if (__BYTE_ORDER == __LITTLE_ENDIAN)
+
+#define OVERRIDE_32_sync_file_range2
+SC_LTTNG_TRACEPOINT_EVENT(sync_file_range2,
+       TP_PROTO(sc_exit(long ret,) int fd,
+               unsigned int flags,
+               int32_t offset_low, int32_t offset_high,
+               int32_t nbytes_low, int32_t nbytes_high),
+       TP_ARGS(sc_exit(ret,) fd, flags, offset_low, offset_high,
+               nbytes_low, nbytes_high),
+       TP_FIELDS(sc_exit(ctf_integer(long, ret, ret))
+               sc_in(ctf_integer(int, fd, fd))
+               sc_in(ctf_integer(unsigned int, flags, flags))
+               sc_in(ctf_integer(loff_t, offset,
+                       ((loff_t) offset_high << 32) | offset_low))
+               sc_in(ctf_integer(loff_t, nbytes,
+                       ((loff_t) nbytes_high << 32) | nbytes_low))
+       )
+)
+
+#else  /* __BIG_ENDIAN */
+
+#define OVERRIDE_32_sync_file_range2
+SC_LTTNG_TRACEPOINT_EVENT(sync_file_range2,
+       TP_PROTO(sc_exit(long ret,) int fd,
+               unsigned int flags,
+               int32_t offset_high, int32_t offset_low,
+               int32_t nbytes_high, int32_t nbytes_low),
+       TP_ARGS(sc_exit(ret,) fd, flags, offset_high, offset_low,
+               nbytes_high, nbytes_low),
+       TP_FIELDS(sc_exit(ctf_integer(long, ret, ret))
+               sc_in(ctf_integer(int, fd, fd))
+               sc_in(ctf_integer(unsigned int, flags, flags))
+               sc_in(ctf_integer(loff_t, offset,
+                       ((loff_t) offset_high << 32) | offset_low))
+               sc_in(ctf_integer(loff_t, nbytes,
+                       ((loff_t) nbytes_high << 32) | nbytes_low))
+       )
+)
+
+#endif
+
 #else  /* CREATE_SYSCALL_TABLE */
 
 #define OVERRIDE_TABLE_32_mmap
 TRACE_SYSCALL_TABLE(mmap, mmap, 90, 6)
+#define OVERRIDE_TABLE_32_mmap2
+TRACE_SYSCALL_TABLE(mmap2, mmap2, 192, 6)
+#define OVERRIDE_TABLE_32_sync_file_range2
+TRACE_SYSCALL_TABLE(sync_file_range2, sync_file_range2, 308, 6)
 
 #endif /* CREATE_SYSCALL_TABLE */
 
index 1fd3ec45e598b03ccc415d15fcdd0d8b88638d42..06704b90a699bab229def9c529f5563940ba1e5b 100644 (file)
@@ -2,20 +2,6 @@
 
 #ifndef CREATE_SYSCALL_TABLE
 
-SC_LTTNG_TRACEPOINT_EVENT(mmap2,
-       TP_PROTO(void *addr, size_t len, int prot,
-                 int flags, int fd, off_t pgoff),
-       TP_ARGS(addr, len, prot, flags, fd, pgoff),
-       TP_FIELDS(
-               ctf_integer_hex(void *, addr, addr)
-               ctf_integer(size_t, len, len)
-               ctf_integer(int, prot, prot)
-               ctf_integer(int, flags, flags)
-               ctf_integer(int, fd, fd)
-               ctf_integer(off_t, pgoff, pgoff)
-       )
-)
-
 #define OVERRIDE_32_pipe
 SC_LTTNG_TRACEPOINT_EVENT(pipe,
        TP_PROTO(sc_exit(long ret,) int * fildes),
@@ -31,8 +17,6 @@ SC_LTTNG_TRACEPOINT_EVENT(pipe,
 TRACE_SYSCALL_TABLE(execve, execve, 11, 3)
 #define OVERRIDE_TABLE_32_clone
 TRACE_SYSCALL_TABLE(clone, clone, 120, 5)
-#define OVERRIDE_TABLE_32_mmap2
-TRACE_SYSCALL_TABLE(mmap2, mmap2, 192, 6)
 
 #endif /* CREATE_SYSCALL_TABLE */
 
index 1f4266fb2bde6fb2ddfb080c0b88888b66e9c101..29bcefbc849e0f39eaae460766c62d3c89944078 100644 (file)
@@ -1,12 +1,14 @@
-#define OVERRIDE_32_mmap
-#define OVERRIDE_64_mmap
-
 #ifndef CREATE_SYSCALL_TABLE
 
+#define OVERRIDE_32_mmap
+#define OVERRIDE_64_mmap
 SC_LTTNG_TRACEPOINT_EVENT(mmap,
-       TP_PROTO(sc_exit(long ret,) unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long off),
+       TP_PROTO(sc_exit(unsigned long ret,)
+               unsigned long addr, unsigned long len,
+               unsigned long prot, unsigned long flags,
+               unsigned long fd, unsigned long off),
        TP_ARGS(sc_exit(ret,) addr, len, prot, flags, fd, off),
-       TP_FIELDS(sc_exit(ctf_integer(long, ret, ret))
+       TP_FIELDS(sc_exit(ctf_integer_hex(unsigned long, ret, ret))
                sc_in(ctf_integer_hex(unsigned long, addr, addr))
                sc_in(ctf_integer(size_t, len, len))
                sc_in(ctf_integer(int, prot, prot))
index c9478f44f79f156776fd2bb72bcc8e313cbe316b..bf5c632efa126610088ac58c037a4513e22f17bc 100644 (file)
@@ -1,8 +1,7 @@
-#define OVERRIDE_32_execve
-#define OVERRIDE_64_execve
-
 #ifndef CREATE_SYSCALL_TABLE
 
+#define OVERRIDE_32_execve
+#define OVERRIDE_64_execve
 SC_LTTNG_TRACEPOINT_EVENT(execve,
        TP_PROTO(sc_exit(long ret,) const char *filename, char *const *argv, char *const *envp),
        TP_ARGS(sc_exit(ret,) filename, argv, envp),
@@ -13,6 +12,8 @@ SC_LTTNG_TRACEPOINT_EVENT(execve,
        )
 )
 
+#define OVERRIDE_32_clone
+#define OVERRIDE_64_clone
 SC_LTTNG_TRACEPOINT_EVENT(clone,
        TP_PROTO(sc_exit(long ret,) unsigned long clone_flags, unsigned long newsp,
                void __user *parent_tid,
index 24690a51d7f26c59d7189d6dcdbfff0ac9602d42..df814d30a754626e58eb31da07955bb76aa5375a 100644 (file)
 
 #endif
 
-#ifdef CREATE_SYSCALL_TABLE
+#ifndef CREATE_SYSCALL_TABLE
+
+/* mmap_pgoff is kernel internal. mmap2 is exposed in unistd.h. */
+#define OVERRIDE_32_mmap_pgoff
+#define OVERRIDE_32_mmap2
+SC_LTTNG_TRACEPOINT_EVENT(mmap2,
+       TP_PROTO(sc_exit(unsigned long ret,)
+               unsigned long addr, unsigned long len,
+               unsigned long prot, unsigned long flags,
+               unsigned long fd, unsigned long pgoff),
+       TP_ARGS(sc_exit(ret,) addr, len, prot, flags, fd, pgoff),
+       TP_FIELDS(sc_exit(ctf_integer_hex(unsigned long, ret, ret))
+               sc_in(ctf_integer_hex(unsigned long, addr, addr))
+               sc_in(ctf_integer(size_t, len, len))
+               sc_in(ctf_integer(int, prot, prot))
+               sc_in(ctf_integer(int, flags, flags))
+               sc_in(ctf_integer(int, fd, fd))
+               sc_in(ctf_integer(off_t, pgoff, pgoff))
+       )
+)
+
+#define OVERRIDE_32_sync_file_range
+SC_LTTNG_TRACEPOINT_EVENT(sync_file_range,
+       TP_PROTO(sc_exit(long ret,) int fd,
+               int32_t offset_low, int32_t offset_high,
+               int32_t nbytes_low, int32_t nbytes_high,
+               unsigned int flags),
+       TP_ARGS(sc_exit(ret,) fd, offset_low, offset_high,
+               nbytes_low, nbytes_high, flags),
+       TP_FIELDS(sc_exit(ctf_integer(long, ret, ret))
+               sc_in(ctf_integer(int, fd, fd))
+               sc_in(ctf_integer(loff_t, offset,
+                       ((loff_t) offset_high << 32) | offset_low))
+               sc_in(ctf_integer(loff_t, nbytes,
+                       ((loff_t) nbytes_high << 32) | nbytes_low))
+               sc_in(ctf_integer(unsigned int, flags, flags))
+       )
+)
+
+#else /* #ifndef CREATE_SYSCALL_TABLE */
 
 #define OVERRIDE_TABLE_32_mmap
 TRACE_SYSCALL_TABLE(mmap, mmap, 90, 6)
 
-#endif
+/* mmap_pgoff is kernel internal. mmap2 is exposed in unistd.h. */
+#define OVERRIDE_TABLE_32_mmap_pgoff
+#define OVERRIDE_TABLE_32_mmap2
+TRACE_SYSCALL_TABLE(mmap2, mmap2, 192, 6)
+
+#define OVERRIDE_TABLE_32_sync_file_range
+TRACE_SYSCALL_TABLE(sync_file_range, sync_file_range, 314, 6)
+
+#endif /* #else #ifndef CREATE_SYSCALL_TABLE */
This page took 0.034798 seconds and 4 git commands to generate.