SIDE_TYPE_GATHER_BYTE,
SIDE_TYPE_GATHER_POINTER,
SIDE_TYPE_GATHER_FLOAT,
+ SIDE_TYPE_GATHER_STRING,
/* Gather compound types */
SIDE_TYPE_GATHER_STRUCT,
struct side_type_float type;
} SIDE_PACKED;
+struct side_type_gather_string {
+ uint64_t offset; /* bytes */
+ uint8_t access_mode; /* enum side_type_gather_access_mode */
+ struct side_type_string type;
+} SIDE_PACKED;
+
struct side_type_gather_enum {
const struct side_enum_mappings *mappings;
const struct side_type *elem_type;
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_string side_string;
struct side_type_gather_enum side_enum;
struct side_type_gather_array side_array;
struct side_type_gather_vla side_vla;
void *side_byte_gather_ptr;
void *side_integer_gather_ptr;
void *side_float_gather_ptr;
+ void *side_string_gather_ptr;
/* Gather compound types */
void *side_array_gather_ptr;
#define side_field_gather_float_be(_name, _offset, _float_size, _access_mode, _attr) \
_side_field(_name, side_type_gather_float_be(_offset, _float_size, _access_mode, _attr))
+#define side_type_gather_string(_offset, _access_mode, _attr) \
+ { \
+ .type = SIDE_TYPE_GATHER_STRING, \
+ .u = { \
+ .side_gather = { \
+ .u = { \
+ .side_string = { \
+ .offset = _offset, \
+ .access_mode = _access_mode, \
+ .type = { \
+ .attr = _attr, \
+ .nr_attr = SIDE_ARRAY_SIZE(SIDE_PARAM(_attr)), \
+ }, \
+ }, \
+ }, \
+ }, \
+ }, \
+ }
+#define side_field_gather_string(_name, _offset, _access_mode, _attr) \
+ _side_field(_name, side_type_gather_string(_offset, _access_mode, SIDE_PARAM(_attr)))
+
#define side_type_gather_enum(_mappings, _elem_type) \
{ \
.type = SIDE_TYPE_GATHER_ENUM, \
#define side_arg_gather_pointer(_ptr) { .type = SIDE_TYPE_GATHER_POINTER, .u = { .side_static = { .side_integer_gather_ptr = (_ptr) } } }
#define side_arg_gather_integer(_ptr) { .type = SIDE_TYPE_GATHER_INTEGER, .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_string(_ptr) { .type = SIDE_TYPE_GATHER_STRING, .u = { .side_static = { .side_string_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) } } } }
);
}
+side_static_event(my_provider_event_gatherstring,
+ "myprovider", "myeventgatherstring", SIDE_LOGLEVEL_DEBUG,
+ side_field_list(
+ side_field_gather_string("string", 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()),
+ side_field_gather_array("arrayptr",
+ side_elem(side_type_gather_string(0, SIDE_TYPE_GATHER_ACCESS_POINTER, side_attr_list())),
+ 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()
+ ),
+ side_field_gather_array("array",
+ side_elem(side_type_gather_string(0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list())),
+ 3, 0, SIDE_TYPE_GATHER_ACCESS_DIRECT, side_attr_list()
+ ),
+ ),
+ side_attr_list()
+);
+
+static
+void test_gather_string(void)
+{
+ side_event_cond(my_provider_event_gatherstring) {
+ char *str1 = "abcdef";
+ char *ptrarray[3] = {
+ "abc",
+ "def",
+ "ghi",
+ };
+ char flatarray[] = { 'a', 'b', '\0', 'c', 'd', '\0', 'e', 'f', '\0' };
+
+ side_event_call(my_provider_event_gatherstring,
+ side_arg_list(
+ side_arg_gather_string(str1),
+ side_arg_gather_array(ptrarray),
+ side_arg_gather_array(flatarray),
+ )
+ );
+ }
+}
+
int main()
{
test_fields();
test_gather_bool();
test_gather_pointer();
test_gather_enum();
+ test_gather_string();
return 0;
}
static
uint32_t tracer_print_gather_float_type(const struct side_type_gather *type_gather, const void *_ptr);
static
+uint32_t tracer_print_gather_string_type(const struct side_type_gather *type_gather, const void *_ptr);
+static
uint32_t tracer_print_gather_enum_type(const struct side_type_gather *type_gather, const void *_ptr);
static
uint32_t tracer_print_gather_struct(const struct side_type_gather *type_gather, const void *_ptr);
case SIDE_TYPE_GATHER_FLOAT:
(void) tracer_print_gather_float_type(&type_desc->u.side_gather, item->u.side_static.side_float_gather_ptr);
break;
+ case SIDE_TYPE_GATHER_STRING:
+ (void) tracer_print_gather_string_type(&type_desc->u.side_gather, item->u.side_static.side_string_gather_ptr);
+ break;
/* Gather compound type */
case SIDE_TYPE_GATHER_STRUCT:
return tracer_gather_size(access_mode, float_size_bytes);
}
+static
+uint32_t tracer_print_gather_string_type(const struct side_type_gather *type_gather, const void *_ptr)
+{
+ enum side_type_gather_access_mode access_mode =
+ (enum side_type_gather_access_mode) type_gather->u.side_string.access_mode;
+ const char *ptr = (const char *) _ptr;
+ size_t string_len;
+
+ ptr = tracer_gather_access(access_mode, ptr + type_gather->u.side_string.offset);
+ tracer_print_type_header(":", type_gather->u.side_string.type.attr,
+ type_gather->u.side_string.type.nr_attr);
+ if (ptr) {
+ printf("\"%s\"", ptr);
+ string_len = strlen(ptr) + 1;
+ } else {
+ printf("<NULL>");
+ string_len = 1;
+ }
+ return tracer_gather_size(access_mode, string_len);
+}
+
static
uint32_t tracer_print_gather_type(const struct side_type *type_desc, const void *ptr)
{
case SIDE_TYPE_GATHER_FLOAT:
len = tracer_print_gather_float_type(&type_desc->u.side_gather, ptr);
break;
+ case SIDE_TYPE_GATHER_STRING:
+ len = tracer_print_gather_string_type(&type_desc->u.side_gather, ptr);
+ break;
/* Gather enum types */
case SIDE_TYPE_GATHER_ENUM: