Move attributes into dynamic compound types
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 24 Oct 2022 17:17:15 +0000 (13:17 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 24 Oct 2022 17:17:15 +0000 (13:17 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/side/trace.h
src/test.c
src/tracer.c

index a50f9f976183d07c1fd03f19417a62bb51b8da16..611dbc3d8928704b564ae6086885cd008092501e 100644 (file)
@@ -310,57 +310,67 @@ struct side_event_description {
        struct side_callbacks *callbacks;
 };
 
-struct side_arg_dynamic_vec_vla {
-       const struct side_arg_dynamic_vec *sav;
-       uint32_t len;
-};
-
 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;
-               uint8_t side_blob;
+               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_blob;
 
 #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;
+                               const char *string;
+                       } u;
+               } side_basic;
 
                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;
@@ -368,7 +378,9 @@ 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 {
@@ -687,155 +699,217 @@ struct side_tracer_dynamic_vla_visitor_ctx {
 #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_blob(_val, _attr) \
        { \
                .dynamic_type = SIDE_DYNAMIC_TYPE_BLOB, \
-               .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
-               .attr = _attr, \
                .u = { \
-                       .side_blob = (_val), \
+                       .side_basic = { \
+                               .attr = _attr, \
+                               .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+                               .u = { \
+                                       .side_blob = (_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), \
                }, \
@@ -844,21 +918,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), \
                }, \
@@ -867,28 +939,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) \
@@ -937,7 +1013,7 @@ struct side_tracer_dynamic_vla_visitor_ctx {
        side_event_cond(_desc) \
                side_event_call(_desc, SIDE_PARAM(_sav))
 
-#define side_event_call_variadic(_desc, _sav, _var_fields) \
+#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 = { \
@@ -947,14 +1023,16 @@ struct side_tracer_dynamic_vla_visitor_ctx {
                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) \
+#define side_event_variadic(_desc, _sav, _var, _attr) \
        side_event_cond(_desc) \
-               side_event_call_variadic(_desc, SIDE_PARAM(_sav), SIDE_PARAM(_var))
+               side_event_call_variadic(_desc, SIDE_PARAM(_sav), SIDE_PARAM(_var), SIDE_PARAM(_attr))
 
 #define side_define_enum(_identifier, _mappings, _attr) \
        const struct side_enum_mappings _identifier = { \
index 2e9484ddae85b06c73c72597bafd44029f1710d6..f716d33c2bb3c6c97ee61f9f3c98f993dcb6cfcc 100644 (file)
@@ -313,11 +313,12 @@ void test_dynamic_vla(void)
                        side_arg_dynamic_u32(1, side_attr_list()),
                        side_arg_dynamic_u32(2, side_attr_list()),
                        side_arg_dynamic_u32(3, side_attr_list()),
-               )
+               ),
+               side_attr_list()
        );
        my_provider_event_dynamic_vla_enabled = 1;
        side_event(my_provider_event_dynamic_vla,
-               side_arg_list(side_arg_dynamic(side_arg_dynamic_vla(&myvla, side_attr_list()))));
+               side_arg_list(side_arg_dynamic(side_arg_dynamic_vla(&myvla))));
 }
 
 static side_define_event(my_provider_event_dynamic_null,
@@ -352,12 +353,13 @@ void test_dynamic_struct(void)
                        side_arg_dynamic_field("a", side_arg_dynamic_u32(43, side_attr_list())),
                        side_arg_dynamic_field("b", side_arg_dynamic_string("zzz", side_attr_list())),
                        side_arg_dynamic_field("c", side_arg_dynamic_null(side_attr_list())),
-               )
+               ),
+               side_attr_list()
        );
 
        my_provider_event_dynamic_struct_enabled = 1;
        side_event(my_provider_event_dynamic_struct,
-               side_arg_list(side_arg_dynamic(side_arg_dynamic_struct(&mystruct, side_attr_list()))));
+               side_arg_list(side_arg_dynamic(side_arg_dynamic_struct(&mystruct))));
 }
 
 static side_define_event(my_provider_event_dynamic_nested_struct,
@@ -375,23 +377,26 @@ void test_dynamic_nested_struct(void)
                side_arg_list(
                        side_arg_dynamic_field("a", side_arg_dynamic_u32(43, side_attr_list())),
                        side_arg_dynamic_field("b", side_arg_dynamic_u8(55, side_attr_list())),
-               )
+               ),
+               side_attr_list()
        );
        side_arg_dynamic_define_struct(nested2,
                side_arg_list(
                        side_arg_dynamic_field("aa", side_arg_dynamic_u64(128, side_attr_list())),
                        side_arg_dynamic_field("bb", side_arg_dynamic_u16(1, side_attr_list())),
-               )
+               ),
+               side_attr_list()
        );
        side_arg_dynamic_define_struct(mystruct,
                side_arg_list(
-                       side_arg_dynamic_field("nested", side_arg_dynamic_struct(&nested, side_attr_list())),
-                       side_arg_dynamic_field("nested2", side_arg_dynamic_struct(&nested2, side_attr_list())),
-               )
+                       side_arg_dynamic_field("nested", side_arg_dynamic_struct(&nested)),
+                       side_arg_dynamic_field("nested2", side_arg_dynamic_struct(&nested2)),
+               ),
+               side_attr_list()
        );
        my_provider_event_dynamic_nested_struct_enabled = 1;
        side_event(my_provider_event_dynamic_nested_struct,
-               side_arg_list(side_arg_dynamic(side_arg_dynamic_struct(&mystruct, side_attr_list()))));
+               side_arg_list(side_arg_dynamic(side_arg_dynamic_struct(&mystruct))));
 }
 
 static side_define_event(my_provider_event_dynamic_vla_struct,
@@ -409,19 +414,21 @@ void test_dynamic_vla_struct(void)
                side_arg_list(
                        side_arg_dynamic_field("a", side_arg_dynamic_u32(43, side_attr_list())),
                        side_arg_dynamic_field("b", side_arg_dynamic_u8(55, side_attr_list())),
-               )
+               ),
+               side_attr_list()
        );
        side_arg_dynamic_define_vec(myvla,
                side_arg_list(
-                       side_arg_dynamic_struct(&nested, side_attr_list()),
-                       side_arg_dynamic_struct(&nested, side_attr_list()),
-                       side_arg_dynamic_struct(&nested, side_attr_list()),
-                       side_arg_dynamic_struct(&nested, side_attr_list()),
-               )
+                       side_arg_dynamic_struct(&nested),
+                       side_arg_dynamic_struct(&nested),
+                       side_arg_dynamic_struct(&nested),
+                       side_arg_dynamic_struct(&nested),
+               ),
+               side_attr_list()
        );
        my_provider_event_dynamic_vla_struct_enabled = 1;
        side_event(my_provider_event_dynamic_vla_struct,
-               side_arg_list(side_arg_dynamic(side_arg_dynamic_vla(&myvla, side_attr_list()))));
+               side_arg_list(side_arg_dynamic(side_arg_dynamic_vla(&myvla))));
 }
 
 static side_define_event(my_provider_event_dynamic_struct_vla,
@@ -440,24 +447,27 @@ void test_dynamic_struct_vla(void)
                        side_arg_dynamic_u32(1, side_attr_list()),
                        side_arg_dynamic_u32(2, side_attr_list()),
                        side_arg_dynamic_u32(3, side_attr_list()),
-               )
+               ),
+               side_attr_list()
        );
        side_arg_dynamic_define_vec(myvla2,
                side_arg_list(
                        side_arg_dynamic_u32(4, side_attr_list()),
                        side_arg_dynamic_u64(5, side_attr_list()),
                        side_arg_dynamic_u32(6, side_attr_list()),
-               )
+               ),
+               side_attr_list()
        );
        side_arg_dynamic_define_struct(mystruct,
                side_arg_list(
-                       side_arg_dynamic_field("a", side_arg_dynamic_vla(&myvla, side_attr_list())),
-                       side_arg_dynamic_field("b", side_arg_dynamic_vla(&myvla2, side_attr_list())),
-               )
+                       side_arg_dynamic_field("a", side_arg_dynamic_vla(&myvla)),
+                       side_arg_dynamic_field("b", side_arg_dynamic_vla(&myvla2)),
+               ),
+               side_attr_list()
        );
        my_provider_event_dynamic_struct_vla_enabled = 1;
        side_event(my_provider_event_dynamic_struct_vla,
-               side_arg_list(side_arg_dynamic(side_arg_dynamic_struct(&mystruct, side_attr_list()))));
+               side_arg_list(side_arg_dynamic(side_arg_dynamic_struct(&mystruct))));
 }
 
 static side_define_event(my_provider_event_dynamic_nested_vla,
@@ -476,24 +486,27 @@ void test_dynamic_nested_vla(void)
                        side_arg_dynamic_u32(1, side_attr_list()),
                        side_arg_dynamic_u16(2, side_attr_list()),
                        side_arg_dynamic_u32(3, side_attr_list()),
-               )
+               ),
+               side_attr_list()
        );
        side_arg_dynamic_define_vec(nestedvla2,
                side_arg_list(
                        side_arg_dynamic_u8(4, side_attr_list()),
                        side_arg_dynamic_u32(5, side_attr_list()),
                        side_arg_dynamic_u32(6, side_attr_list()),
-               )
+               ),
+               side_attr_list()
        );
        side_arg_dynamic_define_vec(myvla,
                side_arg_list(
-                       side_arg_dynamic_vla(&nestedvla, side_attr_list()),
-                       side_arg_dynamic_vla(&nestedvla2, side_attr_list()),
-               )
+                       side_arg_dynamic_vla(&nestedvla),
+                       side_arg_dynamic_vla(&nestedvla2),
+               ),
+               side_attr_list()
        );
        my_provider_event_dynamic_nested_vla_enabled = 1;
        side_event(my_provider_event_dynamic_nested_vla,
-               side_arg_list(side_arg_dynamic(side_arg_dynamic_vla(&myvla, side_attr_list()))));
+               side_arg_list(side_arg_dynamic(side_arg_dynamic_vla(&myvla))));
 }
 
 static side_define_event_variadic(my_provider_event_variadic,
@@ -511,7 +524,8 @@ void test_variadic(void)
                side_arg_list(
                        side_arg_dynamic_field("a", side_arg_dynamic_u32(55, side_attr_list())),
                        side_arg_dynamic_field("b", side_arg_dynamic_s8(-4, side_attr_list())),
-               )
+               ),
+               side_attr_list()
        );
 }
 
