Add tracer private data pointer
[libside.git] / src / tracer.c
index b48baff5fedc5eccaf618dc79a5dffb8285ba826..d2b79ec7393faf117fbc545b0b2ced9604378fce 100644 (file)
@@ -7,6 +7,7 @@
 #include <inttypes.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <stdbool.h>
 
 #include <side/trace.h>
 
@@ -25,6 +26,152 @@ void tracer_print_vla_fixint(const struct side_type_description *type_desc, cons
 static
 void tracer_print_dynamic(const struct side_arg_dynamic_vec *dynamic_item);
 
+static
+void tracer_print_attr_type(const struct side_attr *attr)
+{
+       printf("{ key: \"%s\", value: ", attr->key);
+       switch (attr->value.type) {
+       case SIDE_ATTR_TYPE_BOOL:
+               printf("%s", attr->value.u.side_bool ? "true" : "false");
+               break;
+       case SIDE_ATTR_TYPE_U8:
+               printf("%" PRIu8, attr->value.u.side_u8);
+               break;
+       case SIDE_ATTR_TYPE_U16:
+               printf("%" PRIu16, attr->value.u.side_u16);
+               break;
+       case SIDE_ATTR_TYPE_U32:
+               printf("%" PRIu32, attr->value.u.side_u32);
+               break;
+       case SIDE_ATTR_TYPE_U64:
+               printf("%" PRIu64, attr->value.u.side_u64);
+               break;
+       case SIDE_ATTR_TYPE_S8:
+               printf("%" PRId8, attr->value.u.side_s8);
+               break;
+       case SIDE_ATTR_TYPE_S16:
+               printf("%" PRId16, attr->value.u.side_s16);
+               break;
+       case SIDE_ATTR_TYPE_S32:
+               printf("%" PRId32, attr->value.u.side_s32);
+               break;
+       case SIDE_ATTR_TYPE_S64:
+               printf("%" PRId64, attr->value.u.side_s64);
+               break;
+       case SIDE_ATTR_TYPE_FLOAT_BINARY16:
+#if __HAVE_FLOAT16
+               printf("%g", (double) attr->value.u.side_float_binary16);
+               break;
+#else
+               printf("ERROR: Unsupported binary16 float type\n");
+               abort();
+#endif
+       case SIDE_ATTR_TYPE_FLOAT_BINARY32:
+#if __HAVE_FLOAT32
+               printf("%g", (double) attr->value.u.side_float_binary32);
+               break;
+#else
+               printf("ERROR: Unsupported binary32 float type\n");
+               abort();
+#endif
+       case SIDE_ATTR_TYPE_FLOAT_BINARY64:
+#if __HAVE_FLOAT64
+               printf("%g", (double) attr->value.u.side_float_binary64);
+               break;
+#else
+               printf("ERROR: Unsupported binary64 float type\n");
+               abort();
+#endif
+       case SIDE_ATTR_TYPE_FLOAT_BINARY128:
+#if __HAVE_FLOAT128
+               printf("%Lg", (long double) attr->value.u.side_float_binary128);
+               break;
+#else
+               printf("ERROR: Unsupported binary128 float type\n");
+               abort();
+#endif
+       case SIDE_ATTR_TYPE_STRING:
+               printf("\"%s\"", attr->value.u.string);
+               break;
+       default:
+               printf("<UNKNOWN TYPE>");
+               abort();
+       }
+       printf(" }");
+}
+
+static
+void print_attributes(const char *prefix_str, const struct side_attr *attr, uint32_t nr_attr)
+{
+       int i;
+
+       if (!nr_attr)
+               return;
+       printf("%s[ ", prefix_str);
+       for (i = 0; i < nr_attr; i++) {
+               printf("%s", i ? ", " : "");
+               tracer_print_attr_type(&attr[i]);
+       }
+       printf(" ]");
+}
+
+static
+void print_enum(const struct side_enum_mappings *side_enum_mappings, int64_t value)
+{
+       int i, print_count = 0;
+
+       printf("%" PRId64 ", labels: [ ", value);
+       for (i = 0; i < side_enum_mappings->nr_mappings; i++) {
+               const struct side_enum_mapping *mapping = &side_enum_mappings->mappings[i];
+
+               if (mapping->range_end < mapping->range_begin) {
+                       printf("ERROR: Unexpected enum range: %" PRIu64 "-%" PRIu64 "\n",
+                               mapping->range_begin, mapping->range_end);
+                       abort();
+               }
+               if (value >= mapping->range_begin && value <= mapping->range_end) {
+                       printf("%s", print_count++ ? ", " : "");
+                       printf("\"%s\"", mapping->label);
+               }
+       }
+       if (!print_count)
+               printf("<NO LABEL>");
+       printf(" ]");
+}
+
+static
+void print_enum_bitmap(const struct side_enum_bitmap_mappings *side_enum_mappings, uint64_t value)
+{
+       int i, print_count = 0;
+
+       printf("0x%" PRIx64 ", labels: [ ", value);
+       for (i = 0; i < side_enum_mappings->nr_mappings; i++) {
+               const struct side_enum_bitmap_mapping *mapping = &side_enum_mappings->mappings[i];
+               bool match = false;
+               int64_t bit;
+
+               if (mapping->range_begin < 0 || mapping->range_end > 63
+                               || mapping->range_end < mapping->range_begin) {
+                       printf("ERROR: Unexpected enum bitmap range: %" PRIu64 "-%" PRIu64 "\n",
+                               mapping->range_begin, mapping->range_end);
+                       abort();
+               }
+               for (bit = mapping->range_begin; bit <= mapping->range_end; bit++) {
+                       if (value & (1ULL << bit)) {
+                               match = true;
+                               break;
+                       }
+               }
+               if (match) {
+                       printf("%s", print_count++ ? ", " : "");
+                       printf("\"%s\"", mapping->label);
+               }
+       }
+       if (!print_count)
+               printf("<NO LABEL>");
+       printf(" ]");
+}
+
 static
 void tracer_print_type(const struct side_type_description *type_desc, const struct side_arg_vec *item)
 {
@@ -37,6 +184,7 @@ void tracer_print_type(const struct side_type_description *type_desc, const stru
        case SIDE_TYPE_ARRAY_S16:
        case SIDE_TYPE_ARRAY_S32:
        case SIDE_TYPE_ARRAY_S64:
+       case SIDE_TYPE_ARRAY_BLOB:
                if (type_desc->type != SIDE_TYPE_ARRAY) {
                        printf("ERROR: type mismatch between description and arguments\n");
                        abort();
@@ -50,6 +198,7 @@ void tracer_print_type(const struct side_type_description *type_desc, const stru
        case SIDE_TYPE_VLA_S16:
        case SIDE_TYPE_VLA_S32:
        case SIDE_TYPE_VLA_S64:
+       case SIDE_TYPE_VLA_BLOB:
                if (type_desc->type != SIDE_TYPE_VLA) {
                        printf("ERROR: type mismatch between description and arguments\n");
                        abort();
@@ -63,7 +212,14 @@ void tracer_print_type(const struct side_type_description *type_desc, const stru
                }
                break;
        }
+       printf("{ ");
+       print_attributes("attr: ", type_desc->attr, type_desc->nr_attr);
+       printf("%s", type_desc->nr_attr ? ", " : "");
+       printf("value: ");
        switch (item->type) {
+       case SIDE_TYPE_BOOL:
+               printf("%s", item->u.side_bool ? "true" : "false");
+               break;
        case SIDE_TYPE_U8:
                printf("%" PRIu8, item->u.side_u8);
                break;
@@ -88,6 +244,92 @@ void tracer_print_type(const struct side_type_description *type_desc, const stru
        case SIDE_TYPE_S64:
                printf("%" PRId64, item->u.side_s64);
                break;
+       case SIDE_TYPE_BLOB:
+               printf("0x%" PRIx8, item->u.side_blob);
+               break;
+
+       case SIDE_TYPE_ENUM_U8:
+               print_enum(type_desc->u.side_enum_mappings,
+                       (int64_t) item->u.side_u8);
+               break;
+       case SIDE_TYPE_ENUM_U16:
+               print_enum(type_desc->u.side_enum_mappings,
+                       (int64_t) item->u.side_u16);
+               break;
+       case SIDE_TYPE_ENUM_U32:
+               print_enum(type_desc->u.side_enum_mappings,
+                       (int64_t) item->u.side_u32);
+               break;
+       case SIDE_TYPE_ENUM_U64:
+               print_enum(type_desc->u.side_enum_mappings,
+                       (int64_t) item->u.side_u64);
+               break;
+       case SIDE_TYPE_ENUM_S8:
+               print_enum(type_desc->u.side_enum_mappings,
+                       (int64_t) item->u.side_s8);
+               break;
+       case SIDE_TYPE_ENUM_S16:
+               print_enum(type_desc->u.side_enum_mappings,
+                       (int64_t) item->u.side_s16);
+               break;
+       case SIDE_TYPE_ENUM_S32:
+               print_enum(type_desc->u.side_enum_mappings,
+                       (int64_t) item->u.side_s32);
+               break;
+       case SIDE_TYPE_ENUM_S64:
+               print_enum(type_desc->u.side_enum_mappings,
+                       item->u.side_s64);
+               break;
+
+       case SIDE_TYPE_ENUM_BITMAP8:
+               print_enum_bitmap(type_desc->u.side_enum_bitmap_mappings,
+                       (uint64_t) item->u.side_u8);
+               break;
+       case SIDE_TYPE_ENUM_BITMAP16:
+               print_enum_bitmap(type_desc->u.side_enum_bitmap_mappings,
+                       (uint64_t) item->u.side_u16);
+               break;
+       case SIDE_TYPE_ENUM_BITMAP32:
+               print_enum_bitmap(type_desc->u.side_enum_bitmap_mappings,
+                       (uint64_t) item->u.side_u32);
+               break;
+       case SIDE_TYPE_ENUM_BITMAP64:
+               print_enum_bitmap(type_desc->u.side_enum_bitmap_mappings,
+                       item->u.side_u64);
+               break;
+
+       case SIDE_TYPE_FLOAT_BINARY16:
+#if __HAVE_FLOAT16
+               printf("%g", (double) item->u.side_float_binary16);
+               break;
+#else
+               printf("ERROR: Unsupported binary16 float type\n");
+               abort();
+#endif
+       case SIDE_TYPE_FLOAT_BINARY32:
+#if __HAVE_FLOAT32
+               printf("%g", (double) item->u.side_float_binary32);
+               break;
+#else
+               printf("ERROR: Unsupported binary32 float type\n");
+               abort();
+#endif
+       case SIDE_TYPE_FLOAT_BINARY64:
+#if __HAVE_FLOAT64
+               printf("%g", (double) item->u.side_float_binary64);
+               break;
+#else
+               printf("ERROR: Unsupported binary64 float type\n");
+               abort();
+#endif
+       case SIDE_TYPE_FLOAT_BINARY128:
+#if __HAVE_FLOAT128
+               printf("%Lg", (long double) item->u.side_float_binary128);
+               break;
+#else
+               printf("ERROR: Unsupported binary128 float type\n");
+               abort();
+#endif
        case SIDE_TYPE_STRING:
                printf("\"%s\"", item->u.string);
                break;
@@ -111,6 +353,7 @@ void tracer_print_type(const struct side_type_description *type_desc, const stru
        case SIDE_TYPE_ARRAY_S16:
        case SIDE_TYPE_ARRAY_S32:
        case SIDE_TYPE_ARRAY_S64:
+       case SIDE_TYPE_ARRAY_BLOB:
                tracer_print_array_fixint(type_desc, item);
                break;
        case SIDE_TYPE_VLA_U8:
@@ -121,6 +364,7 @@ void tracer_print_type(const struct side_type_description *type_desc, const stru
        case SIDE_TYPE_VLA_S16:
        case SIDE_TYPE_VLA_S32:
        case SIDE_TYPE_VLA_S64:
+       case SIDE_TYPE_VLA_BLOB:
                tracer_print_vla_fixint(type_desc, item);
                break;
        case SIDE_TYPE_DYNAMIC:
@@ -130,6 +374,7 @@ void tracer_print_type(const struct side_type_description *type_desc, const stru
                printf("<UNKNOWN TYPE>");
                abort();
        }
+       printf(" }");
 }
 
 static
@@ -241,70 +486,47 @@ void tracer_print_array_fixint(const struct side_type_description *type_desc, co
        enum side_type side_type;
        int i;
 
-       if (elem_type->type != SIDE_TYPE_DYNAMIC) {
-               switch (item->type) {
-               case SIDE_TYPE_ARRAY_U8:
-                       if (elem_type->type != SIDE_TYPE_U8)
-                               goto type_error;
-                       break;
-               case SIDE_TYPE_ARRAY_U16:
-                       if (elem_type->type != SIDE_TYPE_U16)
-                               goto type_error;
-                       break;
-               case SIDE_TYPE_ARRAY_U32:
-                       if (elem_type->type != SIDE_TYPE_U32)
-                               goto type_error;
-                       break;
-               case SIDE_TYPE_ARRAY_U64:
-                       if (elem_type->type != SIDE_TYPE_U64)
-                               goto type_error;
-                       break;
-               case SIDE_TYPE_ARRAY_S8:
-                       if (elem_type->type != SIDE_TYPE_S8)
-                               goto type_error;
-                       break;
-               case SIDE_TYPE_ARRAY_S16:
-                       if (elem_type->type != SIDE_TYPE_S16)
-                               goto type_error;
-                       break;
-               case SIDE_TYPE_ARRAY_S32:
-                       if (elem_type->type != SIDE_TYPE_S32)
-                               goto type_error;
-                       break;
-               case SIDE_TYPE_ARRAY_S64:
-                       if (elem_type->type != SIDE_TYPE_S64)
-                               goto type_error;
-                       break;
-               }
-               side_type = elem_type->type;
-       } else {
-               switch (item->type) {
-               case SIDE_TYPE_ARRAY_U8:
-                       side_type = SIDE_TYPE_U8;
-                       break;
-               case SIDE_TYPE_ARRAY_U16:
-                       side_type = SIDE_TYPE_U16;
-                       break;
-               case SIDE_TYPE_ARRAY_U32:
-                       side_type = SIDE_TYPE_U32;
-                       break;
-               case SIDE_TYPE_ARRAY_U64:
-                       side_type = SIDE_TYPE_U64;
-                       break;
-               case SIDE_TYPE_ARRAY_S8:
-                       side_type = SIDE_TYPE_S8;
-                       break;
-               case SIDE_TYPE_ARRAY_S16:
-                       side_type = SIDE_TYPE_S16;
-                       break;
-               case SIDE_TYPE_ARRAY_S32:
-                       side_type = SIDE_TYPE_S32;
-                       break;
-               case SIDE_TYPE_ARRAY_S64:
-                       side_type = SIDE_TYPE_S64;
-                       break;
-               }
+       switch (item->type) {
+       case SIDE_TYPE_ARRAY_U8:
+               if (elem_type->type != SIDE_TYPE_U8)
+                       goto type_error;
+               break;
+       case SIDE_TYPE_ARRAY_U16:
+               if (elem_type->type != SIDE_TYPE_U16)
+                       goto type_error;
+               break;
+       case SIDE_TYPE_ARRAY_U32:
+               if (elem_type->type != SIDE_TYPE_U32)
+                       goto type_error;
+               break;
+       case SIDE_TYPE_ARRAY_U64:
+               if (elem_type->type != SIDE_TYPE_U64)
+                       goto type_error;
+               break;
+       case SIDE_TYPE_ARRAY_S8:
+               if (elem_type->type != SIDE_TYPE_S8)
+                       goto type_error;
+               break;
+       case SIDE_TYPE_ARRAY_S16:
+               if (elem_type->type != SIDE_TYPE_S16)
+                       goto type_error;
+               break;
+       case SIDE_TYPE_ARRAY_S32:
+               if (elem_type->type != SIDE_TYPE_S32)
+                       goto type_error;
+               break;
+       case SIDE_TYPE_ARRAY_S64:
+               if (elem_type->type != SIDE_TYPE_S64)
+                       goto type_error;
+               break;
+       case SIDE_TYPE_ARRAY_BLOB:
+               if (elem_type->type != SIDE_TYPE_BLOB)
+                       goto type_error;
+               break;
+       default:
+               goto type_error;
        }
+       side_type = elem_type->type;
 
        printf("[ ");
        for (i = 0; i < side_sav_len; i++) {
@@ -337,6 +559,9 @@ void tracer_print_array_fixint(const struct side_type_description *type_desc, co
                case SIDE_TYPE_S64:
                        sav_elem.u.side_s64 = ((const int64_t *) p)[i];
                        break;
+               case SIDE_TYPE_BLOB:
+                       sav_elem.u.side_blob = ((const uint8_t *) p)[i];
+                       break;
 
                default:
                        printf("ERROR: Unexpected type\n");
@@ -395,6 +620,10 @@ void tracer_print_vla_fixint(const struct side_type_description *type_desc, cons
                if (elem_type->type != SIDE_TYPE_S64)
                        goto type_error;
                break;
+       case SIDE_TYPE_VLA_BLOB:
+               if (elem_type->type != SIDE_TYPE_BLOB)
+                       goto type_error;
+               break;
        default:
                goto type_error;
        }
@@ -431,6 +660,9 @@ void tracer_print_vla_fixint(const struct side_type_description *type_desc, cons
                case SIDE_TYPE_S64:
                        sav_elem.u.side_s64 = ((const int64_t *) p)[i];
                        break;
+               case SIDE_TYPE_BLOB:
+                       sav_elem.u.side_blob = ((const uint8_t *) p)[i];
+                       break;
 
                default:
                        printf("ERROR: Unexpected type\n");
@@ -464,10 +696,46 @@ void tracer_print_dynamic_struct(const struct side_arg_dynamic_event_struct *dyn
        printf(" ]");
 }
 
+struct tracer_dynamic_struct_visitor_priv {
+       int i;
+};
+
+static
+enum side_visitor_status tracer_dynamic_struct_write_elem_cb(
+                       const struct side_tracer_dynamic_struct_visitor_ctx *tracer_ctx,
+                       const struct side_arg_dynamic_event_field *dynamic_field)
+{
+       struct tracer_dynamic_struct_visitor_priv *tracer_priv = tracer_ctx->priv;
+
+       printf("%s", tracer_priv->i++ ? ", " : "");
+       printf("%s:: ", dynamic_field->field_name);
+       tracer_print_dynamic(&dynamic_field->elem);
+       return SIDE_VISITOR_STATUS_OK;
+}
+
 static
 void tracer_print_dynamic_struct_visitor(const struct side_arg_dynamic_vec *item)
 {
-       //TODO
+       enum side_visitor_status status;
+       struct tracer_dynamic_struct_visitor_priv tracer_priv = {
+               .i = 0,
+       };
+       const struct side_tracer_dynamic_struct_visitor_ctx tracer_ctx = {
+               .write_field = tracer_dynamic_struct_write_elem_cb,
+               .priv = &tracer_priv,
+       };
+       void *app_ctx = item->u.side_dynamic_struct_visitor.app_ctx;
+
+       printf("[ ");
+       status = item->u.side_dynamic_struct_visitor.visitor(&tracer_ctx, app_ctx);
+       switch (status) {
+       case SIDE_VISITOR_STATUS_OK:
+               break;
+       case SIDE_VISITOR_STATUS_ERROR:
+               printf("ERROR: Visitor error\n");
+               abort();
+       }
+       printf(" ]");
 }
 
 static
@@ -485,19 +753,61 @@ void tracer_print_dynamic_vla(const struct side_arg_dynamic_vec_vla *vla)
        printf(" ]");
 }
 
+struct tracer_dynamic_vla_visitor_priv {
+       int i;
+};
+
+static
+enum side_visitor_status tracer_dynamic_vla_write_elem_cb(
+                       const struct side_tracer_dynamic_vla_visitor_ctx *tracer_ctx,
+                       const struct side_arg_dynamic_vec *elem)
+{
+       struct tracer_dynamic_vla_visitor_priv *tracer_priv = tracer_ctx->priv;
+
+       printf("%s", tracer_priv->i++ ? ", " : "");
+       tracer_print_dynamic(elem);
+       return SIDE_VISITOR_STATUS_OK;
+}
+
 static
 void tracer_print_dynamic_vla_visitor(const struct side_arg_dynamic_vec *item)
 {
-       //TODO
+       enum side_visitor_status status;
+       struct tracer_dynamic_vla_visitor_priv tracer_priv = {
+               .i = 0,
+       };
+       const struct side_tracer_dynamic_vla_visitor_ctx tracer_ctx = {
+               .write_elem = tracer_dynamic_vla_write_elem_cb,
+               .priv = &tracer_priv,
+       };
+       void *app_ctx = item->u.side_dynamic_vla_visitor.app_ctx;
+
+       printf("[ ");
+       status = item->u.side_dynamic_vla_visitor.visitor(&tracer_ctx, app_ctx);
+       switch (status) {
+       case SIDE_VISITOR_STATUS_OK:
+               break;
+       case SIDE_VISITOR_STATUS_ERROR:
+               printf("ERROR: Visitor error\n");
+               abort();
+       }
+       printf(" ]");
 }
 
 static
 void tracer_print_dynamic(const struct side_arg_dynamic_vec *item)
 {
-       switch (item->type) {
+       printf("{ ");
+       print_attributes("attr:: ", item->attr, item->nr_attr);
+       printf("%s", item->nr_attr ? ", " : "");
+       printf("value: ");
+       switch (item->dynamic_type) {
        case SIDE_DYNAMIC_TYPE_NULL:
                printf("<NULL TYPE>");
                break;
+       case SIDE_DYNAMIC_TYPE_BOOL:
+               printf("%s", item->u.side_bool ? "true" : "false");
+               break;
        case SIDE_DYNAMIC_TYPE_U8:
                printf("%" PRIu8, item->u.side_u8);
                break;
@@ -522,6 +832,42 @@ void tracer_print_dynamic(const struct side_arg_dynamic_vec *item)
        case SIDE_DYNAMIC_TYPE_S64:
                printf("%" PRId64, item->u.side_s64);
                break;
+       case SIDE_DYNAMIC_TYPE_BLOB:
+               printf("0x%" PRIx8, item->u.side_blob);
+               break;
+
+       case SIDE_DYNAMIC_TYPE_FLOAT_BINARY16:
+#if __HAVE_FLOAT16
+               printf("%g", (double) item->u.side_float_binary16);
+               break;
+#else
+               printf("ERROR: Unsupported binary16 float type\n");
+               abort();
+#endif
+       case SIDE_DYNAMIC_TYPE_FLOAT_BINARY32:
+#if __HAVE_FLOAT32
+               printf("%g", (double) item->u.side_float_binary32);
+               break;
+#else
+               printf("ERROR: Unsupported binary32 float type\n");
+               abort();
+#endif
+       case SIDE_DYNAMIC_TYPE_FLOAT_BINARY64:
+#if __HAVE_FLOAT64
+               printf("%g", (double) item->u.side_float_binary64);
+               break;
+#else
+               printf("ERROR: Unsupported binary64 float type\n");
+               abort();
+#endif
+       case SIDE_DYNAMIC_TYPE_FLOAT_BINARY128:
+#if __HAVE_FLOAT128
+               printf("%Lg", (long double) item->u.side_float_binary128);
+               break;
+#else
+               printf("ERROR: Unsupported binary128 float type\n");
+               abort();
+#endif
        case SIDE_DYNAMIC_TYPE_STRING:
                printf("\"%s\"", item->u.string);
                break;
@@ -541,50 +887,66 @@ void tracer_print_dynamic(const struct side_arg_dynamic_vec *item)
                printf("<UNKNOWN TYPE>");
                abort();
        }
+       printf(" }");
 }
 
-void tracer_call(const struct side_event_description *desc, const struct side_arg_vec_description *sav_desc)
+static
+void tracer_print_static_fields(const struct side_event_description *desc,
+               const struct side_arg_vec_description *sav_desc,
+               int *nr_items)
 {
        const struct side_arg_vec *sav = sav_desc->sav;
        uint32_t side_sav_len = sav_desc->len;
        int i;
 
-       printf("provider: %s, event: %s", desc->provider_name, desc->event_name);
+       printf("provider: %s, event: %s", desc->provider_name, desc->event_name);
        if (desc->nr_fields != side_sav_len) {
                printf("ERROR: number of fields mismatch between description and arguments\n");
                abort();
        }
+       print_attributes(", attributes: ", desc->attr, desc->nr_attr);
+       printf("%s", side_sav_len ? ", fields: [ " : "");
        for (i = 0; i < side_sav_len; i++) {
                printf("%s", i ? ", " : "");
                tracer_print_field(&desc->fields[i], &sav[i]);
        }
+       if (nr_items)
+               *nr_items = i;
+}
+
+void tracer_call(const struct side_event_description *desc,
+               const struct side_arg_vec_description *sav_desc,
+               void *priv __attribute__((unused)))
+{
+       int nr_fields = 0;
+
+       tracer_print_static_fields(desc, sav_desc, &nr_fields);
+       if (nr_fields)
+               printf(" ]");
        printf("\n");
 }
 
 void tracer_call_variadic(const struct side_event_description *desc,
-       const struct side_arg_vec_description *sav_desc,
-       const struct side_arg_dynamic_event_struct *var_struct)
+               const struct side_arg_vec_description *sav_desc,
+               const struct side_arg_dynamic_event_struct *var_struct,
+               void *priv __attribute__((unused)))
 {
-       const struct side_arg_vec *sav = sav_desc->sav;
-       uint32_t side_sav_len = sav_desc->len,
-               var_struct_len = var_struct->len;
-       int i, j;
+       uint32_t var_struct_len = var_struct->len;
+       int nr_fields = 0, i;
 
-       printf("provider: %s, event: %s, ", desc->provider_name, desc->event_name);
-       if (desc->nr_fields != side_sav_len) {
-               printf("ERROR: number of fields mismatch between description and arguments\n");
+       tracer_print_static_fields(desc, sav_desc, &nr_fields);
+
+       if (side_unlikely(!(desc->flags & SIDE_EVENT_FLAG_VARIADIC))) {
+               printf("ERROR: unexpected non-variadic event description\n");
                abort();
        }
-       /* static */
-       for (i = 0; i < side_sav_len; i++) {
-               printf("%s", i ? ", " : "");
-               tracer_print_field(&desc->fields[i], &sav[i]);
-       }
-       /* variadic */
-       for (j = 0; j < var_struct_len; j++, i++) {
-               printf("%s", i ? ", " : "");
-               printf("%s:: ", var_struct->fields[j].field_name);
-               tracer_print_dynamic(&var_struct->fields[j].elem);
+       printf("%s", var_struct_len && !nr_fields ? ", fields: [ " : "");
+       for (i = 0; i < var_struct_len; i++, nr_fields++) {
+               printf("%s", nr_fields ? ", " : "");
+               printf("%s:: ", var_struct->fields[i].field_name);
+               tracer_print_dynamic(&var_struct->fields[i].elem);
        }
+       if (i)
+               printf(" ]");
        printf("\n");
 }
This page took 0.0314 seconds and 4 git commands to generate.