From: Mathieu Desnoyers Date: Mon, 2 May 2016 16:33:13 +0000 (-0400) Subject: Implement custom field support X-Git-Tag: v2.9.0-rc1~75 X-Git-Url: http://git.liburcu.org/?p=lttng-modules.git;a=commitdiff_plain;h=f64dd4be1e73872c4eebe25f37b96e2a03de079b Implement custom field support Signed-off-by: Mathieu Desnoyers --- diff --git a/lttng-events.h b/lttng-events.h index 9d775d57..5d0ef4dc 100644 --- a/lttng-events.h +++ b/lttng-events.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include diff --git a/probes/lttng-events-reset.h b/probes/lttng-events-reset.h index 8262d83e..3b39233c 100644 --- a/probes/lttng-events-reset.h +++ b/probes/lttng-events-reset.h @@ -130,6 +130,18 @@ #undef ctf_string #define ctf_string(_item, _src) +#undef ctf_custom_field +#define ctf_custom_field(_type, _item, _code) + +#undef ctf_custom_type +#define ctf_custom_type(...) + +#undef ctf_custom_code +#define ctf_custom_code(...) + +#undef ctf_align +#define ctf_align(_type) + /* "nowrite" */ #undef ctf_integer_nowrite #define ctf_integer_nowrite(_type, _item, _src) diff --git a/probes/lttng-events-write.h b/probes/lttng-events-write.h index 19041e5d..a1f25237 100644 --- a/probes/lttng-events-write.h +++ b/probes/lttng-events-write.h @@ -131,3 +131,117 @@ #undef ctf_user_string #define ctf_user_string(_item, _src) \ _ctf_string(_item, _src, 1, 0) + +/* types */ +#undef ctf_integer_type +#define ctf_integer_type(_type, _src) \ + ctf_integer(_type, unused, _src) + +#undef ctf_integer_hex_type +#define ctf_integer_hex_type(_type, _src) \ + ctf_integer_hex(_type, unused, _src) + +#undef ctf_integer_oct_type +#define ctf_integer_oct_type(_type, _item, _src) \ + ctf_integer_oct(_type, unused, _src) + +#undef ctf_integer_network_type +#define ctf_integer_network_type(_type, _src) \ + ctf_integer_network(_type, unused, _src) + +#undef ctf_integer_network_hex_type +#define ctf_integer_network_hex_type(_type, _src) \ + ctf_integer_network_hex(_type, unused, _src) + +#undef ctf_array_type +#define ctf_array_type(_type, _src, _length) \ + ctf_array(_type, unused, _src, _length) + +#undef ctf_array_text_type +#define ctf_array_text_type(_type, _src, _length) \ + ctf_array_text(_type, unused, _src, _length) + +#undef ctf_array_bitfield_type +#define ctf_array_bitfield_type(_type, _src, _length) \ + ctf_array_bitfield(_type, unused, _src, _length) + +#undef ctf_sequence_type +#define ctf_sequence_type(_type, _src, _length_type, _src_length) \ + ctf_sequence(_type, unused, _src, _length_type, _src_length) + +#undef ctf_sequence_hex_type +#define ctf_sequence_hex_type(_type, _src, _length_type, _src_length) \ + ctf_sequence_hex(_type, unused, _src, _length_type, _src_length) + +#undef ctf_sequence_network_type +#define ctf_sequence_network_type(_type, _src, _length_type, _src_length) \ + ctf_sequence_network(_type, unused, _src, _length_type, _src_length) + +#undef ctf_sequence_text_type +#define ctf_sequence_text_type(_type, _src, _length_type, _src_length) \ + ctf_sequence_text(_type, unused, _src, _length_type, _src_length) + +#undef ctf_sequence_bitfield_type +#define ctf_sequence_bitfield_type(_type, _src, _length_type, _src_length) \ + ctf_sequence_bitfield(_type, unused, _src, _length_type, _src_length) + +#undef ctf_string_type +#define ctf_string_type(_src) \ + ctf_string(unused, _src) + +/* user src types */ +#undef ctf_user_integer_type +#define ctf_user_integer_type(_type, _src) \ + ctf_user_integer(_type, unused, _src) + +#undef ctf_user_integer_hex_type +#define ctf_user_integer_hex_type(_type, _src) \ + ctf_user_integer_hex(_type, unused, _src) + +#undef ctf_user_integer_oct_type +#define ctf_user_integer_oct_type(_type, _item, _src) \ + ctf_user_integer_oct(_type, unused, _src) + +#undef ctf_user_integer_network_type +#define ctf_user_integer_network_type(_type, _src) \ + ctf_user_integer_network(_type, unused, _src) + +#undef ctf_user_integer_network_hex_type +#define ctf_user_integer_network_hex_type(_type, _src) \ + ctf_user_integer_network_hex(_type, unused, _src) + +#undef ctf_user_array_type +#define ctf_user_array_type(_type, _src, _length) \ + ctf_user_array(_type, unused, _src, _length) + +#undef ctf_user_array_text_type +#define ctf_user_array_text_type(_type, _src, _length) \ + ctf_user_array_text(_type, unused, _src, _length) + +#undef ctf_user_array_bitfield_type +#define ctf_user_array_bitfield_type(_type, _src, _length) \ + ctf_user_array_bitfield(_type, unused, _src, _length) + +#undef ctf_user_sequence_type +#define ctf_user_sequence_type(_type, _src, _length_type, _src_length) \ + ctf_user_sequence(_type, unused, _src, _length_type, _src_length) + +#undef ctf_user_sequence_hex_type +#define ctf_user_sequence_hex_type(_type, _src, _length_type, _src_length) \ + ctf_user_sequence_hex(_type, unused, _src, _length_type, _src_length) + +#undef ctf_user_sequence_network_type +#define ctf_user_sequence_network_type(_type, _src, _length_type, _src_length) \ + ctf_user_sequence_network(_type, unused, _src, _length_type, _src_length) + +#undef ctf_user_sequence_text_type +#define ctf_user_sequence_text_type(_type, _src, _length_type, _src_length) \ + ctf_user_sequence_text(_type, unused, _src, _length_type, _src_length) + +#undef ctf_user_sequence_bitfield_type +#define ctf_user_sequence_bitfield_type(_type, _src, _length_type, _src_length) \ + ctf_user_sequence_bitfield(_type, unused, _src, _length_type, _src_length) + +#undef ctf_user_string_type +#define ctf_user_string_type(_src) \ + ctf_user_string(unused, _src) diff --git a/probes/lttng-tracepoint-event-impl.h b/probes/lttng-tracepoint-event-impl.h index 42a4be30..fbedea1c 100644 --- a/probes/lttng-tracepoint-event-impl.h +++ b/probes/lttng-tracepoint-event-impl.h @@ -303,6 +303,19 @@ void __event_template_proto___##_name(void); .user = _user, \ }, + +#undef ctf_custom_field +#define ctf_custom_field(_type, _item, _code) \ + { \ + .name = #_item, \ + .type = { _type }, \ + .nowrite = 0, \ + .user = 0, \ + }, + +#undef ctf_custom_type +#define ctf_custom_type(...) __VA_ARGS__ + #undef TP_FIELDS #define TP_FIELDS(...) __VA_ARGS__ /* Only one used in this phase */ @@ -404,6 +417,19 @@ static void __event_probe__##_name(void *__data); strlen(_src) + 1; \ } +#undef ctf_align +#define ctf_align(_type) \ + __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); + +#undef ctf_custom_field +#define ctf_custom_field(_type, _item, _code) \ + { \ + _code \ + } + +#undef ctf_custom_code +#define ctf_custom_code(...) __VA_ARGS__ + #undef TP_PROTO #define TP_PROTO(...) __VA_ARGS__ @@ -673,6 +699,10 @@ void __event_prepare_filter_stack__##_name(char *__stack_data, \ #undef _ctf_string #define _ctf_string(_item, _src, _user, _nowrite) +#undef ctf_align +#define ctf_align(_type) \ + __event_align = max_t(size_t, __event_align, lttng_alignof(_type)); + #undef TP_PROTO #define TP_PROTO(...) __VA_ARGS__ @@ -682,6 +712,15 @@ void __event_prepare_filter_stack__##_name(char *__stack_data, \ #undef TP_locvar #define TP_locvar(...) __VA_ARGS__ +#undef ctf_custom_field +#define ctf_custom_field(_type, _item, _code) _code + +#undef ctf_custom_code +#define ctf_custom_code(...) \ + { \ + __VA_ARGS__ \ + } + #undef LTTNG_TRACEPOINT_EVENT_CLASS_CODE #define LTTNG_TRACEPOINT_EVENT_CLASS_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \ static inline size_t __event_get_align__##_name(void *__tp_locvar, _proto) \ @@ -896,6 +935,20 @@ static inline size_t __event_get_align__##_name(void *__tp_locvar) \ __get_dynamic_len(dest)); \ } + +#undef ctf_align +#define ctf_align(_type) \ + lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); + +#undef ctf_custom_field +#define ctf_custom_field(_type, _item, _code) _code + +#undef ctf_custom_code +#define ctf_custom_code(...) \ + { \ + __VA_ARGS__ \ + } + /* Beware: this get len actually consumes the len value */ #undef __get_dynamic_len #define __get_dynamic_len(field) this_cpu_ptr(<tng_dynamic_len_stack)->stack[__dynamic_len_idx++]