ctf_sequence_text(char, seqfield2, text, size_t, textlen)
ctf_string(stringfield, text)
ctf_string(stringfield2, etext)
+ ctf_sequence_bitfield(long, bitfield_seq, values, uint8_t, 3)
+ ctf_array_bitfield(long, bitfield_array, values, 3)
)
)
const struct lttng_basic_type *elem_type;
elem_type = &field->type.u.array.elem_type;
+ if (field->type.u.array.elem_alignment) {
+ ret = lttng_metadata_printf(session,
+ " struct { } align(%u) _%s_padding;\n",
+ field->type.u.array.elem_alignment * CHAR_BIT,
+ field->name);
+ if (ret)
+ return ret;
+ }
ret = lttng_metadata_printf(session,
" integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s[%u];\n",
elem_type->u.basic.integer.size,
if (ret)
return ret;
+ if (field->type.u.sequence.elem_alignment) {
+ ret = lttng_metadata_printf(session,
+ " struct { } align(%u) _%s_padding;\n",
+ field->type.u.sequence.elem_alignment * CHAR_BIT,
+ field->name);
+ if (ret)
+ return ret;
+ }
ret = lttng_metadata_printf(session,
" integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s[ __%s_length ];\n",
elem_type->u.basic.integer.size,
const char *string;
};
-#define __type_integer(_type, _byte_order, _base, _encoding) \
+#define __type_integer(_type, _size, _alignment, _signedness, \
+ _byte_order, _base, _encoding) \
{ \
.atype = atype_integer, \
.u.basic.integer = \
{ \
- .size = sizeof(_type) * CHAR_BIT, \
- .alignment = lttng_alignof(_type) * CHAR_BIT, \
- .signedness = lttng_is_signed_type(_type), \
- .reverse_byte_order = _byte_order != __BYTE_ORDER, \
+ .size = (_size) ? : sizeof(_type) * CHAR_BIT, \
+ .alignment = (_alignment) ? : lttng_alignof(_type) * CHAR_BIT, \
+ .signedness = (_signedness) >= 0 ? (_signedness) : lttng_is_signed_type(_type), \
+ .reverse_byte_order = _byte_order != __BYTE_ORDER, \
.base = _base, \
.encoding = lttng_encode_##_encoding, \
}, \
struct {
struct lttng_basic_type elem_type;
unsigned int length; /* num. elems. */
+ unsigned int elem_alignment; /* alignment override */
} array;
struct {
struct lttng_basic_type length_type;
struct lttng_basic_type elem_type;
+ unsigned int elem_alignment; /* alignment override */
} sequence;
} u;
};
#define ctf_array_text_nowrite(_type, _item, _user_src, _length) \
_ctf_array_encoded(_type, _item, _user_src, _length, UTF8, 0, 1)
+#undef ctf_array_bitfield_nowrite
+#define ctf_array_bitfield_nowrite(_type, _item, _src, _length) \
+ _ctf_array_bitfield(_type, _item, _src, _length, 0, 1)
+
#undef ctf_sequence_nowrite
#define ctf_sequence_nowrite(_type, _item, _user_src, _length_type, _user_src_length) \
_ctf_sequence_encoded(_type, _item, _user_src, \
_ctf_sequence_encoded(_type, _item, _user_src, \
_length_type, _user_src_length, UTF8, __BYTE_ORDER, 10, 0, 1)
+#undef ctf_sequence_bitfield_nowrite
+#define ctf_sequence_bitfield_nowrite(_type, _item, _src, _length_type, _src_length) \
+ _ctf_sequence_bitfield(_type, _item, _src, \
+ _length_type, _src_length, 0, 1)
+
#undef ctf_string_nowrite
#define ctf_string_nowrite(_item, _user_src) \
_ctf_string(_item, _user_src, 0, 1)
#define ctf_user_array_text_nowrite(_type, _item, _user_src, _length) \
_ctf_array_encoded(_type, _item, _user_src, _length, UTF8, 1, 1)
+#undef ctf_user_array_bitfield_nowrite
+#define ctf_user_array_bitfield_nowrite(_type, _item, _src, _length) \
+ _ctf_array_bitfield(_type, _item, _src, _length, 1, 1)
+
#undef ctf_user_sequence_nowrite
#define ctf_user_sequence_nowrite(_type, _item, _user_src, _length_type, _user_src_length) \
_ctf_sequence_encoded(_type, _item, _user_src, \
_ctf_sequence_encoded(_type, _item, _user_src, \
_length_type, _user_src_length, UTF8, __BYTE_ORDER, 10, 1, 1)
+#undef ctf_user_sequence_bitfield_nowrite
+#define ctf_user_sequence_bitfield_nowrite(_type, _item, _src, _length_type, _src_length) \
+ _ctf_sequence_bitfield(_type, _item, _src, \
+ _length_type, _src_length, 1, 1)
+
#undef ctf_user_string_nowrite
#define ctf_user_string_nowrite(_item, _user_src) \
_ctf_string(_item, _user_src, 1, 1)
#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, \
_user, _nowrite)
+#undef _ctf_array_bitfield
+#define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite)
+
#undef _ctf_sequence_encoded
#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
_src_length, _encoding, _byte_order, _base, _user, _nowrite)
+#undef _ctf_sequence_bitfield
+#define _ctf_sequence_bitfield(_type, _item, _src, _length_type, \
+ _src_length, _byte_order, _user, _nowrite)
+
#undef _ctf_string
#define _ctf_string(_item, _src, _user, _nowrite)
#undef ctf_array_text
#define ctf_array_text(_type, _item, _src, _length)
+#undef ctf_array_bitfield
+#define ctf_array_bitfield(_type, _item, _src, _length)
+
#undef ctf_sequence
#define ctf_sequence(_type, _item, _src, _length_type, _src_length)
#undef ctf_sequence_text
#define ctf_sequence_text(_type, _item, _src, _length_type, _src_length)
+#undef ctf_sequence_bitfield
+#define ctf_sequence_bitfield(_type, _item, _src, _length_type, _src_length)
+
#undef ctf_string
#define ctf_string(_item, _src)
#undef ctf_array_text_nowrite
#define ctf_array_text_nowrite(_type, _item, _src, _length)
+#undef ctf_array_bitfield_nowrite
+#define ctf_array_bitfield_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_sequence_bitfield_nowrite
+#define ctf_sequence_bitfield_nowrite(_type, _item, _src, _length_type, _src_length)
+
#undef ctf_string_nowrite
#define ctf_string_nowrite(_item, _src)
#undef ctf_user_array_text
#define ctf_user_array_text(_type, _item, _user_src, _length)
+#undef ctf_user_array_bitfield
+#define ctf_user_array_bitfield(_type, _item, _src, _length)
+
#undef ctf_user_sequence
#define ctf_user_sequence(_type, _item, _user_src, _length_type, _user_src_length)
#undef ctf_user_sequence_text
#define ctf_user_sequence_text(_type, _item, _user_src, _length_type, _user_src_length)
+#undef ctf_user_sequence_bitfield
+#define ctf_user_sequence_bitfield(_type, _item, _src, _length_type, _src_length)
+
#undef ctf_user_string
#define ctf_user_string(_item, _user_src)
#undef ctf_user_array_text_nowrite
#define ctf_user_array_text_nowrite(_type, _item, _user_src, _length)
+#undef ctf_user_array_bitfield_nowrite
+#define ctf_user_array_bitfield_nowrite(_type, _item, _src, _length)
+
#undef ctf_user_sequence_nowrite
#define ctf_user_sequence_nowrite(_type, _item, _user_src, _length_type, _user_src_length)
#undef ctf_user_sequence_text_nowrite
#define ctf_user_sequence_text_nowrite(_type, _item, _user_src, _length_type, _user_src_length)
+#undef ctf_user_sequence_bitfield_nowrite
+#define ctf_user_sequence_bitfield_nowrite(_type, _item, _src, _length_type, _src_length)
+
#undef ctf_user_string_nowrite
#define ctf_user_string_nowrite(_item, _user_src)
#define ctf_array_text(_type, _item, _src, _length) \
_ctf_array_encoded(_type, _item, _src, _length, UTF8, 0, 0)
+#undef ctf_array_bitfield
+#define ctf_array_bitfield(_type, _item, _src, _length) \
+ _ctf_array_bitfield(_type, _item, _src, _length, 0, 0)
+
#undef ctf_sequence
#define ctf_sequence(_type, _item, _src, _length_type, _src_length) \
_ctf_sequence_encoded(_type, _item, _src, \
_ctf_sequence_encoded(_type, _item, _src, \
_length_type, _src_length, UTF8, __BYTE_ORDER, 10, 0, 0)
+#undef ctf_sequence_bitfield
+#define ctf_sequence_bitfield(_type, _item, _src, _length_type, _src_length) \
+ _ctf_sequence_bitfield(_type, _item, _src, \
+ _length_type, _src_length, 0, 0)
+
#undef ctf_string
#define ctf_string(_item, _src) \
_ctf_string(_item, _src, 0, 0)
#define ctf_user_array_text(_type, _item, _src, _length) \
_ctf_array_encoded(_type, _item, _src, _length, UTF8, 1, 0)
+#undef ctf_user_array_bitfield
+#define ctf_user_array_bitfield(_type, _item, _src, _length) \
+ _ctf_array_bitfield(_type, _item, _src, _length, 1, 0)
+
#undef ctf_user_sequence
#define ctf_user_sequence(_type, _item, _src, _length_type, _src_length) \
_ctf_sequence_encoded(_type, _item, _src, \
_ctf_sequence_encoded(_type, _item, _src, \
_length_type, _src_length, UTF8, __BYTE_ORDER, 10, 1, 0)
+#undef ctf_user_sequence_bitfield
+#define ctf_user_sequence_bitfield(_type, _item, _src, _length_type, _src_length) \
+ _ctf_sequence_bitfield(_type, _item, _src, \
+ _length_type, _src_length, 1, 0)
+
#undef ctf_user_string
#define ctf_user_string(_item, _src) \
_ctf_string(_item, _src, 1, 0)
#include <linux/uaccess.h>
#include <linux/debugfs.h>
#include <linux/rculist.h>
+#include <asm/byteorder.h>
#include "lttng.h"
#include "lttng-types.h"
#include "lttng-probe-user.h"
#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _user, _nowrite) \
{ \
.name = #_item, \
- .type = __type_integer(_type, _byte_order, _base, none),\
+ .type = __type_integer(_type, 0, 0, -1, _byte_order, _base, none),\
.nowrite = _nowrite, \
.user = _user, \
},
{ \
.array = \
{ \
- .elem_type = __type_integer(_type, __BYTE_ORDER, 10, _encoding), \
+ .elem_type = __type_integer(_type, 0, 0, 0, __BYTE_ORDER, 10, _encoding), \
.length = _length, \
} \
} \
.user = _user, \
},
+#undef _ctf_array_bitfield
+#define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
+ { \
+ .name = #_item, \
+ .type = \
+ { \
+ .atype = atype_array, \
+ .u = \
+ { \
+ .array = \
+ { \
+ .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none), \
+ .length = (_length) * sizeof(_type) * CHAR_BIT, \
+ .elem_alignment = lttng_alignof(_type), \
+ } \
+ } \
+ }, \
+ .nowrite = _nowrite, \
+ .user = _user, \
+ },
+
+
#undef _ctf_sequence_encoded
#define _ctf_sequence_encoded(_type, _item, _src, \
_length_type, _src_length, _encoding, \
{ \
.sequence = \
{ \
- .length_type = __type_integer(_length_type, __BYTE_ORDER, 10, none), \
- .elem_type = __type_integer(_type, _byte_order, _base, _encoding), \
+ .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 10, none), \
+ .elem_type = __type_integer(_type, 0, 0, -1, _byte_order, _base, _encoding), \
+ }, \
+ }, \
+ }, \
+ .nowrite = _nowrite, \
+ .user = _user, \
+ },
+
+#undef _ctf_sequence_bitfield
+#define _ctf_sequence_bitfield(_type, _item, _src, \
+ _length_type, _src_length, \
+ _user, _nowrite) \
+ { \
+ .name = #_item, \
+ .type = \
+ { \
+ .atype = atype_sequence, \
+ .u = \
+ { \
+ .sequence = \
+ { \
+ .length_type = __type_integer(_length_type, 0, 0, 0, __BYTE_ORDER, 10, none), \
+ .elem_type = __type_integer(_type, 1, 1, 0, __LITTLE_ENDIAN, 10, none), \
+ .elem_alignment = lttng_alignof(_type), \
}, \
}, \
}, \
__event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
__event_len += sizeof(_type) * (_length);
+#undef _ctf_array_bitfield
+#define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
+ _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
+
#undef _ctf_sequence_encoded
#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
_src_length, _encoding, _byte_order, _base, _user, _nowrite) \
__event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx]; \
__dynamic_len_idx++;
+#undef _ctf_sequence_bitfield
+#define _ctf_sequence_bitfield(_type, _item, _src, \
+ _length_type, _src_length, \
+ _user, _nowrite) \
+ _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
+ none, __LITTLE_ENDIAN, 10, _user, _nowrite)
+
/*
* ctf_user_string includes \0. If returns 0, it faulted, so we set size to
* 1 (\0 only).
__stack_data += sizeof(void *); \
}
+#undef _ctf_array_bitfield
+#define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
+ _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
+
#undef _ctf_sequence_encoded
#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
_src_length, _encoding, _byte_order, _base, _user, _nowrite) \
__stack_data += sizeof(void *); \
}
+#undef _ctf_sequence_bitfield
+#define _ctf_sequence_bitfield(_type, _item, _src, \
+ _length_type, _src_length, \
+ _user, _nowrite) \
+ _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
+ none, __LITTLE_ENDIAN, 10, _user, _nowrite)
+
#undef _ctf_string
#define _ctf_string(_item, _src, _user, _nowrite) \
{ \
#define _ctf_array_encoded(_type, _item, _src, _length, _encoding, _user, _nowrite) \
__event_align = max_t(size_t, __event_align, lttng_alignof(_type));
+#undef _ctf_array_bitfield
+#define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
+ _ctf_array_encoded(_type, _item, _src, _length, none, _user, _nowrite)
+
#undef _ctf_sequence_encoded
#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
_src_length, _encoding, _byte_order, _base, _user, _nowrite) \
__event_align = max_t(size_t, __event_align, lttng_alignof(_length_type)); \
__event_align = max_t(size_t, __event_align, lttng_alignof(_type));
+#undef _ctf_sequence_bitfield
+#define _ctf_sequence_bitfield(_type, _item, _src, \
+ _length_type, _src_length, \
+ _user, _nowrite) \
+ _ctf_sequence_encoded(_type, _item, _src, _length_type, _src_length, \
+ none, __LITTLE_ENDIAN, 10, _user, _nowrite)
+
#undef _ctf_string
#define _ctf_string(_item, _src, _user, _nowrite)
__chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
}
+#if (__BYTE_ORDER == __LITTLE_ENDIAN)
+#undef _ctf_array_bitfield
+#define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
+ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
+ if (_user) { \
+ __chan->ops->event_write_from_user(&__ctx, _src, sizeof(_type) * (_length)); \
+ } else { \
+ __chan->ops->event_write(&__ctx, _src, sizeof(_type) * (_length)); \
+ }
+#else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
+/*
+ * For big endian, we need to byteswap into little endian.
+ */
+#undef _ctf_array_bitfield
+#define _ctf_array_bitfield(_type, _item, _src, _length, _user, _nowrite) \
+ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
+ { \
+ size_t _i; \
+ \
+ for (_i = 0; _i < (_length); _i++) { \
+ _type _tmp; \
+ \
+ if (_user) { \
+ if (get_user(_tmp, (_type *) _src + _i)) \
+ _tmp = 0; \
+ } else { \
+ _tmp = ((_type *) _src)[_i]; \
+ } \
+ switch (sizeof(_type)) { \
+ case 1: \
+ break; \
+ case 2: \
+ _tmp = cpu_to_le16(_tmp); \
+ break; \
+ case 4: \
+ _tmp = cpu_to_le32(_tmp); \
+ break; \
+ case 8: \
+ _tmp = cpu_to_le64(_tmp); \
+ break; \
+ default: \
+ BUG_ON(1); \
+ } \
+ __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
+ } \
+ }
+#endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
+
#undef _ctf_sequence_encoded
#define _ctf_sequence_encoded(_type, _item, _src, _length_type, \
_src_length, _encoding, _byte_order, _base, _user, _nowrite) \
sizeof(_type) * __get_dynamic_len(dest)); \
}
+#if (__BYTE_ORDER == __LITTLE_ENDIAN)
+#undef _ctf_sequence_bitfield
+#define _ctf_sequence_bitfield(_type, _item, _src, \
+ _length_type, _src_length, \
+ _user, _nowrite) \
+ { \
+ _length_type __tmpl = __stackvar.__dynamic_len[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
+ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
+ __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
+ } \
+ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
+ if (_user) { \
+ __chan->ops->event_write_from_user(&__ctx, _src, \
+ sizeof(_type) * __get_dynamic_len(dest)); \
+ } else { \
+ __chan->ops->event_write(&__ctx, _src, \
+ sizeof(_type) * __get_dynamic_len(dest)); \
+ }
+#else /* #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
+/*
+ * For big endian, we need to byteswap into little endian.
+ */
+#undef _ctf_sequence_bitfield
+#define _ctf_sequence_bitfield(_type, _item, _src, \
+ _length_type, _src_length, \
+ _user, _nowrite) \
+ { \
+ _length_type __tmpl = __stackvar.__dynamic_len[__dynamic_len_idx] * sizeof(_type) * CHAR_BIT; \
+ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_length_type));\
+ __chan->ops->event_write(&__ctx, &__tmpl, sizeof(_length_type));\
+ } \
+ lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(_type)); \
+ { \
+ size_t _i, _length; \
+ \
+ _length = __get_dynamic_len(dest); \
+ for (_i = 0; _i < _length; _i++) { \
+ _type _tmp; \
+ \
+ if (_user) { \
+ if (get_user(_tmp, (_type *) _src + _i)) \
+ _tmp = 0; \
+ } else { \
+ _tmp = ((_type *) _src)[_i]; \
+ } \
+ switch (sizeof(_type)) { \
+ case 1: \
+ break; \
+ case 2: \
+ _tmp = cpu_to_le16(_tmp); \
+ break; \
+ case 4: \
+ _tmp = cpu_to_le32(_tmp); \
+ break; \
+ case 8: \
+ _tmp = cpu_to_le64(_tmp); \
+ break; \
+ default: \
+ BUG_ON(1); \
+ } \
+ __chan->ops->event_write(&__ctx, &_tmp, sizeof(_type)); \
+ } \
+ }
+#endif /* #else #if (__BYTE_ORDER == __LITTLE_ENDIAN) */
+
#undef _ctf_string
#define _ctf_string(_item, _src, _user, _nowrite) \
lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src))); \
#define TRACE_EVENT_TYPE___enum(_name, _container_type) \
{ \
.name = #_name, \
- .container_type = __type_integer(_container_type, __BYTE_ORDER, 10, none), \
+ .container_type = __type_integer(_container_type, 0, 0, -1, __BYTE_ORDER, 10, none), \
.entries = __trace_event_enum_##_name, \
.len = ARRAY_SIZE(__trace_event_enum_##_name), \
},