From f3ec4cb5bbc1a7bf860207a3e080f4f3eb7dbab0 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 6 May 2016 16:09:57 -0400 Subject: [PATCH] Tracepoint: add ctf array for network byte order integers Signed-off-by: Mathieu Desnoyers --- include/lttng/ust-tracepoint-event-nowrite.h | 4 ++-- include/lttng/ust-tracepoint-event-reset.h | 4 ++-- include/lttng/ust-tracepoint-event-write.h | 21 ++++++++++++++++++-- include/lttng/ust-tracepoint-event.h | 18 +++++++++++------ tests/hello/ust_tests_hello.h | 5 +++++ 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/include/lttng/ust-tracepoint-event-nowrite.h b/include/lttng/ust-tracepoint-event-nowrite.h index 83a9c93e..c0b42665 100644 --- a/include/lttng/ust-tracepoint-event-nowrite.h +++ b/include/lttng/ust-tracepoint-event-nowrite.h @@ -30,11 +30,11 @@ #undef ctf_array_nowrite #define ctf_array_nowrite(_type, _item, _src, _length) \ - _ctf_array_encoded(_type, _item, _src, _length, none, 1) + _ctf_array_encoded(_type, _item, _src, BYTE_ORDER, _length, none, 1, 10) #undef ctf_array_text_nowrite #define ctf_array_text_nowrite(_type, _item, _src, _length) \ - _ctf_array_encoded(_type, _item, _src, _length, UTF8, 1) + _ctf_array_encoded(_type, _item, _src, BYTE_ORDER, _length, UTF8, 1, 10) #undef ctf_sequence_nowrite #define ctf_sequence_nowrite(_type, _item, _src, _length_type, _src_length) \ diff --git a/include/lttng/ust-tracepoint-event-reset.h b/include/lttng/ust-tracepoint-event-reset.h index 7852bd8b..a89e6efa 100644 --- a/include/lttng/ust-tracepoint-event-reset.h +++ b/include/lttng/ust-tracepoint-event-reset.h @@ -54,8 +54,8 @@ #define _ctf_float(_type, _item, _src, _nowrite) #undef _ctf_array_encoded -#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, \ - _nowrite) +#define _ctf_array_encoded(_type, _item, _src, _byte_order, _length, _encoding, \ + _nowrite, _elem_type_base) #undef _ctf_sequence_encoded #define _ctf_sequence_encoded(_type, _item, _src, _byte_order, _length_type, \ diff --git a/include/lttng/ust-tracepoint-event-write.h b/include/lttng/ust-tracepoint-event-write.h index faf26e2c..0d4cf684 100644 --- a/include/lttng/ust-tracepoint-event-write.h +++ b/include/lttng/ust-tracepoint-event-write.h @@ -42,11 +42,28 @@ #undef ctf_array #define ctf_array(_type, _item, _src, _length) \ - _ctf_array_encoded(_type, _item, _src, _length, none, 0) + _ctf_array_encoded(_type, _item, _src, BYTE_ORDER, \ + _length, none, 0, 10) + +#undef ctf_array_hex +#define ctf_array_hex(_type, _item, _src, _length) \ + _ctf_array_encoded(_type, _item, _src, BYTE_ORDER, \ + _length, none, 0, 16) + +#undef ctf_array_network +#define ctf_array_network(_type, _item, _src, _length) \ + _ctf_array_encoded(_type, _item, _src, BIG_ENDIAN, \ + _length, none, 0, 10) + +#undef ctf_array_network_hex +#define ctf_array_network_hex(_type, _item, _src, _length) \ + _ctf_array_encoded(_type, _item, _src, BIG_ENDIAN, \ + _length, none, 0, 16) #undef ctf_array_text #define ctf_array_text(_type, _item, _src, _length) \ - _ctf_array_encoded(_type, _item, _src, _length, UTF8, 0) + _ctf_array_encoded(_type, _item, _src, BYTE_ORDER, \ + _length, UTF8, 0, 10) #undef ctf_sequence #define ctf_sequence(_type, _item, _src, _length_type, _src_length) \ diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 2b599a88..64c45357 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -202,7 +202,9 @@ static const char \ }, #undef _ctf_array_encoded -#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \ +#define _ctf_array_encoded(_type, _item, _src, _byte_order, \ + _length, _encoding, _nowrite, \ + _elem_type_base) \ { \ .name = #_item, \ .type = \ @@ -212,7 +214,7 @@ static const char \ { \ .array = \ { \ - .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \ + .elem_type = __type_integer(_type, _byte_order, _elem_type_base, _encoding), \ .length = _length, \ } \ } \ @@ -339,7 +341,8 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)); __event_len += sizeof(_type); #undef _ctf_array_encoded -#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \ +#define _ctf_array_encoded(_type, _item, _src, _byte_order, _length, _encoding, \ + _nowrite, _elem_type_base) \ __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ __event_len += sizeof(_type) * (_length); @@ -486,7 +489,8 @@ size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS } #undef _ctf_array_encoded -#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \ +#define _ctf_array_encoded(_type, _item, _src, _byte_order, _length, \ + _encoding, _nowrite, _elem_type_base) \ { \ unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \ const void *__ctf_tmp_ptr = (_src); \ @@ -557,7 +561,8 @@ void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\ __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); #undef _ctf_array_encoded -#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \ +#define _ctf_array_encoded(_type, _item, _src, _byte_order, _length, \ + _encoding, _nowrite, _elem_type_base) \ __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); #undef _ctf_sequence_encoded @@ -622,7 +627,8 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \ } #undef _ctf_array_encoded -#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \ +#define _ctf_array_encoded(_type, _item, _src, _byte_order, _length, \ + _encoding, _nowrite, _elem_type_base) \ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); diff --git a/tests/hello/ust_tests_hello.h b/tests/hello/ust_tests_hello.h index 84a799a0..ec5c00cd 100644 --- a/tests/hello/ust_tests_hello.h +++ b/tests/hello/ust_tests_hello.h @@ -41,9 +41,14 @@ TRACEPOINT_EVENT(ust_tests_hello, tptest, ctf_integer_network(int, netintfield, netint) ctf_integer_network_hex(int, netintfieldhex, netint) ctf_array(long, arrfield1, values, 3) + ctf_array_hex(long, arrfield1_hex, values, 3) + ctf_array_network(long, arrfield1_network, values, 3) + ctf_array_network_hex(long, arrfield1_network_hex, values, 3) ctf_array_text(char, arrfield2, text, 10) ctf_sequence(char, seqfield1, text, size_t, textlen) + ctf_sequence_hex(char, seqfield1_hex, text, + size_t, textlen) ctf_sequence_text(char, seqfield2, text, size_t, textlen) ctf_sequence_network(long, seqfield_network_3, values, -- 2.34.1