+/*
+ * lttng-events.h
+ *
+ * Copyright (C) 2009 Steven Rostedt <rostedt@goodmis.org>
+ * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Dual LGPL v2.1/GPL v2 license.
+ */
+
#include <linux/debugfs.h>
#include "lttng.h"
#include "lttng-types.h"
/* Named field types must be defined in lttng-types.h */
-#undef __field
-#define __field(_type, _item) \
+#undef __field_full
+#define __field_full(_type, _item, _order, _base) \
{ \
.name = #_item, \
- .type = __type_integer(_type, __BYTE_ORDER, 10, none),\
+ .type = __type_integer(_type, _order, _base, none), \
},
+#undef __field
+#define __field(_type, _item) \
+ __field_full(_type, _item, __BYTE_ORDER, 10)
+
#undef __field_ext
-#define __field_ext(_type, _item, _filter_type) __field(_type, _item)
+#define __field_ext(_type, _item, _filter_type) \
+ __field(_type, _item)
#undef __field_network
#define __field_network(_type, _item) \
- { \
- .name = #_item, \
- .type = __type_integer(_type, __BIG_ENDIAN, 10, none),\
- },
+ __field_full(_type, _item, __BIG_ENDIAN, 10)
+
+#undef __field_network_hex
+#define __field_network_hex(_type, _item) \
+ __field_full(_type, _item, __BIG_ENDIAN, 16)
-#undef __array_enc
-#define __array_enc(_type, _item, _length, _encoding) \
+#undef __array_enc_ext
+#define __array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
{ \
.name = #_item, \
.type = \
.u.array = \
{ \
.length = _length, \
- .elem_type = __type_integer(_type, __BYTE_ORDER, 10, _encoding), \
+ .elem_type = __type_integer(_type, _order, _base, _encoding), \
}, \
}, \
},
#undef __array
#define __array(_type, _item, _length) \
- __array_enc(_type, _item, _length, none)
+ __array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, none)
#undef __array_text
#define __array_text(_type, _item, _length) \
- __array_enc(_type, _item, _length, UTF8)
+ __array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, UTF8)
-#undef __dynamic_array_enc
-#define __dynamic_array_enc(_type, _item, _length, _encoding) \
+#undef __array_hex
+#define __array_hex(_type, _item, _length) \
+ __array_enc_ext(_type, _item, _length, __BYTE_ORDER, 16, none)
+
+#undef __dynamic_array_enc_ext
+#define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding) \
{ \
.name = #_item, \
.type = \
.u.sequence = \
{ \
.length_type = __type_integer(u32, __BYTE_ORDER, 10, none), \
- .elem_type = __type_integer(_type, __BYTE_ORDER, 10, _encoding), \
+ .elem_type = __type_integer(_type, _order, _base, _encoding), \
}, \
}, \
},
#undef __dynamic_array
#define __dynamic_array(_type, _item, _length) \
- __dynamic_array_enc(_type, _item, _length, none)
+ __dynamic_array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, none)
#undef __dynamic_array_text
#define __dynamic_array_text(_type, _item, _length) \
- __dynamic_array_enc(_type, _item, _length, UTF8)
+ __dynamic_array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, UTF8)
+
+#undef __dynamic_array_hex
+#define __dynamic_array_hex(_type, _item, _length) \
+ __dynamic_array_enc_ext(_type, _item, _length, __BYTE_ORDER, 16, none)
#undef __string
#define __string(_item, _src) \
/* Named field types must be defined in lttng-types.h */
-#undef __field
-#define __field(_type, _item) \
+#undef __field_full
+#define __field_full(_type, _item, _order, _base) \
__event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_type)); \
__event_len += sizeof(_type);
-#undef __field_ext
-#define __field_ext(_type, _item, _filter_type) __field(_type, _item)
-
-#undef __array
-#define __array(_type, _item, _length) \
+#undef __array_enc_ext
+#define __array_enc_ext(_type, _item, _length, _order, _base, _encoding) \
__event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_type)); \
__event_len += sizeof(_type) * (_length);
-#undef __array_text
-#define __array_text(_type, _item, _length) \
- __array(_type, _item, _length)
-
-#undef __dynamic_array
-#define __dynamic_array(_type, _item, _length) \
+#undef __dynamic_array_enc_ext
+#define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
__event_len += lib_ring_buffer_align(__event_len, ltt_alignof(u32)); \
__event_len += sizeof(u32); \
__event_len += lib_ring_buffer_align(__event_len, ltt_alignof(_type)); \
- __event_len += sizeof(_type) * (_length);
-
-#undef __dynamic_array_text
-#define __dynamic_array_text(_type, _item, _length) \
- __dynamic_array(_type, _item, _length)
+ __dynamic_len[__dynamic_len_idx] = (_length); \
+ __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \
+ __dynamic_len_idx++;
#undef __string
#define __string(_item, _src) \
/* Named field types must be defined in lttng-types.h */
-#undef __field
-#define __field(_type, _item) \
+#undef __field_full
+#define __field_full(_type, _item, _order, _base) \
__event_align = max_t(size_t, __event_align, ltt_alignof(_type));
-#undef __field_ext
-#define __field_ext(_type, _item, _filter_type) __field(_type, _item)
-
-#undef __array
-#define __array(_type, _item, _length) \
+#undef __array_enc_ext
+#define __array_enc_ext(_type, _item, _length, _order, _base, _encoding) \
__event_align = max_t(size_t, __event_align, ltt_alignof(_type));
-#undef __array_text
-#define __array_text(_type, _item, _length) \
- __array(_type, _item, _length)
-
-#undef __dynamic_array
-#define __dynamic_array(_type, _item, _length) \
+#undef __dynamic_array_enc_ext
+#define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
__event_align = max_t(size_t, __event_align, ltt_alignof(u32)); \
__event_align = max_t(size_t, __event_align, ltt_alignof(_type));
-#undef __dynamic_array_text
-#define __dynamic_array_text(_type, _item, _length) \
- __dynamic_array(_type, _item, _length)
-
#undef __string
#define __string(_item, _src)
/* Named field types must be defined in lttng-types.h */
-#undef __field
-#define __field(_type, _item) _type _item;
-
-#undef __field_ext
-#define __field_ext(_type, _item, _filter_type) __field(_type, _item)
+#undef __field_full
+#define __field_full(_type, _item, _order, _base) _type _item;
-#undef __array
-#define __array(_type, _item, _length) _type _item;
+#undef __array_enc_ext
+#define __array_enc_ext(_type, _item, _length, _order, _base, _encoding) \
+ _type _item;
-#undef __array_text
-#define __array_text(_type, _item, _length) \
- __array(_type, _item, _length)
-
-#undef __dynamic_array
-#define __dynamic_array(_type, _item, _length) _type _item;
-
-#undef __dynamic_array_text
-#define __dynamic_array_text(_type, _item, _length) \
- __dynamic_array(_type, _item, _length)
+#undef __dynamic_array_enc_ext
+#define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
+ _type _item;
#undef __string
#define __string(_item, _src) char _item;
#include "lttng-events-reset.h" /* Reset all macros within TRACE_EVENT */
-#undef __field
-#define __field(_type, _item) \
+#undef __field_full
+#define __field_full(_type, _item, _order, _base) \
goto __assign_##_item; \
__end_field_##_item:
-#undef __field_ext
-#define __field_ext(_type, _item, _filter_type) __field(_type, _item)
-
-#undef __array
-#define __array(_type, _item, _length) \
+#undef __array_enc_ext
+#define __array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
goto __assign_##_item; \
__end_field_##_item:
-#undef __array_text
-#define __array_text(_type, _item, _length) \
- __array(_type, _item, _length)
-
-#undef __dynamic_array
-#define __dynamic_array(_type, _item, _length) \
+#undef __dynamic_array_enc_ext
+#define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
goto __assign_##_item##_1; \
__end_field_##_item##_1: \
goto __assign_##_item##_2; \
__end_field_##_item##_2:
-#undef __dynamic_array_text
-#define __dynamic_array_text(_type, _item, _length) \
- __dynamic_array(_type, _item, _length)
-
#undef __string
#define __string(_item, _src) \
goto __assign_##_item; \
__assign_##dest: \
{ \
__typeof__(__typemap.dest) __tmp = (src); \
- lib_ring_buffer_align_ctx(&ctx, ltt_alignof(__tmp)); \
- __chan->ops->event_write(&ctx, &__tmp, sizeof(__tmp)); \
+ lib_ring_buffer_align_ctx(&__ctx, ltt_alignof(__tmp)); \
+ __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
} \
goto __end_field_##dest;
__assign_##dest: \
if (0) \
(void) __typemap.dest; \
- lib_ring_buffer_align_ctx(&ctx, ltt_alignof(__typemap.dest)); \
- __chan->ops->event_write(&ctx, src, len); \
+ lib_ring_buffer_align_ctx(&__ctx, ltt_alignof(__typemap.dest)); \
+ __chan->ops->event_write(&__ctx, src, len); \
goto __end_field_##dest;
#undef tp_memcpy_dyn
-#define tp_memcpy_dyn(dest, src, len) \
+#define tp_memcpy_dyn(dest, src) \
__assign_##dest##_1: \
{ \
- u32 __tmpl = (len); \
- lib_ring_buffer_align_ctx(&ctx, ltt_alignof(u32)); \
- __chan->ops->event_write(&ctx, &__tmpl, sizeof(u32)); \
+ u32 __tmpl = __dynamic_len[__dynamic_len_idx]; \
+ lib_ring_buffer_align_ctx(&__ctx, ltt_alignof(u32)); \
+ __chan->ops->event_write(&__ctx, &__tmpl, sizeof(u32)); \
} \
goto __end_field_##dest##_1; \
__assign_##dest##_2: \
- lib_ring_buffer_align_ctx(&ctx, ltt_alignof(__typemap.dest)); \
- __chan->ops->event_write(&ctx, src, len); \
+ lib_ring_buffer_align_ctx(&__ctx, ltt_alignof(__typemap.dest)); \
+ __chan->ops->event_write(&__ctx, src, \
+ sizeof(__typemap.dest) * __get_dynamic_array_len(dest));\
goto __end_field_##dest##_2;
#undef tp_strcpy
{ \
struct ltt_event *__event = __data; \
struct ltt_channel *__chan = __event->chan; \
- struct lib_ring_buffer_ctx ctx; \
+ struct lib_ring_buffer_ctx __ctx; \
size_t __event_len, __event_align; \
size_t __dynamic_len_idx = 0; \
size_t __dynamic_len[ARRAY_SIZE(__event_fields___##_name)]; \
\
if (0) \
(void) __dynamic_len_idx; /* don't warn if unused */ \
- if (!ACCESS_ONCE(__chan->session->active)) \
+ if (unlikely(!ACCESS_ONCE(__chan->session->active))) \
+ return; \
+ if (unlikely(!ACCESS_ONCE(__chan->enabled))) \
+ return; \
+ if (unlikely(!ACCESS_ONCE(__event->enabled))) \
return; \
__event_len = __event_get_size__##_name(__dynamic_len, _args); \
__event_align = __event_get_align__##_name(_args); \
- lib_ring_buffer_ctx_init(&ctx, __chan->chan, NULL, __event_len, \
+ lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len, \
__event_align, -1); \
- __ret = __chan->ops->event_reserve(&ctx, __event->id); \
+ __ret = __chan->ops->event_reserve(&__ctx, __event->id); \
if (__ret < 0) \
return; \
/* Control code (field ordering) */ \
_tstruct \
- __chan->ops->event_commit(&ctx); \
+ __chan->ops->event_commit(&__ctx); \
return; \
/* Copy code, steered by control code */ \
_assign \