@@ -536,7 +550,8 @@ void test_static_variadic(void)
                side_arg_list(
                        side_arg_dynamic_field("a", side_arg_dynamic_u32(55, side_attr_list())),
                        side_arg_dynamic_field("b", side_arg_dynamic_s8(-4, side_attr_list())),
-               )
+               ),
+               side_attr_list()
        );
 }
 
@@ -595,7 +610,8 @@ void test_dynamic_bool(void)
                        side_arg_dynamic_field("b_true", side_arg_dynamic_bool(-4, side_attr_list())),
                        side_arg_dynamic_field("c_false", side_arg_dynamic_bool(0, side_attr_list())),
                        side_arg_dynamic_field("d_true", side_arg_dynamic_bool(256, side_attr_list())),
-               )
+               ),
+               side_attr_list()
        );
 }
 
@@ -621,10 +637,14 @@ enum side_visitor_status test_dynamic_vla_visitor(const struct side_tracer_dynam
        for (i = 0; i < length; i++) {
                const struct side_arg_dynamic_vec elem = {
                        .dynamic_type = SIDE_DYNAMIC_TYPE_U32,
-                       .nr_attr = 0,
-                       .attr = NULL,
                        .u = {
-                               .side_u32 = ctx->ptr[i],
+                               .side_basic = {
+                                       .attr = NULL,
+                                       .nr_attr = 0,
+                                       .u = {
+                                               .side_u32 = ctx->ptr[i],
+                                       },
+                               },
                        },
                };
                if (tracer_ctx->write_elem(tracer_ctx, &elem) != SIDE_VISITOR_STATUS_OK)
@@ -683,10 +703,14 @@ enum side_visitor_status test_dynamic_struct_visitor(const struct side_tracer_dy
                        .field_name = ctx->ptr[i].name,
                        .elem = {
                                .dynamic_type = SIDE_DYNAMIC_TYPE_U32,
-                               .nr_attr = 0,
-                               .attr = NULL,
                                .u = {
-                                       .side_u32 = ctx->ptr[i].value,
+                                       .side_basic = {
+                                               .nr_attr = 0,
+                                               .attr = NULL,
+                                               .u = {
+                                                       .side_u32 = ctx->ptr[i].value,
+                                               },
+                                       },
                                },
                        },
                };
@@ -794,7 +818,8 @@ void test_variadic_attr(void)
                                        )
                                )
                        ),
