Add 'ctf_unused' tracepoint field type
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 31 Mar 2021 21:52:30 +0000 (17:52 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 1 Apr 2021 15:18:19 +0000 (11:18 -0400)
Some tracepoint definitions have one or more arguments that don't have a
corresponding field to allow passing a value to a probe without
recording it in the trace buffer nor using it in the filter.

This results in tracepoint macros generating inline functions with unused
arguments which prevents us from turning on -Wunuse-parameter.

Add a new tracepoint field type name 'ctf_unused' to adress this and
properly handle unused values in the tracepoint macros.

[ Mathieu: ctf_unused() takes only the _src parameter, no "type",
  because an unused "field" does not have any representation in the ring
  buffer nor the filter. If this ends up limiting us in the future, I
  accept all the blame. ]

Change-Id: I56d8024926340e9c965ca01fa24a0fff7b7c5baa
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 files changed:
include/lttng/tp/lttng-ust-tracef.h
include/lttng/tp/lttng-ust-tracelog.h
include/lttng/ust-tracepoint-event-nowrite.h
include/lttng/ust-tracepoint-event-reset.h
include/lttng/ust-tracepoint-event-write.h
include/lttng/ust-tracepoint-event.h
liblttng-ust-cyg-profile/lttng-ust-cyg-profile-fast.h
liblttng-ust-dl/ust_dl.h
liblttng-ust-libc-wrapper/ust_libc.h
liblttng-ust-libc-wrapper/ust_pthread.h
liblttng-ust/lttng-ust-statedump-provider.h
liblttng-ust/ust_lib.h

index 785f21321cb8e2c6aa44df4cfda9adbb130518d8..4feeb6940712ad5d2b97023fc11a4d1b2bf19c83 100644 (file)
@@ -11,6 +11,7 @@ TRACEPOINT_EVENT(lttng_ust_tracef, event,
        TP_ARGS(const char *, msg, unsigned int, len, void *, ip),
        TP_FIELDS(
                ctf_sequence_text(char, msg, msg, unsigned int, len)
+               ctf_unused(ip)
        )
 )
 TRACEPOINT_LOGLEVEL(lttng_ust_tracef, event, TRACE_DEBUG)
index abc66a0c68998653b40278fb3cac61ed2334bff0..95564707aa37db14da0ec721426034cefa3b0990 100644 (file)
@@ -15,6 +15,7 @@ TRACEPOINT_EVENT_CLASS(lttng_ust_tracelog, tlclass,
                ctf_string(file, file)
                ctf_string(func, func)
                ctf_sequence_text(char, msg, msg, unsigned int, len)
+               ctf_unused(ip)
        )
 )
 
index 57a970d18a1926a197362e585580d3ed5d9347df..3193d7025133a59a89d4f23b6ae059ad70ae0e46 100644 (file)
 #define ctf_string_nowrite(_item, _src)                                \
        _ctf_string(_item, _src, 1)
 
+#undef ctf_unused_nowrite
+#define ctf_unused_nowrite(_src)                               \
+       _ctf_unused(_src)
+
 #undef ctf_enum_nowrite
 #define ctf_enum_nowrite(_provider, _name, _type, _item, _src)         \
        _ctf_enum(_provider, _name, _type, _item, _src, 1)
index acc1207bc5ac6f28bc415004113a4d398c5d724e..d42213d17418c08d99a0051e6e36a358a9f51829 100644 (file)
@@ -48,6 +48,9 @@
 #undef _ctf_string
 #define _ctf_string(_item, _src, _nowrite)
 
+#undef _ctf_unused
+#define _ctf_unused(_src)
+
 #undef _ctf_enum
 #define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite)
 
 #undef ctf_string
 #define ctf_string(_item, _src)
 
+#undef ctf_unused
+#define ctf_unused(_src)
+
 #undef ctf_enum
 #define ctf_enum(_provider, _name, _type, _item, _src)
 
 #undef ctf_string_nowrite
 #define ctf_string_nowrite(_item, _src)
 
+#undef ctf_unused_nowrite
+#define ctf_unused_nowrite(_src)
+
 #undef ctf_enum_nowrite
 #define ctf_enum_nowrite(_provider, _name, _type, _item, _src)
