X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=include%2Fside%2Ftrace.h;h=f09463d7f7e1bcd5ade93ea8a05b63bc46fad729;hb=117e507d02e594fde9e7a3f87f75d5faae3edebe;hp=8a9cfe17c826d5fc43230e391e22954bd3fbea9d;hpb=66cff3283486f96605e603f76ac9d04f85078627;p=libside.git diff --git a/include/side/trace.h b/include/side/trace.h index 8a9cfe1..f09463d 100644 --- a/include/side/trace.h +++ b/include/side/trace.h @@ -28,10 +28,12 @@ struct side_event_field; struct side_tracer_visitor_ctx; struct side_tracer_dynamic_struct_visitor_ctx; struct side_tracer_dynamic_vla_visitor_ctx; +struct side_event_description; +struct side_arg_dynamic_event_struct; enum side_type { + /* Basic types */ SIDE_TYPE_BOOL, - SIDE_TYPE_U8, SIDE_TYPE_U16, SIDE_TYPE_U32, @@ -40,28 +42,14 @@ enum side_type { SIDE_TYPE_S16, SIDE_TYPE_S32, SIDE_TYPE_S64, - - SIDE_TYPE_ENUM_U8, - SIDE_TYPE_ENUM_U16, - SIDE_TYPE_ENUM_U32, - SIDE_TYPE_ENUM_U64, - SIDE_TYPE_ENUM_S8, - SIDE_TYPE_ENUM_S16, - SIDE_TYPE_ENUM_S32, - SIDE_TYPE_ENUM_S64, - - SIDE_TYPE_ENUM_BITMAP8, - SIDE_TYPE_ENUM_BITMAP16, - SIDE_TYPE_ENUM_BITMAP32, - SIDE_TYPE_ENUM_BITMAP64, - + SIDE_TYPE_BYTE, SIDE_TYPE_FLOAT_BINARY16, SIDE_TYPE_FLOAT_BINARY32, SIDE_TYPE_FLOAT_BINARY64, SIDE_TYPE_FLOAT_BINARY128, - SIDE_TYPE_STRING, + /* Compound types */ SIDE_TYPE_STRUCT, SIDE_TYPE_ARRAY, SIDE_TYPE_VLA, @@ -75,6 +63,7 @@ enum side_type { SIDE_TYPE_ARRAY_S16, SIDE_TYPE_ARRAY_S32, SIDE_TYPE_ARRAY_S64, + SIDE_TYPE_ARRAY_BYTE, SIDE_TYPE_VLA_U8, SIDE_TYPE_VLA_U16, @@ -84,15 +73,20 @@ enum side_type { SIDE_TYPE_VLA_S16, SIDE_TYPE_VLA_S32, SIDE_TYPE_VLA_S64, + SIDE_TYPE_VLA_BYTE, + + /* Enumeration types */ + SIDE_TYPE_ENUM, + SIDE_TYPE_ENUM_BITMAP, + /* Dynamic type */ SIDE_TYPE_DYNAMIC, }; enum side_dynamic_type { + /* Basic types */ SIDE_DYNAMIC_TYPE_NULL, - SIDE_DYNAMIC_TYPE_BOOL, - SIDE_DYNAMIC_TYPE_U8, SIDE_DYNAMIC_TYPE_U16, SIDE_DYNAMIC_TYPE_U32, @@ -101,24 +95,22 @@ enum side_dynamic_type { SIDE_DYNAMIC_TYPE_S16, SIDE_DYNAMIC_TYPE_S32, SIDE_DYNAMIC_TYPE_S64, - + SIDE_DYNAMIC_TYPE_BYTE, SIDE_DYNAMIC_TYPE_FLOAT_BINARY16, SIDE_DYNAMIC_TYPE_FLOAT_BINARY32, SIDE_DYNAMIC_TYPE_FLOAT_BINARY64, SIDE_DYNAMIC_TYPE_FLOAT_BINARY128, - SIDE_DYNAMIC_TYPE_STRING, + /* Compound types */ SIDE_DYNAMIC_TYPE_STRUCT, SIDE_DYNAMIC_TYPE_STRUCT_VISITOR, - SIDE_DYNAMIC_TYPE_VLA, SIDE_DYNAMIC_TYPE_VLA_VISITOR, }; enum side_attr_type { SIDE_ATTR_TYPE_BOOL, - SIDE_ATTR_TYPE_U8, SIDE_ATTR_TYPE_U16, SIDE_ATTR_TYPE_U32, @@ -127,12 +119,10 @@ enum side_attr_type { SIDE_ATTR_TYPE_S16, SIDE_ATTR_TYPE_S32, SIDE_ATTR_TYPE_S64, - SIDE_ATTR_TYPE_FLOAT_BINARY16, SIDE_ATTR_TYPE_FLOAT_BINARY32, SIDE_ATTR_TYPE_FLOAT_BINARY64, SIDE_ATTR_TYPE_FLOAT_BINARY128, - SIDE_ATTR_TYPE_STRING, }; @@ -166,7 +156,6 @@ struct side_attr_value { uint32_t type; /* enum side_attr_type */ union { uint8_t side_bool; - uint8_t side_u8; uint16_t side_u16; uint32_t side_u32; @@ -175,7 +164,6 @@ struct side_attr_value { int16_t side_s16; int32_t side_s32; int64_t side_s64; - #if __HAVE_FLOAT16 _Float16 side_float_binary16; #endif @@ -188,7 +176,6 @@ struct side_attr_value { #if __HAVE_FLOAT128 _Float128 side_float_binary128; #endif - const char *string; } u; }; @@ -207,7 +194,9 @@ struct side_enum_mapping { struct side_enum_mappings { const struct side_enum_mapping *mappings; + const struct side_attr *attr; uint32_t nr_mappings; + uint32_t nr_attr; }; struct side_enum_bitmap_mapping { @@ -218,31 +207,56 @@ struct side_enum_bitmap_mapping { struct side_enum_bitmap_mappings { const struct side_enum_bitmap_mapping *mappings; + const struct side_attr *attr; uint32_t nr_mappings; + uint32_t nr_attr; }; -struct side_type_description { - uint32_t type; /* enum side_type */ +struct side_type_struct { + uint32_t nr_fields; uint32_t nr_attr; + const struct side_event_field *fields; const struct side_attr *attr; +}; + +struct side_type_description { + uint32_t type; /* enum side_type */ union { + /* Basic types */ struct { - uint32_t nr_fields; - const struct side_event_field *fields; - } side_struct; + const struct side_attr *attr; + uint32_t nr_attr; + } side_basic; + + /* Compound types */ struct { - uint32_t length; const struct side_type_description *elem_type; + const struct side_attr *attr; + uint32_t length; + uint32_t nr_attr; } side_array; struct { const struct side_type_description *elem_type; + const struct side_attr *attr; + uint32_t nr_attr; } side_vla; struct { const struct side_type_description *elem_type; side_visitor visitor; + const struct side_attr *attr; + uint32_t nr_attr; } side_vla_visitor; - const struct side_enum_mappings *side_enum_mappings; - const struct side_enum_bitmap_mappings *side_enum_bitmap_mappings; + const struct side_type_struct *side_struct; + + /* Enumeration types */ + struct { + const struct side_enum_mappings *mappings; + const struct side_type_description *elem_type; + } side_enum; + struct { + const struct side_enum_bitmap_mappings *mappings; + const struct side_type_description *elem_type; + } side_enum_bitmap; } u; }; @@ -255,9 +269,27 @@ enum side_event_flags { SIDE_EVENT_FLAG_VARIADIC = (1 << 0), }; +struct side_callback { + union { + void (*call)(const struct side_event_description *desc, + const struct side_arg_vec_description *sav_desc, + void *priv); + void (*call_variadic)(const struct side_event_description *desc, + const struct side_arg_vec_description *sav_desc, + const struct side_arg_dynamic_event_struct *var_struct, + void *priv); + } u; + void *priv; +}; + +struct side_callbacks { + struct side_callback *cb; + uint32_t nr_cb; +}; + struct side_event_description { uint32_t version; - uint32_t enabled; + uint32_t *enabled; uint32_t loglevel; /* enum side_loglevel */ uint32_t nr_fields; uint32_t nr_attr; @@ -267,58 +299,68 @@ struct side_event_description { const char *event_name; const struct side_event_field *fields; const struct side_attr *attr; -}; - -struct side_arg_dynamic_vec_vla { - const struct side_arg_dynamic_vec *sav; - uint32_t len; + struct side_callbacks *callbacks; }; struct side_arg_dynamic_vec { uint32_t dynamic_type; /* enum side_dynamic_type */ - uint32_t nr_attr; - const struct side_attr *attr; union { - uint8_t side_bool; - - uint8_t side_u8; - uint16_t side_u16; - uint32_t side_u32; - uint64_t side_u64; - int8_t side_s8; - int16_t side_s16; - int32_t side_s32; - int64_t side_s64; - + /* Basic types */ + struct { + const struct side_attr *attr; + uint32_t nr_attr; + union { + uint8_t side_bool; + uint8_t side_u8; + uint16_t side_u16; + uint32_t side_u32; + uint64_t side_u64; + int8_t side_s8; + int16_t side_s16; + int32_t side_s32; + int64_t side_s64; + uint8_t side_byte; #if __HAVE_FLOAT16 - _Float16 side_float_binary16; + _Float16 side_float_binary16; #endif #if __HAVE_FLOAT32 - _Float32 side_float_binary32; + _Float32 side_float_binary32; #endif #if __HAVE_FLOAT64 - _Float64 side_float_binary64; + _Float64 side_float_binary64; #endif #if __HAVE_FLOAT128 - _Float128 side_float_binary128; + _Float128 side_float_binary128; #endif + const char *string; + } u; + } side_basic; - const char *string; - + /* Compound types */ const struct side_arg_dynamic_event_struct *side_dynamic_struct; struct { void *app_ctx; side_dynamic_struct_visitor visitor; + const struct side_attr *attr; + uint32_t nr_attr; } side_dynamic_struct_visitor; - const struct side_arg_dynamic_vec_vla *side_dynamic_vla; struct { void *app_ctx; side_dynamic_vla_visitor visitor; + const struct side_attr *attr; + uint32_t nr_attr; } side_dynamic_vla_visitor; } u; }; +struct side_arg_dynamic_vec_vla { + const struct side_arg_dynamic_vec *sav; + const struct side_attr *attr; + uint32_t len; + uint32_t nr_attr; +}; + struct side_arg_dynamic_event_field { const char *field_name; const struct side_arg_dynamic_vec elem; @@ -326,14 +368,16 @@ struct side_arg_dynamic_event_field { struct side_arg_dynamic_event_struct { const struct side_arg_dynamic_event_field *fields; + const struct side_attr *attr; uint32_t len; + uint32_t nr_attr; }; struct side_arg_vec { enum side_type type; union { + /* Basic types */ uint8_t side_bool; - uint8_t side_u8; uint16_t side_u16; uint32_t side_u32; @@ -342,7 +386,7 @@ struct side_arg_vec { int16_t side_s16; int32_t side_s32; int64_t side_s64; - + uint8_t side_byte; #if __HAVE_FLOAT16 _Float16 side_float_binary16; #endif @@ -355,19 +399,20 @@ struct side_arg_vec { #if __HAVE_FLOAT128 _Float128 side_float_binary128; #endif - const char *string; + + /* Compound types */ const struct side_arg_vec_description *side_struct; const struct side_arg_vec_description *side_array; const struct side_arg_vec_description *side_vla; void *side_vla_app_visitor_ctx; - void *side_array_fixint; struct { void *p; uint32_t length; } side_vla_fixint; + /* Dynamic type */ struct side_arg_dynamic_vec dynamic; } u; }; @@ -399,6 +444,8 @@ struct side_tracer_dynamic_vla_visitor_ctx { void *priv; /* Private tracer context. */ }; +/* Event and type attributes */ + #define side_attr(_key, _value) \ { \ .key = _key, \ @@ -408,156 +455,199 @@ struct side_tracer_dynamic_vla_visitor_ctx { #define side_attr_list(...) \ SIDE_COMPOUND_LITERAL(const struct side_attr, __VA_ARGS__) -#define side_type_decl(_type, _attr) \ +#define side_attr_bool(_val) { .type = SIDE_ATTR_TYPE_BOOL, .u = { .side_bool = !!(_val) } } +#define side_attr_u8(_val) { .type = SIDE_ATTR_TYPE_U8, .u = { .side_u8 = (_val) } } +#define side_attr_u16(_val) { .type = SIDE_ATTR_TYPE_U16, .u = { .side_u16 = (_val) } } +#define side_attr_u32(_val) { .type = SIDE_ATTR_TYPE_U32, .u = { .side_u32 = (_val) } } +#define side_attr_u64(_val) { .type = SIDE_ATTR_TYPE_U64, .u = { .side_u64 = (_val) } } +#define side_attr_s8(_val) { .type = SIDE_ATTR_TYPE_S8, .u = { .side_s8 = (_val) } } +#define side_attr_s16(_val) { .type = SIDE_ATTR_TYPE_S16, .u = { .side_s16 = (_val) } } +#define side_attr_s32(_val) { .type = SIDE_ATTR_TYPE_S32, .u = { .side_s32 = (_val) } } +#define side_attr_s64(_val) { .type = SIDE_ATTR_TYPE_S64, .u = { .side_s64 = (_val) } } +#define side_attr_float_binary16(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY16, .u = { .side_float_binary16 = (_val) } } +#define side_attr_float_binary32(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY32, .u = { .side_float_binary32 = (_val) } } +#define side_attr_float_binary64(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY64, .u = { .side_float_binary64 = (_val) } } +#define side_attr_float_binary128(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY128, .u = { .side_float_binary128 = (_val) } } +#define side_attr_string(_val) { .type = SIDE_ATTR_TYPE_STRING, .u = { .string = (_val) } } + +/* Static field definition */ + +#define _side_type_basic(_type, _attr) \ { \ .type = _type, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ + .u = { \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }, \ + }, \ } -#define side_field(_name, _type, _attr) \ +#define side_type_bool(_attr) _side_type_basic(SIDE_TYPE_BOOL, SIDE_PARAM(_attr)) +#define side_type_u8(_attr) _side_type_basic(SIDE_TYPE_U8, SIDE_PARAM(_attr)) +#define side_type_u16(_attr) _side_type_basic(SIDE_TYPE_U16, SIDE_PARAM(_attr)) +#define side_type_u32(_attr) _side_type_basic(SIDE_TYPE_U32, SIDE_PARAM(_attr)) +#define side_type_u64(_attr) _side_type_basic(SIDE_TYPE_U64, SIDE_PARAM(_attr)) +#define side_type_s8(_attr) _side_type_basic(SIDE_TYPE_S8, SIDE_PARAM(_attr)) +#define side_type_s16(_attr) _side_type_basic(SIDE_TYPE_S16, SIDE_PARAM(_attr)) +#define side_type_s32(_attr) _side_type_basic(SIDE_TYPE_S32, SIDE_PARAM(_attr)) +#define side_type_s64(_attr) _side_type_basic(SIDE_TYPE_S64, SIDE_PARAM(_attr)) +#define side_type_byte(_attr) _side_type_basic(SIDE_TYPE_BYTE, SIDE_PARAM(_attr)) +#define side_type_float_binary16(_attr) _side_type_basic(SIDE_TYPE_FLOAT_BINARY16, SIDE_PARAM(_attr)) +#define side_type_float_binary32(_attr) _side_type_basic(SIDE_TYPE_FLOAT_BINARY32, SIDE_PARAM(_attr)) +#define side_type_float_binary64(_attr) _side_type_basic(SIDE_TYPE_FLOAT_BINARY64, SIDE_PARAM(_attr)) +#define side_type_float_binary128(_attr) _side_type_basic(SIDE_TYPE_FLOAT_BINARY128, SIDE_PARAM(_attr)) +#define side_type_string(_attr) _side_type_basic(SIDE_TYPE_STRING, SIDE_PARAM(_attr)) +#define side_type_dynamic(_attr) _side_type_basic(SIDE_TYPE_DYNAMIC, SIDE_PARAM(_attr)) + +#define _side_field(_name, _type) \ { \ .field_name = _name, \ - .side_type = side_type_decl(_type, SIDE_PARAM(_attr)), \ + .side_type = _type, \ } -#define side_type_enum_decl(_type, _mappings, _attr) \ +#define side_field_bool(_name, _attr) _side_field(_name, side_type_bool(SIDE_PARAM(_attr))) +#define side_field_u8(_name, _attr) _side_field(_name, side_type_u8(SIDE_PARAM(_attr))) +#define side_field_u16(_name, _attr) _side_field(_name, side_type_u16(SIDE_PARAM(_attr))) +#define side_field_u32(_name, _attr) _side_field(_name, side_type_u32(SIDE_PARAM(_attr))) +#define side_field_u64(_name, _attr) _side_field(_name, side_type_u64(SIDE_PARAM(_attr))) +#define side_field_s8(_name, _attr) _side_field(_name, side_type_s8(SIDE_PARAM(_attr))) +#define side_field_s16(_name, _attr) _side_field(_name, side_type_s16(SIDE_PARAM(_attr))) +#define side_field_s32(_name, _attr) _side_field(_name, side_type_s32(SIDE_PARAM(_attr))) +#define side_field_s64(_name, _attr) _side_field(_name, side_type_s64(SIDE_PARAM(_attr))) +#define side_field_byte(_name, _attr) _side_field(_name, side_type_byte(SIDE_PARAM(_attr))) +#define side_field_float_binary16(_name, _attr) _side_field(_name, side_type_float_binary16(SIDE_PARAM(_attr))) +#define side_field_float_binary32(_name, _attr) _side_field(_name, side_type_float_binary32(SIDE_PARAM(_attr))) +#define side_field_float_binary64(_name, _attr) _side_field(_name, side_type_float_binary64(SIDE_PARAM(_attr))) +#define side_field_float_binary128(_name, _attr) _side_field(_name, side_type_float_binary128(SIDE_PARAM(_attr))) +#define side_field_string(_name, _attr) _side_field(_name, side_type_string(SIDE_PARAM(_attr))) +#define side_field_dynamic(_name, _attr) _side_field(_name, side_type_dynamic(SIDE_PARAM(_attr))) + +#define side_type_enum(_mappings, _elem_type) \ { \ - .type = _type, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ + .type = SIDE_TYPE_ENUM, \ .u = { \ - .side_enum_mappings = _mappings, \ + .side_enum = { \ + .mappings = _mappings, \ + .elem_type = _elem_type, \ + }, \ }, \ } -#define side_field_enum(_name, _type, _mappings, _attr) \ - { \ - .field_name = _name, \ - .side_type = side_type_enum_decl(_type, SIDE_PARAM(_mappings), SIDE_PARAM(_attr)), \ - } +#define side_field_enum(_name, _mappings, _elem_type) \ + _side_field(_name, side_type_enum(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type))) -#define side_type_enum_bitmap_decl(_type, _mappings, _attr) \ +#define side_type_enum_bitmap(_mappings, _elem_type) \ { \ - .type = _type, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ + .type = SIDE_TYPE_ENUM_BITMAP, \ .u = { \ - .side_enum_bitmap_mappings = _mappings, \ + .side_enum_bitmap = { \ + .mappings = _mappings, \ + .elem_type = _elem_type, \ + }, \ }, \ } -#define side_field_enum_bitmap(_name, _type, _mappings, _attr) \ - { \ - .field_name = _name, \ - .side_type = side_type_enum_bitmap_decl(_type, SIDE_PARAM(_mappings), SIDE_PARAM(_attr)), \ - } +#define side_field_enum_bitmap(_name, _mappings, _elem_type) \ + _side_field(_name, side_type_enum_bitmap(SIDE_PARAM(_mappings), SIDE_PARAM(_elem_type))) -#define side_type_struct_decl(_fields, _attr) \ +#define side_type_struct(_struct) \ { \ .type = SIDE_TYPE_STRUCT, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .side_struct = { \ - .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \ - .fields = _fields, \ - }, \ + .side_struct = _struct, \ }, \ } -#define side_field_struct(_name, _fields, _attr) \ +#define side_field_struct(_name, _struct) \ + _side_field(_name, side_type_struct(SIDE_PARAM(_struct))) + +#define _side_type_struct_define(_fields, _attr) \ { \ - .field_name = _name, \ - .side_type = side_type_struct_decl(SIDE_PARAM(_fields), SIDE_PARAM(_attr)), \ + .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .fields = _fields, \ + .attr = _attr, \ } -#define side_type_array_decl(_elem_type, _length, _attr) \ +#define side_define_struct(_identifier, _fields, _attr) \ + const struct side_type_struct _identifier = _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM(_attr)) + +#define side_struct_literal(_fields, _attr) \ + SIDE_COMPOUND_LITERAL(const struct side_type_struct, \ + _side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM(_attr))) + +#define side_type_array(_elem_type, _length, _attr) \ { \ .type = SIDE_TYPE_ARRAY, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ .side_array = { \ - .length = _length, \ .elem_type = _elem_type, \ + .attr = _attr, \ + .length = _length, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ }, \ }, \ } #define side_field_array(_name, _elem_type, _length, _attr) \ - { \ - .field_name = _name, \ - .side_type = side_type_array_decl(SIDE_PARAM(_elem_type), _length, SIDE_PARAM(_attr)), \ - } + _side_field(_name, side_type_array(SIDE_PARAM(_elem_type), _length, SIDE_PARAM(_attr))) -#define side_type_vla_decl(_elem_type, _attr) \ +#define side_type_vla(_elem_type, _attr) \ { \ .type = SIDE_TYPE_VLA, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ .side_vla = { \ .elem_type = _elem_type, \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ }, \ }, \ } #define side_field_vla(_name, _elem_type, _attr) \ - { \ - .field_name = _name, \ - .side_type = side_type_vla_decl(SIDE_PARAM(_elem_type), SIDE_PARAM(_attr)), \ - } + _side_field(_name, side_type_vla(SIDE_PARAM(_elem_type), SIDE_PARAM(_attr))) -#define side_type_vla_visitor_decl(_elem_type, _visitor, _attr) \ +#define side_type_vla_visitor(_elem_type, _visitor, _attr) \ { \ .type = SIDE_TYPE_VLA_VISITOR, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ .side_vla_visitor = { \ .elem_type = SIDE_PARAM(_elem_type), \ .visitor = _visitor, \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ }, \ }, \ } #define side_field_vla_visitor(_name, _elem_type, _visitor, _attr) \ - { \ - .field_name = _name, \ - .side_type = side_type_vla_visitor_decl(SIDE_PARAM(_elem_type), _visitor, SIDE_PARAM(_attr)), \ - } + _side_field(_name, side_type_vla_visitor(SIDE_PARAM(_elem_type), _visitor, SIDE_PARAM(_attr))) #define side_elem(...) \ SIDE_COMPOUND_LITERAL(const struct side_type_description, __VA_ARGS__) -#define side_elem_type(_type, _attr) \ - side_elem(side_type_decl(_type, SIDE_PARAM(_attr))) - #define side_field_list(...) \ SIDE_COMPOUND_LITERAL(const struct side_event_field, __VA_ARGS__) -#define side_arg_bool(val) { .type = SIDE_TYPE_BOOL, .u = { .side_bool = !!(val) } } -#define side_arg_u8(val) { .type = SIDE_TYPE_U8, .u = { .side_u8 = (val) } } -#define side_arg_u16(val) { .type = SIDE_TYPE_U16, .u = { .side_u16 = (val) } } -#define side_arg_u32(val) { .type = SIDE_TYPE_U32, .u = { .side_u32 = (val) } } -#define side_arg_u64(val) { .type = SIDE_TYPE_U64, .u = { .side_u64 = (val) } } -#define side_arg_s8(val) { .type = SIDE_TYPE_S8, .u = { .side_s8 = (val) } } -#define side_arg_s16(val) { .type = SIDE_TYPE_S16, .u = { .side_s16 = (val) } } -#define side_arg_s32(val) { .type = SIDE_TYPE_S32, .u = { .side_s32 = (val) } } -#define side_arg_s64(val) { .type = SIDE_TYPE_S64, .u = { .side_s64 = (val) } } -#define side_arg_enum_u8(val) { .type = SIDE_TYPE_ENUM_U8, .u = { .side_u8 = (val) } } -#define side_arg_enum_u16(val) { .type = SIDE_TYPE_ENUM_U16, .u = { .side_u16 = (val) } } -#define side_arg_enum_u32(val) { .type = SIDE_TYPE_ENUM_U32, .u = { .side_u32 = (val) } } -#define side_arg_enum_u64(val) { .type = SIDE_TYPE_ENUM_U64, .u = { .side_u64 = (val) } } -#define side_arg_enum_s8(val) { .type = SIDE_TYPE_ENUM_S8, .u = { .side_s8 = (val) } } -#define side_arg_enum_s16(val) { .type = SIDE_TYPE_ENUM_S16, .u = { .side_s16 = (val) } } -#define side_arg_enum_s32(val) { .type = SIDE_TYPE_ENUM_S32, .u = { .side_s32 = (val) } } -#define side_arg_enum_s64(val) { .type = SIDE_TYPE_ENUM_S64, .u = { .side_s64 = (val) } } -#define side_arg_enum_bitmap8(val) { .type = SIDE_TYPE_ENUM_BITMAP8, .u = { .side_u8 = (val) } } -#define side_arg_enum_bitmap16(val) { .type = SIDE_TYPE_ENUM_BITMAP16, .u = { .side_u16 = (val) } } -#define side_arg_enum_bitmap32(val) { .type = SIDE_TYPE_ENUM_BITMAP32, .u = { .side_u32 = (val) } } -#define side_arg_enum_bitmap64(val) { .type = SIDE_TYPE_ENUM_BITMAP64, .u = { .side_u64 = (val) } } -#define side_arg_float_binary16(val) { .type = SIDE_TYPE_FLOAT_BINARY16, .u = { .side_float_binary16 = (val) } } -#define side_arg_float_binary32(val) { .type = SIDE_TYPE_FLOAT_BINARY32, .u = { .side_float_binary32 = (val) } } -#define side_arg_float_binary64(val) { .type = SIDE_TYPE_FLOAT_BINARY64, .u = { .side_float_binary64 = (val) } } -#define side_arg_float_binary128(val) { .type = SIDE_TYPE_FLOAT_BINARY128, .u = { .side_float_binary128 = (val) } } - -#define side_arg_string(val) { .type = SIDE_TYPE_STRING, .u = { .string = (val) } } +/* Static field arguments */ + +#define side_arg_bool(_val) { .type = SIDE_TYPE_BOOL, .u = { .side_bool = !!(_val) } } +#define side_arg_u8(_val) { .type = SIDE_TYPE_U8, .u = { .side_u8 = (_val) } } +#define side_arg_u16(_val) { .type = SIDE_TYPE_U16, .u = { .side_u16 = (_val) } } +#define side_arg_u32(_val) { .type = SIDE_TYPE_U32, .u = { .side_u32 = (_val) } } +#define side_arg_u64(_val) { .type = SIDE_TYPE_U64, .u = { .side_u64 = (_val) } } +#define side_arg_s8(_val) { .type = SIDE_TYPE_S8, .u = { .side_s8 = (_val) } } +#define side_arg_s16(_val) { .type = SIDE_TYPE_S16, .u = { .side_s16 = (_val) } } +#define side_arg_s32(_val) { .type = SIDE_TYPE_S32, .u = { .side_s32 = (_val) } } +#define side_arg_s64(_val) { .type = SIDE_TYPE_S64, .u = { .side_s64 = (_val) } } +#define side_arg_byte(_val) { .type = SIDE_TYPE_BYTE, .u = { .side_byte = (_val) } } +#define side_arg_enum_bitmap8(_val) { .type = SIDE_TYPE_ENUM_BITMAP8, .u = { .side_u8 = (_val) } } +#define side_arg_enum_bitmap16(_val) { .type = SIDE_TYPE_ENUM_BITMAP16, .u = { .side_u16 = (_val) } } +#define side_arg_enum_bitmap32(_val) { .type = SIDE_TYPE_ENUM_BITMAP32, .u = { .side_u32 = (_val) } } +#define side_arg_enum_bitmap64(_val) { .type = SIDE_TYPE_ENUM_BITMAP64, .u = { .side_u64 = (_val) } } +#define side_arg_enum_bitmap_array(_side_type) { .type = SIDE_TYPE_ENUM_BITMAP_ARRAY, .u = { .side_array = (_side_type) } } +#define side_arg_enum_bitmap_vla(_side_type) { .type = SIDE_TYPE_ENUM_BITMAP_VLA, .u = { .side_vla = (_side_type) } } +#define side_arg_float_binary16(_val) { .type = SIDE_TYPE_FLOAT_BINARY16, .u = { .side_float_binary16 = (_val) } } +#define side_arg_float_binary32(_val) { .type = SIDE_TYPE_FLOAT_BINARY32, .u = { .side_float_binary32 = (_val) } } +#define side_arg_float_binary64(_val) { .type = SIDE_TYPE_FLOAT_BINARY64, .u = { .side_float_binary64 = (_val) } } +#define side_arg_float_binary128(_val) { .type = SIDE_TYPE_FLOAT_BINARY128, .u = { .side_float_binary128 = (_val) } } + +#define side_arg_string(_val) { .type = SIDE_TYPE_STRING, .u = { .string = (_val) } } #define side_arg_struct(_side_type) { .type = SIDE_TYPE_STRUCT, .u = { .side_struct = (_side_type) } } #define side_arg_array(_side_type) { .type = SIDE_TYPE_ARRAY, .u = { .side_array = (_side_type) } } #define side_arg_vla(_side_type) { .type = SIDE_TYPE_VLA, .u = { .side_vla = (_side_type) } } @@ -571,6 +661,7 @@ struct side_tracer_dynamic_vla_visitor_ctx { #define side_arg_array_s16(_ptr) { .type = SIDE_TYPE_ARRAY_S16, .u = { .side_array_fixint = (_ptr) } } #define side_arg_array_s32(_ptr) { .type = SIDE_TYPE_ARRAY_S32, .u = { .side_array_fixint = (_ptr) } } #define side_arg_array_s64(_ptr) { .type = SIDE_TYPE_ARRAY_S64, .u = { .side_array_fixint = (_ptr) } } +#define side_arg_array_byte(_ptr) { .type = SIDE_TYPE_ARRAY_BYTE, .u = { .side_array_fixint = (_ptr) } } #define side_arg_vla_u8(_ptr, _length) { .type = SIDE_TYPE_VLA_U8, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } #define side_arg_vla_u16(_ptr, _length) { .type = SIDE_TYPE_VLA_U16, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } @@ -580,158 +671,232 @@ struct side_tracer_dynamic_vla_visitor_ctx { #define side_arg_vla_s16(_ptr, _length) { .type = SIDE_TYPE_VLA_S16, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } #define side_arg_vla_s32(_ptr, _length) { .type = SIDE_TYPE_VLA_S32, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } #define side_arg_vla_s64(_ptr, _length) { .type = SIDE_TYPE_VLA_S64, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } +#define side_arg_vla_byte(_ptr, _length) { .type = SIDE_TYPE_VLA_BYTE, .u = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } -#define side_arg_dynamic(dynamic_arg_type) \ +#define side_arg_dynamic(_dynamic_arg_type) \ { \ .type = SIDE_TYPE_DYNAMIC, \ .u = { \ - .dynamic = dynamic_arg_type, \ + .dynamic = _dynamic_arg_type, \ }, \ } +/* Dynamic field arguments */ + #define side_arg_dynamic_null(_attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_NULL, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ + .u = { \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }, \ + }, \ } #define side_arg_dynamic_bool(_val, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_BOOL, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .side_bool = !!(_val), \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .side_bool = !!(_val), \ + }, \ + }, \ }, \ } #define side_arg_dynamic_u8(_val, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_U8, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .side_u8 = (_val), \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .side_u8 = (_val), \ + }, \ + }, \ }, \ } #define side_arg_dynamic_u16(_val, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_U16, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .side_u16 = (_val), \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .side_u16 = (_val), \ + }, \ + }, \ }, \ } #define side_arg_dynamic_u32(_val, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_U32, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .side_u32 = (_val), \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .side_u32 = (_val), \ + }, \ + }, \ }, \ } #define side_arg_dynamic_u64(_val, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_U64, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .side_u64 = (_val), \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .side_u64 = (_val), \ + }, \ + }, \ }, \ } #define side_arg_dynamic_s8(_val, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_S8, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .side_s8 = (_val), \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .side_s8 = (_val), \ + }, \ + }, \ }, \ } #define side_arg_dynamic_s16(_val, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_S16, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .side_s16 = (_val), \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .side_s16 = (_val), \ + }, \ + }, \ }, \ } #define side_arg_dynamic_s32(_val, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_S32, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .side_s32 = (_val), \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .side_s32 = (_val), \ + }, \ + }, \ }, \ } #define side_arg_dynamic_s64(_val, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_S64, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .side_s64 = (_val), \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .side_s64 = (_val), \ + }, \ + }, \ + }, \ + } +#define side_arg_dynamic_byte(_val, _attr) \ + { \ + .dynamic_type = SIDE_DYNAMIC_TYPE_BYTE, \ + .u = { \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .side_byte = (_val), \ + }, \ + }, \ }, \ } #define side_arg_dynamic_float_binary16(_val, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY16, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .side_float_binary16 = (_val), \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .side_float_binary16 = (_val), \ + }, \ + }, \ }, \ } #define side_arg_dynamic_float_binary32(_val, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY32, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .side_float_binary32 = (_val), \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .side_float_binary32 = (_val), \ + }, \ + }, \ }, \ } #define side_arg_dynamic_float_binary64(_val, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY64, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .side_float_binary64 = (_val), \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .side_float_binary64 = (_val), \ + }, \ + }, \ }, \ } #define side_arg_dynamic_float_binary128(_val, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_FLOAT_BINARY128, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .side_float_binary128 = (_val), \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .side_float_binary128 = (_val), \ + }, \ + }, \ }, \ } #define side_arg_dynamic_string(_val, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_STRING, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ - .string = (_val), \ + .side_basic = { \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + .u = { \ + .string = (_val), \ + }, \ + }, \ }, \ } -#define side_arg_dynamic_vla(_vla, _attr) \ +#define side_arg_dynamic_vla(_vla) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_VLA, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ .side_dynamic_vla = (_vla), \ }, \ @@ -740,21 +905,19 @@ struct side_tracer_dynamic_vla_visitor_ctx { #define side_arg_dynamic_vla_visitor(_dynamic_vla_visitor, _ctx, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_VLA_VISITOR, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ .side_dynamic_vla_visitor = { \ .app_ctx = _ctx, \ .visitor = _dynamic_vla_visitor, \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ }, \ }, \ } -#define side_arg_dynamic_struct(_struct, _attr) \ +#define side_arg_dynamic_struct(_struct) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_STRUCT, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ .side_dynamic_struct = (_struct), \ }, \ @@ -763,28 +926,32 @@ struct side_tracer_dynamic_vla_visitor_ctx { #define side_arg_dynamic_struct_visitor(_dynamic_struct_visitor, _ctx, _attr) \ { \ .dynamic_type = SIDE_DYNAMIC_TYPE_STRUCT_VISITOR, \ - .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ - .attr = _attr, \ .u = { \ .side_dynamic_struct_visitor = { \ .app_ctx = _ctx, \ .visitor = _dynamic_struct_visitor, \ + .attr = _attr, \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ }, \ }, \ } -#define side_arg_dynamic_define_vec(_identifier, _sav) \ +#define side_arg_dynamic_define_vec(_identifier, _sav, _attr) \ const struct side_arg_dynamic_vec _identifier##_vec[] = { _sav }; \ const struct side_arg_dynamic_vec_vla _identifier = { \ .sav = _identifier##_vec, \ + .attr = _attr, \ .len = SIDE_ARRAY_SIZE(_identifier##_vec), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ } -#define side_arg_dynamic_define_struct(_identifier, _struct_fields) \ +#define side_arg_dynamic_define_struct(_identifier, _struct_fields, _attr) \ const struct side_arg_dynamic_event_field _identifier##_fields[] = { _struct_fields }; \ const struct side_arg_dynamic_event_struct _identifier = { \ .fields = _identifier##_fields, \ + .attr = _attr, \ .len = SIDE_ARRAY_SIZE(_identifier##_fields), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ } #define side_arg_define_vec(_identifier, _sav) \ @@ -802,60 +969,12 @@ struct side_tracer_dynamic_vla_visitor_ctx { #define side_arg_list(...) __VA_ARGS__ -#define side_attr_bool(val) { .type = SIDE_ATTR_TYPE_BOOL, .u = { .side_bool = !!(val) } } -#define side_attr_u8(val) { .type = SIDE_ATTR_TYPE_U8, .u = { .side_u8 = (val) } } -#define side_attr_u16(val) { .type = SIDE_ATTR_TYPE_U16, .u = { .side_u16 = (val) } } -#define side_attr_u32(val) { .type = SIDE_ATTR_TYPE_U32, .u = { .side_u32 = (val) } } -#define side_attr_u64(val) { .type = SIDE_ATTR_TYPE_U64, .u = { .side_u64 = (val) } } -#define side_attr_s8(val) { .type = SIDE_ATTR_TYPE_S8, .u = { .side_s8 = (val) } } -#define side_attr_s16(val) { .type = SIDE_ATTR_TYPE_S16, .u = { .side_s16 = (val) } } -#define side_attr_s32(val) { .type = SIDE_ATTR_TYPE_S32, .u = { .side_s32 = (val) } } -#define side_attr_s64(val) { .type = SIDE_ATTR_TYPE_S64, .u = { .side_s64 = (val) } } -#define side_attr_float_binary16(val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY16, .u = { .side_float_binary16 = (val) } } -#define side_attr_float_binary32(val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY32, .u = { .side_float_binary32 = (val) } } -#define side_attr_float_binary64(val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY64, .u = { .side_float_binary64 = (val) } } -#define side_attr_float_binary128(val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY128, .u = { .side_float_binary128 = (val) } } -#define side_attr_string(val) { .type = SIDE_ATTR_TYPE_STRING, .u = { .string = (val) } } - -#define side_event_cond(desc) if (side_unlikely((desc)->enabled)) - -#define side_event_call(desc, _sav) \ - { \ - const struct side_arg_vec side_sav[] = { _sav }; \ - const struct side_arg_vec_description sav_desc = { \ - .sav = side_sav, \ - .len = SIDE_ARRAY_SIZE(side_sav), \ - }; \ - side_call(desc, &sav_desc); \ - } - -#define side_event(desc, sav) \ - side_event_cond(desc) \ - side_event_call(desc, SIDE_PARAM(sav)) - -#define side_event_call_variadic(desc, _sav, _var_fields) \ - { \ - const struct side_arg_vec side_sav[] = { _sav }; \ - const struct side_arg_vec_description sav_desc = { \ - .sav = side_sav, \ - .len = SIDE_ARRAY_SIZE(side_sav), \ - }; \ - const struct side_arg_dynamic_event_field side_fields[] = { _var_fields }; \ - const struct side_arg_dynamic_event_struct var_struct = { \ - .fields = side_fields, \ - .len = SIDE_ARRAY_SIZE(side_fields), \ - }; \ - side_call_variadic(desc, &sav_desc, &var_struct); \ - } - -#define side_event_variadic(desc, sav, var) \ - side_event_cond(desc) \ - side_event_call_variadic(desc, SIDE_PARAM(sav), SIDE_PARAM(var)) - -#define side_define_enum(_identifier, _mappings) \ +#define side_define_enum(_identifier, _mappings, _attr) \ const struct side_enum_mappings _identifier = { \ .mappings = _mappings, \ + .attr = _attr, \ .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ } #define side_enum_mapping_list(...) \ @@ -875,10 +994,12 @@ struct side_tracer_dynamic_vla_visitor_ctx { .label = _label, \ } -#define side_define_enum_bitmap(_identifier, _mappings) \ +#define side_define_enum_bitmap(_identifier, _mappings, _attr) \ const struct side_enum_bitmap_mappings _identifier = { \ .mappings = _mappings, \ + .attr = _attr, \ .nr_mappings = SIDE_ARRAY_SIZE(SIDE_PARAM(_mappings)), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ } #define side_enum_bitmap_mapping_list(...) \ @@ -898,10 +1019,49 @@ struct side_tracer_dynamic_vla_visitor_ctx { .label = _label, \ } +#define side_event_cond(_desc) if (side_unlikely(_desc##_enabled)) + +#define side_event_call(_desc, _sav) \ + { \ + const struct side_arg_vec side_sav[] = { _sav }; \ + const struct side_arg_vec_description sav_desc = { \ + .sav = side_sav, \ + .len = SIDE_ARRAY_SIZE(side_sav), \ + }; \ + side_call(&(_desc), &sav_desc); \ + } + +#define side_event(_desc, _sav) \ + side_event_cond(_desc) \ + side_event_call(_desc, SIDE_PARAM(_sav)) + +#define side_event_call_variadic(_desc, _sav, _var_fields, _attr) \ + { \ + const struct side_arg_vec side_sav[] = { _sav }; \ + const struct side_arg_vec_description sav_desc = { \ + .sav = side_sav, \ + .len = SIDE_ARRAY_SIZE(side_sav), \ + }; \ + const struct side_arg_dynamic_event_field side_fields[] = { _var_fields }; \ + const struct side_arg_dynamic_event_struct var_struct = { \ + .fields = side_fields, \ + .attr = _attr, \ + .len = SIDE_ARRAY_SIZE(side_fields), \ + .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ + }; \ + side_call_variadic(&(_desc), &sav_desc, &var_struct); \ + } + +#define side_event_variadic(_desc, _sav, _var, _attr) \ + side_event_cond(_desc) \ + side_event_call_variadic(_desc, SIDE_PARAM(_sav), SIDE_PARAM(_var), SIDE_PARAM(_attr)) + #define _side_define_event(_identifier, _provider, _event, _loglevel, _fields, _attr, _flags) \ - struct side_event_description _identifier = { \ + uint32_t _identifier##_enabled __attribute__((section("side_event_enable"))); \ + struct side_callbacks _identifier##_callbacks __attribute__((section("side_event_callbacks"))); \ + const struct side_event_description _identifier = { \ .version = 0, \ - .enabled = 0, \ + .enabled = &(_identifier##_enabled), \ .loglevel = _loglevel, \ .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \ @@ -910,7 +1070,10 @@ struct side_tracer_dynamic_vla_visitor_ctx { .event_name = _event, \ .fields = _fields, \ .attr = _attr, \ - } + .callbacks = &(_identifier##_callbacks), \ + }; \ + const struct side_event_description *_identifier##_ptr \ + __attribute__((section("side_event_description"), used)) = &(_identifier); #define side_define_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \ _side_define_event(_identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \