From: Mathieu Desnoyers Date: Fri, 13 Jul 2012 18:06:12 +0000 (-0400) Subject: TRACEPOINT_EVENT: add *_nowrite fields for filter X-Git-Tag: v2.1.0-rc1~43 X-Git-Url: http://git.liburcu.org/?p=lttng-ust.git;a=commitdiff_plain;h=4774c8f387042911d3256d29a06cfdbb8091bb10 TRACEPOINT_EVENT: add *_nowrite fields for filter Signed-off-by: Mathieu Desnoyers --- diff --git a/include/Makefile.am b/include/Makefile.am index 571e32f9..633260ba 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -5,6 +5,8 @@ nobase_include_HEADERS = \ lttng/tracepoint-event.h \ lttng/ust-tracepoint-event.h \ lttng/ust-tracepoint-event-reset.h \ + lttng/ust-tracepoint-event-write.h \ + lttng/ust-tracepoint-event-nowrite.h \ lttng/ust-events.h \ lttng/ust-ctl.h \ lttng/ust-version.h \ diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index 1e2b349f..8a2fa14c 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -181,10 +181,11 @@ struct lttng_enum { /* Event field description */ -#define LTTNG_UST_EVENT_FIELD_PADDING 32 +#define LTTNG_UST_EVENT_FIELD_PADDING 28 struct lttng_event_field { const char *name; struct lttng_type type; + unsigned int written; /* written into trace */ char padding[LTTNG_UST_EVENT_FIELD_PADDING]; }; diff --git a/include/lttng/ust-tracepoint-event-nowrite.h b/include/lttng/ust-tracepoint-event-nowrite.h new file mode 100644 index 00000000..7ddbc16e --- /dev/null +++ b/include/lttng/ust-tracepoint-event-nowrite.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011 - Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + */ + +#undef ctf_integer_nowrite +#define ctf_integer_nowrite(_type, _item, _src) \ + _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10, 0) + +#undef ctf_float_nowrite +#define ctf_float_nowrite(_type, _item, _src) \ + _ctf_float_nowrite(_type, _item, _src, 0) + +#undef ctf_array_nowrite +#define ctf_array_nowrite(_type, _item, _src, _length) \ + _ctf_array_encoded(_type, _item, _src, _length, none, 0) + +#undef ctf_array_text_nowrite +#define ctf_array_text_nowrite(_type, _item, _src, _length) \ + _ctf_array_encoded(_type, _item, _src, _length, UTF8, 0) + +#undef ctf_sequence_nowrite +#define ctf_sequence_nowrite(_type, _item, _src, _length_type, _src_length) \ + _ctf_sequence_encoded(_type, _item, _src, \ + _length_type, _src_length, none, 0) + +#undef ctf_sequence_text_nowrite +#define ctf_sequence_text_nowrite(_type, _item, _src, _length_type, _src_length) \ + _ctf_sequence_encoded(_type, _item, _src, \ + _length_type, _src_length, UTF8, 0) + +#undef ctf_string_nowrite +#define ctf_string_nowrite(_item, _src) \ + _ctf_string(_item, _src, 0) diff --git a/include/lttng/ust-tracepoint-event-reset.h b/include/lttng/ust-tracepoint-event-reset.h index 31a533d5..25432fdc 100644 --- a/include/lttng/ust-tracepoint-event-reset.h +++ b/include/lttng/ust-tracepoint-event-reset.h @@ -26,24 +26,79 @@ #undef TP_FIELDS #define TP_FIELDS(...) -#undef ctf_integer_ext -#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) +#undef TRACEPOINT_LOGLEVEL_ENUM +#define TRACEPOINT_LOGLEVEL_ENUM(...) + +#undef TRACEPOINT_LOGLEVEL +#define TRACEPOINT_LOGLEVEL(provider, name, loglevel) + +#undef _ctf_integer_ext +#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, \ + _written) + +#undef _ctf_float +#define _ctf_float(_type, _item, _src, _written) + +#undef _ctf_array_encoded +#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, \ + _written) + +#undef _ctf_sequence_encoded +#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ + _src_length, _encoding, _written) + +#undef _ctf_string +#define _ctf_string(_item, _src, _written) + +/* "write" */ +#undef ctf_integer +#define ctf_integer(_type, _item, _src) + +#undef ctf_integer_hex +#define ctf_integer_hex(_type, _item, _src) + +#undef ctf_integer_network +#define ctf_integer_network(_type, _item, _src) + +#undef ctf_integer_network_hex +#define ctf_integer_network_hex(_type, _item, _src) #undef ctf_float #define ctf_float(_type, _item, _src) -#undef ctf_array_encoded -#define ctf_array_encoded(_type, _item, _src, _length, _encoding) +#undef ctf_array +#define ctf_array(_type, _item, _src, _length) + +#undef ctf_array_text +#define ctf_array_text(_type, _item, _src, _length) + +#undef ctf_sequence +#define ctf_sequence(_type, _item, _src, _length_type, _src_length) -#undef ctf_sequence_encoded -#define ctf_sequence_encoded(_type, _item, _src, _length_type, \ - _src_length, _encoding) +#undef ctf_sequence_text +#define ctf_sequence_text(_type, _item, _src, _length_type, _src_length) #undef ctf_string #define ctf_string(_item, _src) -#undef TRACEPOINT_LOGLEVEL_ENUM -#define TRACEPOINT_LOGLEVEL_ENUM(...) +/* "nowrite" */ +#undef ctf_integer_nowrite +#define ctf_integer_nowrite(_type, _item, _src) -#undef TRACEPOINT_LOGLEVEL -#define TRACEPOINT_LOGLEVEL(provider, name, loglevel) +#undef ctf_float_nowrite +#define ctf_float_nowrite(_type, _item, _src) + +#undef ctf_array_nowrite +#define ctf_array_nowrite(_type, _item, _src, _length) + +#undef ctf_array_text_nowrite +#define ctf_array_text_nowrite(_type, _item, _src, _length) + +#undef ctf_sequence_nowrite +#define ctf_sequence_nowrite(_type, _item, _src, _length_type, _src_length) + +#undef ctf_sequence_text_nowrite +#define ctf_sequence_text_nowrite(_type, _item, _src, _length_type, _src_length) + +#undef ctf_string_nowrite +#define ctf_string_nowrite(_item, _src) diff --git a/include/lttng/ust-tracepoint-event-write.h b/include/lttng/ust-tracepoint-event-write.h new file mode 100644 index 00000000..a23cab60 --- /dev/null +++ b/include/lttng/ust-tracepoint-event-write.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2011 - Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + */ + +#undef ctf_integer +#define ctf_integer(_type, _item, _src) \ + _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10, 1) + +#undef ctf_integer_hex +#define ctf_integer_hex(_type, _item, _src) \ + _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 16, 1) + +#undef ctf_integer_network +#define ctf_integer_network(_type, _item, _src) \ + _ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 10, 1) + +#undef ctf_integer_network_hex +#define ctf_integer_network_hex(_type, _item, _src) \ + _ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 16, 1) + +#undef ctf_float +#define ctf_float(_type, _item, _src) \ + _ctf_float(_type, _item, _src, 1) + +#undef ctf_array +#define ctf_array(_type, _item, _src, _length) \ + _ctf_array_encoded(_type, _item, _src, _length, none, 1) + +#undef ctf_array_text +#define ctf_array_text(_type, _item, _src, _length) \ + _ctf_array_encoded(_type, _item, _src, _length, UTF8, 1) + +#undef ctf_sequence +#define ctf_sequence(_type, _item, _src, _length_type, _src_length) \ + _ctf_sequence_encoded(_type, _item, _src, \ + _length_type, _src_length, none, 1) + +#undef ctf_sequence_text +#define ctf_sequence_text(_type, _item, _src, _length_type, _src_length) \ + _ctf_sequence_encoded(_type, _item, _src, \ + _length_type, _src_length, UTF8, 1) + +#undef ctf_string +#define ctf_string(_item, _src) \ + _ctf_string(_item, _src, 1) diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 4130b7cb..8db1e688 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -18,48 +18,6 @@ #include #include -/* - * Macro declarations used for all stages. - */ - -#undef ctf_integer -#define ctf_integer(_type, _item, _src) \ - ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10) - -#undef ctf_integer_hex -#define ctf_integer_hex(_type, _item, _src) \ - ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 16) - -#undef ctf_integer_network -#define ctf_integer_network(_type, _item, _src) \ - ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 10) - -#undef ctf_integer_network_hex -#define ctf_integer_network_hex(_type, _item, _src) \ - ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 16) - -/* ctf_float is redefined at each step */ - -#undef ctf_array -#define ctf_array(_type, _item, _src, _length) \ - ctf_array_encoded(_type, _item, _src, _length, none) - -#undef ctf_array_text -#define ctf_array_text(_type, _item, _src, _length) \ - ctf_array_encoded(_type, _item, _src, _length, UTF8) - -#undef ctf_sequence -#define ctf_sequence(_type, _item, _src, _length_type, _src_length) \ - ctf_sequence_encoded(_type, _item, _src, \ - _length_type, _src_length, none) - -#undef ctf_sequence_text -#define ctf_sequence_text(_type, _item, _src, _length_type, _src_length) \ - ctf_sequence_encoded(_type, _item, _src, \ - _length_type, _src_length, UTF8) - -/* ctf_string is redefined at each step */ - /* * TRACEPOINT_EVENT_CLASS declares a class of tracepoints receiving the * same arguments and having the same field layout. @@ -146,23 +104,27 @@ static const char \ /* Reset all macros within TRACEPOINT_EVENT */ #include +#include +#include -#undef ctf_integer_ext -#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ +#undef _ctf_integer_ext +#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _written) \ { \ .name = #_item, \ .type = __type_integer(_type, _byte_order, _base, none),\ + .written = _written, \ }, -#undef ctf_float -#define ctf_float(_type, _item, _src) \ +#undef _ctf_float +#define _ctf_float(_type, _item, _src, _written) \ { \ .name = #_item, \ .type = __type_float(_type), \ + .written = _written, \ }, -#undef ctf_array_encoded -#define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ +#undef _ctf_array_encoded +#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _written) \ { \ .name = #_item, \ .type = \ @@ -174,11 +136,12 @@ static const char \ .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \ }, \ }, \ + .written = _written, \ }, -#undef ctf_sequence_encoded -#define ctf_sequence_encoded(_type, _item, _src, \ - _length_type, _src_length, _encoding) \ +#undef _ctf_sequence_encoded +#define _ctf_sequence_encoded(_type, _item, _src, \ + _length_type, _src_length, _encoding, _written) \ { \ .name = #_item, \ .type = \ @@ -190,10 +153,11 @@ static const char \ .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \ }, \ }, \ + .written = _written, \ }, -#undef ctf_string -#define ctf_string(_item, _src) \ +#undef _ctf_string +#define _ctf_string(_item, _src, _written) \ { \ .name = #_item, \ .type = \ @@ -201,6 +165,7 @@ static const char \ .atype = atype_string, \ .u.basic.string.encoding = lttng_encode_UTF8, \ }, \ + .written = _written, \ }, #undef TP_FIELDS @@ -240,25 +205,26 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)); /* Reset all macros within TRACEPOINT_EVENT */ #include +#include -#undef ctf_integer_ext -#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ +#undef _ctf_integer_ext +#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _written) \ __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ __event_len += sizeof(_type); -#undef ctf_float -#define ctf_float(_type, _item, _src) \ +#undef _ctf_float +#define _ctf_float(_type, _item, _src, _written) \ __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ __event_len += sizeof(_type); -#undef ctf_array_encoded -#define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ +#undef _ctf_array_encoded +#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _written) \ __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ __event_len += sizeof(_type) * (_length); -#undef ctf_sequence_encoded -#define ctf_sequence_encoded(_type, _item, _src, _length_type, \ - _src_length, _encoding) \ +#undef _ctf_sequence_encoded +#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ + _src_length, _encoding, _written) \ __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)); \ @@ -266,8 +232,8 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)); __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \ __dynamic_len_idx++; -#undef ctf_string -#define ctf_string(_item, _src) \ +#undef _ctf_string +#define _ctf_string(_item, _src, _written) \ __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1; #undef TP_ARGS @@ -295,41 +261,44 @@ static inline size_t __event_get_size__##_provider##___##_name(size_t *__dynamic * Stage 3.1 of tracepoint event generation. * * Create static inline function that layout the filter stack data. + * We make both write and nowrite data available to the filter. */ /* Reset all macros within TRACEPOINT_EVENT */ #include +#include +#include -#undef ctf_integer_ext -#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ +#undef _ctf_integer_ext +#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _written) \ if (lttng_is_signed_type(_type)) \ *(int64_t *) __stack_data = (int64_t) (_type) (_src); \ else \ *(uint64_t *) __stack_data = (uint64_t) (_type) (_src); \ __stack_data += sizeof(int64_t); -#undef ctf_float -#define ctf_float(_type, _item, _src) \ +#undef _ctf_float +#define _ctf_float(_type, _item, _src, _written) \ *(double *) __stack_data = (double) (_type) (_src); \ __stack_data += sizeof(double); -#undef ctf_array_encoded -#define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ +#undef _ctf_array_encoded +#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _written) \ *(unsigned long *) __stack_data = (unsigned long) (_length); \ __stack_data += sizeof(unsigned long); \ *(const void **) __stack_data = (_src); \ __stack_data += sizeof(void *); -#undef ctf_sequence_encoded -#define ctf_sequence_encoded(_type, _item, _src, _length_type, \ - _src_length, _encoding) \ +#undef _ctf_sequence_encoded +#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ + _src_length, _encoding, _written) \ *(unsigned long *) __stack_data = (unsigned long) (_src_length); \ __stack_data += sizeof(unsigned long); \ *(const void **) __stack_data = (_src); \ __stack_data += sizeof(void *); -#undef ctf_string -#define ctf_string(_item, _src) \ +#undef _ctf_string +#define _ctf_string(_item, _src, _written) \ *(const void **) __stack_data = (_src); \ __stack_data += sizeof(void *); @@ -360,27 +329,28 @@ void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\ /* Reset all macros within TRACEPOINT_EVENT */ #include +#include -#undef ctf_integer_ext -#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ +#undef _ctf_integer_ext +#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _written) \ __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); -#undef ctf_float -#define ctf_float(_type, _item, _src) \ +#undef _ctf_float +#define _ctf_float(_type, _item, _src, _written) \ __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) \ +#undef _ctf_array_encoded +#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _written) \ __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); -#undef ctf_sequence_encoded -#define ctf_sequence_encoded(_type, _item, _src, _length_type, \ - _src_length, _encoding) \ +#undef _ctf_sequence_encoded +#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ + _src_length, _encoding, _written) \ __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_length_type)); \ __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); -#undef ctf_string -#define ctf_string(_item, _src) +#undef _ctf_string +#define _ctf_string(_item, _src, _written) #undef TP_ARGS #define TP_ARGS(...) __VA_ARGS__ @@ -410,31 +380,32 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \ /* Reset all macros within TRACEPOINT_EVENT */ #include +#include -#undef ctf_integer_ext -#define ctf_integer_ext(_type, _item, _src, _byte_order, _base) \ +#undef _ctf_integer_ext +#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _written) \ { \ _type __tmp = (_src); \ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\ __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\ } -#undef ctf_float -#define ctf_float(_type, _item, _src) \ +#undef _ctf_float +#define _ctf_float(_type, _item, _src, _written) \ { \ _type __tmp = (_src); \ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\ __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\ } -#undef ctf_array_encoded -#define ctf_array_encoded(_type, _item, _src, _length, _encoding) \ +#undef _ctf_array_encoded +#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _written) \ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \ __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); -#undef ctf_sequence_encoded -#define ctf_sequence_encoded(_type, _item, _src, _length_type, \ - _src_length, _encoding) \ +#undef _ctf_sequence_encoded +#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ + _src_length, _encoding, _written) \ { \ _length_type __tmpl = __stackvar.__dynamic_len[__dynamic_len_idx]; \ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\ @@ -444,8 +415,8 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \ __chan->ops->event_write(&__ctx, _src, \ sizeof(_type) * __get_dynamic_len(dest)); -#undef ctf_string -#define ctf_string(_item, _src) \ +#undef _ctf_string +#define _ctf_string(_item, _src, _written) \ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \ __chan->ops->event_write(&__ctx, _src, __get_dynamic_len(dest)); diff --git a/liblttng-ust/ltt-events.c b/liblttng-ust/ltt-events.c index 120dffff..2bc5a159 100644 --- a/liblttng-ust/ltt-events.c +++ b/liblttng-ust/ltt-events.c @@ -726,6 +726,9 @@ int _ltt_field_statedump(struct ltt_session *session, { int ret = 0; + if (!field->written) + return 0; + switch (field->type.atype) { case atype_integer: ret = lttng_metadata_printf(session, diff --git a/tests/hello/ust_tests_hello.h b/tests/hello/ust_tests_hello.h index b06dea00..8ac681c2 100644 --- a/tests/hello/ust_tests_hello.h +++ b/tests/hello/ust_tests_hello.h @@ -46,6 +46,7 @@ TRACEPOINT_EVENT(ust_tests_hello, tptest, ctf_float(float, floatfield, floatarg) ctf_float(double, doublefield, doublearg) ctf_integer(bool, boolfield, boolarg) + ctf_integer_nowrite(int, filterfield, anint) ) )