index 17afbc8c1fdab4a9d150227e3ab47c54eef4bff5..87f621cd47dfe5918db92fd7736dd6042c3de1f1 100644 (file)
 #define ctf_string(_item, _src)                                        \
        _ctf_string(_item, _src, 0)
 
+#undef ctf_unused
+#define ctf_unused(_src)                                       \
+       _ctf_unused(_src)
+
 #undef ctf_enum
 #define ctf_enum(_provider, _name, _type, _item, _src)                 \
        _ctf_enum(_provider, _name, _type, _item, _src, 0)
index c4ec05eb86b538cb33bff297f14f7cf2a69bd77b..fe96bf24ada82528c63f463f98300b0ad9b82a66 100644 (file)
@@ -340,6 +340,9 @@ void __event_template_proto___##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)
                .nofilter = 0,                                  \
        }),
 
+#undef _ctf_unused
+#define _ctf_unused(_src)
+
 #undef _ctf_enum
 #define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \
        __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { \
@@ -408,23 +411,31 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
 
 #undef _ctf_integer_ext
 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite)       \
+       if (0)                                                                   \
+               (void) (_src);  /* Unused */                                     \
        __event_len += lttng_ust_lib_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_type)); \
        __event_len += sizeof(_type);
 
 #undef _ctf_float
 #define _ctf_float(_type, _item, _src, _nowrite)                                \
+       if (0)                                                                   \
+               (void) (_src);  /* Unused */                                     \
        __event_len += lttng_ust_lib_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_type)); \
        __event_len += sizeof(_type);
 
 #undef _ctf_array_encoded
 #define _ctf_array_encoded(_type, _item, _src, _byte_order, _length, _encoding,         \
                        _nowrite, _elem_type_base)                               \
+       if (0)                                                                   \
+               (void) (_src);  /* Unused */                                     \
        __event_len += lttng_ust_lib_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_type)); \
        __event_len += sizeof(_type) * (_length);
 
 #undef _ctf_sequence_encoded
 #define _ctf_sequence_encoded(_type, _item, _src, _byte_order, _length_type,    \
                        _src_length, _encoding, _nowrite, _elem_type_base)       \
+       if (0)                                                                   \
+               (void) (_src);  /* Unused */                                     \
        __event_len += lttng_ust_lib_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_length_type));   \
        __event_len += sizeof(_length_type);                                   \
        __event_len += lttng_ust_lib_ring_buffer_align(__event_len, lttng_ust_rb_alignof(_type)); \
@@ -437,6 +448,11 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
        __event_len += __dynamic_len[__dynamic_len_idx++] =                    \
                strlen((_src) ? (_src) : __LTTNG_UST_NULL_STRING) + 1;
 
+#undef _ctf_unused
+#define _ctf_unused(_src)                                                      \
+       if (0)                                                                  \
+               (void) (_src);  /* Unused */
+
 #undef _ctf_enum
 #define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite)              \
        _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10, _nowrite)
@@ -453,13 +469,16 @@ static inline                                                                   \
 size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
        lttng_ust_notrace;                                                    \
 static inline                                                                \
-size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS_DATA_PROTO(_args)) \
+size_t __event_get_size__##_provider##___##_name(                            \
+               size_t *__dynamic_len __attribute__((__unused__)),            \
+               _TP_ARGS_DATA_PROTO(_args))                                   \
 {                                                                            \
        size_t __event_len = 0;                                               \
-       unsigned int __dynamic_len_idx = 0;                                   \
+       unsigned int __dynamic_len_idx __attribute__((__unused__)) = 0;       \
                                                                              \
        if (0)                                                                \
-               (void) __dynamic_len_idx;       /* don't warn if unused */    \
+               (void) __tp_data;       /* don't warn if unused */            \
+                                                                             \
        _fields                                                               \
        return __event_len;                                                   \
 }
@@ -598,6 +617,11 @@ size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS
                __stack_data += sizeof(void *);                                \
        }
 
+#undef _ctf_unused
+#define _ctf_unused(_src)                                                      \
+       if (0)                                                                  \
+               (void) (_src);
+
 #undef _ctf_enum
 #define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite)              \
        _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10, _nowrite)
