From 818c4c9ea4d00b77ae6b15d0211f933d37fb261a Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 9 Jun 2015 11:51:06 +0200 Subject: [PATCH] Fix: fetch caller address from tracef() Don't fetch the address within the ust trampoline, but rather the caller address. Signed-off-by: Mathieu Desnoyers --- include/lttng/lttng-ust-tracef.h | 2 +- include/lttng/ust-tracepoint-event.h | 9 ++++++++- liblttng-ust/lttng-ust-tracef-provider.h | 1 + liblttng-ust/tracef.c | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/lttng/lttng-ust-tracef.h b/include/lttng/lttng-ust-tracef.h index 1910447f..3095b3db 100644 --- a/include/lttng/lttng-ust-tracef.h +++ b/include/lttng/lttng-ust-tracef.h @@ -24,7 +24,7 @@ #include TRACEPOINT_EVENT(lttng_ust_tracef, event, - TP_ARGS(const char *, msg, unsigned int, len), + TP_ARGS(const char *, msg, unsigned int, len, void *, ip), TP_FIELDS( ctf_sequence_text(char, msg, msg, unsigned int, len) ) diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 3f99f662..6c32249c 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -565,6 +565,13 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \ #define _TP_SESSION_CHECK(session, csession) 1 #endif /* TP_SESSION_CHECK */ +#undef _TP_IP_PARAM +#ifdef TP_IP_PARAM +#define _TP_IP_PARAM() ip +#else /* TP_IP_PARAM */ +#define _TP_IP_PARAM() __builtin_return_address(0) +#endif /* TP_IP_PARAM */ + /* * Using twice size for filter stack data to hold size and pointer for * each field (worse case). For integers, max size required is 64-bit. @@ -621,7 +628,7 @@ void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)) \ __event_align = __event_get_align__##_provider##___##_name(_TP_ARGS_VAR(_args)); \ lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \ __event_align, -1, __chan->handle); \ - __ctx.ip = __builtin_return_address(0); \ + __ctx.ip = _TP_IP_PARAM(); \ __ret = __chan->ops->event_reserve(&__ctx, __event->id); \ if (__ret < 0) \ return; \ diff --git a/liblttng-ust/lttng-ust-tracef-provider.h b/liblttng-ust/lttng-ust-tracef-provider.h index 1e328884..2afd7f99 100644 --- a/liblttng-ust/lttng-ust-tracef-provider.h +++ b/liblttng-ust/lttng-ust-tracef-provider.h @@ -30,6 +30,7 @@ #endif /* _TRACEPOINT_LTTNG_UST_TRACEF_PROVIDER_H */ +#define TP_IP_PARAM /* IP context received as parameter */ #undef TRACEPOINT_INCLUDE #define TRACEPOINT_INCLUDE "./lttng-ust-tracef.h" diff --git a/liblttng-ust/tracef.c b/liblttng-ust/tracef.c index 9ef063ce..dcae3be7 100644 --- a/liblttng-ust/tracef.c +++ b/liblttng-ust/tracef.c @@ -39,7 +39,8 @@ void _lttng_ust_tracef(const char *fmt, ...) /* len does not include the final \0 */ if (len < 0) goto end; - __tracepoint_cb_lttng_ust_tracef___event(msg, len); + __tracepoint_cb_lttng_ust_tracef___event(msg, len, + __builtin_return_address(0)); free(msg); end: va_end(ap); -- 2.34.1