| 1 | /* |
| 2 | * SPDX-License-Identifier: MIT |
| 3 | * |
| 4 | * Copyright (C) 2013-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 5 | */ |
| 6 | |
| 7 | #define _LGPL_SOURCE |
| 8 | #include <stdio.h> |
| 9 | #include "common/macros.h" |
| 10 | |
| 11 | /* The tracepoint definition is public, but the provider definition is hidden. */ |
| 12 | #define LTTNG_UST_TRACEPOINT_PROVIDER_HIDDEN_DEFINITION |
| 13 | |
| 14 | #define LTTNG_UST_TRACEPOINT_CREATE_PROBES |
| 15 | #define LTTNG_UST_TRACEPOINT_DEFINE |
| 16 | #include "lttng-ust-tracef-provider.h" |
| 17 | |
| 18 | static inline |
| 19 | void lttng_ust___vtracef(const char *fmt, va_list ap) |
| 20 | __attribute__((always_inline, format(printf, 1, 0))); |
| 21 | static inline |
| 22 | void lttng_ust___vtracef(const char *fmt, va_list ap) |
| 23 | { |
| 24 | char *msg; |
| 25 | const int len = vasprintf(&msg, fmt, ap); |
| 26 | |
| 27 | /* len does not include the final \0 */ |
| 28 | if (len < 0) |
| 29 | goto end; |
| 30 | lttng_ust_tracepoint_cb_lttng_ust_tracef___event(msg, len, |
| 31 | LTTNG_UST_CALLER_IP()); |
| 32 | free(msg); |
| 33 | end: |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | void lttng_ust__vtracef(const char *fmt, va_list ap) |
| 38 | __attribute__((format(printf, 1, 0))); |
| 39 | void lttng_ust__vtracef(const char *fmt, va_list ap) |
| 40 | { |
| 41 | lttng_ust___vtracef(fmt, ap); |
| 42 | } |
| 43 | |
| 44 | void lttng_ust__tracef(const char *fmt, ...) |
| 45 | __attribute__((format(printf, 1, 2))); |
| 46 | void lttng_ust__tracef(const char *fmt, ...) |
| 47 | { |
| 48 | va_list ap; |
| 49 | |
| 50 | va_start(ap, fmt); |
| 51 | lttng_ust___vtracef(fmt, ap); |
| 52 | va_end(ap); |
| 53 | } |