@@ -614,6 +638,11 @@ static inline                                                                    \
 void __event_prepare_interpreter_stack__##_provider##___##_name(char *__stack_data,\
                                                 _TP_ARGS_DATA_PROTO(_args))  \
 {                                                                            \
+       if (0) {                                                              \
+               (void) __tp_data;       /* don't warn if unused */            \
+               (void) __stack_data;    /* don't warn if unused */            \
+       }                                                                     \
+                                                                             \
        _fields                                                               \
 }
 
@@ -631,25 +660,42 @@ void __event_prepare_interpreter_stack__##_provider##___##_name(char *__stack_da
 
 #undef _ctf_integer_ext
 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite)     \
+       if (0)                                                                 \
+               (void) (_src);  /* Unused */                                   \
        __event_align = _tp_max_t(size_t, __event_align, lttng_ust_rb_alignof(_type));
 
 #undef _ctf_float
 #define _ctf_float(_type, _item, _src, _nowrite)                              \
+       if (0)                                                                 \
+               (void) (_src);  /* Unused */                                   \
        __event_align = _tp_max_t(size_t, __event_align, lttng_ust_rb_alignof(_type));
 
 #undef _ctf_array_encoded
 #define _ctf_array_encoded(_type, _item, _src, _byte_order, _length,          \
                        _encoding, _nowrite, _elem_type_base)                  \
+       if (0)                                                                 \
+               (void) (_src);  /* Unused */                                   \
        __event_align = _tp_max_t(size_t, __event_align, lttng_ust_rb_alignof(_type));
 
 #undef _ctf_sequence_encoded
 #define _ctf_sequence_encoded(_type, _item, _src, _byte_order, _length_type,   \
                        _src_length, _encoding, _nowrite, _elem_type_base)     \
+       if (0)                                                                 \
+               (void) (_src);  /* Unused */                                   \
+       if (0)                                                                 \
+               (void) (_src_length);   /* Unused */                           \
        __event_align = _tp_max_t(size_t, __event_align, lttng_ust_rb_alignof(_length_type));     \
        __event_align = _tp_max_t(size_t, __event_align, lttng_ust_rb_alignof(_type));
 
 #undef _ctf_string
-#define _ctf_string(_item, _src, _nowrite)
+#define _ctf_string(_item, _src, _nowrite)                                     \
+       if (0)                                                                  \
+               (void) (_src);  /* Unused */
+
+#undef _ctf_unused
+#define _ctf_unused(_src)                                                      \
+       if (0)                                                                  \
+               (void) (_src);  /* Unused */
 
 #undef _ctf_enum
 #define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite)              \
@@ -732,6 +778,8 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
                        __get_dynamic_len(dest));                               \
        }
 
+#undef _ctf_unused
+#define _ctf_unused(_src)
 
 #undef _ctf_enum
 #define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite)      \
