X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=probes%2Flttng-events.h;h=1fab263dd2521631f0495f35164938fcbd4c4652;hb=8e4b115ba22066b923d36ff230a7c155f59f03de;hp=86c13bbed5b31661c75a01496b8ae01924703629;hpb=47086178b1a3e880b8e861f9cc4060bae1532695;p=lttng-modules.git diff --git a/probes/lttng-events.h b/probes/lttng-events.h index 86c13bbe..1fab263d 100644 --- a/probes/lttng-events.h +++ b/probes/lttng-events.h @@ -34,6 +34,8 @@ #include #include +#define __LTTNG_NULL_STRING "(null)" + /* * Macro declarations used for all stages. */ @@ -333,7 +335,7 @@ static void __event_probe__##_name(void *__data); max_t(size_t, lttng_strlen_user_inatomic(_src), 1); \ else \ __event_len += __dynamic_len[__dynamic_len_idx++] = \ - strlen(_src) + 1; + strlen((_src) ? (_src) : __LTTNG_NULL_STRING) + 1; #undef TP_PROTO #define TP_PROTO(...) __VA_ARGS__ @@ -511,7 +513,8 @@ static inline size_t __event_get_size__##_name(size_t *__dynamic_len, \ #undef _ctf_string #define _ctf_string(_item, _src, _user, _nowrite) \ { \ - const void *__ctf_tmp_ptr = (_src); \ + const void *__ctf_tmp_ptr = \ + ((_src) ? (_src) : __LTTNG_NULL_STRING); \ memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \ __stack_data += sizeof(void *); \ } @@ -677,12 +680,16 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar) \ #undef _ctf_string #define _ctf_string(_item, _src, _user, _nowrite) \ - lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \ if (_user) { \ + lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \ __chan->ops->event_strcpy_from_user(&__ctx, _src, \ __get_dynamic_len(dest)); \ } else { \ - __chan->ops->event_strcpy(&__ctx, _src, \ + const char *__ctf_tmp_string = \ + ((_src) ? (_src) : __LTTNG_NULL_STRING); \ + lib_ring_buffer_align_ctx(&__ctx, \ + lttng_alignof(*__ctf_tmp_string)); \ + __chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \ __get_dynamic_len(dest)); \ }