Fix: pad strings that are modified concurrently with tracing
[lttng-ust.git] / include / lttng / ust-tracepoint-event.h
index 8140b9df78c32425e0ea97f6185a4844bda9cfc7..d12e8bb71779dbff8ee1dd7196f52126c4465ba9 100644 (file)
@@ -520,10 +520,24 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
        __chan->ops->event_write(&__ctx, _src,                          \
                sizeof(_type) * __get_dynamic_len(dest));
 
+/*
+ * __chan->ops->u.has_strcpy is a flag letting us know if the LTTng-UST
+ * tracepoint provider ABI implements event_strcpy. This dynamic check
+ * can be removed when the tracepoint provider ABI moves to 2.
+ */
+#if (LTTNG_UST_PROVIDER_MAJOR > 1)
+#error "Tracepoint probe provider major version has changed. Please remove dynamic check for has_strcpy."
+#endif
+
 #undef _ctf_string
 #define _ctf_string(_item, _src, _nowrite)                             \
        lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src)));      \
-       __chan->ops->event_write(&__ctx, _src, __get_dynamic_len(dest));
+       if (__chan->ops->u.has_strcpy)                                  \
+               __chan->ops->event_strcpy(&__ctx, _src,                 \
+                       __get_dynamic_len(dest));                       \
+       else                                                            \
+               __chan->ops->event_write(&__ctx, _src,                  \
+                       __get_dynamic_len(dest));
 
 /* Beware: this get len actually consumes the len value */
 #undef __get_dynamic_len
This page took 0.024065 seconds and 4 git commands to generate.