/* Statically declared compound types */
SIDE_TYPE_STRUCT,
- SIDE_TYPE_STRUCT_SG,
SIDE_TYPE_ARRAY,
SIDE_TYPE_VLA,
SIDE_TYPE_VLA_VISITOR,
#define side_type_struct_sg(_struct_sg, _offset) \
{ \
- .type = SIDE_TYPE_STRUCT_SG, \
+ .type = SIDE_TYPE_SG_STRUCT, \
.u = { \
.side_sg = { \
.offset = _offset, \
#define side_arg_float_binary128(_val) { .type = SIDE_TYPE_FLOAT_BINARY128, .u = { .side_static = { .float_value = { .side_float_binary128 = (_val) } } } }
#define side_arg_struct(_side_type) { .type = SIDE_TYPE_STRUCT, .u = { .side_static = { .side_struct = (_side_type) } } }
-#define side_arg_struct_sg(_ptr) { .type = SIDE_TYPE_STRUCT_SG, .u = { .side_static = { .side_struct_sg_ptr = (_ptr) } } }
+#define side_arg_struct_sg(_ptr) { .type = SIDE_TYPE_SG_STRUCT, .u = { .side_static = { .side_struct_sg_ptr = (_ptr) } } }
#define side_arg_unsigned_integer_sg(_ptr) { .type = SIDE_TYPE_SG_UNSIGNED_INT, .u = { .side_static = { .side_integer_sg_ptr = (_ptr) } } }
#define side_arg_signed_integer_sg(_ptr) { .type = SIDE_TYPE_SG_SIGNED_INT, .u = { .side_static = { .side_integer_sg_ptr = (_ptr) } } }
#define side_arg_array(_side_type) { .type = SIDE_TYPE_ARRAY, .u = { .side_static = { .side_array = (_side_type) } } }
}
}
+struct testnest2 {
+ uint8_t c;
+};
+
+struct testnest1 {
+ uint64_t b;
+ struct testnest2 *nest;
+};
+
+struct testnest0 {
+ uint32_t a;
+ struct testnest1 *nest;
+};
+
+static side_define_struct(mystructsgnest2,
+ side_field_list(
+ side_field_sg_unsigned_integer("c", offsetof(struct testnest2, c),
+ side_struct_field_sizeof_bit(struct testnest2, c), 0,
+ side_struct_field_sizeof_bit(struct testnest2, c), side_attr_list()),
+ ),
+ side_attr_list()
+);
+
+static side_define_struct(mystructsgnest1,
+ side_field_list(
+ side_field_sg_unsigned_integer("b", offsetof(struct testnest1, b),
+ side_struct_field_sizeof_bit(struct testnest1, b), 0,
+ side_struct_field_sizeof_bit(struct testnest1, b), side_attr_list()),
+ side_field_struct_sg("nest2", &mystructsgnest2,
+ offsetof(struct testnest1, nest)),
+ ),
+ side_attr_list()
+);
+
+static side_define_struct(mystructsgnest0,
+ side_field_list(
+ side_field_sg_unsigned_integer("a", offsetof(struct testnest0, a),
+ side_struct_field_sizeof_bit(struct testnest0, a), 0,
+ side_struct_field_sizeof_bit(struct testnest0, a), side_attr_list()),
+ side_field_struct_sg("nest1", &mystructsgnest1,
+ offsetof(struct testnest0, nest)),
+ ),
+ side_attr_list()
+);
+
+side_static_event(my_provider_event_structsg_nest,
+ "myprovider", "myeventstructsgnest", SIDE_LOGLEVEL_DEBUG,
+ side_field_list(
+ side_field_struct_sg("nest0", &mystructsgnest0, 0),
+ ),
+ side_attr_list()
+);
+
+static
+void test_struct_sg_nest(void)
+{
+ side_event_cond(my_provider_event_structsg_nest) {
+ struct testnest2 mystruct2 = {
+ .c = 77,
+ };
+ struct testnest1 mystruct1 = {
+ .b = 66,
+ .nest = &mystruct2,
+ };
+ struct testnest0 mystruct = {
+ .a = 55,
+ .nest = &mystruct1,
+ };
+ side_event_call(my_provider_event_structsg_nest,
+ side_arg_list(
+ side_arg_struct_sg(&mystruct),
+ )
+ );
+ }
+}
+
int main()
{
test_fields();
test_endian();
test_base();
test_struct_sg();
+ test_struct_sg_nest();
return 0;
}
static
void tracer_print_struct(const struct side_type *type_desc, const struct side_arg_vec *side_arg_vec);
static
-void tracer_print_sg_struct(const struct side_type_sg *type_sg, void *_ptr);
+void tracer_print_sg_struct(const struct side_type_sg *type_sg, const void *_ptr);
static
-void tracer_print_sg_integer_type(const struct side_type_sg *type_sg, void *_ptr);
+void tracer_print_sg_integer_type(const struct side_type_sg *type_sg, const void *_ptr);
static
void tracer_print_array(const struct side_type *type_desc, const struct side_arg_vec *side_arg_vec);
static
case SIDE_TYPE_STRUCT:
tracer_print_struct(type_desc, item->u.side_static.side_struct);
break;
- case SIDE_TYPE_STRUCT_SG:
- tracer_print_sg_struct(&type_desc->u.side_sg, item->u.side_static.side_struct_sg_ptr);
+ case SIDE_TYPE_SG_STRUCT:
+ tracer_print_sg_struct(&type_desc->u.side_sg, &item->u.side_static.side_struct_sg_ptr);
break;
case SIDE_TYPE_SG_UNSIGNED_INT:
case SIDE_TYPE_SG_SIGNED_INT:
}
static
-void tracer_print_sg_integer_type(const struct side_type_sg *type_sg, void *_ptr)
+void tracer_print_sg_integer_type(const struct side_type_sg *type_sg, const void *_ptr)
{
const char *ptr = (const char *) _ptr;
union side_integer_value value;
}
static
-void tracer_print_sg_struct(const struct side_type_sg *type_sg, void *_ptr)
+void tracer_print_sg_struct(const struct side_type_sg *type_sg, const void *_ptr)
{
char *ptr = (char *) _ptr;
int i;
+ memcpy(&ptr, ptr + type_sg->offset, sizeof(ptr));
print_attributes("attr", ":", type_sg->u.side_struct->attr, type_sg->u.side_struct->nr_attr);
printf("%s", type_sg->u.side_struct->nr_attr ? ", " : "");
printf("fields: { ");
for (i = 0; i < type_sg->u.side_struct->nr_fields; i++) {
printf("%s", i ? ", " : "");
- tracer_print_sg_field(&type_sg->u.side_struct->fields[i], ptr + type_sg->offset);
+ tracer_print_sg_field(&type_sg->u.side_struct->fields[i], ptr);
}
printf(" }");
}