-               )
+               ),
+               side_attr_list()
        );
 }
 
@@ -817,21 +842,19 @@ void test_variadic_vla_attr(void)
                        ),
                        side_arg_dynamic_u32(2, side_attr_list()),
                        side_arg_dynamic_u32(3, side_attr_list()),
+               ),
+               side_attr_list(
+                       side_attr("X", side_attr_u8(1)),
+                       side_attr("Y", side_attr_u8(2)),
                )
        );
        my_provider_event_variadic_vla_attr_enabled = 1;
        side_event_variadic(my_provider_event_variadic_vla_attr,
                side_arg_list(),
                side_arg_list(
-                       side_arg_dynamic_field("a",
-                               side_arg_dynamic_vla(&myvla,
-                                       side_attr_list(
-                                               side_attr("X", side_attr_u8(1)),
-                                               side_attr("Y", side_attr_u8(2)),
-                                       )
-                               )
-                       ),
-               )
+                       side_arg_dynamic_field("a", side_arg_dynamic_vla(&myvla)),
+               ),
+               side_attr_list()
        );
 }
 
@@ -856,20 +879,18 @@ void test_variadic_struct_attr(void)
                                        )
                                ),
                                side_arg_dynamic_field("b", side_arg_dynamic_u8(55, side_attr_list())),
