| 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 <ust-helper.h> |
| 10 | |
| 11 | #define TRACEPOINT_CREATE_PROBES |
| 12 | #define TRACEPOINT_DEFINE |
| 13 | #include "lttng-ust-tracef-provider.h" |
| 14 | |
| 15 | static inline __attribute__((always_inline)) |
| 16 | void __lttng_ust_vtracef(const char *fmt, va_list ap) |
| 17 | { |
| 18 | char *msg; |
| 19 | const int len = vasprintf(&msg, fmt, ap); |
| 20 | |
| 21 | /* len does not include the final \0 */ |
| 22 | if (len < 0) |
| 23 | goto end; |
| 24 | __tracepoint_cb_lttng_ust_tracef___event(msg, len, |
| 25 | LTTNG_UST_CALLER_IP()); |
| 26 | free(msg); |
| 27 | end: |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | void _lttng_ust_vtracef(const char *fmt, va_list ap) |
| 32 | { |
| 33 | __lttng_ust_vtracef(fmt, ap); |
| 34 | } |
| 35 | |
| 36 | void _lttng_ust_tracef(const char *fmt, ...) |
| 37 | { |
| 38 | va_list ap; |
| 39 | |
| 40 | va_start(ap, fmt); |
| 41 | __lttng_ust_vtracef(fmt, ap); |
| 42 | va_end(ap); |
| 43 | } |