[lttng-dev] [PATCH v3 lttng-ust 1/2] Introduce vtracef
Mathieu Desnoyers
mathieu.desnoyers at efficios.com
Tue Mar 3 14:10:25 EST 2020
----- On Feb 26, 2020, at 4:14 PM, Mathieu Desnoyers mathieu.desnoyers at efficios.com wrote:
> ----- On Feb 24, 2020, at 12:34 PM, Maxime Roussin-Belanger
> maxime.roussinbelanger at gmail.com wrote:
> [...]
>> diff --git a/liblttng-ust/tracef.c b/liblttng-ust/tracef.c
>> index ea98e43e..1311f0d5 100644
>> --- a/liblttng-ust/tracef.c
>> +++ b/liblttng-ust/tracef.c
>> @@ -29,20 +29,26 @@
>> #define TRACEPOINT_DEFINE
>> #include "lttng-ust-tracef-provider.h"
>>
>> -void _lttng_ust_tracef(const char *fmt, ...)
>> +void _lttng_ust_vtracef(const char *fmt, va_list ap)
>> {
>> - va_list ap;
>> char *msg;
>> - int len;
>> -
>> - va_start(ap, fmt);
>> - len = vasprintf(&msg, fmt, ap);
>> + const int len = vasprintf(&msg, fmt, ap);
>> /* len does not include the final \0 */
>> if (len < 0)
>> goto end;
>> __tracepoint_cb_lttng_ust_tracef___event(msg, len,
>> LTTNG_UST_CALLER_IP());
>
> I don't think LTTNG_UST_CALLER_IP() has the behavior we would expect
> for _lttng_ust_tracef() anymore here. We want the callsite in the application
> or library which has been instrumented, not an IP within lttng-ust.
The following should fix both inlining and CALLER_IP() issues:
static inline __attribute__((always_inline))
void __lttng_ust_vtracef(const char *fmt, va_list ap)
{
char *msg;
const int len = vasprintf(&msg, fmt, ap);
/* len does not include the final \0 */
if (len < 0)
goto end;
__tracepoint_cb_lttng_ust_tracef___event(msg, len,
LTTNG_UST_CALLER_IP());
free(msg);
end:
return;
}
void _lttng_ust_vtracef(const char *fmt, va_list ap)
{
__lttng_ust_vtracef(fmt, ap);
}
void _lttng_ust_tracef(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
__lttng_ust_vtracef(fmt, ap);
va_end(ap);
}
Thanks,
Mathieu
>
> Thanks,
>
> Mathieu
>
>> free(msg);
>> end:
>> + return;
>> +}
>> +
>> +void _lttng_ust_tracef(const char *fmt, ...)
>> +{
>> + va_list ap;
>> +
>> + va_start(ap, fmt);
>> + _lttng_ust_vtracef(fmt, ap);
>> +
>> va_end(ap);
>> }
>> --
>> 2.20.1
>>
>> _______________________________________________
>> lttng-dev mailing list
>> lttng-dev at lists.lttng.org
>> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
More information about the lttng-dev
mailing list