+                       ),
+                       side_attr_list(
+                               side_attr("X", side_attr_u8(1)),
+                               side_attr("Y", side_attr_u8(2)),
                        )
                );
                side_event_call_variadic(my_provider_event_variadic_struct_attr,
                        side_arg_list(),
                        side_arg_list(
-                               side_arg_dynamic_field("a",
-                                       side_arg_dynamic_struct(&mystruct,
-                                               side_attr_list(
-                                                       side_attr("X", side_attr_u8(1)),
-                                                       side_attr("Y", side_attr_u8(2)),
-                                               )
-                                       )
-                               ),
-                       )
+                               side_arg_dynamic_field("a", side_arg_dynamic_struct(&mystruct)),
+                       ),
+                       side_attr_list()
                );
        }
 }
@@ -947,7 +968,8 @@ void test_variadic_float(void)
                                side_arg_dynamic_float_binary128(4.4, side_attr_list())
                        ),
 #endif
-               )
+               ),
+               side_attr_list()
        );
 }
 
@@ -1052,7 +1074,8 @@ void test_blob(void)
                        side_arg_list(
                                side_arg_dynamic_blob(0x22, side_attr_list()),
                                side_arg_dynamic_blob(0x33, side_attr_list()),
-                       )
+                       ),
+                       side_attr_list()
                );
                side_event_call_variadic(my_provider_event_blob,
                        side_arg_list(
@@ -1065,10 +1088,9 @@ void test_blob(void)
                                side_arg_dynamic_field("varblobfield",
                                        side_arg_dynamic_blob(0x55, side_attr_list())
                                ),
-                               side_arg_dynamic_field("varblobvla",
-                                       side_arg_dynamic_vla(&myvla, side_attr_list())
-                               ),
-                       )
+                               side_arg_dynamic_field("varblobvla", side_arg_dynamic_vla(&myvla)),
+                       ),
+                       side_attr_list()
                );
        }
 }
