X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=include%2Flttng%2Ftracepoint.h;h=f85db068d378383d941dbc8271ed555a71d1a9b9;hb=81b16412749579b79a4d829ff87e170d0e1ebd0d;hp=b47b1e0e1c00ab5eb5d1a79356762b8852b35874;hpb=0b4b88119eced28c0cd4fcec773f76525103ac3f;p=lttng-ust.git diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h index b47b1e0e..f85db068 100644 --- a/include/lttng/tracepoint.h +++ b/include/lttng/tracepoint.h @@ -20,6 +20,8 @@ #include #include +#define LTTNG_UST_TRACEPOINT_NAME_LEN_MAX 256 + #ifdef LTTNG_UST_HAVE_SDT_INTEGRATION /* * Instead of using SDT_USE_VARIADIC from 'sys/sdt.h', use our own namespaced @@ -154,6 +156,25 @@ extern "C" { #define _TP_ARGS_DATA_VAR(...) _TP_DATA_VAR_N(_TP_NARGS(0, ##__VA_ARGS__), ##__VA_ARGS__) #define _TP_PARAMS(...) __VA_ARGS__ +/* + * sizeof(#_provider) - 1 : length of the provider string (excluding \0). + * sizeof(#_name) - 1 : length of the name string (excluding \0). + * + 1 : separator between provider and event name. + * + * Upper bound (inclusive) is LTTNG_UST_TRACEPOINT_NAME_LEN_MAX - 1 to + * account for \0. + * + * The comparison is: + * left hand side: sizeof(#_provider) - 1 + sizeof(#_name) - 1 + 1 + * right hand side: LTTNG_UST_TRACEPOINT_NAME_LEN_MAX - 1 + * operator: <= (inclusive) + * Simplified in the code below. + */ +#define lttng_ust_tracepoint_validate_name_len(_provider, _name) \ + lttng_ust_static_assert(sizeof(#_provider) + sizeof(#_name) <= LTTNG_UST_TRACEPOINT_NAME_LEN_MAX, \ + "Tracepoint name length is too long", \ + Tracepoint_name_length_is_too_long) + /* * The tracepoint cb is marked always inline so we can distinguish * between caller's ip addresses within the probe using the return @@ -446,6 +467,7 @@ extern struct lttng_ust_tracepoint * const __stop___tracepoints_ptrs[] #define _TP_EXTRACT_STRING(...) #__VA_ARGS__ #define _DEFINE_TRACEPOINT(_provider, _name, _args) \ + lttng_ust_tracepoint_validate_name_len(_provider, _name); \ extern int __tracepoint_provider_##_provider; \ static const char __tp_strtab_##_provider##___##_name[] \ __attribute__((section("__tracepoints_strings"))) = \