struct side_arg_dynamic_vla;
struct side_type;
struct side_event_field;
-struct side_event_field_sg;
struct side_tracer_visitor_ctx;
struct side_tracer_dynamic_struct_visitor_ctx;
struct side_tracer_dynamic_vla_visitor_ctx;
SIDE_TYPE_DYNAMIC,
+ /* Scatter-gather types */
+ SIDE_TYPE_SG_UNSIGNED_INT,
+ SIDE_TYPE_SG_SIGNED_INT,
+ SIDE_TYPE_SG_STRUCT,
+
/* Dynamic types */
SIDE_TYPE_DYNAMIC_NULL,
SIDE_TYPE_DYNAMIC_BOOL,
SIDE_ATTR_TYPE_STRING,
};
-enum side_type_label_sg {
- SIDE_TYPE_SG_NULL,
- SIDE_TYPE_SG_UNSIGNED_INT,
- SIDE_TYPE_SG_SIGNED_INT,
-};
-
enum side_loglevel {
SIDE_LOGLEVEL_EMERG = 0,
SIDE_LOGLEVEL_ALERT = 1,
const struct side_attr *attr;
} SIDE_PACKED;
-struct side_type_sg_description {
+struct side_type_sg {
uint64_t offset; /* bytes */
- uint32_t type; /* enum side_type_label_sg */
union {
- struct side_type_null side_null;
struct {
struct side_type_integer type;
uint16_t offset_bits; /* bits */
} SIDE_PACKED side_integer;
+ const struct side_type_struct *side_struct;
} SIDE_PACKED u;
} SIDE_PACKED;
-struct side_struct_field_sg {
- const char *field_name;
- struct side_type_sg_description side_type;
-} SIDE_PACKED;
-
-/* Structure fields scatter-gather. */
-struct side_type_struct_sg {
- uint32_t nr_fields;
- uint32_t nr_attr;
- const struct side_struct_field_sg *fields_sg;
- const struct side_attr *attr;
-} SIDE_PACKED;
-
/* Statically defined types. */
struct side_type {
uint32_t type; /* enum side_type_label */
uint32_t nr_attr;
} SIDE_PACKED side_vla_visitor;
const struct side_type_struct *side_struct;
- const struct side_type_struct_sg *side_struct_sg;
/* Enumeration types */
struct {
const struct side_enum_bitmap_mappings *mappings;
const struct side_type *elem_type;
} SIDE_PACKED side_enum_bitmap;
+
+ /* Scatter-gather type */
+ struct side_type_sg side_sg;
} SIDE_PACKED u;
} SIDE_PACKED;
void *p;
uint32_t length;
} SIDE_PACKED side_vla_fixint;
+
+ /* Scatter-gather */
+ void *side_integer_sg_ptr;
void *side_struct_sg_ptr;
} SIDE_PACKED;
SIDE_COMPOUND_LITERAL(const struct side_type_struct, \
_side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM(_attr)))
-/* Scatter-gather struct */
-
-#define _side_field_sg(_name, _type) \
- { \
- .field_name = _name, \
- .side_type = _type, \
- }
-
-#define side_type_sg_null(_attr) \
- { \
- .offset = 0, \
- .type = SIDE_TYPE_SG_NULL, \
- .u = { \
- .side_null = { \
- .attr = _attr, \
- .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
- }, \
- }, \
- }
-
-#define side_field_sg_null(_name, _attr) \
- _side_field_sg(_name, side_type_sg_null(SIDE_PARAM(_attr)))
+/* Scatter-gather fields */
#define _side_type_sg_integer(_type, _signedness, _byte_order, _offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
{ \
- .offset = _offset, \
.type = _type, \
.u = { \
- .side_integer = { \
- .type = { \
- .attr = _attr, \
- .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
- .integer_size_bits = _integer_size_bits, \
- .len_bits = _len_bits, \
- .signedness = _signedness, \
- .byte_order = _byte_order, \
+ .side_sg = { \
+ .offset = _offset, \
+ .u = { \
+ .side_integer = { \
+ .type = { \
+ .attr = _attr, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .integer_size_bits = _integer_size_bits, \
+ .len_bits = _len_bits, \
+ .signedness = _signedness, \
+ .byte_order = _byte_order, \
+ }, \
+ .offset_bits = _offset_bits, \
+ }, \
}, \
- .offset_bits = _offset_bits, \
}, \
}, \
}
_integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr))
#define side_field_sg_unsigned_integer(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
- _side_field_sg(_name, side_type_sg_unsigned_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr)))
+ _side_field(_name, side_type_sg_unsigned_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr)))
#define side_field_sg_signed_integer(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
- _side_field_sg(_name, side_type_sg_signed_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr)))
+ _side_field(_name, side_type_sg_signed_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr)))
-#define side_type_struct_sg(_struct_sg) \
+#define side_type_struct_sg(_struct_sg, _offset) \
{ \
.type = SIDE_TYPE_STRUCT_SG, \
.u = { \
- .side_struct_sg = _struct_sg, \
+ .side_sg = { \
+ .offset = _offset, \
+ .u = { \
+ .side_struct = _struct_sg, \
+ }, \
+ }, \
}, \
}
-#define side_field_struct_sg(_name, _struct_sg) \
- _side_field(_name, side_type_struct_sg(SIDE_PARAM(_struct_sg)))
-
-#define _side_type_struct_sg_define(_fields_sg, _attr) \
- { \
- .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields_sg)), \
- .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
- .fields_sg = _fields_sg, \
- .attr = _attr, \
- }
-
-#define side_define_struct_sg(_identifier, _fields_sg, _attr) \
- const struct side_type_struct_sg _identifier = _side_type_struct_sg_define(SIDE_PARAM(_fields_sg), SIDE_PARAM(_attr))
-
-#define side_struct_sg_literal(_fields_sg, _attr) \
- SIDE_COMPOUND_LITERAL(const struct side_type_struct_sg, \
- _side_type_struct_sg_define(SIDE_PARAM(_fields_sg), SIDE_PARAM(_attr)))
+#define side_field_struct_sg(_name, _struct_sg, _offset) \
+ _side_field(_name, side_type_struct_sg(SIDE_PARAM(_struct_sg), _offset))
#define side_type_array(_elem_type, _length, _attr) \
{ \
#define side_field_list(...) \
SIDE_COMPOUND_LITERAL(const struct side_event_field, __VA_ARGS__)
-#define side_field_sg_list(...) \
- SIDE_COMPOUND_LITERAL(const struct side_struct_field_sg, __VA_ARGS__)
-
/* Static field arguments */
#define side_arg_null(_val) { .type = SIDE_TYPE_NULL }
#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_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) } } }
#define side_arg_vla(_side_type) { .type = SIDE_TYPE_VLA, .u = { .side_static = { .side_vla = (_side_type) } } }
#define side_arg_vla_visitor(_ctx) { .type = SIDE_TYPE_VLA_VISITOR, .u = { .side_static = { .side_vla_app_visitor_ctx = (_ctx) } } }
int64_t k;
};
-static side_define_struct_sg(mystructsgdef,
- side_field_sg_list(
+static side_define_struct(mystructsgdef,
+ side_field_list(
side_field_sg_unsigned_integer("a", offsetof(struct test, a),
side_struct_field_sizeof_bit(struct test, a), 0,
side_struct_field_sizeof_bit(struct test, a), side_attr_list()),
side_field_sg_signed_integer("k", offsetof(struct test, k),
side_struct_field_sizeof_bit(struct test, k), 1, 63,
side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
- side_field_sg_null("null", side_attr_list()),
),
side_attr_list()
);
side_static_event(my_provider_event_structsg, "myprovider", "myeventstructsg", SIDE_LOGLEVEL_DEBUG,
side_field_list(
- side_field_struct_sg("structsg", &mystructsgdef),
+ side_field_struct_sg("structsg", &mystructsgdef, 0),
+ side_field_sg_signed_integer("intsg", 0, 32, 0, 32,
+ side_attr_list(side_attr("std.integer.base", side_attr_u8(10)))),
),
side_attr_list()
);
.j = -1,
.k = -1,
};
- side_event_call(my_provider_event_structsg, side_arg_list(side_arg_struct_sg(&mystruct)));
+ int32_t val = -66;
+ side_event_call(my_provider_event_structsg,
+ side_arg_list(
+ side_arg_struct_sg(&mystruct),
+ side_arg_signed_integer_sg(&val),
+ )
+ );
}
}
static
void tracer_print_struct(const struct side_type *type_desc, const struct side_arg_vec *side_arg_vec);
static
-void tracer_print_struct_sg(const struct side_type *type_desc, void *ptr);
+void tracer_print_sg_struct(const struct side_type_sg *type_sg, void *_ptr);
+static
+void tracer_print_sg_integer_type(const struct side_type_sg *type_sg, void *_ptr);
static
void tracer_print_array(const struct side_type *type_desc, const struct side_arg_vec *side_arg_vec);
static
tracer_print_struct(type_desc, item->u.side_static.side_struct);
break;
case SIDE_TYPE_STRUCT_SG:
- tracer_print_struct_sg(type_desc, item->u.side_static.side_struct_sg_ptr);
+ 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:
+ tracer_print_sg_integer_type(&type_desc->u.side_sg, item->u.side_static.side_integer_sg_ptr);
break;
case SIDE_TYPE_ARRAY:
tracer_print_array(type_desc, item->u.side_static.side_array);
}
static
-void tracer_print_sg_type(const struct side_type_sg_description *sg_type, void *_ptr)
+void tracer_print_sg_integer_type(const struct side_type_sg *type_sg, void *_ptr)
{
const char *ptr = (const char *) _ptr;
union side_integer_value value;
- printf("{ ");
- switch (sg_type->type) {
- case SIDE_TYPE_SG_NULL:
- tracer_print_type_header(":", sg_type->u.side_null.attr, sg_type->u.side_null.nr_attr);
- printf("<NULL TYPE>");
+ switch (type_sg->u.side_integer.type.integer_size_bits) {
+ case 8:
+ case 16:
+ case 32:
+ case 64:
break;
+ default:
+ abort();
+ }
+ memcpy(&value, ptr + type_sg->offset, type_sg->u.side_integer.type.integer_size_bits >> 3);
+ tracer_print_type_integer(":", &type_sg->u.side_integer.type, &value,
+ type_sg->u.side_integer.offset_bits, TRACER_DISPLAY_BASE_10);
+}
+static
+void tracer_print_sg_type(const struct side_type *type_desc, void *ptr)
+{
+ printf("{ ");
+ switch (type_desc->type) {
case SIDE_TYPE_SG_UNSIGNED_INT:
case SIDE_TYPE_SG_SIGNED_INT:
- switch (sg_type->u.side_integer.type.integer_size_bits) {
- case 8:
- case 16:
- case 32:
- case 64:
- break;
- default:
- abort();
- }
- memcpy(&value, ptr + sg_type->offset, sg_type->u.side_integer.type.integer_size_bits >> 3);
- tracer_print_type_integer(":", &sg_type->u.side_integer.type, &value,
- sg_type->u.side_integer.offset_bits, TRACER_DISPLAY_BASE_10);
+ tracer_print_sg_integer_type(&type_desc->u.side_sg, ptr);
+ break;
+ case SIDE_TYPE_SG_STRUCT:
+ tracer_print_sg_struct(&type_desc->u.side_sg, ptr);
break;
default:
- fprintf(stderr, "<UNKNOWN TYPE>");
+ fprintf(stderr, "<UNKNOWN SCATTER-GATHER TYPE>");
abort();
}
printf(" }");
}
static
-void tracer_print_sg_field(const struct side_struct_field_sg *field_sg, void *ptr)
+void tracer_print_sg_field(const struct side_event_field *field, void *ptr)
{
- printf("%s: ", field_sg->field_name);
- tracer_print_sg_type(&field_sg->side_type, ptr);
+ printf("%s: ", field->field_name);
+ tracer_print_sg_type(&field->side_type, ptr);
}
static
-void tracer_print_struct_sg(const struct side_type *type_desc, void *ptr)
+void tracer_print_sg_struct(const struct side_type_sg *type_sg, void *_ptr)
{
- const struct side_type_struct_sg *struct_sg = type_desc->u.side_struct_sg;
+ char *ptr = (char *) _ptr;
int i;
- print_attributes("attr", ":", struct_sg->attr, struct_sg->nr_attr);
- printf("%s", struct_sg->nr_attr ? ", " : "");
+ 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 < struct_sg->nr_fields; i++) {
+ for (i = 0; i < type_sg->u.side_struct->nr_fields; i++) {
printf("%s", i ? ", " : "");
- tracer_print_sg_field(&struct_sg->fields_sg[i], ptr);
+ tracer_print_sg_field(&type_sg->u.side_struct->fields[i], ptr + type_sg->offset);
}
printf(" }");
}