} SIDE_PACKED;
struct side_type_struct {
- const struct side_event_field *fields;
+ side_ptr_t(const struct side_event_field) fields;
side_ptr_t(const struct side_attr) attr;
uint32_t nr_fields;
uint32_t nr_attr;
} SIDE_PACKED;
struct side_type_array {
- const struct side_type *elem_type;
+ side_ptr_t(const struct side_type) elem_type;
side_ptr_t(const struct side_attr) attr;
uint32_t length;
uint32_t nr_attr;
} SIDE_PACKED;
struct side_type_vla {
- const struct side_type *elem_type;
+ side_ptr_t(const struct side_type) elem_type;
side_ptr_t(const struct side_attr) attr;
uint32_t nr_attr;
} SIDE_PACKED;
struct side_type_vla_visitor {
- const struct side_type *elem_type;
+ side_ptr_t(const struct side_type) elem_type;
side_visitor_func visitor;
side_ptr_t(const struct side_attr) attr;
uint32_t nr_attr;
struct side_type_enum {
side_ptr_t(const struct side_enum_mappings) mappings;
- const struct side_type *elem_type;
+ side_ptr_t(const struct side_type) elem_type;
} SIDE_PACKED;
struct side_type_enum_bitmap {
side_ptr_t(const struct side_enum_bitmap_mappings) mappings;
- const struct side_type *elem_type;
+ side_ptr_t(const struct side_type) elem_type;
} SIDE_PACKED;
struct side_type_gather_bool {
struct side_type_gather_enum {
side_ptr_t(const struct side_enum_mappings) mappings;
- const struct side_type *elem_type;
+ side_ptr_t(const struct side_type) elem_type;
} SIDE_PACKED;
struct side_type_gather_struct {
uint64_t offset; /* bytes */
uint8_t access_mode; /* enum side_type_gather_access_mode */
- const struct side_type_struct *type;
+ side_ptr_t(const struct side_type_struct) type;
uint32_t size; /* bytes */
} SIDE_PACKED;
} SIDE_PACKED;
struct side_type_gather_vla {
- const struct side_type *length_type; /* side_length() */
+ side_ptr_t(const struct side_type) length_type; /* side_length() */
uint64_t offset; /* bytes */
uint8_t access_mode; /* enum side_type_gather_access_mode */
struct side_type_array side_array;
struct side_type_vla side_vla;
struct side_type_vla_visitor side_vla_visitor;
- const struct side_type_struct *side_struct;
- const struct side_type_variant *side_variant;
+ side_ptr_t(const struct side_type_struct) side_struct;
+ side_ptr_t(const struct side_type_variant) side_variant;
/* Stack-copy enumeration types */
struct side_type_enum side_enum;
struct side_type_variant {
const struct side_type selector;
- const struct side_variant_option *options;
+ side_ptr_t(const struct side_variant_option) options;
side_ptr_t(const struct side_attr) attr;
uint32_t nr_options;
uint32_t nr_attr;
} SIDE_PACKED;
struct side_event_field {
- const char *field_name;
+ side_ptr_t(const char) field_name;
struct side_type side_type;
} SIDE_PACKED;
#define _side_field(_name, _type) \
{ \
- .field_name = _name, \
+ .field_name = SIDE_PTR_INIT(_name), \
.side_type = _type, \
}
.u = { \
.side_enum = { \
.mappings = SIDE_PTR_INIT(_mappings), \
- .elem_type = _elem_type, \
+ .elem_type = SIDE_PTR_INIT(_elem_type), \
}, \
}, \
}
.u = { \
.side_enum_bitmap = { \
.mappings = SIDE_PTR_INIT(_mappings), \
- .elem_type = _elem_type, \
+ .elem_type = SIDE_PTR_INIT(_elem_type), \
}, \
}, \
}
{ \
.type = SIDE_TYPE_STRUCT, \
.u = { \
- .side_struct = _struct, \
+ .side_struct = SIDE_PTR_INIT(_struct), \
}, \
}
#define side_field_struct(_name, _struct) \
#define _side_type_struct_define(_fields, _attr) \
{ \
- .fields = _fields, \
+ .fields = SIDE_PTR_INIT(_fields), \
.attr = SIDE_PTR_INIT(_attr), \
.nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
.nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
{ \
.type = SIDE_TYPE_VARIANT, \
.u = { \
- .side_variant = _variant, \
+ .side_variant = SIDE_PTR_INIT(_variant), \
}, \
}
#define side_field_variant(_name, _variant) \
#define _side_type_variant_define(_selector, _options, _attr) \
{ \
.selector = _selector, \
- .options = _options, \
+ .options = SIDE_PTR_INIT(_options), \
.attr = SIDE_PTR_INIT(_attr), \
.nr_options = SIDE_ARRAY_SIZE(SIDE_PARAM(_options)), \
.nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
.type = SIDE_TYPE_ARRAY, \
.u = { \
.side_array = { \
- .elem_type = _elem_type, \
+ .elem_type = SIDE_PTR_INIT(_elem_type), \
.attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
.length = _length, \
.nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
.type = SIDE_TYPE_VLA, \
.u = { \
.side_vla = { \
- .elem_type = _elem_type, \
+ .elem_type = SIDE_PTR_INIT(_elem_type), \
.attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
.nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
}, \
.type = SIDE_TYPE_VLA_VISITOR, \
.u = { \
.side_vla_visitor = { \
- .elem_type = SIDE_PARAM(_elem_type), \
+ .elem_type = SIDE_PTR_INIT(_elem_type), \
.visitor = _visitor, \
.attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
.nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
.u = { \
.side_enum = { \
.mappings = SIDE_PTR_INIT(_mappings), \
- .elem_type = _elem_type, \
+ .elem_type = SIDE_PTR_INIT(_elem_type), \
}, \
}, \
}
.side_struct = { \
.offset = _offset, \
.access_mode = _access_mode, \
- .type = _struct_gather, \
+ .type = SIDE_PTR_INIT(_struct_gather), \
.size = _size, \
}, \
}, \
.offset = _offset, \
.access_mode = _access_mode, \
.type = { \
- .elem_type = _elem_type_gather, \
+ .elem_type = SIDE_PTR_INIT(_elem_type_gather), \
.attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
.length = _length, \
.nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
.side_gather = { \
.u = { \
.side_vla = { \
- .length_type = _length_type_gather, \
+ .length_type = SIDE_PTR_INIT(_length_type_gather), \
.offset = _offset, \
.access_mode = _access_mode, \
.type = { \
- .elem_type = _elem_type_gather, \
+ .elem_type = SIDE_PTR_INIT(_elem_type_gather), \
.attr = SIDE_PTR_INIT(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
.nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM_SELECT_ARG1(_, ##_attr, side_attr_list())), \
}, \
void tracer_print_enum(const struct side_type *type_desc, const struct side_arg *item)
{
const struct side_enum_mappings *mappings = side_ptr_get(type_desc->u.side_enum.mappings);
- const struct side_type *elem_type = type_desc->u.side_enum.elem_type;
+ const struct side_type *elem_type = side_ptr_get(type_desc->u.side_enum.elem_type);
union int64_value v64;
if (elem_type->type != item->type) {
const struct side_arg *item)
{
const struct side_enum_bitmap_mappings *side_enum_mappings = side_ptr_get(type_desc->u.side_enum_bitmap.mappings);
- const struct side_type *enum_elem_type = type_desc->u.side_enum_bitmap.elem_type, *elem_type;
+ const struct side_type *enum_elem_type = side_ptr_get(type_desc->u.side_enum_bitmap.elem_type), *elem_type;
uint32_t i, print_count = 0, stride_bit, nr_items;
const struct side_arg *array_item;
nr_items = 1;
break;
case SIDE_TYPE_ARRAY:
- elem_type = enum_elem_type->u.side_array.elem_type;
+ elem_type = side_ptr_get(enum_elem_type->u.side_array.elem_type);
array_item = item->u.side_static.side_array->sav;
nr_items = type_desc->u.side_array.length;
break;
case SIDE_TYPE_VLA:
- elem_type = enum_elem_type->u.side_vla.elem_type;
+ elem_type = side_ptr_get(enum_elem_type->u.side_vla.elem_type);
array_item = item->u.side_static.side_vla->sav;
nr_items = item->u.side_static.side_vla->len;
break;
static
void tracer_print_field(const struct side_event_field *item_desc, const struct side_arg *item)
{
- printf("%s: ", item_desc->field_name);
+ printf("%s: ", side_ptr_get(item_desc->field_name));
tracer_print_type(&item_desc->side_type, item);
}
void tracer_print_struct(const struct side_type *type_desc, const struct side_arg_vec *side_arg_vec)
{
const struct side_arg *sav = side_arg_vec->sav;
+ const struct side_type_struct *side_struct = side_ptr_get(type_desc->u.side_struct);
uint32_t i, side_sav_len = side_arg_vec->len;
- if (type_desc->u.side_struct->nr_fields != side_sav_len) {
+ if (side_struct->nr_fields != side_sav_len) {
fprintf(stderr, "ERROR: number of fields mismatch between description and arguments of structure\n");
abort();
}
- print_attributes("attr", ":", side_ptr_get(type_desc->u.side_struct->attr), type_desc->u.side_struct->nr_attr);
- printf("%s", type_desc->u.side_struct->nr_attr ? ", " : "");
+ print_attributes("attr", ":", side_ptr_get(side_struct->attr), side_struct->nr_attr);
+ printf("%s", side_struct->nr_attr ? ", " : "");
printf("fields: { ");
for (i = 0; i < side_sav_len; i++) {
printf("%s", i ? ", " : "");
- tracer_print_field(&type_desc->u.side_struct->fields[i], &sav[i]);
+ tracer_print_field(&side_ptr_get(side_struct->fields)[i], &sav[i]);
}
printf(" }");
}
static
void tracer_print_variant(const struct side_type *type_desc, const struct side_arg_variant *side_arg_variant)
{
- const struct side_type_variant *side_type_variant = type_desc->u.side_variant;
+ const struct side_type_variant *side_type_variant = side_ptr_get(type_desc->u.side_variant);
const struct side_type *selector_type = &side_type_variant->selector;
union int64_value v64;
uint32_t i;
v64 = tracer_load_integer_value(&selector_type->u.side_integer,
&side_arg_variant->selector.u.side_static.integer_value, 0, NULL);
for (i = 0; i < side_type_variant->nr_options; i++) {
- const struct side_variant_option *option = &side_type_variant->options[i];
+ const struct side_variant_option *option = &side_ptr_get(side_type_variant->options)[i];
if (v64.s >= option->range_begin && v64.s <= option->range_end) {
tracer_print_type(&option->side_type, &side_arg_variant->option);
printf("[ ");
for (i = 0; i < side_sav_len; i++) {
printf("%s", i ? ", " : "");
- tracer_print_type(type_desc->u.side_array.elem_type, &sav[i]);
+ tracer_print_type(side_ptr_get(type_desc->u.side_array.elem_type), &sav[i]);
}
printf(" ]");
}
printf("[ ");
for (i = 0; i < side_sav_len; i++) {
printf("%s", i ? ", " : "");
- tracer_print_type(type_desc->u.side_vla.elem_type, &sav[i]);
+ tracer_print_type(side_ptr_get(type_desc->u.side_vla.elem_type), &sav[i]);
}
printf(" ]");
}
uint32_t tracer_print_gather_enum_type(const struct side_type_gather *type_gather, const void *_ptr)
{
const struct side_enum_mappings *mappings = side_ptr_get(type_gather->u.side_enum.mappings);
- const struct side_type *enum_elem_type = type_gather->u.side_enum.elem_type;
+ const struct side_type *enum_elem_type = side_ptr_get(type_gather->u.side_enum.elem_type);
const struct side_type_gather_integer *side_integer = &enum_elem_type->u.side_gather.u.side_integer;
enum side_type_gather_access_mode access_mode =
(enum side_type_gather_access_mode) side_integer->access_mode;
static
void tracer_print_gather_field(const struct side_event_field *field, const void *ptr)
{
- printf("%s: ", field->field_name);
+ printf("%s: ", side_ptr_get(field->field_name));
(void) tracer_print_gather_type(&field->side_type, ptr);
}
{
enum side_type_gather_access_mode access_mode =
(enum side_type_gather_access_mode) type_gather->u.side_struct.access_mode;
+ const struct side_type_struct *side_struct = side_ptr_get(type_gather->u.side_struct.type);
const char *ptr = (const char *) _ptr;
uint32_t i;
ptr = tracer_gather_access(access_mode, ptr + type_gather->u.side_struct.offset);
- print_attributes("attr", ":", side_ptr_get(type_gather->u.side_struct.type->attr), type_gather->u.side_struct.type->nr_attr);
- printf("%s", type_gather->u.side_struct.type->nr_attr ? ", " : "");
+ print_attributes("attr", ":", side_ptr_get(side_struct->attr), side_struct->nr_attr);
+ printf("%s", side_struct->nr_attr ? ", " : "");
printf("fields: { ");
- for (i = 0; i < type_gather->u.side_struct.type->nr_fields; i++) {
+ for (i = 0; i < side_struct->nr_fields; i++) {
printf("%s", i ? ", " : "");
- tracer_print_gather_field(&type_gather->u.side_struct.type->fields[i], ptr);
+ tracer_print_gather_field(&side_ptr_get(side_struct->fields)[i], ptr);
}
printf(" }");
return tracer_gather_size(access_mode, type_gather->u.side_struct.size);
printf("elements: ");
printf("[ ");
for (i = 0; i < type_gather->u.side_array.type.length; i++) {
- switch (type_gather->u.side_array.type.elem_type->type) {
+ const struct side_type *elem_type = side_ptr_get(type_gather->u.side_array.type.elem_type);
+
+ switch (elem_type->type) {
case SIDE_TYPE_GATHER_VLA:
fprintf(stderr, "<gather VLA only supported within gather structures>\n");
abort();
break;
}
printf("%s", i ? ", " : "");
- ptr += tracer_print_gather_type(type_gather->u.side_array.type.elem_type, ptr);
+ ptr += tracer_print_gather_type(elem_type, ptr);
}
printf(" ]");
return tracer_gather_size(access_mode, ptr - orig_ptr);
{
enum side_type_gather_access_mode access_mode =
(enum side_type_gather_access_mode) type_gather->u.side_vla.access_mode;
+ const struct side_type *length_type = side_ptr_get(type_gather->u.side_vla.length_type);
const char *ptr = (const char *) _ptr, *orig_ptr;
const char *length_ptr = (const char *) _length_ptr;
union int64_value v64;
uint32_t i, length;
/* Access length */
- switch (type_gather->u.side_vla.length_type->type) {
+ switch (length_type->type) {
case SIDE_TYPE_GATHER_INTEGER:
break;
default:
fprintf(stderr, "<gather VLA expects integer gather length type>\n");
abort();
}
- v64 = tracer_load_gather_integer_value(&type_gather->u.side_vla.length_type->u.side_gather.u.side_integer,
+ v64 = tracer_load_gather_integer_value(&length_type->u.side_gather.u.side_integer,
length_ptr);
length = (uint32_t) v64.u;
ptr = tracer_gather_access(access_mode, ptr + type_gather->u.side_vla.offset);
printf("elements: ");
printf("[ ");
for (i = 0; i < length; i++) {
- switch (type_gather->u.side_vla.type.elem_type->type) {
+ const struct side_type *elem_type = side_ptr_get(type_gather->u.side_vla.type.elem_type);
+
+ switch (elem_type->type) {
case SIDE_TYPE_GATHER_VLA:
fprintf(stderr, "<gather VLA only supported within gather structures>\n");
abort();
break;
}
printf("%s", i ? ", " : "");
- ptr += tracer_print_gather_type(type_gather->u.side_vla.type.elem_type, ptr);
+ ptr += tracer_print_gather_type(elem_type, ptr);
}
printf(" ]");
return tracer_gather_size(access_mode, ptr - orig_ptr);
{
enum side_visitor_status status;
struct tracer_visitor_priv tracer_priv = {
- .elem_type = type_desc->u.side_vla_visitor.elem_type,
+ .elem_type = side_ptr_get(type_desc->u.side_vla_visitor.elem_type),
.i = 0,
};
const struct side_tracer_visitor_ctx tracer_ctx = {