Fix: incorrect parameters passed to vtracelog
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 16 Dec 2020 21:23:53 +0000 (16:23 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 16 Dec 2020 21:23:53 +0000 (16:23 -0500)
The vtracelog APIs should be called from the vtracelog instrumentation
rather than the "tracelog" APIs, because it passes a va_list rather than
a variable argument list (...).

This can be verified by tracing the demo program doc/examples/demo-tracelog/demo-vtracelog:

Issue (corrupted trace output):

16:17:26.686073539] (+0.000000530) thinkos lttng_ust_tracelog:TRACE_ERR: { cpu_id = 2 }, { line = 31, file = "demo-vtracelog.c", func = "print_err", _msg_length = 49, msg = "This is a \"\b\" formatted 638975520 error event d68" }

Fixed:

[16:23:33.538189343] (+0.000000600) thinkos lttng_ust_tracelog:TRACE_ERR: { cpu_id = 3 }, { line = 31, file = "demo-vtracelog.c", func = "print_err", _msg_length = 52, msg = "This is a \"mystring test\" formatted 4 error event 42" }

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I330e339a3bf68fb8d9779bbc71b08c3bc033ac4e

include/lttng/tracelog.h

index 7aa8680987847ea2c76e9cae43c8aa05929dcc52..d4406a430e44b7dd18486ec64b4b5e355b91699a 100644 (file)
 extern "C" {
 #endif
 
-#define TP_TRACELOG_CB_TEMPLATE(level) \
-       extern void _lttng_ust_tracelog_##level(const char *file, \
-               int line, const char *func, const char *fmt, ...)
+#define TP_TRACELOG_CB_TEMPLATE(level)                                 \
+       extern void _lttng_ust_tracelog_##level(const char *file,       \
+               int line, const char *func, const char *fmt, ...);      \
+       extern void _lttng_ust_vtracelog_##level(const char *file,      \
+               int line, const char *func, const char *fmt, va_list ap);
 
 TP_TRACELOG_CB_TEMPLATE(TRACE_EMERG);
 TP_TRACELOG_CB_TEMPLATE(TRACE_ALERT);
@@ -56,14 +58,14 @@ TP_TRACELOG_CB_TEMPLATE(TRACE_DEBUG);
                LTTNG_STAP_PROBEV(tracepoint_lttng_ust_tracelog, level, ## __VA_ARGS__); \
                if (caa_unlikely(__tracepoint_lttng_ust_tracelog___##level.state)) \
                        _lttng_ust_tracelog_##level(__FILE__, __LINE__, __func__, \
-                               fmt, ## __VA_ARGS__); \
+                               fmt, ## __VA_ARGS__);                   \
        } while (0)
 
 #define vtracelog(level, fmt, ap)                                      \
        do {                                                            \
                if (caa_unlikely(__tracepoint_lttng_ust_tracelog___##level.state)) \
-                       _lttng_ust_tracelog_##level(__FILE__, __LINE__, __func__, \
-                               fmt, ap); \
+                       _lttng_ust_vtracelog_##level(__FILE__, __LINE__, __func__, \
+                               fmt, ap);                               \
        } while (0)
 
 #ifdef __cplusplus
This page took 0.02848 seconds and 4 git commands to generate.