test and fix array, sequence, string
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 11 Aug 2011 23:46:24 +0000 (19:46 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 11 Aug 2011 23:46:24 +0000 (19:46 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/ust/lttng-tracepoint-event.h
tests/hello/hello.c
tests/hello/ust_tests_hello.h

index 010a54dc01565c71594a8e69118c647ee5438904..a83cc545e2d8522db2a3213a1062dc6753ff4d71 100644 (file)
@@ -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.
  *
index 469561cc5641462dbb2066ff245939b9a14bb9f9..0725163645e0e12757db364b9383d1590fb23607 100644 (file)
@@ -25,6 +25,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <signal.h>
+#include <string.h>
 
 #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;
index 6d19ab6eb6de3dcc832c53ebeced68360894baaa..9ee132b7f6ffed2266219be834851a03c41b0632 100644 (file)
 #include <ust/tracepoint.h>
 
 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,
This page took 0.027342 seconds and 4 git commands to generate.