From: Mathieu Desnoyers Date: Thu, 11 Aug 2011 23:46:24 +0000 (-0400) Subject: test and fix array, sequence, string X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5dba59370c99b0d253f1bda39b12a0a076ef09c6;p=ust.git test and fix array, sequence, string Signed-off-by: Mathieu Desnoyers --- diff --git a/include/ust/lttng-tracepoint-event.h b/include/ust/lttng-tracepoint-event.h index 010a54d..a83cc54 100644 --- a/include/ust/lttng-tracepoint-event.h +++ b/include/ust/lttng-tracepoint-event.h @@ -289,7 +289,7 @@ static struct lttng_probe_desc TP_ID(__probe_desc___, TRACEPOINT_SYSTEM) = { __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_length_type)); \ __event_len += sizeof(_length_type); \ __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ - __dynamic_len[__dynamic_len_idx] = (_length); \ + __dynamic_len[__dynamic_len_idx] = (_src_length); \ __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \ __dynamic_len_idx++; @@ -430,20 +430,21 @@ static inline size_t __event_get_align__##_name(void) \ _src_length, _encoding) \ { \ _length_type __tmpl = __dynamic_len[__dynamic_len_idx]; \ - lib_ring_buffer_align_ctx(&ctx, lttng_alignof(_length_type)); \ + lib_ring_buffer_align_ctx(&ctx, lttng_alignof(_length_type)); \ __chan->ops->event_write(&ctx, &__tmpl, sizeof(_length_type)); \ } \ lib_ring_buffer_align_ctx(&ctx, lttng_alignof(_type)); \ __chan->ops->event_write(&ctx, _src, \ - sizeof(_type) * __get_sequence_len(dest)); + sizeof(_type) * __get_dynamic_len(dest)); #undef ctf_string #define ctf_string(_item, _src) \ - tp_memcpy(dest, _src, __get_sequence_len(dest)) + lib_ring_buffer_align_ctx(&ctx, lttng_alignof(*(_src))); \ + __chan->ops->event_write(&ctx, _src, __get_dynamic_len(dest)); /* Beware: this get len actually consumes the len value */ -#undef __get_sequence_len -#define __get_sequence_len(field) __dynamic_len[__dynamic_len_idx++] +#undef __get_dynamic_len +#define __get_dynamic_len(field) __dynamic_len[__dynamic_len_idx++] #undef TP_PROTO #define TP_PROTO(args...) args @@ -518,6 +519,8 @@ static void __event_probe__##_name(void *__data) \ #include TRACEPOINT_INCLUDE(TRACEPOINT_INCLUDE_FILE) +#undef __get_dynamic_len + /* * Stage 8 of the trace events. * diff --git a/tests/hello/hello.c b/tests/hello/hello.c index 469561c..0725163 100644 --- a/tests/hello/hello.c +++ b/tests/hello/hello.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "ust_tests_hello.h" @@ -64,6 +65,7 @@ int main(int argc, char **argv) { int i; long values[] = { 1, 2, 3 }; + char text[10] = "test"; init_int_handler(); @@ -72,7 +74,8 @@ int main(int argc, char **argv) sleep(1); for (i = 0; i < 50; i++) { - tracepoint(ust_tests_hello_tptest, i, values); + tracepoint(ust_tests_hello_tptest, i, values, + text, strlen(text)); usleep(100000); } return 0; diff --git a/tests/hello/ust_tests_hello.h b/tests/hello/ust_tests_hello.h index 6d19ab6..9ee132b 100644 --- a/tests/hello/ust_tests_hello.h +++ b/tests/hello/ust_tests_hello.h @@ -25,14 +25,21 @@ #include TRACEPOINT_EVENT(ust_tests_hello_tptest, - TP_PROTO(int anint, long *values), - TP_ARGS(anint, values), + TP_PROTO(int anint, long *values, + char *text, size_t textlen), + TP_ARGS(anint, values, text, textlen), TP_FIELDS( ctf_integer(int, intfield, anint) ctf_integer_hex(int, intfield2, anint) ctf_integer_network(int, intfield3, anint) ctf_integer_network_hex(int, intfield4, anint) ctf_array(long, arrfield1, values, 3) + ctf_array_text(char, arrfield2, text, 10) + ctf_sequence(char, seqfield1, text, + size_t, textlen) + ctf_sequence_text(char, seqfield2, text, + size_t, textlen) + ctf_string(stringfield, text) )) TRACEPOINT_EVENT_NOARGS(ust_tests_hello_tptest_sighandler,