Add trace support for memalign and posix_memalign
authorStefan Seefeld <stefan_seefeld@mentor.com>
Wed, 7 Aug 2013 18:34:02 +0000 (14:34 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 7 Aug 2013 18:34:02 +0000 (14:34 -0400)
Signed-off-by: Stefan Seefeld <stefan_seefeld@mentor.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust-libc-wrapper/lttng-ust-malloc.c
liblttng-ust-libc-wrapper/ust_libc.h

index 4fe8fa97324e92ca14ac7edcd5efaf8b683b2ab8..33ed18be09d5ea48eb5f0cabd73ce27ca151da46 100644 (file)
@@ -133,3 +133,37 @@ void *realloc(void *ptr, size_t size)
        tracepoint(ust_libc, realloc, ptr, size, retval);
        return retval;
 }
+
+void *memalign(size_t alignment, size_t size)
+{
+       static void *(*plibc_memalign)(size_t alignment, size_t size);
+       void *retval;
+
+       if (plibc_memalign == NULL) {
+               plibc_memalign = dlsym(RTLD_NEXT, "memalign");
+               if (plibc_memalign == NULL) {
+                       fprintf(stderr, "memalignwrap: unable to find memalign\n");
+                       return NULL;
+               }
+       }
+       retval = plibc_memalign(alignment, size);
+       tracepoint(ust_libc, memalign, alignment, size, retval);
+       return retval;
+}
+
+int posix_memalign(void **memptr, size_t alignment, size_t size)
+{
+       static int(*plibc_posix_memalign)(void **memptr, size_t alignment, size_t size);
+       int retval;
+
+       if (plibc_posix_memalign == NULL) {
+               plibc_posix_memalign = dlsym(RTLD_NEXT, "posix_memalign");
+               if (plibc_posix_memalign == NULL) {
+                       fprintf(stderr, "posix_memalignwrap: unable to find posix_memalign\n");
+                       return ENOMEM;
+               }
+       }
+       retval = plibc_posix_memalign(memptr, alignment, size);
+       tracepoint(ust_libc, posix_memalign, *memptr, alignment, size, retval);
+       return retval;
+}
index d2096a3aa43667de90ecfc43f0c49632096bc173..a8ff9c65e846769f4184222e57eeff6d145fd46c 100644 (file)
@@ -65,6 +65,25 @@ TRACEPOINT_EVENT(ust_libc, realloc,
        )
 )
 
+TRACEPOINT_EVENT(ust_libc, memalign,
+       TP_ARGS(size_t, alignment, size_t, size, void *, ptr),
+       TP_FIELDS(
+               ctf_integer(size_t, alignment, alignment)
+               ctf_integer(size_t, size, size)
+               ctf_integer_hex(void *, ptr, ptr)
+       )
+)
+
+TRACEPOINT_EVENT(ust_libc, posix_memalign,
+       TP_ARGS(void *, out_ptr, size_t, alignment, size_t, size, int, result),
+       TP_FIELDS(
+               ctf_integer_hex(void *, out_ptr, out_ptr)
+               ctf_integer(size_t, alignment, alignment)
+               ctf_integer(size_t, size, size)
+               ctf_integer(int, result, result)
+       )
+)
+
 #endif /* _TRACEPOINT_UST_LIBC_H */
 
 #undef TRACEPOINT_INCLUDE
This page took 0.02608 seconds and 4 git commands to generate.