index 3d73620d79e8c99b0f57dece83d5efbc8b0d9cf0..d46dc17de144adea62208800570b3c4e2f126a39 100644 (file)
@@ -753,6 +753,8 @@ void tracer_print_dynamic_struct(const struct side_arg_dynamic_event_struct *dyn
        uint32_t len = dynamic_struct->len;
        int i;
 
+       print_attributes("attr:: ", dynamic_struct->attr, dynamic_struct->nr_attr);
+       printf("%s", dynamic_struct->nr_attr ? ", " : "");
        printf("fields:: ");
        printf("[ ");
        for (i = 0; i < len; i++) {
@@ -793,6 +795,8 @@ void tracer_print_dynamic_struct_visitor(const struct side_arg_dynamic_vec *item
        };
        void *app_ctx = item->u.side_dynamic_struct_visitor.app_ctx;
 
+       print_attributes("attr:: ", item->u.side_dynamic_struct_visitor.attr, item->u.side_dynamic_struct_visitor.nr_attr);
+       printf("%s", item->u.side_dynamic_struct_visitor.nr_attr ? ", " : "");
        printf("fields:: ");
        printf("[ ");
        status = item->u.side_dynamic_struct_visitor.visitor(&tracer_ctx, app_ctx);
@@ -813,6 +817,8 @@ void tracer_print_dynamic_vla(const struct side_arg_dynamic_vec_vla *vla)
        uint32_t side_sav_len = vla->len;
        int i;
 
+       print_attributes("attr:: ", vla->attr, vla->nr_attr);
+       printf("%s", vla->nr_attr ? ", " : "");
        printf("elements:: ");
        printf("[ ");
        for (i = 0; i < side_sav_len; i++) {
@@ -851,6 +857,8 @@ void tracer_print_dynamic_vla_visitor(const struct side_arg_dynamic_vec *item)
        };
        void *app_ctx = item->u.side_dynamic_vla_visitor.app_ctx;
 
+       print_attributes("attr:: ", item->u.side_dynamic_vla_visitor.attr, item->u.side_dynamic_vla_visitor.nr_attr);
+       printf("%s", item->u.side_dynamic_vla_visitor.nr_attr ? ", " : "");
        printf("elements:: ");
        printf("[ ");
        status = item->u.side_dynamic_vla_visitor.visitor(&tracer_ctx, app_ctx);
@@ -868,93 +876,123 @@ static
 void tracer_print_dynamic(const struct side_arg_dynamic_vec *item)
 {
        printf("{ ");
-       print_attributes("attr:: ", item->attr, item->nr_attr);
-       printf("%s", item->nr_attr ? ", " : "");
        switch (item->dynamic_type) {
        case SIDE_DYNAMIC_TYPE_NULL:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
                printf("<NULL TYPE>");
                break;
        case SIDE_DYNAMIC_TYPE_BOOL:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
-               printf("%s", item->u.side_bool ? "true" : "false");
+               printf("%s", item->u.side_basic.u.side_bool ? "true" : "false");
                break;
        case SIDE_DYNAMIC_TYPE_U8:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
-               printf("%" PRIu8, item->u.side_u8);
+               printf("%" PRIu8, item->u.side_basic.u.side_u8);
                break;
        case SIDE_DYNAMIC_TYPE_U16:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
-               printf("%" PRIu16, item->u.side_u16);
+               printf("%" PRIu16, item->u.side_basic.u.side_u16);
                break;
        case SIDE_DYNAMIC_TYPE_U32:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
-               printf("%" PRIu32, item->u.side_u32);
+               printf("%" PRIu32, item->u.side_basic.u.side_u32);
                break;
        case SIDE_DYNAMIC_TYPE_U64:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
-               printf("%" PRIu64, item->u.side_u64);
+               printf("%" PRIu64, item->u.side_basic.u.side_u64);
                break;
        case SIDE_DYNAMIC_TYPE_S8:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
-               printf("%" PRId8, item->u.side_s8);
+               printf("%" PRId8, item->u.side_basic.u.side_s8);
                break;
        case SIDE_DYNAMIC_TYPE_S16:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
-               printf("%" PRId16, item->u.side_s16);
+               printf("%" PRId16, item->u.side_basic.u.side_s16);
                break;
        case SIDE_DYNAMIC_TYPE_S32:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
-               printf("%" PRId32, item->u.side_s32);
+               printf("%" PRId32, item->u.side_basic.u.side_s32);
                break;
        case SIDE_DYNAMIC_TYPE_S64:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
-               printf("%" PRId64, item->u.side_s64);
+               printf("%" PRId64, item->u.side_basic.u.side_s64);
                break;
        case SIDE_DYNAMIC_TYPE_BLOB:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
-               printf("0x%" PRIx8, item->u.side_blob);
+               printf("0x%" PRIx8, item->u.side_basic.u.side_blob);
                break;
 
        case SIDE_DYNAMIC_TYPE_FLOAT_BINARY16:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
 #if __HAVE_FLOAT16
-               printf("%g", (double) item->u.side_float_binary16);
+               printf("%g", (double) item->u.side_basic.u.side_float_binary16);
                break;
 #else
                printf("ERROR: Unsupported binary16 float type\n");
                abort();
 #endif
        case SIDE_DYNAMIC_TYPE_FLOAT_BINARY32:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
 #if __HAVE_FLOAT32
-               printf("%g", (double) item->u.side_float_binary32);
+               printf("%g", (double) item->u.side_basic.u.side_float_binary32);
                break;
 #else
                printf("ERROR: Unsupported binary32 float type\n");
                abort();
 #endif
        case SIDE_DYNAMIC_TYPE_FLOAT_BINARY64:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
 #if __HAVE_FLOAT64
-               printf("%g", (double) item->u.side_float_binary64);
+               printf("%g", (double) item->u.side_basic.u.side_float_binary64);
                break;
 #else
                printf("ERROR: Unsupported binary64 float type\n");
                abort();
 #endif
        case SIDE_DYNAMIC_TYPE_FLOAT_BINARY128:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
 #if __HAVE_FLOAT128
-               printf("%Lg", (long double) item->u.side_float_binary128);
+               printf("%Lg", (long double) item->u.side_basic.u.side_float_binary128);
                break;
 #else
                printf("ERROR: Unsupported binary128 float type\n");
                abort();
 #endif
        case SIDE_DYNAMIC_TYPE_STRING:
+               print_attributes("attr:: ", item->u.side_basic.attr, item->u.side_basic.nr_attr);
+               printf("%s", item->u.side_basic.nr_attr ? ", " : "");
                printf("value:: ");
-               printf("\"%s\"", item->u.string);
+               printf("\"%s\"", item->u.side_basic.u.string);
                break;
        case SIDE_DYNAMIC_TYPE_STRUCT:
                tracer_print_dynamic_struct(item->u.side_dynamic_struct);
This page took 0.035552 seconds and 4 git commands to generate.