index 9dbe9da2f65ad14d8342163124bdafd9e4ab04d8..f2cdaabe94b32c620c82ad956b91344404bf2fd1 100644 (file)
@@ -29,7 +29,9 @@ TRACEPOINT_LOGLEVEL(lttng_ust_cyg_profile_fast, func_entry,
 
 TRACEPOINT_EVENT(lttng_ust_cyg_profile_fast, func_exit,
        TP_ARGS(void *, func_addr),
-       TP_FIELDS()
+       TP_FIELDS(
+               ctf_unused(func_addr)
+       )
 )
 
 TRACEPOINT_LOGLEVEL(lttng_ust_cyg_profile_fast, func_exit,
index 94fc87ef6fabf1bc7fe81e747898fdada076de51..7f618da778518998927b856f4a02b0ca9dff0531 100644 (file)
@@ -27,6 +27,7 @@ TRACEPOINT_EVENT(lttng_ust_dl, dlopen,
                int, flags, uint64_t, memsz, uint8_t, has_build_id,
                uint8_t, has_debug_link),
        TP_FIELDS(
+               ctf_unused(ip)
                ctf_integer_hex(void *, baddr, baddr)
                ctf_integer(uint64_t, memsz, memsz)
                ctf_integer_hex(int, flags, flags)
@@ -43,6 +44,7 @@ TRACEPOINT_EVENT(lttng_ust_dl, dlmopen,
                uint64_t, memsz, uint8_t, has_build_id,
                uint8_t, has_debug_link),
        TP_FIELDS(
+               ctf_unused(ip)
                ctf_integer_hex(void *, baddr, baddr)
                ctf_integer(uint64_t, memsz, memsz)
                ctf_integer(Lmid_t, nsid, nsid)
@@ -62,6 +64,7 @@ TRACEPOINT_EVENT(lttng_ust_dl, build_id,
                size_t, build_id_len
        ),
        TP_FIELDS(
+               ctf_unused(ip)
                ctf_integer_hex(void *, baddr, baddr)
                ctf_sequence_hex(uint8_t, build_id, build_id,
                        size_t, build_id_len)
@@ -76,6 +79,7 @@ TRACEPOINT_EVENT(lttng_ust_dl, debug_link,
                uint32_t, crc
        ),
        TP_FIELDS(
+               ctf_unused(ip)
                ctf_integer_hex(void *, baddr, baddr)
                ctf_integer(uint32_t, crc, crc)
                ctf_string(filename, filename)
@@ -85,6 +89,7 @@ TRACEPOINT_EVENT(lttng_ust_dl, debug_link,
 TRACEPOINT_EVENT(lttng_ust_dl, dlclose,
        TP_ARGS(void *, ip, void *, baddr),
        TP_FIELDS(
+               ctf_unused(ip)
                ctf_integer_hex(void *, baddr, baddr)
        )
 )
index 77056691c00a72508108e10f24eb53f211fdeea4..6aaef22b60af0d464654118d0227966622430c88 100644 (file)
@@ -21,6 +21,7 @@ TRACEPOINT_EVENT(lttng_ust_libc, malloc,
        TP_FIELDS(
                ctf_integer(size_t, size, size)
                ctf_integer_hex(void *, ptr, ptr)
+               ctf_unused(ip)
        )
 )
 
@@ -28,6 +29,7 @@ TRACEPOINT_EVENT(lttng_ust_libc, free,
        TP_ARGS(void *, ptr, void *, ip),
        TP_FIELDS(
                ctf_integer_hex(void *, ptr, ptr)
+               ctf_unused(ip)
        )
 )
 
@@ -37,6 +39,7 @@ TRACEPOINT_EVENT(lttng_ust_libc, calloc,
                ctf_integer(size_t, nmemb, nmemb)
                ctf_integer(size_t, size, size)
                ctf_integer_hex(void *, ptr, ptr)
+               ctf_unused(ip)
        )
 )
 
@@ -46,6 +49,7 @@ TRACEPOINT_EVENT(lttng_ust_libc, realloc,
                ctf_integer_hex(void *, in_ptr, in_ptr)
                ctf_integer(size_t, size, size)
                ctf_integer_hex(void *, ptr, ptr)
+               ctf_unused(ip)
        )
 )
 
@@ -55,6 +59,7 @@ TRACEPOINT_EVENT(lttng_ust_libc, memalign,
                ctf_integer(size_t, alignment, alignment)
                ctf_integer(size_t, size, size)
                ctf_integer_hex(void *, ptr, ptr)
+               ctf_unused(ip)
        )
 )
 
@@ -65,6 +70,7 @@ TRACEPOINT_EVENT(lttng_ust_libc, posix_memalign,
                ctf_integer(size_t, alignment, alignment)
                ctf_integer(size_t, size, size)
                ctf_integer(int, result, result)
+               ctf_unused(ip)
        )
 )
 
index 7296bf4c0c8614947c033f85cc9e8723a92cd956..4fdc11aa445f9d244d740d07dd6e440679a6398f 100644 (file)
@@ -20,6 +20,7 @@ TRACEPOINT_EVENT(lttng_ust_pthread, pthread_mutex_lock_req,
        TP_ARGS(pthread_mutex_t *, mutex, void *, ip),
        TP_FIELDS(
                ctf_integer_hex(void *, mutex, mutex)
+               ctf_unused(ip)
        )
 )
 
@@ -28,6 +29,7 @@ TRACEPOINT_EVENT(lttng_ust_pthread, pthread_mutex_lock_acq,
        TP_FIELDS(
                ctf_integer_hex(void *, mutex, mutex)
                ctf_integer(int, status, status)
+               ctf_unused(ip)
        )
 )
 
@@ -36,6 +38,7 @@ TRACEPOINT_EVENT(lttng_ust_pthread, pthread_mutex_trylock,
        TP_FIELDS(
                ctf_integer_hex(void *, mutex, mutex)
                ctf_integer(int, status, status)
+               ctf_unused(ip)
        )
 )
 
@@ -44,6 +47,7 @@ TRACEPOINT_EVENT(lttng_ust_pthread, pthread_mutex_unlock,
        TP_FIELDS(
                ctf_integer_hex(void *, mutex, mutex)
                ctf_integer(int, status, status)
+               ctf_unused(ip)
        )
 )
 
index 4529369d382f15a7e9852508f71da0bdece9c6ba..cab628aa8ea1131d4d96908314a652225298b1bb 100644 (file)
@@ -26,7 +26,9 @@ extern "C" {
 
 TRACEPOINT_EVENT(lttng_ust_statedump, start,
        TP_ARGS(struct lttng_ust_session *, session),
-       TP_FIELDS()
+       TP_FIELDS(
+               ctf_unused(session)
+       )
 )
 
 TRACEPOINT_EVENT(lttng_ust_statedump, bin_info,
@@ -40,6 +42,7 @@ TRACEPOINT_EVENT(lttng_ust_statedump, bin_info,
                uint8_t, has_debug_link
        ),
        TP_FIELDS(
+               ctf_unused(session)
                ctf_integer_hex(void *, baddr, baddr)
                ctf_integer(uint64_t, memsz, memsz)
                ctf_string(path, path)
@@ -57,6 +60,7 @@ TRACEPOINT_EVENT(lttng_ust_statedump, build_id,
                size_t, build_id_len
        ),
        TP_FIELDS(
+               ctf_unused(session)
                ctf_integer_hex(void *, baddr, baddr)
                ctf_sequence_hex(uint8_t, build_id, build_id,
                        size_t, build_id_len)
@@ -71,6 +75,7 @@ TRACEPOINT_EVENT(lttng_ust_statedump, debug_link,
                uint32_t, crc
        ),
        TP_FIELDS(
+               ctf_unused(session)
                ctf_integer_hex(void *, baddr, baddr)
                ctf_integer(uint32_t, crc, crc)
                ctf_string(filename, filename)
@@ -83,13 +88,16 @@ TRACEPOINT_EVENT(lttng_ust_statedump, procname,
                char *, name
        ),
        TP_FIELDS(
+               ctf_unused(session)
                ctf_array_text(char, procname, name, LTTNG_UST_ABI_PROCNAME_LEN)
        )
 )
 
 TRACEPOINT_EVENT(lttng_ust_statedump, end,
        TP_ARGS(struct lttng_ust_session *, session),
-       TP_FIELDS()
+       TP_FIELDS(
+               ctf_unused(session)
+       )
 )
 
 #endif /* _TRACEPOINT_LTTNG_UST_STATEDUMP_H */
index ca525d401caaeb6a26e26e00792b74aa772f005a..f704efb61d86e36822f5b62043d5042a729dfed1 100644 (file)
@@ -28,6 +28,7 @@ TRACEPOINT_EVENT(lttng_ust_lib, load,
                uint64_t, memsz, uint8_t, has_build_id,
                uint8_t, has_debug_link),
        TP_FIELDS(
+               ctf_unused(ip)
                ctf_integer_hex(void *, baddr, baddr)
                ctf_integer(uint64_t, memsz, memsz)
                ctf_string(path, path)
@@ -44,6 +45,7 @@ TRACEPOINT_EVENT(lttng_ust_lib, build_id,
                size_t, build_id_len
        ),
        TP_FIELDS(
+               ctf_unused(ip)
                ctf_integer_hex(void *, baddr, baddr)
                ctf_sequence_hex(uint8_t, build_id, build_id,
                        size_t, build_id_len)
@@ -58,6 +60,7 @@ TRACEPOINT_EVENT(lttng_ust_lib, debug_link,
                uint32_t, crc
        ),
        TP_FIELDS(
+               ctf_unused(ip)
                ctf_integer_hex(void *, baddr, baddr)
                ctf_integer(uint32_t, crc, crc)
                ctf_string(filename, filename)
@@ -67,6 +70,7 @@ TRACEPOINT_EVENT(lttng_ust_lib, debug_link,
 TRACEPOINT_EVENT(lttng_ust_lib, unload,
        TP_ARGS(void *, ip, void *, baddr),
        TP_FIELDS(
+               ctf_unused(ip)
                ctf_integer_hex(void *, baddr, baddr)
        )
 )
This page took 0.033287 seconds and 4 git commands to generate.