Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output "(null)" when ctf_string()'s arg is NULL #17

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions include/lttng/ust-tracepoint-event.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <lttng/tracepoint.h>
#include <string.h>

#define __LTTNG_UST_NULL_STRING "(null)"

#undef tp_list_for_each_entry_rcu
#define tp_list_for_each_entry_rcu(pos, head, member) \
for (pos = cds_list_entry(tp_rcu_dereference_bp((head)->next), __typeof__(*pos), member); \
Expand Down Expand Up @@ -328,7 +330,8 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));

#undef _ctf_string
#define _ctf_string(_item, _src, _nowrite) \
__event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1;
__event_len += __dynamic_len[__dynamic_len_idx++] = \
strlen((_src) ? (_src) : __LTTNG_UST_NULL_STRING) + 1;

#undef _ctf_enum
#define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \
Expand Down Expand Up @@ -471,7 +474,8 @@ size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS
#undef _ctf_string
#define _ctf_string(_item, _src, _nowrite) \
{ \
const void *__ctf_tmp_ptr = (_src); \
const void *__ctf_tmp_ptr = \
((_src) ? (_src) : __LTTNG_UST_NULL_STRING); \
memcpy(__stack_data, &__ctf_tmp_ptr, sizeof(void *)); \
__stack_data += sizeof(void *); \
}
Expand Down Expand Up @@ -608,13 +612,19 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \

#undef _ctf_string
#define _ctf_string(_item, _src, _nowrite) \
lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \
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));
{ \
const char *__ctf_tmp_string = \
((_src) ? (_src) : __LTTNG_UST_NULL_STRING); \
lib_ring_buffer_align_ctx(&__ctx, \
lttng_alignof(*__ctf_tmp_string)); \
if (__chan->ops->u.has_strcpy) \
__chan->ops->event_strcpy(&__ctx, __ctf_tmp_string, \
__get_dynamic_len(dest)); \
else \
__chan->ops->event_write(&__ctx, __ctf_tmp_string, \
__get_dynamic_len(dest)); \
}


#undef _ctf_enum
#define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \
Expand Down