From 180901e6c233d9a352ab4ba5f31ddae460017774 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 7 Sep 2012 15:19:45 -0400 Subject: [PATCH] Fix: backward compatibility with UST 2.0 app probes Signed-off-by: Mathieu Desnoyers --- include/lttng/ringbuffer-config.h | 4 ++ include/lttng/ust-abi.h | 2 +- include/lttng/ust-events.h | 35 ++++++++++-- include/lttng/ust-tracepoint-event-nowrite.h | 14 ++--- include/lttng/ust-tracepoint-event-reset.h | 10 ++-- include/lttng/ust-tracepoint-event-write.h | 20 +++---- include/lttng/ust-tracepoint-event.h | 60 ++++++++++---------- liblttng-ust/ltt-events.c | 2 +- liblttng-ust/ltt-probes.c | 2 +- 9 files changed, 90 insertions(+), 59 deletions(-) diff --git a/include/lttng/ringbuffer-config.h b/include/lttng/ringbuffer-config.h index 650b56b2..174906cb 100644 --- a/include/lttng/ringbuffer-config.h +++ b/include/lttng/ringbuffer-config.h @@ -188,6 +188,10 @@ struct lttng_ust_lib_ring_buffer_config { * Context passed to lib_ring_buffer_reserve(), lib_ring_buffer_commit(), * lib_ring_buffer_try_discard_reserve(), lib_ring_buffer_align_ctx() and * lib_ring_buffer_write(). + * + * IMPORTANT: this structure is part of the ABI between the probe and + * UST. Fields need to be only added at the end, never reordered, never + * removed. */ #define LTTNG_UST_RING_BUFFER_CTX_PADDING 24 struct lttng_ust_lib_ring_buffer_ctx { diff --git a/include/lttng/ust-abi.h b/include/lttng/ust-abi.h index 91639a7c..c9be4bd9 100644 --- a/include/lttng/ust-abi.h +++ b/include/lttng/ust-abi.h @@ -105,7 +105,7 @@ struct lttng_ust_field_iter { char field_name[LTTNG_UST_SYM_NAME_LEN]; enum lttng_ust_field_type type; int loglevel; /* event loglevel */ - int written; + int nowrite; char padding[LTTNG_UST_FIELD_ITER_PADDING]; }; diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index 8a2fa14c..daf58902 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -179,13 +179,19 @@ struct lttng_enum { char padding[LTTNG_UST_ENUM_TYPE_PADDING]; }; -/* Event field description */ +/* + * Event field description + * + * IMPORTANT: this structure is part of the ABI between the probe and + * UST. Fields need to be only added at the end, never reordered, never + * removed. + */ #define LTTNG_UST_EVENT_FIELD_PADDING 28 struct lttng_event_field { const char *name; struct lttng_type type; - unsigned int written; /* written into trace */ + unsigned int nowrite; /* do not write into trace */ char padding[LTTNG_UST_EVENT_FIELD_PADDING]; }; @@ -291,14 +297,18 @@ struct lttng_ust_filter_bytecode; /* * ltt_event structure is referred to by the tracing fast path. It must be * kept small. + * + * IMPORTANT: this structure is part of the ABI between the probe and + * UST. Fields need to be only added at the end, never reordered, never + * removed. */ struct ltt_event { + /* LTTng-UST 2.0 starts here */ unsigned int id; struct ltt_channel *chan; int enabled; const struct lttng_event_desc *desc; int (*filter)(void *filter_data, const char *filter_stack_data); - void *filter_data; struct lttng_ctx *ctx; enum lttng_ust_instrumentation instrumentation; union { @@ -306,13 +316,20 @@ struct ltt_event { struct cds_list_head list; /* Event list */ struct cds_list_head wildcard_list; /* Event list for wildcard */ struct ust_pending_probe *pending_probe; - struct lttng_ust_filter_bytecode *filter_bytecode; unsigned int metadata_dumped:1; + /* LTTng-UST 2.1 starts here */ + struct lttng_ust_filter_bytecode *filter_bytecode; + void *filter_data; }; struct channel; struct lttng_ust_shm_handle; +/* + * IMPORTANT: this structure is part of the ABI between the probe and + * UST. Fields need to be only added at the end, never reordered, never + * removed. + */ struct ltt_channel_ops { struct ltt_channel *(*channel_create)(const char *name, void *buf_addr, @@ -348,6 +365,11 @@ struct ltt_channel_ops { int (*flush_buffer)(struct channel *chan, struct lttng_ust_shm_handle *handle); }; +/* + * IMPORTANT: this structure is part of the ABI between the probe and + * UST. Fields need to be only added at the end, never reordered, never + * removed. + */ struct ltt_channel { /* * The pointers located in this private data are NOT safe to be @@ -375,6 +397,11 @@ struct ltt_channel { unsigned char uuid[LTTNG_UST_UUID_LEN]; /* Trace session unique ID */ }; +/* + * IMPORTANT: this structure is part of the ABI between the probe and + * UST. Fields need to be only added at the end, never reordered, never + * removed. + */ struct ltt_session { int active; /* Is trace session active ? */ int been_active; /* Has trace session been active ? */ diff --git a/include/lttng/ust-tracepoint-event-nowrite.h b/include/lttng/ust-tracepoint-event-nowrite.h index 2b23a81d..bd7c5752 100644 --- a/include/lttng/ust-tracepoint-event-nowrite.h +++ b/include/lttng/ust-tracepoint-event-nowrite.h @@ -14,30 +14,30 @@ #undef ctf_integer_nowrite #define ctf_integer_nowrite(_type, _item, _src) \ - _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10, 0) + _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10, 1) #undef ctf_float_nowrite #define ctf_float_nowrite(_type, _item, _src) \ - _ctf_float(_type, _item, _src, 0) + _ctf_float(_type, _item, _src, 1) #undef ctf_array_nowrite #define ctf_array_nowrite(_type, _item, _src, _length) \ - _ctf_array_encoded(_type, _item, _src, _length, none, 0) + _ctf_array_encoded(_type, _item, _src, _length, none, 1) #undef ctf_array_text_nowrite #define ctf_array_text_nowrite(_type, _item, _src, _length) \ - _ctf_array_encoded(_type, _item, _src, _length, UTF8, 0) + _ctf_array_encoded(_type, _item, _src, _length, UTF8, 1) #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) + _length_type, _src_length, none, 1) #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) + _length_type, _src_length, UTF8, 1) #undef ctf_string_nowrite #define ctf_string_nowrite(_item, _src) \ - _ctf_string(_item, _src, 0) + _ctf_string(_item, _src, 1) diff --git a/include/lttng/ust-tracepoint-event-reset.h b/include/lttng/ust-tracepoint-event-reset.h index 25432fdc..e76072fc 100644 --- a/include/lttng/ust-tracepoint-event-reset.h +++ b/include/lttng/ust-tracepoint-event-reset.h @@ -34,21 +34,21 @@ #undef _ctf_integer_ext #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, \ - _written) + _nowrite) #undef _ctf_float -#define _ctf_float(_type, _item, _src, _written) +#define _ctf_float(_type, _item, _src, _nowrite) #undef _ctf_array_encoded #define _ctf_array_encoded(_type, _item, _src, _length, _encoding, \ - _written) + _nowrite) #undef _ctf_sequence_encoded #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ - _src_length, _encoding, _written) + _src_length, _encoding, _nowrite) #undef _ctf_string -#define _ctf_string(_item, _src, _written) +#define _ctf_string(_item, _src, _nowrite) /* "write" */ #undef ctf_integer diff --git a/include/lttng/ust-tracepoint-event-write.h b/include/lttng/ust-tracepoint-event-write.h index a23cab60..e0c6eed7 100644 --- a/include/lttng/ust-tracepoint-event-write.h +++ b/include/lttng/ust-tracepoint-event-write.h @@ -14,42 +14,42 @@ #undef ctf_integer #define ctf_integer(_type, _item, _src) \ - _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10, 1) + _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 10, 0) #undef ctf_integer_hex #define ctf_integer_hex(_type, _item, _src) \ - _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 16, 1) + _ctf_integer_ext(_type, _item, _src, BYTE_ORDER, 16, 0) #undef ctf_integer_network #define ctf_integer_network(_type, _item, _src) \ - _ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 10, 1) + _ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 10, 0) #undef ctf_integer_network_hex #define ctf_integer_network_hex(_type, _item, _src) \ - _ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 16, 1) + _ctf_integer_ext(_type, _item, _src, BIG_ENDIAN, 16, 0) #undef ctf_float #define ctf_float(_type, _item, _src) \ - _ctf_float(_type, _item, _src, 1) + _ctf_float(_type, _item, _src, 0) #undef ctf_array #define ctf_array(_type, _item, _src, _length) \ - _ctf_array_encoded(_type, _item, _src, _length, none, 1) + _ctf_array_encoded(_type, _item, _src, _length, none, 0) #undef ctf_array_text #define ctf_array_text(_type, _item, _src, _length) \ - _ctf_array_encoded(_type, _item, _src, _length, UTF8, 1) + _ctf_array_encoded(_type, _item, _src, _length, UTF8, 0) #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) + _length_type, _src_length, none, 0) #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) + _length_type, _src_length, UTF8, 0) #undef ctf_string #define ctf_string(_item, _src) \ - _ctf_string(_item, _src, 1) + _ctf_string(_item, _src, 0) diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 30414e81..aaba93ea 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -109,23 +109,23 @@ static const char \ #include #undef _ctf_integer_ext -#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _written) \ +#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \ { \ .name = #_item, \ .type = __type_integer(_type, _byte_order, _base, none),\ - .written = _written, \ + .nowrite = _nowrite, \ }, #undef _ctf_float -#define _ctf_float(_type, _item, _src, _written) \ +#define _ctf_float(_type, _item, _src, _nowrite) \ { \ .name = #_item, \ .type = __type_float(_type), \ - .written = _written, \ + .nowrite = _nowrite, \ }, #undef _ctf_array_encoded -#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _written) \ +#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \ { \ .name = #_item, \ .type = \ @@ -137,12 +137,12 @@ static const char \ .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \ }, \ }, \ - .written = _written, \ + .nowrite = _nowrite, \ }, #undef _ctf_sequence_encoded #define _ctf_sequence_encoded(_type, _item, _src, \ - _length_type, _src_length, _encoding, _written) \ + _length_type, _src_length, _encoding, _nowrite) \ { \ .name = #_item, \ .type = \ @@ -154,11 +154,11 @@ static const char \ .elem_type = __type_integer(_type, BYTE_ORDER, 10, _encoding), \ }, \ }, \ - .written = _written, \ + .nowrite = _nowrite, \ }, #undef _ctf_string -#define _ctf_string(_item, _src, _written) \ +#define _ctf_string(_item, _src, _nowrite) \ { \ .name = #_item, \ .type = \ @@ -166,7 +166,7 @@ static const char \ .atype = atype_string, \ .u.basic.string.encoding = lttng_encode_UTF8, \ }, \ - .written = _written, \ + .nowrite = _nowrite, \ }, #undef TP_FIELDS @@ -209,23 +209,23 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)); #include #undef _ctf_integer_ext -#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _written) \ +#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \ __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \ __event_len += sizeof(_type); #undef _ctf_float -#define _ctf_float(_type, _item, _src, _written) \ +#define _ctf_float(_type, _item, _src, _nowrite) \ __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, _written) \ +#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \ __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, _written) \ + _src_length, _encoding, _nowrite) \ __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)); \ @@ -234,7 +234,7 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)); __dynamic_len_idx++; #undef _ctf_string -#define _ctf_string(_item, _src, _written) \ +#define _ctf_string(_item, _src, _nowrite) \ __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1; #undef TP_ARGS @@ -274,7 +274,7 @@ size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS #include #undef _ctf_integer_ext -#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _written) \ +#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \ if (lttng_is_signed_type(_type)) { \ int64_t __ctf_tmp_int64 = (int64_t) (_type) (_src); \ memcpy(__stack_data, &__ctf_tmp_int64, sizeof(int64_t)); \ @@ -285,7 +285,7 @@ size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS __stack_data += sizeof(int64_t); #undef _ctf_float -#define _ctf_float(_type, _item, _src, _written) \ +#define _ctf_float(_type, _item, _src, _nowrite) \ { \ double __ctf_tmp_double = (double) (_type) (_src); \ memcpy(__stack_data, &__ctf_tmp_double, sizeof(double)); \ @@ -293,7 +293,7 @@ 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, _written) \ +#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \ { \ unsigned long __ctf_tmp_ulong = (unsigned long) (_length); \ memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \ @@ -304,7 +304,7 @@ size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS #undef _ctf_sequence_encoded #define _ctf_sequence_encoded(_type, _item, _src, _length_type, \ - _src_length, _encoding, _written) \ + _src_length, _encoding, _nowrite) \ { \ unsigned long __ctf_tmp_ulong = (unsigned long) (_src_length); \ memcpy(__stack_data, &__ctf_tmp_ulong, sizeof(unsigned long)); \ @@ -314,7 +314,7 @@ size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS } #undef _ctf_string -#define _ctf_string(_item, _src, _written) \ +#define _ctf_string(_item, _src, _nowrite) \ { \ memcpy(__stack_data, &(_src), sizeof(void **)); \ __stack_data += sizeof(void **); \ @@ -350,25 +350,25 @@ void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\ #include #undef _ctf_integer_ext -#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _written) \ +#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \ __event_align = _tp_max_t(size_t, __event_align, lttng_alignof(_type)); #undef _ctf_float -#define _ctf_float(_type, _item, _src, _written) \ +#define _ctf_float(_type, _item, _src, _nowrite) \ __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, _written) \ +#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \ __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, _written) \ + _src_length, _encoding, _nowrite) \ __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, _written) +#define _ctf_string(_item, _src, _nowrite) #undef TP_ARGS #define TP_ARGS(...) __VA_ARGS__ @@ -403,7 +403,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \ #include #undef _ctf_integer_ext -#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _written) \ +#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \ { \ _type __tmp = (_src); \ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\ @@ -411,7 +411,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \ } #undef _ctf_float -#define _ctf_float(_type, _item, _src, _written) \ +#define _ctf_float(_type, _item, _src, _nowrite) \ { \ _type __tmp = (_src); \ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));\ @@ -419,13 +419,13 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \ } #undef _ctf_array_encoded -#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _written) \ +#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _nowrite) \ 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, _written) \ + _src_length, _encoding, _nowrite) \ { \ _length_type __tmpl = __stackvar.__dynamic_len[__dynamic_len_idx]; \ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\ @@ -436,7 +436,7 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args)) \ sizeof(_type) * __get_dynamic_len(dest)); #undef _ctf_string -#define _ctf_string(_item, _src, _written) \ +#define _ctf_string(_item, _src, _nowrite) \ 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 fd70279a..ab099e1a 100644 --- a/liblttng-ust/ltt-events.c +++ b/liblttng-ust/ltt-events.c @@ -726,7 +726,7 @@ int _ltt_field_statedump(struct ltt_session *session, { int ret = 0; - if (!field->written) + if (field->nowrite) return 0; switch (field->type.atype) { diff --git a/liblttng-ust/ltt-probes.c b/liblttng-ust/ltt-probes.c index 884a9740..1e1407e6 100644 --- a/liblttng-ust/ltt-probes.c +++ b/liblttng-ust/ltt-probes.c @@ -296,7 +296,7 @@ int ltt_probes_get_field_list(struct lttng_ust_field_list *list) } else { list_entry->field.loglevel = *(*event_desc->loglevel); } - list_entry->field.written = event_field->written; + list_entry->field.nowrite = event_field->nowrite; } } } -- 2.34.1