From 887bba304db29a6f9eb16d2efd0e821794def6d2 Mon Sep 17 00:00:00 2001 From: Olivier Delbeke Date: Mon, 19 Jan 2015 14:14:16 -0500 Subject: [PATCH] Add return address to liblttng-ust-libc-wrapper Signed-off-by: Olivier Delbeke Signed-off-by: Mathieu Desnoyers --- liblttng-ust-libc-wrapper/lttng-ust-malloc.c | 12 ++++++------ liblttng-ust-libc-wrapper/ust_libc.h | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/liblttng-ust-libc-wrapper/lttng-ust-malloc.c b/liblttng-ust-libc-wrapper/lttng-ust-malloc.c index 54afb144..14545c2a 100644 --- a/liblttng-ust-libc-wrapper/lttng-ust-malloc.c +++ b/liblttng-ust-libc-wrapper/lttng-ust-malloc.c @@ -260,7 +260,7 @@ void *malloc(size_t size) } retval = cur_alloc.malloc(size); if (URCU_TLS(malloc_nesting) == 1) { - tracepoint(ust_libc, malloc, size, retval); + tracepoint(ust_libc, malloc, size, retval, __builtin_return_address(0)); } URCU_TLS(malloc_nesting)--; return retval; @@ -279,7 +279,7 @@ void free(void *ptr) } if (URCU_TLS(malloc_nesting) == 1) { - tracepoint(ust_libc, free, ptr); + tracepoint(ust_libc, free, ptr, __builtin_return_address(0)); } if (cur_alloc.free == NULL) { @@ -308,7 +308,7 @@ void *calloc(size_t nmemb, size_t size) } retval = cur_alloc.calloc(nmemb, size); if (URCU_TLS(malloc_nesting) == 1) { - tracepoint(ust_libc, calloc, nmemb, size, retval); + tracepoint(ust_libc, calloc, nmemb, size, retval, __builtin_return_address(0)); } URCU_TLS(malloc_nesting)--; return retval; @@ -360,7 +360,7 @@ void *realloc(void *ptr, size_t size) retval = cur_alloc.realloc(ptr, size); end: if (URCU_TLS(malloc_nesting) == 1) { - tracepoint(ust_libc, realloc, ptr, size, retval); + tracepoint(ust_libc, realloc, ptr, size, retval, __builtin_return_address(0)); } URCU_TLS(malloc_nesting)--; return retval; @@ -380,7 +380,7 @@ void *memalign(size_t alignment, size_t size) } retval = cur_alloc.memalign(alignment, size); if (URCU_TLS(malloc_nesting) == 1) { - tracepoint(ust_libc, memalign, alignment, size, retval); + tracepoint(ust_libc, memalign, alignment, size, retval, __builtin_return_address(0)); } URCU_TLS(malloc_nesting)--; return retval; @@ -401,7 +401,7 @@ int posix_memalign(void **memptr, size_t alignment, size_t size) retval = cur_alloc.posix_memalign(memptr, alignment, size); if (URCU_TLS(malloc_nesting) == 1) { tracepoint(ust_libc, posix_memalign, *memptr, alignment, size, - retval); + retval, __builtin_return_address(0)); } URCU_TLS(malloc_nesting)--; return retval; diff --git a/liblttng-ust-libc-wrapper/ust_libc.h b/liblttng-ust-libc-wrapper/ust_libc.h index a8ff9c65..222da2d3 100644 --- a/liblttng-ust-libc-wrapper/ust_libc.h +++ b/liblttng-ust-libc-wrapper/ust_libc.h @@ -33,54 +33,60 @@ extern "C" { #include TRACEPOINT_EVENT(ust_libc, malloc, - TP_ARGS(size_t, size, void *, ptr), + TP_ARGS(size_t, size, void *, ptr, void *, caller), TP_FIELDS( ctf_integer(size_t, size, size) ctf_integer_hex(void *, ptr, ptr) + ctf_integer_hex(void *, caller, caller) ) ) TRACEPOINT_EVENT(ust_libc, free, - TP_ARGS(void *, ptr), + TP_ARGS(void *, ptr, void *, caller), TP_FIELDS( ctf_integer_hex(void *, ptr, ptr) + ctf_integer_hex(void *, caller, caller) ) ) TRACEPOINT_EVENT(ust_libc, calloc, - TP_ARGS(size_t, nmemb, size_t, size, void *, ptr), + TP_ARGS(size_t, nmemb, size_t, size, void *, ptr, void *, caller), TP_FIELDS( ctf_integer(size_t, nmemb, nmemb) ctf_integer(size_t, size, size) ctf_integer_hex(void *, ptr, ptr) + ctf_integer_hex(void *, caller, caller) ) ) TRACEPOINT_EVENT(ust_libc, realloc, - TP_ARGS(void *, in_ptr, size_t, size, void *, ptr), + TP_ARGS(void *, in_ptr, size_t, size, void *, ptr, void *, caller), TP_FIELDS( ctf_integer_hex(void *, in_ptr, in_ptr) ctf_integer(size_t, size, size) ctf_integer_hex(void *, ptr, ptr) + ctf_integer_hex(void *, caller, caller) ) ) TRACEPOINT_EVENT(ust_libc, memalign, - TP_ARGS(size_t, alignment, size_t, size, void *, ptr), + TP_ARGS(size_t, alignment, size_t, size, void *, ptr, void *, caller), TP_FIELDS( ctf_integer(size_t, alignment, alignment) ctf_integer(size_t, size, size) ctf_integer_hex(void *, ptr, ptr) + ctf_integer_hex(void *, caller, caller) ) ) TRACEPOINT_EVENT(ust_libc, posix_memalign, - TP_ARGS(void *, out_ptr, size_t, alignment, size_t, size, int, result), + TP_ARGS(void *, out_ptr, size_t, alignment, size_t, size, int, result, void *, caller), 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) + ctf_integer_hex(void *, caller, caller) ) ) -- 2.34.1