#include <side/macros.h>
#include <side/endian.h>
-/* SIDE stands for "Static Instrumentation Dynamically Enabled" */
+/*
+ * SIDE stands for "Static Instrumentation Dynamically Enabled"
+ *
+ * This is an instrumentation API for Linux user-space, which exposes an
+ * instrumentation type system and facilities allowing a kernel or
+ * user-space tracer to consume user-space instrumentation.
+ *
+ * This instrumentation API exposes 3 type systems:
+ *
+ * * Stack-copy type system: This is the core type system which can
+ * represent all supported types and into which all other type systems
+ * can be nested. This type system requires that every type is
+ * statically or dynamically declared and then registered, thus giving
+ * tracers a complete description of the events and their associated
+ * fields before the associated instrumentation is invoked. The
+ * application needs to copy each argument (side_arg_...()) onto the
+ * stack when calling the instrumentation.
+ *
+ * This is the most expressive of the 3 type systems, althrough not the
+ * fastest due to the extra copy of the arguments.
+ *
+ * * Data-gathering type system: This type system requires every type to
+ * be statically or dynamically declared and registered, but does not
+ * require the application to copy its arguments onto the stack.
+ * Instead, the type description contains all the required information
+ * to fetch the data from the application memory. The only argument
+ * required from the instrumentation is the base pointer from which
+ * the data should be fetched.
+ *
+ * This type system can be used as an event field, or nested within
+ * the stack-copy type system. Nesting of gather-vla within
+ * gather-array and gather-vla types is not allowed.
+ *
+ * This type system is has the least overhead of the 3 type systems.
+ *
+ * * Dynamic type system: This type system receives both type
+ * description and actual data onto the stack at runtime. It has more
+ * overhead that the 2 other type systems, but does not require a
+ * prior registration of event field description. This makes it useful
+ * for seldom used types which are not performance critical, but for
+ * which registering each individual events would needlessly grow the
+ * number of events to declare and register.
+ *
+ * Another use-case for this type system is for use by dynamically
+ * typed language runtimes, where the field type is only known when
+ * the instrumentation is called.
+ *
+ * Those dynamic types can be either used as arguments to a variadic
+ * field list, or as on-stack instrumentation argument for a static
+ * type SIDE_TYPE_DYNAMIC place holder in the stack-copy type system.
+ */
//TODO: as those structures will be ABI, we need to either consider them
//fixed forever, or think of a scheme that would allow their binary
struct side_arg;
struct side_arg_vec;
struct side_arg_dynamic;
+struct side_arg_dynamic_field;
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;
struct side_event_description;
-struct side_arg_dynamic_event_struct;
+struct side_arg_dynamic_struct;
struct side_events_register_handle;
enum side_type_label {
- /* Statically declared types */
+ /* Stack-copy basic types */
SIDE_TYPE_NULL,
SIDE_TYPE_BOOL,
SIDE_TYPE_U8,
SIDE_TYPE_FLOAT_BINARY128,
SIDE_TYPE_STRING,
- /* Statically declared compound types */
+ /* Stack-copy compound types */
SIDE_TYPE_STRUCT,
- SIDE_TYPE_STRUCT_SG,
SIDE_TYPE_ARRAY,
SIDE_TYPE_VLA,
SIDE_TYPE_VLA_VISITOR,
SIDE_TYPE_VLA_POINTER32,
SIDE_TYPE_VLA_POINTER64,
- /* Statically declared enumeration types */
+ /* Stack-copy enumeration types */
SIDE_TYPE_ENUM,
SIDE_TYPE_ENUM_BITMAP,
+ /* Stack-copy place holder for dynamic types */
SIDE_TYPE_DYNAMIC,
- /* Dynamic types */
+ /* Gather basic types */
+ SIDE_TYPE_GATHER_BOOL,
+ SIDE_TYPE_GATHER_UNSIGNED_INT,
+ SIDE_TYPE_GATHER_SIGNED_INT,
+ SIDE_TYPE_GATHER_BYTE,
+ SIDE_TYPE_GATHER_FLOAT,
+
+ /* Gather compound types */
+ SIDE_TYPE_GATHER_STRUCT,
+ SIDE_TYPE_GATHER_ARRAY,
+ SIDE_TYPE_GATHER_VLA,
+
+ /* Dynamic basic types */
SIDE_TYPE_DYNAMIC_NULL,
SIDE_TYPE_DYNAMIC_BOOL,
SIDE_TYPE_DYNAMIC_U8,
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,
# define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE
#endif
-typedef enum side_visitor_status (*side_visitor)(
+enum side_type_gather_access_mode {
+ SIDE_TYPE_GATHER_ACCESS_DIRECT,
+ SIDE_TYPE_GATHER_ACCESS_POINTER, /* Pointer dereference */
+};
+
+typedef enum side_visitor_status (*side_visitor_func)(
const struct side_tracer_visitor_ctx *tracer_ctx,
void *app_ctx);
-typedef enum side_visitor_status (*side_dynamic_struct_visitor)(
+typedef enum side_visitor_status (*side_dynamic_struct_visitor_func)(
const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx,
void *app_ctx);
-typedef enum side_visitor_status (*side_dynamic_vla_visitor)(
- const struct side_tracer_dynamic_vla_visitor_ctx *tracer_ctx,
- void *app_ctx);
union side_integer_value {
uint8_t side_u8;
union side_float_value {
#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
} SIDE_PACKED;
struct side_type_bool {
const struct side_attr *attr;
uint32_t nr_attr;
+ uint16_t bool_size_bits; /* bits */
+ uint16_t len_bits; /* bits */
+ uint8_t byte_order; /* enum side_type_label_byte_order */
} SIDE_PACKED;
struct side_type_byte {
struct side_type_float {
const struct side_attr *attr;
uint32_t nr_attr;
- uint32_t byte_order; /* enum side_type_label_byte_order */
uint16_t float_size_bits; /* bits */
+ uint8_t byte_order; /* enum side_type_label_byte_order */
} SIDE_PACKED;
struct side_enum_mapping {
} SIDE_PACKED;
struct side_type_struct {
+ const struct side_event_field *fields;
+ const struct side_attr *attr;
uint32_t nr_fields;
uint32_t nr_attr;
- const struct side_event_field *fields;
+} SIDE_PACKED;
+
+struct side_type_array {
+ const struct side_type *elem_type;
+ const struct side_attr *attr;
+ uint32_t length;
+ uint32_t nr_attr;
+} SIDE_PACKED;
+
+struct side_type_vla {
+ const struct side_type *elem_type;
+ const struct side_attr *attr;
+ uint32_t nr_attr;
+} SIDE_PACKED;
+
+struct side_type_vla_visitor {
+ const struct side_type *elem_type;
+ side_visitor_func visitor;
const struct side_attr *attr;
+ uint32_t nr_attr;
+} SIDE_PACKED;
+
+struct side_type_enum {
+ const struct side_enum_mappings *mappings;
+ const struct side_type *elem_type;
+} SIDE_PACKED;
+
+struct side_type_enum_bitmap {
+ const struct side_enum_bitmap_mappings *mappings;
+ const struct side_type *elem_type;
} SIDE_PACKED;
-struct side_type_sg_description {
+struct side_type_gather_bool {
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;
- } SIDE_PACKED u;
+ uint8_t access_mode; /* enum side_type_gather_access_mode */
+ struct side_type_bool type;
+ uint16_t offset_bits; /* bits */
} SIDE_PACKED;
-struct side_struct_field_sg {
- const char *field_name;
- struct side_type_sg_description side_type;
+struct side_type_gather_byte {
+ uint64_t offset; /* bytes */
+ uint8_t access_mode; /* enum side_type_gather_access_mode */
+ struct side_type_byte 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;
+struct side_type_gather_integer {
+ uint64_t offset; /* bytes */
+ uint8_t access_mode; /* enum side_type_gather_access_mode */
+ struct side_type_integer type;
+ uint16_t offset_bits; /* bits */
+} SIDE_PACKED;
+
+struct side_type_gather_float {
+ uint64_t offset; /* bytes */
+ uint8_t access_mode; /* enum side_type_gather_access_mode */
+ struct side_type_float 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;
+ uint32_t size; /* bytes */
+} SIDE_PACKED;
+
+struct side_type_gather_array {
+ uint64_t offset; /* bytes */
+ uint8_t access_mode; /* enum side_type_gather_access_mode */
+ struct side_type_array type;
+} SIDE_PACKED;
+
+struct side_type_gather_vla {
+ 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_vla type;
+} SIDE_PACKED;
+
+struct side_type_gather {
+ union {
+ struct side_type_gather_bool side_bool;
+ struct side_type_gather_byte side_byte;
+ struct side_type_gather_integer side_integer;
+ struct side_type_gather_float side_float;
+ struct side_type_gather_array side_array;
+ struct side_type_gather_vla side_vla;
+ struct side_type_gather_struct side_struct;
+ } SIDE_PACKED u;
} SIDE_PACKED;
-/* Statically defined types. */
struct side_type {
uint32_t type; /* enum side_type_label */
union {
- /* Basic types */
+ /* Stack-copy basic types */
struct side_type_null side_null;
struct side_type_bool side_bool;
struct side_type_byte side_byte;
struct side_type_integer side_integer;
struct side_type_float side_float;
- /* Compound types */
- struct {
- const struct side_type *elem_type;
- const struct side_attr *attr;
- uint32_t length;
- uint32_t nr_attr;
- } SIDE_PACKED side_array;
- struct {
- const struct side_type *elem_type;
- const struct side_attr *attr;
- uint32_t nr_attr;
- } SIDE_PACKED side_vla;
- struct {
- const struct side_type *elem_type;
- side_visitor visitor;
- const struct side_attr *attr;
- uint32_t nr_attr;
- } SIDE_PACKED side_vla_visitor;
+ /* Stack-copy compound types */
+ 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_struct_sg *side_struct_sg;
-
- /* Enumeration types */
- struct {
- const struct side_enum_mappings *mappings;
- const struct side_type *elem_type;
- } SIDE_PACKED side_enum;
- struct {
- const struct side_enum_bitmap_mappings *mappings;
- const struct side_type *elem_type;
- } SIDE_PACKED side_enum_bitmap;
+
+ /* Stack-copy enumeration types */
+ struct side_type_enum side_enum;
+ struct side_type_enum_bitmap side_enum_bitmap;
+
+ /* Gather types */
+ struct side_type_gather side_gather;
} SIDE_PACKED u;
} SIDE_PACKED;
struct side_callback {
union {
void (*call)(const struct side_event_description *desc,
- const struct side_arg_vec *sav_desc,
+ const struct side_arg_vec *side_arg_vec,
void *priv);
void (*call_variadic)(const struct side_event_description *desc,
- const struct side_arg_vec *sav_desc,
- const struct side_arg_dynamic_event_struct *var_struct,
+ const struct side_arg_vec *side_arg_vec,
+ const struct side_arg_dynamic_struct *var_struct,
void *priv);
} SIDE_PACKED u;
void *priv;
} SIDE_PACKED;
struct side_arg_static {
- /* Basic types */
+ /* Stack-copy basic types */
uint8_t bool_value;
uint8_t byte_value;
uint64_t string_value; /* const char * */
union side_integer_value integer_value;
union side_float_value float_value;
- /* Compound types */
+ /* Stack-copy compound types */
const struct side_arg_vec *side_struct;
const struct side_arg_vec *side_array;
const struct side_arg_vec *side_vla;
void *p;
uint32_t length;
} SIDE_PACKED side_vla_fixint;
- void *side_struct_sg_ptr;
+
+ /* Gather basic types */
+ void *side_bool_gather_ptr;
+ void *side_byte_gather_ptr;
+ void *side_integer_gather_ptr;
+ void *side_float_gather_ptr;
+
+ /* Gather compound types */
+ void *side_array_gather_ptr;
+ void *side_struct_gather_ptr;
+ struct {
+ void *ptr;
+ void *length_ptr;
+ } SIDE_PACKED side_vla_gather;
+} SIDE_PACKED;
+
+struct side_arg_dynamic_vla {
+ const struct side_arg *sav;
+ const struct side_attr *attr;
+ uint32_t len;
+ uint32_t nr_attr;
+} SIDE_PACKED;
+
+struct side_arg_dynamic_struct {
+ const struct side_arg_dynamic_field *fields;
+ const struct side_attr *attr;
+ uint32_t len;
+ uint32_t nr_attr;
+} SIDE_PACKED;
+
+struct side_dynamic_struct_visitor {
+ void *app_ctx;
+ side_dynamic_struct_visitor_func visitor;
+ const struct side_attr *attr;
+ uint32_t nr_attr;
+} SIDE_PACKED;
+
+struct side_dynamic_vla_visitor {
+ void *app_ctx;
+ side_visitor_func visitor;
+ const struct side_attr *attr;
+ uint32_t nr_attr;
} SIDE_PACKED;
struct side_arg_dynamic {
- /* Basic types */
+ /* Dynamic basic types */
struct side_type_null side_null;
struct {
struct side_type_bool type;
uint8_t value;
} SIDE_PACKED side_bool;
-
struct {
struct side_type_byte type;
uint8_t value;
} SIDE_PACKED side_byte;
-
struct {
struct side_type_string type;
uint64_t value; /* const char * */
} SIDE_PACKED side_string;
-
- /* Integer type */
struct {
struct side_type_integer type;
union side_integer_value value;
} SIDE_PACKED side_integer;
-
struct {
struct side_type_float type;
union side_float_value value;
} SIDE_PACKED side_float;
- /* 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_PACKED side_dynamic_struct_visitor;
+ /* Dynamic compound types */
+ const struct side_arg_dynamic_struct *side_dynamic_struct;
const struct side_arg_dynamic_vla *side_dynamic_vla;
- struct {
- void *app_ctx;
- side_dynamic_vla_visitor visitor;
- const struct side_attr *attr;
- uint32_t nr_attr;
- } SIDE_PACKED side_dynamic_vla_visitor;
+
+ struct side_dynamic_struct_visitor side_dynamic_struct_visitor;
+ struct side_dynamic_vla_visitor side_dynamic_vla_visitor;
} SIDE_PACKED;
struct side_arg {
uint32_t len;
} SIDE_PACKED;
-struct side_event_description {
- uintptr_t *enabled;
- const char *provider_name;
- const char *event_name;
- const struct side_event_field *fields;
- const struct side_attr *attr;
- const struct side_callback *callbacks;
- uint64_t flags;
- uint32_t version;
- uint32_t loglevel; /* enum side_loglevel */
- uint32_t nr_fields;
- uint32_t nr_attr;
- uint32_t nr_callbacks;
-} SIDE_PACKED;
-
-struct side_arg_dynamic_vla {
- const struct side_arg *sav;
- const struct side_attr *attr;
- uint32_t len;
- uint32_t nr_attr;
-} SIDE_PACKED;
-
-struct side_arg_dynamic_event_field {
+struct side_arg_dynamic_field {
const char *field_name;
const struct side_arg elem;
} SIDE_PACKED;
-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;
-} SIDE_PACKED;
-
/* The visitor pattern is a double-dispatch visitor. */
struct side_tracer_visitor_ctx {
enum side_visitor_status (*write_elem)(
struct side_tracer_dynamic_struct_visitor_ctx {
enum side_visitor_status (*write_field)(
const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx,
- const struct side_arg_dynamic_event_field *dynamic_field);
+ const struct side_arg_dynamic_field *dynamic_field);
void *priv; /* Private tracer context. */
} SIDE_PACKED;
-struct side_tracer_dynamic_vla_visitor_ctx {
- enum side_visitor_status (*write_elem)(
- const struct side_tracer_dynamic_vla_visitor_ctx *tracer_ctx,
- const struct side_arg *elem);
- void *priv; /* Private tracer context. */
+struct side_event_description {
+ uintptr_t *enabled;
+ const char *provider_name;
+ const char *event_name;
+ const struct side_event_field *fields;
+ const struct side_attr *attr;
+ const struct side_callback *callbacks;
+ uint64_t flags;
+ uint32_t version;
+ uint32_t loglevel; /* enum side_loglevel */
+ uint32_t nr_fields;
+ uint32_t nr_attr;
+ uint32_t nr_callbacks;
} SIDE_PACKED;
/* Event and type attributes */
#define side_attr_float_binary128(_val) { .type = SIDE_ATTR_TYPE_FLOAT_BINARY128, .u = { .float_value = { .side_float_binary128 = (_val) } } }
#define side_attr_string(_val) { .type = SIDE_ATTR_TYPE_STRING, .u = { .string_value = (uintptr_t) (_val) } }
-/* Static field definition */
+/* Stack-copy enumeration type definitions */
+
+#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(...) \
+ SIDE_COMPOUND_LITERAL(const struct side_enum_mapping, __VA_ARGS__)
+
+#define side_enum_mapping_range(_label, _begin, _end) \
+ { \
+ .range_begin = _begin, \
+ .range_end = _end, \
+ .label = _label, \
+ }
+
+#define side_enum_mapping_value(_label, _value) \
+ { \
+ .range_begin = _value, \
+ .range_end = _value, \
+ .label = _label, \
+ }
+
+#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(...) \
+ SIDE_COMPOUND_LITERAL(const struct side_enum_bitmap_mapping, __VA_ARGS__)
+
+#define side_enum_bitmap_mapping_range(_label, _begin, _end) \
+ { \
+ .range_begin = _begin, \
+ .range_end = _end, \
+ .label = _label, \
+ }
+
+#define side_enum_bitmap_mapping_value(_label, _value) \
+ { \
+ .range_begin = _value, \
+ .range_end = _value, \
+ .label = _label, \
+ }
+
+/* Stack-copy field and type definitions */
#define side_type_null(_attr) \
{ \
.side_bool = { \
.attr = _attr, \
.nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .bool_size_bits = 8, \
+ .len_bits = 1, \
+ .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
}, \
}, \
}
.side_float = { \
.attr = _attr, \
.nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
- .byte_order = _byte_order, \
.float_size_bits = _float_size_bits, \
+ .byte_order = _byte_order, \
}, \
}, \
}
#define _side_type_struct_define(_fields, _attr) \
{ \
- .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
- .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
.fields = _fields, \
.attr = _attr, \
+ .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields)), \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
}
#define side_define_struct(_identifier, _fields, _attr) \
SIDE_COMPOUND_LITERAL(const struct side_type_struct, \
_side_type_struct_define(SIDE_PARAM(_fields), SIDE_PARAM(_attr)))
-/* Scatter-gather struct */
+#define side_type_array(_elem_type, _length, _attr) \
+ { \
+ .type = SIDE_TYPE_ARRAY, \
+ .u = { \
+ .side_array = { \
+ .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) \
+ _side_field(_name, side_type_array(SIDE_PARAM(_elem_type), _length, SIDE_PARAM(_attr)))
-#define _side_field_sg(_name, _type) \
+#define side_type_vla(_elem_type, _attr) \
{ \
- .field_name = _name, \
- .side_type = _type, \
+ .type = SIDE_TYPE_VLA, \
+ .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) \
+ _side_field(_name, side_type_vla(SIDE_PARAM(_elem_type), SIDE_PARAM(_attr)))
-#define side_type_sg_null(_attr) \
+#define side_type_vla_visitor(_elem_type, _visitor, _attr) \
{ \
- .offset = 0, \
- .type = SIDE_TYPE_SG_NULL, \
+ .type = SIDE_TYPE_VLA_VISITOR, \
.u = { \
- .side_null = { \
+ .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) \
+ _side_field(_name, side_type_vla_visitor(SIDE_PARAM(_elem_type), _visitor, SIDE_PARAM(_attr)))
-#define side_field_sg_null(_name, _attr) \
- _side_field_sg(_name, side_type_sg_null(SIDE_PARAM(_attr)))
+/* Gather field and type definitions */
-#define _side_type_sg_integer(_type, _signedness, _byte_order, _offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
+#define side_type_gather_byte(_offset, _access_mode, _attr) \
{ \
- .offset = _offset, \
- .type = _type, \
+ .type = SIDE_TYPE_GATHER_BYTE, \
.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_gather = { \
+ .u = { \
+ .side_byte = { \
+ .offset = _offset, \
+ .access_mode = _access_mode, \
+ .type = { \
+ .attr = _attr, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ }, \
+ }, \
}, \
- .offset_bits = _offset_bits, \
}, \
}, \
}
+#define side_field_gather_byte(_name, _offset, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_byte(_offset, _access_mode, SIDE_PARAM(_attr)))
-#define side_type_sg_unsigned_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
- _side_type_sg_integer(SIDE_TYPE_SG_UNSIGNED_INT, false, SIDE_TYPE_BYTE_ORDER_HOST, \
- _integer_offset, _integer_size_bits, _offset_bits, _len_bits, SIDE_PARAM(_attr))
-#define side_type_sg_signed_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _attr) \
- _side_type_sg_integer(SIDE_TYPE_SG_SIGNED_INT, true, SIDE_TYPE_BYTE_ORDER_HOST, \
- _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)))
-#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)))
-
-#define side_type_struct_sg(_struct_sg) \
+#define _side_type_gather_bool(_byte_order, _offset, _bool_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
{ \
- .type = SIDE_TYPE_STRUCT_SG, \
+ .type = SIDE_TYPE_GATHER_BOOL, \
.u = { \
- .side_struct_sg = _struct_sg, \
+ .side_gather = { \
+ .u = { \
+ .side_bool = { \
+ .offset = _offset, \
+ .access_mode = _access_mode, \
+ .type = { \
+ .attr = _attr, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .bool_size_bits = _bool_size_bits, \
+ .len_bits = _len_bits, \
+ .byte_order = _byte_order, \
+ }, \
+ .offset_bits = _offset_bits, \
+ }, \
+ }, \
+ }, \
}, \
}
-#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) \
+#define side_type_gather_bool(_offset, _bool_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_HOST, _offset, _bool_size_bits, _offset_bits, _len_bits, _access_mode, _attr)
+#define side_type_gather_bool_le(_offset, _bool_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_LE, _offset, _bool_size_bits, _offset_bits, _len_bits, _access_mode, _attr)
+#define side_type_gather_bool_be(_offset, _bool_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_type_gather_bool(SIDE_TYPE_BYTE_ORDER_BE, _offset, _bool_size_bits, _offset_bits, _len_bits, _access_mode, _attr)
+
+#define side_field_gather_bool(_name, _offset, _bool_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_bool(_offset, _bool_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
+#define side_field_gather_bool_le(_name, _offset, _bool_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_bool_le(_offset, _bool_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
+#define side_field_gather_bool_be(_name, _offset, _bool_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_bool_be(_offset, _bool_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
+
+#define _side_type_gather_integer(_type, _signedness, _byte_order, _offset, \
+ _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
{ \
- .nr_fields = SIDE_ARRAY_SIZE(SIDE_PARAM(_fields_sg)), \
- .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
- .fields_sg = _fields_sg, \
- .attr = _attr, \
+ .type = _type, \
+ .u = { \
+ .side_gather = { \
+ .u = { \
+ .side_integer = { \
+ .offset = _offset, \
+ .access_mode = _access_mode, \
+ .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, \
+ }, \
+ }, \
+ }, \
+ }, \
}
-#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_type_gather_unsigned_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_type_gather_integer(SIDE_TYPE_GATHER_UNSIGNED_INT, false, SIDE_TYPE_BYTE_ORDER_HOST, \
+ _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr))
+#define side_type_gather_signed_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_type_gather_integer(SIDE_TYPE_GATHER_SIGNED_INT, true, SIDE_TYPE_BYTE_ORDER_HOST, \
+ _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr))
+
+#define side_type_gather_unsigned_integer_le(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_type_gather_integer(SIDE_TYPE_GATHER_UNSIGNED_INT, false, SIDE_TYPE_BYTE_ORDER_LE, \
+ _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr))
+#define side_type_gather_signed_integer_le(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_type_gather_integer(SIDE_TYPE_GATHER_SIGNED_INT, true, SIDE_TYPE_BYTE_ORDER_LE, \
+ _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr))
+
+#define side_type_gather_unsigned_integer_be(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_type_gather_integer(SIDE_TYPE_GATHER_UNSIGNED_INT, false, SIDE_TYPE_BYTE_ORDER_BE, \
+ _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr))
+#define side_type_gather_signed_integer_be(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_type_gather_integer(SIDE_TYPE_GATHER_SIGNED_INT, true, SIDE_TYPE_BYTE_ORDER_BE, \
+ _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr))
+
+#define side_field_gather_unsigned_integer(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_unsigned_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
+#define side_field_gather_signed_integer(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_signed_integer(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
+
+#define side_field_gather_unsigned_integer_le(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_unsigned_integer_le(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
+#define side_field_gather_signed_integer_le(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_signed_integer_le(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
+
+#define side_field_gather_unsigned_integer_be(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_unsigned_integer_be(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
+#define side_field_gather_signed_integer_be(_name, _integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_signed_integer_be(_integer_offset, _integer_size_bits, _offset_bits, _len_bits, _access_mode, SIDE_PARAM(_attr)))
+
+#define _side_type_gather_float(_byte_order, _offset, _float_size_bits, _access_mode, _attr) \
+ { \
+ .type = SIDE_TYPE_GATHER_FLOAT, \
+ .u = { \
+ .side_gather = { \
+ .u = { \
+ .side_float = { \
+ .offset = _offset, \
+ .access_mode = _access_mode, \
+ .type = { \
+ .attr = _attr, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .float_size_bits = _float_size_bits, \
+ .byte_order = _byte_order, \
+ }, \
+ }, \
+ }, \
+ }, \
+ }, \
+ }
-#define side_type_array(_elem_type, _length, _attr) \
+#define side_type_gather_float(_offset, _float_size_bits, _access_mode, _attr) \
+ _side_type_gather_float(SIDE_TYPE_FLOAT_WORD_ORDER_HOST, _offset, _float_size_bits, _access_mode, _attr)
+#define side_type_gather_float_le(_offset, _float_size_bits, _access_mode, _attr) \
+ _side_type_gather_float(SIDE_TYPE_BYTE_ORDER_LE, _offset, _float_size_bits, _access_mode, _attr)
+#define side_type_gather_float_be(_offset, _float_size_bits, _access_mode, _attr) \
+ _side_type_gather_float(SIDE_TYPE_BYTE_ORDER_BE, _offset, _float_size_bits, _access_mode, _attr)
+
+#define side_field_gather_float(_name, _offset, _float_size_bits, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_float(_offset, _float_size_bits, _access_mode, _attr))
+#define side_field_gather_float_le(_name, _offset, _float_size_bits, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_float_le(_offset, _float_size_bits, _access_mode, _attr))
+#define side_field_gather_float_be(_name, _offset, _float_size_bits, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_float_be(_offset, _float_size_bits, _access_mode, _attr))
+
+#define side_type_gather_struct(_struct_gather, _offset, _size, _access_mode) \
{ \
- .type = SIDE_TYPE_ARRAY, \
+ .type = SIDE_TYPE_GATHER_STRUCT, \
.u = { \
- .side_array = { \
- .elem_type = _elem_type, \
- .attr = _attr, \
- .length = _length, \
- .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .side_gather = { \
+ .u = { \
+ .side_struct = { \
+ .offset = _offset, \
+ .access_mode = _access_mode, \
+ .type = _struct_gather, \
+ .size = _size, \
+ }, \
+ }, \
}, \
}, \
}
-#define side_field_array(_name, _elem_type, _length, _attr) \
- _side_field(_name, side_type_array(SIDE_PARAM(_elem_type), _length, SIDE_PARAM(_attr)))
+#define side_field_gather_struct(_name, _struct_gather, _offset, _size, _access_mode) \
+ _side_field(_name, side_type_gather_struct(SIDE_PARAM(_struct_gather), _offset, _size, _access_mode))
-#define side_type_vla(_elem_type, _attr) \
+#define side_type_gather_array(_elem_type_gather, _length, _offset, _access_mode, _attr) \
{ \
- .type = SIDE_TYPE_VLA, \
+ .type = SIDE_TYPE_GATHER_ARRAY, \
.u = { \
- .side_vla = { \
- .elem_type = _elem_type, \
- .attr = _attr, \
- .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .side_gather = { \
+ .u = { \
+ .side_array = { \
+ .offset = _offset, \
+ .access_mode = _access_mode, \
+ .type = { \
+ .elem_type = _elem_type_gather, \
+ .attr = _attr, \
+ .length = _length, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ }, \
+ }, \
+ }, \
}, \
}, \
}
-#define side_field_vla(_name, _elem_type, _attr) \
- _side_field(_name, side_type_vla(SIDE_PARAM(_elem_type), SIDE_PARAM(_attr)))
+#define side_field_gather_array(_name, _elem_type, _length, _offset, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_array(SIDE_PARAM(_elem_type), _length, _offset, _access_mode, SIDE_PARAM(_attr)))
-#define side_type_vla_visitor(_elem_type, _visitor, _attr) \
+#define side_type_gather_vla(_elem_type_gather, _offset, _access_mode, _length_type_gather, _attr) \
{ \
- .type = SIDE_TYPE_VLA_VISITOR, \
+ .type = SIDE_TYPE_GATHER_VLA, \
.u = { \
- .side_vla_visitor = { \
- .elem_type = SIDE_PARAM(_elem_type), \
- .visitor = _visitor, \
- .attr = _attr, \
- .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .side_gather = { \
+ .u = { \
+ .side_vla = { \
+ .offset = _offset, \
+ .access_mode = _access_mode, \
+ .type = { \
+ .elem_type = _elem_type_gather, \
+ .attr = _attr, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ }, \
+ .length_type = _length_type_gather, \
+ }, \
+ }, \
}, \
}, \
}
-#define side_field_vla_visitor(_name, _elem_type, _visitor, _attr) \
- _side_field(_name, side_type_vla_visitor(SIDE_PARAM(_elem_type), _visitor, SIDE_PARAM(_attr)))
+#define side_field_gather_vla(_name, _elem_type_gather, _offset, _access_mode, _length_type_gather, _attr) \
+ _side_field(_name, side_type_gather_vla(SIDE_PARAM(_elem_type_gather), _offset, _access_mode, SIDE_PARAM(_length_type_gather), SIDE_PARAM(_attr)))
#define side_elem(...) \
SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__)
+#define side_length(...) \
+ SIDE_COMPOUND_LITERAL(const struct side_type, __VA_ARGS__)
+
#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 */
+/* Stack-copy field arguments */
#define side_arg_null(_val) { .type = SIDE_TYPE_NULL }
#define side_arg_bool(_val) { .type = SIDE_TYPE_BOOL, .u = { .side_static = { .bool_value = !!(_val) } } }
#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_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) } } }
#define side_arg_vla_byte(_ptr, _length) { .type = SIDE_TYPE_VLA_BYTE, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
#define side_arg_vla_pointer(_ptr, _length) { .type = SIDE_TYPE_VLA_POINTER_HOST, .u = { .side_static = { .side_vla_fixint = { .p = (_ptr), .length = (_length) } } } }
+/* Gather field arguments */
+
+#define side_arg_gather_bool(_ptr) { .type = SIDE_TYPE_GATHER_BOOL, .u = { .side_static = { .side_bool_gather_ptr = (_ptr) } } }
+#define side_arg_gather_byte(_ptr) { .type = SIDE_TYPE_GATHER_BYTE, .u = { .side_static = { .side_byte_gather_ptr = (_ptr) } } }
+#define side_arg_gather_unsigned_integer(_ptr) { .type = SIDE_TYPE_GATHER_UNSIGNED_INT, .u = { .side_static = { .side_integer_gather_ptr = (_ptr) } } }
+#define side_arg_gather_signed_integer(_ptr) { .type = SIDE_TYPE_GATHER_SIGNED_INT, .u = { .side_static = { .side_integer_gather_ptr = (_ptr) } } }
+#define side_arg_gather_float(_ptr) { .type = SIDE_TYPE_GATHER_FLOAT, .u = { .side_static = { .side_float_gather_ptr = (_ptr) } } }
+#define side_arg_gather_struct(_ptr) { .type = SIDE_TYPE_GATHER_STRUCT, .u = { .side_static = { .side_struct_gather_ptr = (_ptr) } } }
+#define side_arg_gather_array(_ptr) { .type = SIDE_TYPE_GATHER_ARRAY, .u = { .side_static = { .side_array_gather_ptr = (_ptr) } } }
+#define side_arg_gather_vla(_ptr, _length_ptr) { .type = SIDE_TYPE_GATHER_VLA, .u = { .side_static = { .side_vla_gather = { .ptr = (_ptr), .length_ptr = (_length_ptr) } } } }
+
/* Dynamic field arguments */
#define side_arg_dynamic_null(_attr) \
.type = { \
.attr = _attr, \
.nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ .bool_size_bits = sizeof(uint8_t) * CHAR_BIT, \
+ .len_bits = 1, \
+ .byte_order = SIDE_TYPE_BYTE_ORDER_HOST, \
}, \
.value = !!(_val), \
}, \
.type = { \
.attr = _attr, \
.nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
- .byte_order = _byte_order, \
.float_size_bits = _float_size_bits, \
+ .byte_order = _byte_order, \
}, \
.value = { \
_field = (_val), \
}
#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 = { \
+ const struct side_arg_dynamic_field _identifier##_fields[] = { _struct_fields }; \
+ const struct side_arg_dynamic_struct _identifier = { \
.fields = _identifier##_fields, \
.attr = _attr, \
.len = SIDE_ARRAY_SIZE(_identifier##_fields), \
.elem = _elem, \
}
-#define side_arg_list(...) __VA_ARGS__
-
-#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(...) \
- SIDE_COMPOUND_LITERAL(const struct side_enum_mapping, __VA_ARGS__)
-
-#define side_enum_mapping_range(_label, _begin, _end) \
- { \
- .range_begin = _begin, \
- .range_end = _end, \
- .label = _label, \
- }
-
-#define side_enum_mapping_value(_label, _value) \
- { \
- .range_begin = _value, \
- .range_end = _value, \
- .label = _label, \
- }
-
-#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(...) \
- SIDE_COMPOUND_LITERAL(const struct side_enum_bitmap_mapping, __VA_ARGS__)
-
-#define side_enum_bitmap_mapping_range(_label, _begin, _end) \
- { \
- .range_begin = _begin, \
- .range_end = _end, \
- .label = _label, \
- }
+/*
+ * Event instrumentation description registration, runtime enabled state
+ * check, and instrumentation invocation.
+ */
-#define side_enum_bitmap_mapping_value(_label, _value) \
- { \
- .range_begin = _value, \
- .range_end = _value, \
- .label = _label, \
- }
+#define side_arg_list(...) __VA_ARGS__
#define side_event_cond(_identifier) \
if (side_unlikely(__atomic_load_n(&side_event_enable__##_identifier, \
#define side_event_call(_identifier, _sav) \
{ \
const struct side_arg side_sav[] = { _sav }; \
- const struct side_arg_vec sav_desc = { \
+ const struct side_arg_vec side_arg_vec = { \
.sav = side_sav, \
.len = SIDE_ARRAY_SIZE(side_sav), \
}; \
- side_call(&(_identifier), &sav_desc); \
+ side_call(&(_identifier), &side_arg_vec); \
}
#define side_event(_identifier, _sav) \
#define side_event_call_variadic(_identifier, _sav, _var_fields, _attr) \
{ \
const struct side_arg side_sav[] = { _sav }; \
- const struct side_arg_vec sav_desc = { \
+ const struct side_arg_vec side_arg_vec = { \
.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 = { \
+ const struct side_arg_dynamic_field side_fields[] = { _var_fields }; \
+ const struct side_arg_dynamic_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(&(_identifier), &sav_desc, &var_struct); \
+ side_call_variadic(&(_identifier), &side_arg_vec, &var_struct); \
}
#define side_event_variadic(_identifier, _sav, _var, _attr) \
SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC)
#define side_hidden_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \
- _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
- SIDE_PARAM(_attr), 0)
+ _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \
+ _loglevel, SIDE_PARAM(_fields), SIDE_PARAM(_attr), 0)
#define side_hidden_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \
- _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
- SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC)
+ _side_define_event(__attribute__((visibility("hidden"))), _identifier, _provider, _event, \
+ _loglevel, SIDE_PARAM(_fields), SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC)
#define side_export_event(_identifier, _provider, _event, _loglevel, _fields, _attr) \
- _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
- SIDE_PARAM(_attr), 0)
+ _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \
+ _loglevel, SIDE_PARAM(_fields), SIDE_PARAM(_attr), 0)
#define side_export_event_variadic(_identifier, _provider, _event, _loglevel, _fields, _attr) \
- _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, _loglevel, SIDE_PARAM(_fields), \
- SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC)
+ _side_define_event(__attribute__((visibility("default"))), _identifier, _provider, _event, \
+ _loglevel, SIDE_PARAM(_fields), SIDE_PARAM(_attr), SIDE_EVENT_FLAG_VARIADIC)
#define side_declare_event(_identifier) \
extern uintptr_t side_event_enable_##_identifier; \
extern const struct side_callback side_empty_callback;
void side_call(const struct side_event_description *desc,
- const struct side_arg_vec *sav_desc);
+ const struct side_arg_vec *side_arg_vec);
void side_call_variadic(const struct side_event_description *desc,
- const struct side_arg_vec *sav_desc,
- const struct side_arg_dynamic_event_struct *var_struct);
+ const struct side_arg_vec *side_arg_vec,
+ const struct side_arg_dynamic_struct *var_struct);
+
+struct side_events_register_handle *side_events_register(struct side_event_description **events,
+ uint32_t nr_events);
+void side_events_unregister(struct side_events_register_handle *handle);
+
+/*
+ * Userspace tracer registration API. This allows userspace tracers to
+ * register event notification callbacks to be notified of the currently
+ * registered instrumentation, and to register their callbacks to
+ * specific events.
+ */
+typedef void (*side_tracer_callback_func)(const struct side_event_description *desc,
+ const struct side_arg_vec *side_arg_vec,
+ void *priv);
+typedef void (*side_tracer_callback_variadic_func)(const struct side_event_description *desc,
+ const struct side_arg_vec *side_arg_vec,
+ const struct side_arg_dynamic_struct *var_struct,
+ void *priv);
int side_tracer_callback_register(struct side_event_description *desc,
- void (*call)(const struct side_event_description *desc,
- const struct side_arg_vec *sav_desc,
- void *priv),
+ side_tracer_callback_func call,
void *priv);
int side_tracer_callback_variadic_register(struct side_event_description *desc,
- void (*call_variadic)(const struct side_event_description *desc,
- const struct side_arg_vec *sav_desc,
- const struct side_arg_dynamic_event_struct *var_struct,
- void *priv),
+ side_tracer_callback_variadic_func call_variadic,
void *priv);
int side_tracer_callback_unregister(struct side_event_description *desc,
- void (*call)(const struct side_event_description *desc,
- const struct side_arg_vec *sav_desc,
- void *priv),
+ side_tracer_callback_func call,
void *priv);
int side_tracer_callback_variadic_unregister(struct side_event_description *desc,
- void (*call_variadic)(const struct side_event_description *desc,
- const struct side_arg_vec *sav_desc,
- const struct side_arg_dynamic_event_struct *var_struct,
- void *priv),
+ side_tracer_callback_variadic_func call_variadic,
void *priv);
-struct side_events_register_handle *side_events_register(struct side_event_description **events, uint32_t nr_events);
-void side_events_unregister(struct side_events_register_handle *handle);
-
enum side_tracer_notification {
SIDE_TRACER_NOTIFICATION_INSERT_EVENTS,
SIDE_TRACER_NOTIFICATION_REMOVE_EVENTS,
void *priv);
void side_tracer_event_notification_unregister(struct side_tracer_handle *handle);
+/*
+ * Explicit hooks to initialize/finalize the side instrumentation
+ * library. Those are also library constructor/destructor.
+ */
void side_init(void);
void side_exit(void);
+/*
+ * The following constructors/destructors perform automatic registration
+ * of the declared side events. Those may have to be called explicitly
+ * in a statically linked library.
+ */
+
/*
* These weak symbols, the constructor, and destructor take care of
* registering only _one_ instance of the side instrumentation per