X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=lib%2Flib-logging.c;h=11ba9e71ce443a622b3f23f32a69d2d103f8e5ca;hp=b8ab574580ec5234e76ebca274bfbf6bc369c1ae;hb=c9fe7f23d9609caf13253debd50f10a820d8de8f;hpb=e22b45d0f7d3ce1311bf96a930bc42326f555202 diff --git a/lib/lib-logging.c b/lib/lib-logging.c index b8ab5745..11ba9e71 100644 --- a/lib/lib-logging.c +++ b/lib/lib-logging.c @@ -30,30 +30,29 @@ #include #include #include +#include +#include #include #include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -62,19 +61,21 @@ #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #define LIB_LOGGING_BUF_SIZE (4096 * 4) -static char __thread lib_logging_buf[LIB_LOGGING_BUF_SIZE]; +static __thread char lib_logging_buf[LIB_LOGGING_BUF_SIZE]; #define BUF_APPEND(_fmt, ...) \ do { \ @@ -90,73 +91,65 @@ static char __thread lib_logging_buf[LIB_LOGGING_BUF_SIZE]; } while (0) #define BUF_APPEND_UUID(_uuid) \ - BUF_APPEND(", %suuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"", \ - prefix, \ - (unsigned int) (_uuid)[0], \ - (unsigned int) (_uuid)[1], \ - (unsigned int) (_uuid)[2], \ - (unsigned int) (_uuid)[3], \ - (unsigned int) (_uuid)[4], \ - (unsigned int) (_uuid)[5], \ - (unsigned int) (_uuid)[6], \ - (unsigned int) (_uuid)[7], \ - (unsigned int) (_uuid)[8], \ - (unsigned int) (_uuid)[9], \ - (unsigned int) (_uuid)[10], \ - (unsigned int) (_uuid)[11], \ - (unsigned int) (_uuid)[12], \ - (unsigned int) (_uuid)[13], \ - (unsigned int) (_uuid)[14], \ - (unsigned int) (_uuid)[15]) + do { \ + BUF_APPEND(", %suuid=", prefix); \ + format_uuid(buf_ch, (_uuid)); \ + } while (0) #define PRFIELD(_expr) prefix, (_expr) +#define PRFIELD_GSTRING(_expr) PRFIELD((_expr) ? (_expr)->str : NULL) + #define SET_TMP_PREFIX(_prefix2) \ do { \ strcpy(tmp_prefix, prefix); \ strcat(tmp_prefix, (_prefix2)); \ } while (0) -typedef void (*format_func)(char **, bool, const char *, void *); - static inline void format_component(char **buf_ch, bool extended, - const char *prefix, struct bt_component *component); + const char *prefix, const struct bt_component *component); static inline void format_port(char **buf_ch, bool extended, - const char *prefix, struct bt_port *port); + const char *prefix, const struct bt_port *port); static inline void format_connection(char **buf_ch, bool extended, - const char *prefix, struct bt_connection *connection); + const char *prefix, const struct bt_connection *connection); -static inline void format_clock_value(char **buf_ch, bool extended, - const char *prefix, struct bt_clock_value *clock_value); +static inline void format_clock_snapshot(char **buf_ch, bool extended, + const char *prefix, const struct bt_clock_snapshot *clock_snapshot); + +static inline void format_field_path(char **buf_ch, bool extended, + const char *prefix, const struct bt_field_path *field_path); static inline void format_object(char **buf_ch, bool extended, - const char *prefix, struct bt_object *obj) + const char *prefix, const struct bt_object *obj) { BUF_APPEND(", %sref-count=%llu", prefix, obj->ref_count); } -static inline void format_clock_value_set(char **buf_ch, bool extended, - const char *prefix, struct bt_clock_value_set *cv_set) +static inline void format_uuid(char **buf_ch, bt_uuid uuid) { - char tmp_prefix[64]; - - if (!cv_set->clock_values) { - return; - } - - BUF_APPEND(", %ssize=%u", PRFIELD(cv_set->clock_values->len)); - - if (cv_set->default_cv) { - SET_TMP_PREFIX("default-cv-"); - format_clock_value(buf_ch, extended, tmp_prefix, - cv_set->default_cv); - } + BUF_APPEND("\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"", + (unsigned int) uuid[0], + (unsigned int) uuid[1], + (unsigned int) uuid[2], + (unsigned int) uuid[3], + (unsigned int) uuid[4], + (unsigned int) uuid[5], + (unsigned int) uuid[6], + (unsigned int) uuid[7], + (unsigned int) uuid[8], + (unsigned int) uuid[9], + (unsigned int) uuid[10], + (unsigned int) uuid[11], + (unsigned int) uuid[12], + (unsigned int) uuid[13], + (unsigned int) uuid[14], + (unsigned int) uuid[15]); } static inline void format_object_pool(char **buf_ch, bool extended, - const char *prefix, struct bt_object_pool *pool) + const char *prefix, const struct bt_object_pool *pool) { BUF_APPEND(", %ssize=%zu", PRFIELD(pool->size)); @@ -165,99 +158,136 @@ static inline void format_object_pool(char **buf_ch, bool extended, } } -static inline void format_field_type_common(char **buf_ch, bool extended, - const char *prefix, struct bt_field_type_common *field_type) +static inline void format_integer_field_class(char **buf_ch, + bool extended, const char *prefix, + const struct bt_field_class *field_class) +{ + const struct bt_field_class_integer *int_fc = + (const void *) field_class; + + BUF_APPEND(", %srange-size=%" PRIu64 ", %sbase=%s", + PRFIELD(int_fc->range), + PRFIELD(bt_common_field_class_integer_preferred_display_base_string(int_fc->base))); +} + +static inline void format_array_field_class(char **buf_ch, + bool extended, const char *prefix, + const struct bt_field_class *field_class) +{ + const struct bt_field_class_array *array_fc = + (const void *) field_class; + + BUF_APPEND(", %selement-fc-addr=%p, %selement-fc-type=%s", + PRFIELD(array_fc->element_fc), + PRFIELD(bt_common_field_class_type_string(array_fc->element_fc->type))); +} + +static inline void format_field_class(char **buf_ch, bool extended, + const char *prefix, const struct bt_field_class *field_class) { - BUF_APPEND(", %stype-id=%s, %salignment=%u", - PRFIELD(bt_common_field_type_id_string(field_type->id)), - PRFIELD(field_type->alignment)); + char tmp_prefix[64]; + + BUF_APPEND(", %stype=%s", + PRFIELD(bt_common_field_class_type_string(field_class->type))); if (extended) { - BUF_APPEND(", %sis-frozen=%d", PRFIELD(field_type->frozen)); + BUF_APPEND(", %sis-frozen=%d", PRFIELD(field_class->frozen)); + BUF_APPEND(", %sis-part-of-trace-class=%d", + PRFIELD(field_class->part_of_trace_class)); } else { return; } - if (field_type->id == BT_FIELD_TYPE_ID_UNKNOWN) { - return; - } - - switch (field_type->id) { - case BT_FIELD_TYPE_ID_INTEGER: + switch (field_class->type) { + case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER: + case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER: { - struct bt_field_type_common_integer *integer = - BT_FROM_COMMON(field_type); - - BUF_APPEND(", %ssize=%u, %sis-signed=%d, %sbyte-order=%s, " - "%sbase=%d, %sencoding=%s, " - "%smapped-clock-class-addr=%p", - PRFIELD(integer->size), PRFIELD(integer->is_signed), - PRFIELD(bt_common_byte_order_string(integer->user_byte_order)), - PRFIELD(integer->base), - PRFIELD(bt_common_string_encoding_string(integer->encoding)), - PRFIELD(integer->mapped_clock_class)); - - if (integer->mapped_clock_class) { - BUF_APPEND(", %smapped-clock-class-name=\"%s\"", - PRFIELD(bt_clock_class_get_name(integer->mapped_clock_class))); - } + format_integer_field_class(buf_ch, extended, prefix, field_class); break; } - case BT_FIELD_TYPE_ID_FLOAT: + case BT_FIELD_CLASS_TYPE_REAL: { - struct bt_field_type_common_floating_point *flt = - BT_FROM_COMMON(field_type); + const struct bt_field_class_real *real_fc = (void *) field_class; - BUF_APPEND(", %sexp-dig=%u, %smant-dig=%u, %sbyte-order=%s", - PRFIELD(flt->exp_dig), PRFIELD(flt->mant_dig), - PRFIELD(bt_common_byte_order_string(flt->user_byte_order))); + BUF_APPEND(", %sis-single-precision=%d", + PRFIELD(real_fc->is_single_precision)); break; } - case BT_FIELD_TYPE_ID_ENUM: + case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: + case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION: { - struct bt_field_type_common_enumeration *enm = - BT_FROM_COMMON(field_type); + const struct bt_field_class_enumeration *enum_fc = + (const void *) field_class; + format_integer_field_class(buf_ch, extended, prefix, field_class); BUF_APPEND(", %smapping-count=%u", - PRFIELD(enm->entries->len)); + PRFIELD(enum_fc->mappings->len)); break; } - case BT_FIELD_TYPE_ID_STRING: + case BT_FIELD_CLASS_TYPE_STRUCTURE: { - struct bt_field_type_common_string *str = - BT_FROM_COMMON(field_type); + const struct bt_field_class_structure *struct_fc = + (const void *) field_class; + + if (struct_fc->common.named_fcs) { + BUF_APPEND(", %smember-count=%u", + PRFIELD(struct_fc->common.named_fcs->len)); + } - BUF_APPEND(", %sencoding=%s", - PRFIELD(bt_common_string_encoding_string(str->encoding))); break; } - case BT_FIELD_TYPE_ID_STRUCT: + case BT_FIELD_CLASS_TYPE_STATIC_ARRAY: { - struct bt_field_type_common_structure *structure = - BT_FROM_COMMON(field_type); + const struct bt_field_class_static_array *array_fc = + (const void *) field_class; - BUF_APPEND(", %sfield-count=%u", - PRFIELD(structure->fields->len)); + format_array_field_class(buf_ch, extended, prefix, field_class); + BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_fc->length)); break; } - case BT_FIELD_TYPE_ID_SEQUENCE: + case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY: { - struct bt_field_type_common_sequence *seq = - BT_FROM_COMMON(field_type); + const struct bt_field_class_dynamic_array *array_fc = + (const void *) field_class; + + format_array_field_class(buf_ch, extended, prefix, field_class); + + if (array_fc->length_fc) { + SET_TMP_PREFIX("length-fc-"); + format_field_class(buf_ch, extended, tmp_prefix, + array_fc->length_fc); + } + + if (array_fc->length_field_path) { + SET_TMP_PREFIX("length-field-path-"); + format_field_path(buf_ch, extended, tmp_prefix, + array_fc->length_field_path); + } - BUF_APPEND(", %slength-ft-addr=\"%s\", %selem-ft-addr=%p", - PRFIELD(seq->length_field_name->str), - PRFIELD(seq->element_ft)); break; } - case BT_FIELD_TYPE_ID_VARIANT: + case BT_FIELD_CLASS_TYPE_VARIANT: { - struct bt_field_type_common_variant *variant = - BT_FROM_COMMON(field_type); + const struct bt_field_class_variant *var_fc = + (const void *) field_class; + + if (var_fc->common.named_fcs) { + BUF_APPEND(", %soption-count=%u", + PRFIELD(var_fc->common.named_fcs->len)); + } + + if (var_fc->selector_fc) { + SET_TMP_PREFIX("selector-fc-"); + format_field_class(buf_ch, extended, tmp_prefix, + var_fc->selector_fc); + } + + if (var_fc->selector_field_path) { + SET_TMP_PREFIX("selector-field-path-"); + format_field_path(buf_ch, extended, tmp_prefix, + var_fc->selector_field_path); + } - BUF_APPEND(", %stag-name=\"%s\", %sfield-count=%u", - PRFIELD(variant->tag_name->str), - PRFIELD(variant->choices->len)); break; } default: @@ -265,121 +295,108 @@ static inline void format_field_type_common(char **buf_ch, bool extended, } } -static inline void format_field_type(char **buf_ch, bool extended, - const char *prefix, struct bt_field_type *field_type) -{ - format_field_type_common(buf_ch, extended, prefix, - (void *) field_type); -} - -static inline void format_writer_field_type(char **buf_ch, bool extended, - const char *prefix, struct bt_ctf_field_type *field_type) +static inline void format_field_integer_extended(char **buf_ch, + const char *prefix, const struct bt_field *field) { - format_field_type_common(buf_ch, extended, prefix, - (void *) field_type); -} - -static inline void format_field_common_integer_extended(char **buf_ch, - const char *prefix, struct bt_field_common *field) -{ - struct bt_field_common_integer *integer = BT_FROM_COMMON(field); - struct bt_field_type_common_integer *field_type = - BT_FROM_COMMON(field->type); + const struct bt_field_integer *integer = (void *) field; + const struct bt_field_class_integer *field_class = + (void *) field->class; const char *fmt = NULL; - BT_ASSERT(field_type); + BT_ASSERT(field_class); - if (field_type->base == 8) { + if (field_class->base == BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL) { fmt = ", %svalue=%" PRIo64; - } else if (field_type->base == 16) { + } else if (field_class->base == BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL) { fmt = ", %svalue=%" PRIx64; } - if (field_type->is_signed) { + if (field_class->common.type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || + field_class->common.type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION) { if (!fmt) { fmt = ", %svalue=%" PRId64; } - BUF_APPEND(fmt, PRFIELD(integer->payload.signd)); + BUF_APPEND(fmt, PRFIELD(integer->value.i)); } else { if (!fmt) { fmt = ", %svalue=%" PRIu64; } - BUF_APPEND(fmt, PRFIELD(integer->payload.unsignd)); + BUF_APPEND(fmt, PRFIELD(integer->value.u)); } } -static inline void format_field_common(char **buf_ch, bool extended, - const char *prefix, struct bt_field_common *field) +static inline void format_field(char **buf_ch, bool extended, + const char *prefix, const struct bt_field *field) { - BUF_APPEND(", %sis-set=%d", PRFIELD(field->payload_set)); + BUF_APPEND(", %sis-set=%d", PRFIELD(field->is_set)); if (extended) { BUF_APPEND(", %sis-frozen=%d", PRFIELD(field->frozen)); } - BUF_APPEND(", %stype-addr=%p", PRFIELD(field->type)); + BUF_APPEND(", %sclass-addr=%p", PRFIELD(field->class)); - if (!field->type) { + if (!field->class) { return; } - BUF_APPEND(", %stype-id=%s", - PRFIELD(bt_common_field_type_id_string(field->type->id))); + BUF_APPEND(", %sclass-type=%s", + PRFIELD(bt_common_field_class_type_string(field->class->type))); - if (!extended || field->type->id == BT_FIELD_TYPE_ID_UNKNOWN || - !field->payload_set) { + if (!extended || !field->is_set) { return; } - switch (field->type->id) { - case BT_FIELD_TYPE_ID_INTEGER: + switch (field->class->type) { + case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER: + case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER: + case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: + case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION: { - format_field_common_integer_extended(buf_ch, prefix, field); + format_field_integer_extended(buf_ch, prefix, field); break; } - case BT_FIELD_TYPE_ID_FLOAT: + case BT_FIELD_CLASS_TYPE_REAL: { - struct bt_field_common_floating_point *flt = - BT_FROM_COMMON(field); + const struct bt_field_real *real_field = (const void *) field; - BUF_APPEND(", %svalue=%f", PRFIELD(flt->payload)); + BUF_APPEND(", %svalue=%f", PRFIELD(real_field->value)); break; } - case BT_FIELD_TYPE_ID_STRING: + case BT_FIELD_CLASS_TYPE_STRING: { - struct bt_field_common_string *str = - BT_FROM_COMMON(field); + const struct bt_field_string *str = (const void *) field; if (str->buf) { BT_ASSERT(str->buf->data); BUF_APPEND(", %spartial-value=\"%.32s\"", PRFIELD(str->buf->data)); - } + break; } - case BT_FIELD_TYPE_ID_SEQUENCE: + case BT_FIELD_CLASS_TYPE_STATIC_ARRAY: + case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY: { - struct bt_field_common_sequence *seq = - BT_FROM_COMMON(field); + const struct bt_field_array *array_field = (const void *) field; - BUF_APPEND(", %slength=%" PRIu64, PRFIELD(seq->length)); + BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_field->length)); - if (seq->elements) { + if (array_field->fields) { BUF_APPEND(", %sallocated-length=%u", - PRFIELD(seq->elements->len)); + PRFIELD(array_field->fields->len)); } + break; } - case BT_FIELD_TYPE_ID_VARIANT: + case BT_FIELD_CLASS_TYPE_VARIANT: { - struct bt_field_common_variant *variant = - BT_FROM_COMMON(field); + const struct bt_field_variant *var_field = (const void *) field; - BUF_APPEND(", %scur-field-addr=%p", - PRFIELD(variant->current_field)); + BUF_APPEND(", %sselected-field-index=%" PRIu64, + PRFIELD(var_field->selected_index)); break; } default: @@ -387,112 +404,78 @@ static inline void format_field_common(char **buf_ch, bool extended, } } -static inline void format_field(char **buf_ch, bool extended, - const char *prefix, struct bt_field *field) +static inline void format_field_path(char **buf_ch, bool extended, + const char *prefix, const struct bt_field_path *field_path) { - struct bt_field_common *common_field = (void *) field; - - format_field_common(buf_ch, extended, prefix, (void *) field); - - if (!extended) { - return; - } - - if (!common_field->type) { - return; - } + uint64_t i; - switch (common_field->type->id) { - case BT_FIELD_TYPE_ID_ENUM: - { - struct bt_field_common_integer *integer = (void *) field; - struct bt_field_type_common_enumeration *enum_ft = - BT_FROM_COMMON(common_field->type); - - if (enum_ft->container_ft) { - if (enum_ft->container_ft->is_signed) { - BUF_APPEND(", %svalue=%" PRId64, - PRFIELD(integer->payload.signd)); - } else { - BUF_APPEND(", %svalue=%" PRIu64, - PRFIELD(integer->payload.unsignd)); - } - } - break; + if (field_path->items) { + BT_ASSERT(field_path->items); + BUF_APPEND(", %sitem-count=%u", + PRFIELD(field_path->items->len)); } - default: - break; - } -} -static inline void format_writer_field(char **buf_ch, bool extended, - const char *prefix, struct bt_ctf_field *field) -{ - struct bt_field_common *common_field = (void *) field; - - format_field_common(buf_ch, extended, prefix, (void *) field); - - if (!extended) { + if (!extended || !field_path->items) { return; } - if (!common_field->type) { - return; - } + BUF_APPEND(", %spath=[%s", + PRFIELD(bt_common_scope_string(field_path->root))); - switch (common_field->type->id) { - case BT_FIELD_TYPE_ID_ENUM: - { - struct bt_ctf_field_enumeration *enumeration = (void *) field; + for (i = 0; i < bt_field_path_get_item_count(field_path); i++) { + const struct bt_field_path_item *fp_item = + bt_field_path_borrow_item_by_index_const(field_path, i); - if (enumeration->container) { - format_writer_field(buf_ch, extended, prefix, - (void *) enumeration->container); + switch (bt_field_path_item_get_type(fp_item)) { + case BT_FIELD_PATH_ITEM_TYPE_INDEX: + BUF_APPEND(", %" PRIu64, + bt_field_path_item_index_get_index(fp_item)); + break; + case BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT: + BUF_APPEND("%s", ", "); + break; + default: + abort(); } - break; } - case BT_FIELD_TYPE_ID_VARIANT: - { - struct bt_ctf_field_variant *variant = (void *) field; - BUF_APPEND(", %stag-field-addr=%p", PRFIELD(variant->tag)); - break; - } - default: - break; - } + BUF_APPEND("%s", "]"); } -static inline void format_field_path(char **buf_ch, bool extended, - const char *prefix, struct bt_field_path *field_path) +static inline void format_trace_class(char **buf_ch, bool extended, + const char *prefix, const struct bt_trace_class *trace_class) { - uint64_t i; - - if (field_path->indexes) { - BT_ASSERT(field_path->indexes); - BUF_APPEND(", %sindex-count=%u", PRFIELD(field_path->indexes->len)); + if (trace_class->name.value) { + BUF_APPEND(", %sname=\"%s\"", + PRFIELD(trace_class->name.value)); } - if (!extended || !field_path->indexes) { + if (!extended) { return; } - BUF_APPEND(", %spath=[%s", PRFIELD(bt_common_scope_string(field_path->root))); + BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace_class->frozen)); - for (i = 0; i < field_path->indexes->len; i++) { - int index = g_array_index(field_path->indexes, int, i); + if (trace_class->uuid.value) { + BUF_APPEND_UUID(trace_class->uuid.value); + } - BUF_APPEND(", %d", index); + if (trace_class->stream_classes) { + BUF_APPEND(", %sstream-class-count=%u", + PRFIELD(trace_class->stream_classes->len)); } - BUF_APPEND("%s", "]"); + BUF_APPEND(", %sassigns-auto-sc-id=%d", + PRFIELD(trace_class->assigns_automatic_stream_class_id)); } -static inline void format_trace_common(char **buf_ch, bool extended, - const char *prefix, struct bt_trace_common *trace) +static inline void format_trace(char **buf_ch, bool extended, + const char *prefix, const struct bt_trace *trace) { - if (trace->name) { - BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace->name->str)); + char tmp_prefix[64]; + + if (trace->name.value) { + BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace->name.value)); } if (!extended) { @@ -501,65 +484,32 @@ static inline void format_trace_common(char **buf_ch, bool extended, BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace->frozen)); - if (trace->uuid_set) { - BUF_APPEND_UUID(trace->uuid); - } - - if (trace->clock_classes) { - BUF_APPEND(", %sclock-class-count=%u", - PRFIELD(trace->clock_classes->len)); - } - - if (trace->stream_classes) { - BUF_APPEND(", %sstream-class-count=%u", - PRFIELD(trace->stream_classes->len)); - } - if (trace->streams) { BUF_APPEND(", %sstream-count=%u", PRFIELD(trace->streams->len)); } - BUF_APPEND(", %spacket-header-ft-addr=%p", - PRFIELD(trace->packet_header_field_type)); -} - -static inline void format_trace(char **buf_ch, bool extended, - const char *prefix, struct bt_trace *trace) -{ - char tmp_prefix[64]; - - format_trace_common(buf_ch, extended, prefix, BT_TO_COMMON(trace)); - - if (!extended) { + if (!trace->class) { return; } - BUF_APPEND(", %sis-static=%d", PRFIELD(trace->is_static)); - SET_TMP_PREFIX("phf-pool-"); - format_object_pool(buf_ch, extended, prefix, - &trace->packet_header_field_pool); -} - -static inline void format_writer_trace(char **buf_ch, bool extended, - const char *prefix, struct bt_ctf_trace *trace) -{ - format_trace_common(buf_ch, extended, prefix, BT_TO_COMMON(trace)); + BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace->class)); + SET_TMP_PREFIX("trace-class-"); + format_trace_class(buf_ch, false, tmp_prefix, trace->class); } -static inline void format_stream_class_common(char **buf_ch, bool extended, - const char *prefix, struct bt_stream_class_common *stream_class, - format_func trace_format_func) +static inline void format_stream_class(char **buf_ch, bool extended, + const char *prefix, + const struct bt_stream_class *stream_class) { - struct bt_trace_common *trace; + const struct bt_trace_class *trace_class; char tmp_prefix[64]; - if (stream_class->id_set) { - BUF_APPEND(", %sid=%" PRId64, PRFIELD(stream_class->id)); - } + BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream_class->id)); - if (stream_class->name) { - BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream_class->name->str)); + if (stream_class->name.value) { + BUF_APPEND(", %sname=\"%s\"", + PRFIELD(stream_class->name.value)); } if (!extended) { @@ -573,252 +523,140 @@ static inline void format_stream_class_common(char **buf_ch, bool extended, PRFIELD(stream_class->event_classes->len)); } - BUF_APPEND(", %spacket-context-ft-addr=%p, " - "%sevent-header-ft-addr=%p, %sevent-context-ft-addr=%p", - PRFIELD(stream_class->packet_context_field_type), - PRFIELD(stream_class->event_header_field_type), - PRFIELD(stream_class->event_context_field_type)); - trace = bt_stream_class_common_borrow_trace(stream_class); - if (!trace) { + BUF_APPEND(", %spacket-context-fc-addr=%p, " + "%sevent-common-context-fc-addr=%p", + PRFIELD(stream_class->packet_context_fc), + PRFIELD(stream_class->event_common_context_fc)); + trace_class = bt_stream_class_borrow_trace_class_inline(stream_class); + if (!trace_class) { return; } - BUF_APPEND(", %strace-addr=%p", PRFIELD(trace)); - SET_TMP_PREFIX("trace-"); - trace_format_func(buf_ch, false, tmp_prefix, trace); -} - -static inline void format_stream_class(char **buf_ch, bool extended, - const char *prefix, struct bt_stream_class *stream_class) -{ - char tmp_prefix[64]; - - format_stream_class_common(buf_ch, extended, prefix, - BT_TO_COMMON(stream_class), (format_func) format_trace); - - if (!extended) { - return; - } - - SET_TMP_PREFIX("ehf-pool-"); - format_object_pool(buf_ch, extended, prefix, - &stream_class->event_header_field_pool); + BUF_APPEND(", %sassigns-auto-ec-id=%d, %sassigns-auto-stream-id=%d", + PRFIELD(stream_class->assigns_automatic_event_class_id), + PRFIELD(stream_class->assigns_automatic_stream_id)); + BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class)); + SET_TMP_PREFIX("trace-class-"); + format_trace_class(buf_ch, false, tmp_prefix, trace_class); SET_TMP_PREFIX("pcf-pool-"); - format_object_pool(buf_ch, extended, prefix, + format_object_pool(buf_ch, extended, tmp_prefix, &stream_class->packet_context_field_pool); } -static inline void format_writer_stream_class(char **buf_ch, bool extended, - const char *prefix, struct bt_ctf_stream_class *stream_class) -{ - format_stream_class_common(buf_ch, extended, prefix, - BT_TO_COMMON(stream_class), (format_func) format_writer_trace); - - if (extended && stream_class->clock) { - BUF_APPEND(", %sctf-writer-clock-addr=%p, " - "%sctf-writer-clock-name=\"%s\"", - PRFIELD(stream_class->clock), - PRFIELD(bt_clock_class_get_name( - BT_TO_COMMON(stream_class->clock->clock_class)))); - } -} - -static inline void format_event_class_common(char **buf_ch, bool extended, - const char *prefix, struct bt_event_class_common *event_class, - format_func format_stream_class_func, - format_func format_trace_func) +static inline void format_event_class(char **buf_ch, bool extended, + const char *prefix, const struct bt_event_class *event_class) { - struct bt_stream_class_common *stream_class; - struct bt_trace_common *trace; + const struct bt_stream_class *stream_class; + const struct bt_trace_class *trace_class; char tmp_prefix[64]; - BUF_APPEND(", %sid=%" PRId64, PRFIELD(event_class->id)); + BUF_APPEND(", %sid=%" PRIu64, PRFIELD(event_class->id)); - if (event_class->name) { - BUF_APPEND(", %sname=\"%s\"", PRFIELD(event_class->name->str)); + if (event_class->name.value) { + BUF_APPEND(", %sname=\"%s\"", + PRFIELD(event_class->name.value)); } if (!extended) { return; } - BUF_APPEND(", %sis-frozen=%d, %slog-level=%s", - PRFIELD(event_class->frozen), - PRFIELD(bt_common_event_class_log_level_string(event_class->log_level))); + BUF_APPEND(", %sis-frozen=%d", PRFIELD(event_class->frozen)); - if (event_class->emf_uri) { + if (event_class->log_level.base.avail) { + BUF_APPEND(", %slog-level=%s", + PRFIELD(bt_common_event_class_log_level_string( + (int) event_class->log_level.value))); + } + + if (event_class->emf_uri.value) { BUF_APPEND(", %semf-uri=\"%s\"", - PRFIELD(event_class->emf_uri->str)); + PRFIELD(event_class->emf_uri.value)); } - BUF_APPEND(", %scontext-ft-addr=%p, %spayload-ft-addr=%p", - PRFIELD(event_class->context_field_type), - PRFIELD(event_class->payload_field_type)); + BUF_APPEND(", %sspecific-context-fc-addr=%p, %spayload-fc-addr=%p", + PRFIELD(event_class->specific_context_fc), + PRFIELD(event_class->payload_fc)); - stream_class = bt_event_class_common_borrow_stream_class(event_class); + stream_class = bt_event_class_borrow_stream_class_const(event_class); if (!stream_class) { return; } BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class)); SET_TMP_PREFIX("stream-class-"); - format_stream_class_func(buf_ch, false, tmp_prefix, stream_class); - trace = bt_stream_class_common_borrow_trace(stream_class); - if (!trace) { - return; - } - - BUF_APPEND(", %strace-addr=%p", PRFIELD(trace)); - SET_TMP_PREFIX("trace-"); - format_trace_func(buf_ch, false, tmp_prefix, trace); -} - -static inline void format_event_class(char **buf_ch, bool extended, - const char *prefix, struct bt_event_class *event_class) -{ - char tmp_prefix[64]; - - format_event_class_common(buf_ch, extended, prefix, - BT_TO_COMMON(event_class), (format_func) format_stream_class, - (format_func) format_trace); - - if (!extended) { + format_stream_class(buf_ch, false, tmp_prefix, stream_class); + trace_class = bt_stream_class_borrow_trace_class_inline(stream_class); + if (!trace_class) { return; } + BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class)); + SET_TMP_PREFIX("trace-class-"); + format_trace_class(buf_ch, false, tmp_prefix, trace_class); SET_TMP_PREFIX("event-pool-"); - format_object_pool(buf_ch, extended, prefix, &event_class->event_pool); + format_object_pool(buf_ch, extended, tmp_prefix, + &event_class->event_pool); } -static inline void format_writer_event_class(char **buf_ch, bool extended, - const char *prefix, struct bt_ctf_event_class *event_class) -{ - format_event_class_common(buf_ch, extended, prefix, - BT_TO_COMMON(event_class), - (format_func) format_writer_stream_class, - (format_func) format_writer_trace); -} - -static inline void format_stream_common(char **buf_ch, bool extended, - const char *prefix, struct bt_stream_common *stream, - format_func format_stream_class_func, - format_func format_trace_func) +static inline void format_stream(char **buf_ch, bool extended, + const char *prefix, const struct bt_stream *stream) { - struct bt_stream_class_common *stream_class; - struct bt_trace_common *trace; + const struct bt_stream_class *stream_class; + const struct bt_trace_class *trace_class = NULL; + const struct bt_trace *trace = NULL; char tmp_prefix[64]; - BUF_APPEND(", %sid=%" PRId64, PRFIELD(stream->id)); + BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream->id)); - if (stream->name) { - BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream->name->str)); + if (stream->name.value) { + BUF_APPEND(", %sname=\"%s\"", PRFIELD(stream->name.value)); } if (!extended) { return; } - stream_class = bt_stream_common_borrow_class(stream); - if (!stream_class) { - return; + stream_class = bt_stream_borrow_class_const(stream); + if (stream_class) { + BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class)); + SET_TMP_PREFIX("stream-class-"); + format_stream_class(buf_ch, false, tmp_prefix, stream_class); + trace_class = bt_stream_class_borrow_trace_class_inline(stream_class); } - BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class)); - SET_TMP_PREFIX("stream-class-"); - format_stream_class_func(buf_ch, false, tmp_prefix, stream_class); - trace = bt_stream_class_common_borrow_trace(stream_class); - if (!trace) { - return; + if (trace_class) { + BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class)); + SET_TMP_PREFIX("trace-class-"); + format_trace_class(buf_ch, false, tmp_prefix, trace_class); } - trace = (void *) bt_object_borrow_parent(&stream->base); - if (!trace) { - return; + trace = bt_stream_borrow_trace_inline(stream); + if (trace) { + BUF_APPEND(", %strace-addr=%p", PRFIELD(trace)); + SET_TMP_PREFIX("trace-"); + format_trace(buf_ch, false, tmp_prefix, trace); } - BUF_APPEND(", %strace-addr=%p", PRFIELD(trace)); - SET_TMP_PREFIX("trace-"); - format_trace_common(buf_ch, false, tmp_prefix, trace); -} - -static inline void format_stream(char **buf_ch, bool extended, - const char *prefix, struct bt_stream *stream) -{ - char tmp_prefix[64]; - - format_stream_common(buf_ch, extended, prefix, BT_TO_COMMON(stream), - (format_func) format_stream_class, - (format_func) format_trace); SET_TMP_PREFIX("packet-pool-"); - format_object_pool(buf_ch, extended, prefix, &stream->packet_pool); -} - -static inline void format_writer_stream(char **buf_ch, bool extended, - const char *prefix, struct bt_ctf_stream *stream) -{ - format_stream_common(buf_ch, extended, prefix, BT_TO_COMMON(stream), - (format_func) format_writer_stream_class, - (format_func) format_writer_trace); - - BUF_APPEND(", %sheader-field-addr=%p, %scontext-field-addr=%p" - ", %sfd=%d, %smmap-offset=%zu, " - "%smmap-base-offset=%zu, %spacket-size=%" PRIu64 ", " - "%soffset=%" PRId64 ", %sevent-count=%u, " - "%sflushed-packet-count=%u, " - "%sdiscarded-event-count=%" PRIu64 ", " - "%ssize=%" PRIu64 ", %slast-ts-end=%" PRIu64, - PRFIELD(stream->packet_header), - PRFIELD(stream->packet_context), - PRFIELD(stream->pos.fd), - PRFIELD((size_t) stream->pos.mmap_offset), - PRFIELD((size_t) stream->pos.mmap_base_offset), - PRFIELD(stream->pos.packet_size), - PRFIELD(stream->pos.offset), - PRFIELD(stream->events->len), - PRFIELD(stream->flushed_packet_count), - PRFIELD(stream->discarded_events), - PRFIELD(stream->size), PRFIELD(stream->last_ts_end)); - - if (stream->events) { - BUF_APPEND(", %sevent-count=%u", PRFIELD(stream->events->len)); - } - - BUF_APPEND(", %sheader-field-addr=%p, %scontext-field-addr=%p" - ", %sfd=%d, %smmap-offset=%zu, " - "%smmap-base-offset=%zu, %spacket-size=%" PRIu64 ", " - "%soffset=%" PRId64 ", " - "%sflushed-packet-count=%u, " - "%sdiscarded-event-count=%" PRIu64 ", " - "%ssize=%" PRIu64 ", %slast-ts-end=%" PRIu64, - PRFIELD(stream->packet_header), - PRFIELD(stream->packet_context), - PRFIELD(stream->pos.fd), - PRFIELD((size_t) stream->pos.mmap_offset), - PRFIELD((size_t) stream->pos.mmap_base_offset), - PRFIELD(stream->pos.packet_size), - PRFIELD(stream->pos.offset), - PRFIELD(stream->flushed_packet_count), - PRFIELD(stream->discarded_events), - PRFIELD(stream->size), PRFIELD(stream->last_ts_end)); + format_object_pool(buf_ch, extended, tmp_prefix, &stream->packet_pool); } static inline void format_packet(char **buf_ch, bool extended, - const char *prefix, struct bt_packet *packet) + const char *prefix, const struct bt_packet *packet) { - struct bt_stream *stream; - struct bt_trace *trace; + const struct bt_stream *stream; + const struct bt_trace_class *trace_class; char tmp_prefix[64]; if (!extended) { return; } - BUF_APPEND(", %sis-frozen=%d, %sheader-field-addr=%p, " - "%scontext-field-addr=%p", + BUF_APPEND(", %sis-frozen=%d, %scontext-field-addr=%p", PRFIELD(packet->frozen), - PRFIELD(packet->header ? packet->header->field : NULL), - PRFIELD(packet->context)); - stream = bt_packet_borrow_stream(packet); + PRFIELD(packet->context_field ? packet->context_field->field : NULL)); + stream = bt_packet_borrow_stream_const(packet); if (!stream) { return; } @@ -826,37 +664,36 @@ static inline void format_packet(char **buf_ch, bool extended, BUF_APPEND(", %sstream-addr=%p", PRFIELD(stream)); SET_TMP_PREFIX("stream-"); format_stream(buf_ch, false, tmp_prefix, stream); - trace = (struct bt_trace *) bt_object_borrow_parent(&stream->common.base); - if (!trace) { + trace_class = (const struct bt_trace_class *) bt_object_borrow_parent(&stream->base); + if (!trace_class) { return; } - BUF_APPEND(", %strace-addr=%p", PRFIELD(trace)); - SET_TMP_PREFIX("trace-"); - format_trace(buf_ch, false, tmp_prefix, trace); + BUF_APPEND(", %strace-class-addr=%p", PRFIELD(trace_class)); + SET_TMP_PREFIX("trace-class-"); + format_trace_class(buf_ch, false, tmp_prefix, trace_class); } -static inline void format_event_common(char **buf_ch, bool extended, - const char *prefix, struct bt_event_common *event, - format_func format_event_class_func, - format_func format_stream_class_func, - format_func format_trace_func) +static inline void format_event(char **buf_ch, bool extended, + const char *prefix, const struct bt_event *event) { - struct bt_trace_common *trace; - struct bt_stream_class_common *stream_class; + const struct bt_packet *packet; + const struct bt_stream *stream; + const struct bt_trace_class *trace_class; + const struct bt_stream_class *stream_class; char tmp_prefix[64]; if (!extended) { return; } - BUF_APPEND(", %sis-frozen=%d, %sheader-field-addr=%p, " - "%sstream-context-field-addr=%p, " - "%scontext-field-addr=%p, %spayload-field-addr=%p, ", + BUF_APPEND(", %sis-frozen=%d, " + "%scommon-context-field-addr=%p, " + "%sspecific-context-field-addr=%p, " + "%spayload-field-addr=%p, ", PRFIELD(event->frozen), - PRFIELD(event->header_field ? event->header_field->field : NULL), - PRFIELD(event->stream_event_context_field), - PRFIELD(event->context_field), + PRFIELD(event->common_context_field), + PRFIELD(event->specific_context_field), PRFIELD(event->payload_field)); BUF_APPEND(", %sevent-class-addr=%p", PRFIELD(event->class)); @@ -865,41 +702,26 @@ static inline void format_event_common(char **buf_ch, bool extended, } SET_TMP_PREFIX("event-class-"); - format_event_class_func(buf_ch, false, tmp_prefix, event->class); - stream_class = bt_event_class_common_borrow_stream_class(event->class); + format_event_class(buf_ch, false, tmp_prefix, event->class); + stream_class = bt_event_class_borrow_stream_class(event->class); if (stream_class) { BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class)); SET_TMP_PREFIX("stream-class-"); - format_stream_class_func(buf_ch, false, tmp_prefix, + format_stream_class(buf_ch, false, tmp_prefix, stream_class); - trace = bt_stream_class_common_borrow_trace(stream_class); - if (trace) { - BUF_APPEND(", %strace-addr=%p", PRFIELD(trace)); - SET_TMP_PREFIX("trace-"); - format_trace_func(buf_ch, false, tmp_prefix, trace); + trace_class = bt_stream_class_borrow_trace_class_inline( + stream_class); + if (trace_class) { + BUF_APPEND(", %strace-class-addr=%p", + PRFIELD(trace_class)); + SET_TMP_PREFIX("trace-class-"); + format_trace_class(buf_ch, false, tmp_prefix, + trace_class); } } -} - -static inline void format_event(char **buf_ch, bool extended, - const char *prefix, struct bt_event *event) -{ - struct bt_packet *packet; - struct bt_stream *stream; - char tmp_prefix[64]; - - format_event_common(buf_ch, extended, prefix, BT_TO_COMMON(event), - (format_func) format_event_class, - (format_func) format_stream_class, (format_func) format_trace); - - if (!extended) { - return; - } - SET_TMP_PREFIX("cvs-"); - format_clock_value_set(buf_ch, extended, tmp_prefix, &event->cv_set); - packet = bt_event_borrow_packet(event); + packet = bt_event_borrow_packet_const(event); if (!packet) { return; } @@ -907,7 +729,7 @@ static inline void format_event(char **buf_ch, bool extended, BUF_APPEND(", %spacket-addr=%p", PRFIELD(packet)); SET_TMP_PREFIX("packet-"); format_packet(buf_ch, false, tmp_prefix, packet); - stream = bt_packet_borrow_stream(packet); + stream = bt_packet_borrow_stream_const(packet); if (!stream) { return; } @@ -917,73 +739,73 @@ static inline void format_event(char **buf_ch, bool extended, format_stream(buf_ch, false, tmp_prefix, stream); } -static inline void format_writer_event(char **buf_ch, bool extended, - const char *prefix, struct bt_event *event) -{ - format_event_common(buf_ch, extended, prefix, BT_TO_COMMON(event), - (format_func) format_writer_event_class, - (format_func) format_writer_stream_class, - (format_func) format_writer_trace); -} - static inline void format_clock_class(char **buf_ch, bool extended, - const char *prefix, struct bt_clock_class *clock_class) + const char *prefix, const struct bt_clock_class *clock_class) { char tmp_prefix[64]; - BUF_APPEND(", %sname=\"%s\", %sfreq=%" PRIu64, - PRFIELD(clock_class->name->str), - PRFIELD(clock_class->frequency)); + if (clock_class->name.value) { + BUF_APPEND(", %sname=\"%s\"", PRFIELD(clock_class->name.value)); + } + + BUF_APPEND(", %sfreq=%" PRIu64, PRFIELD(clock_class->frequency)); if (!extended) { return; } - if (clock_class->description) { - BUF_APPEND(", %spartial-description=\"%.32s\"", - PRFIELD(clock_class->description->str)); + if (clock_class->description.value) { + BUF_APPEND(", %spartial-descr=\"%.32s\"", + PRFIELD(clock_class->description.value)); + } + + if (clock_class->uuid.value) { + BUF_APPEND_UUID(clock_class->uuid.value); } BUF_APPEND(", %sis-frozen=%d, %sprecision=%" PRIu64 ", " "%soffset-s=%" PRId64 ", " - "%soffset-cycles=%" PRId64 ", %sis-absolute=%d", + "%soffset-cycles=%" PRIu64 ", %sorigin-is-unix-epoch=%d, " + "%sbase-offset-ns=%" PRId64, PRFIELD(clock_class->frozen), PRFIELD(clock_class->precision), - PRFIELD(clock_class->offset_s), PRFIELD(clock_class->offset), - PRFIELD(clock_class->absolute)); - - if (clock_class->uuid_set) { - BUF_APPEND_UUID(clock_class->uuid); - } - - SET_TMP_PREFIX("cv-pool-"); - format_object_pool(buf_ch, extended, prefix, &clock_class->cv_pool); + PRFIELD(clock_class->offset_seconds), + PRFIELD(clock_class->offset_cycles), + PRFIELD(clock_class->origin_is_unix_epoch), + PRFIELD(clock_class->base_offset.value_ns)); + + SET_TMP_PREFIX("cs-pool-"); + format_object_pool(buf_ch, extended, tmp_prefix, + &clock_class->cs_pool); } -static inline void format_clock_value(char **buf_ch, bool extended, - const char *prefix, struct bt_clock_value *clock_value) +static inline void format_clock_snapshot(char **buf_ch, bool extended, + const char *prefix, const struct bt_clock_snapshot *clock_snapshot) { char tmp_prefix[64]; - BUF_APPEND(", %sraw-value=%" PRIu64 ", %sns-from-epoch=%" PRId64, - PRFIELD(clock_value->value), - PRFIELD(clock_value->ns_from_epoch)); + BUF_APPEND(", %svalue=%" PRIu64 ", %sns-from-origin=%" PRId64, + PRFIELD(clock_snapshot->value_cycles), + PRFIELD(clock_snapshot->ns_from_origin)); if (!extended) { return; } - BUF_APPEND(", %sis-frozen=%d, %sis-set=%d", - PRFIELD(clock_value->frozen), PRFIELD(clock_value->is_set)); - BUF_APPEND(", %sclock-class-addr=%p", - PRFIELD(clock_value->clock_class)); - SET_TMP_PREFIX("clock-class-"); - format_clock_class(buf_ch, false, tmp_prefix, clock_value->clock_class); + BUF_APPEND(", %sis-set=%d", PRFIELD(clock_snapshot->is_set)); + + if (clock_snapshot->clock_class) { + BUF_APPEND(", %sclock-class-addr=%p", + PRFIELD(clock_snapshot->clock_class)); + SET_TMP_PREFIX("clock-class-"); + format_clock_class(buf_ch, false, tmp_prefix, + clock_snapshot->clock_class); + } } static inline void format_value(char **buf_ch, bool extended, - const char *prefix, struct bt_value *value) + const char *prefix, const struct bt_value *value) { BUF_APPEND(", %stype=%s", - PRFIELD(bt_value_type_string(bt_value_get_type(value)))); + PRFIELD(bt_common_value_type_string(bt_value_get_type(value)))); if (!extended) { return; @@ -992,39 +814,40 @@ static inline void format_value(char **buf_ch, bool extended, switch (bt_value_get_type(value)) { case BT_VALUE_TYPE_BOOL: { - bt_bool val; + bt_bool val = bt_value_bool_get(value); - (void) bt_value_bool_get(value, &val); BUF_APPEND(", %svalue=%d", PRFIELD(val)); break; } - case BT_VALUE_TYPE_INTEGER: + case BT_VALUE_TYPE_UNSIGNED_INTEGER: { - int64_t val; - - (void) bt_value_integer_get(value, &val); - BUF_APPEND(", %svalue=%" PRId64, PRFIELD(val)); + BUF_APPEND(", %svalue=%" PRIu64, + PRFIELD(bt_value_unsigned_integer_get(value))); break; } - case BT_VALUE_TYPE_FLOAT: + case BT_VALUE_TYPE_SIGNED_INTEGER: { - double val; + BUF_APPEND(", %svalue=%" PRId64, + PRFIELD(bt_value_signed_integer_get(value))); + break; + } + case BT_VALUE_TYPE_REAL: + { + double val = bt_value_real_get(value); - (void) bt_value_float_get(value, &val); BUF_APPEND(", %svalue=%f", PRFIELD(val)); break; } case BT_VALUE_TYPE_STRING: { - const char *val; + const char *val = bt_value_string_get(value); - (void) bt_value_string_get(value, &val); BUF_APPEND(", %spartial-value=\"%.32s\"", PRFIELD(val)); break; } case BT_VALUE_TYPE_ARRAY: { - int64_t count = bt_value_array_size(value); + int64_t count = bt_value_array_get_size(value); BT_ASSERT(count >= 0); BUF_APPEND(", %selement-count=%" PRId64, PRFIELD(count)); @@ -1032,7 +855,7 @@ static inline void format_value(char **buf_ch, bool extended, } case BT_VALUE_TYPE_MAP: { - int64_t count = bt_value_map_size(value); + int64_t count = bt_value_map_get_size(value); BT_ASSERT(count >= 0); BUF_APPEND(", %selement-count=%" PRId64, PRFIELD(count)); @@ -1043,64 +866,126 @@ static inline void format_value(char **buf_ch, bool extended, } } -static inline void format_notification(char **buf_ch, bool extended, - const char *prefix, struct bt_notification *notif) +static inline void format_message(char **buf_ch, bool extended, + const char *prefix, const struct bt_message *msg) { char tmp_prefix[64]; BUF_APPEND(", %stype=%s", - PRFIELD(bt_notification_type_string(notif->type))); + PRFIELD(bt_message_type_string(msg->type))); if (!extended) { return; } BUF_APPEND(", %sis-frozen=%d, %sgraph-addr=%p", - PRFIELD(notif->frozen), PRFIELD(notif->graph)); + PRFIELD(msg->frozen), PRFIELD(msg->graph)); - switch (notif->type) { - case BT_NOTIFICATION_TYPE_EVENT: + switch (msg->type) { + case BT_MESSAGE_TYPE_EVENT: { - struct bt_notification_event *notif_event = (void *) notif; + const struct bt_message_event *msg_event = + (const void *) msg; + + if (msg_event->event) { + SET_TMP_PREFIX("event-"); + format_event(buf_ch, true, tmp_prefix, + msg_event->event); + } + + if (msg_event->default_cs) { + SET_TMP_PREFIX("default-cs-"); + format_clock_snapshot(buf_ch, true, tmp_prefix, + msg_event->default_cs); + } - SET_TMP_PREFIX("event-"); - format_event(buf_ch, true, tmp_prefix, notif_event->event); break; } - case BT_NOTIFICATION_TYPE_STREAM_BEGIN: + case BT_MESSAGE_TYPE_STREAM_BEGINNING: + case BT_MESSAGE_TYPE_STREAM_END: { - struct bt_notification_stream_begin *notif_stream = - (void *) notif; + const struct bt_message_stream *msg_stream = (const void *) msg; + + if (msg_stream->stream) { + SET_TMP_PREFIX("stream-"); + format_stream(buf_ch, true, tmp_prefix, + msg_stream->stream); + } - SET_TMP_PREFIX("stream-"); - format_stream(buf_ch, true, tmp_prefix, notif_stream->stream); break; } - case BT_NOTIFICATION_TYPE_STREAM_END: + case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING: + case BT_MESSAGE_TYPE_STREAM_ACTIVITY_END: { - struct bt_notification_stream_end *notif_stream = - (void *) notif; + const struct bt_message_stream_activity *msg_stream_activity = + (const void *) msg; + + if (msg_stream_activity->stream) { + SET_TMP_PREFIX("stream-"); + format_stream(buf_ch, true, tmp_prefix, + msg_stream_activity->stream); + } + + BUF_APPEND(", %sdefault-cs-state=%s", + PRFIELD(bt_message_stream_activity_clock_snapshot_state_string( + msg_stream_activity->default_cs_state))); + + if (msg_stream_activity->default_cs) { + SET_TMP_PREFIX("default-cs-"); + format_clock_snapshot(buf_ch, true, tmp_prefix, + msg_stream_activity->default_cs); + } - SET_TMP_PREFIX("stream-"); - format_stream(buf_ch, true, tmp_prefix, notif_stream->stream); break; } - case BT_NOTIFICATION_TYPE_PACKET_BEGIN: + case BT_MESSAGE_TYPE_PACKET_BEGINNING: + case BT_MESSAGE_TYPE_PACKET_END: { - struct bt_notification_packet_begin *notif_packet = - (void *) notif; + const struct bt_message_packet *msg_packet = (const void *) msg; + + if (msg_packet->packet) { + SET_TMP_PREFIX("packet-"); + format_packet(buf_ch, true, tmp_prefix, + msg_packet->packet); + } + + if (msg_packet->default_cs) { + SET_TMP_PREFIX("default-cs-"); + format_clock_snapshot(buf_ch, true, tmp_prefix, + msg_packet->default_cs); + } - SET_TMP_PREFIX("packet-"); - format_packet(buf_ch, true, tmp_prefix, notif_packet->packet); break; } - case BT_NOTIFICATION_TYPE_PACKET_END: + case BT_MESSAGE_TYPE_DISCARDED_EVENTS: + case BT_MESSAGE_TYPE_DISCARDED_PACKETS: { - struct bt_notification_packet_end *notif_packet = - (void *) notif; + const struct bt_message_discarded_items *msg_disc_items = + (const void *) msg; + + if (msg_disc_items->stream) { + SET_TMP_PREFIX("stream-"); + format_stream(buf_ch, true, tmp_prefix, + msg_disc_items->stream); + } + + if (msg_disc_items->default_begin_cs) { + SET_TMP_PREFIX("default-begin-cs-"); + format_clock_snapshot(buf_ch, true, tmp_prefix, + msg_disc_items->default_begin_cs); + } + + if (msg_disc_items->default_end_cs) { + SET_TMP_PREFIX("default-end-cs-"); + format_clock_snapshot(buf_ch, true, tmp_prefix, + msg_disc_items->default_end_cs); + } + + if (msg_disc_items->count.base.avail) { + BUF_APPEND(", %scount=%" PRIu64, + PRFIELD(msg_disc_items->count.value)); + } - SET_TMP_PREFIX("packet-"); - format_packet(buf_ch, true, tmp_prefix, notif_packet->packet); break; } default: @@ -1110,27 +995,28 @@ static inline void format_notification(char **buf_ch, bool extended, static inline void format_plugin_so_shared_lib_handle(char **buf_ch, const char *prefix, - struct bt_plugin_so_shared_lib_handle *handle) + const struct bt_plugin_so_shared_lib_handle *handle) { BUF_APPEND(", %saddr=%p", PRFIELD(handle)); if (handle->path) { - BUF_APPEND(", %spath=\"%s\"", PRFIELD(handle->path->str)); + BUF_APPEND(", %spath=\"%s\"", PRFIELD_GSTRING(handle->path)); } } static inline void format_component_class(char **buf_ch, bool extended, - const char *prefix, struct bt_component_class *comp_class) + const char *prefix, + const struct bt_component_class *comp_class) { char tmp_prefix[64]; BUF_APPEND(", %stype=%s, %sname=\"%s\"", PRFIELD(bt_component_class_type_string(comp_class->type)), - PRFIELD(comp_class->name ? comp_class->name->str : NULL)); + PRFIELD_GSTRING(comp_class->name)); if (comp_class->description) { BUF_APPEND(", %spartial-descr=\"%.32s\"", - PRFIELD(comp_class->description->str)); + PRFIELD_GSTRING(comp_class->description)); } if (!extended) { @@ -1147,13 +1033,18 @@ static inline void format_component_class(char **buf_ch, bool extended, } static inline void format_component(char **buf_ch, bool extended, - const char *prefix, struct bt_component *component) + const char *prefix, const struct bt_component *component) { char tmp_prefix[64]; - BUF_APPEND(", %sname=\"%s\"", PRFIELD(component->name->str)); - SET_TMP_PREFIX("class-"); - format_component_class(buf_ch, extended, tmp_prefix, component->class); + BUF_APPEND(", %sname=\"%s\"", + PRFIELD_GSTRING(component->name)); + + if (component->class) { + SET_TMP_PREFIX("class-"); + format_component_class(buf_ch, extended, tmp_prefix, + component->class); + } if (!extended) { return; @@ -1171,13 +1062,13 @@ static inline void format_component(char **buf_ch, bool extended, } static inline void format_port(char **buf_ch, bool extended, - const char *prefix, struct bt_port *port) + const char *prefix, const struct bt_port *port) { char tmp_prefix[64]; BUF_APPEND(", %stype=%s, %sname=\"%s\"", PRFIELD(bt_port_type_string(port->type)), - PRFIELD(port->name->str)); + PRFIELD_GSTRING(port->name)); if (!extended) { return; @@ -1190,7 +1081,7 @@ static inline void format_port(char **buf_ch, bool extended, } static inline void format_connection(char **buf_ch, bool extended, - const char *prefix, struct bt_connection *connection) + const char *prefix, const struct bt_connection *connection) { char tmp_prefix[64]; @@ -1212,11 +1103,15 @@ static inline void format_connection(char **buf_ch, bool extended, } static inline void format_graph(char **buf_ch, bool extended, - const char *prefix, struct bt_graph *graph) + const char *prefix, const struct bt_graph *graph) { char tmp_prefix[64]; - BUF_APPEND(", %sis-canceled=%d", PRFIELD(graph->canceled)); + BUF_APPEND(", %sis-canceled=%d, %scan-consume=%d, " + "%sconfig-state=%s", + PRFIELD(graph->canceled), + PRFIELD(graph->can_consume), + PRFIELD(bt_graph_configuration_state_string(graph->config_state))); if (!extended) { return; @@ -1233,27 +1128,27 @@ static inline void format_graph(char **buf_ch, bool extended, } SET_TMP_PREFIX("en-pool-"); - format_object_pool(buf_ch, extended, prefix, - &graph->event_notif_pool); + format_object_pool(buf_ch, extended, tmp_prefix, + &graph->event_msg_pool); SET_TMP_PREFIX("pbn-pool-"); - format_object_pool(buf_ch, extended, prefix, - &graph->packet_begin_notif_pool); + format_object_pool(buf_ch, extended, tmp_prefix, + &graph->packet_begin_msg_pool); SET_TMP_PREFIX("pen-pool-"); - format_object_pool(buf_ch, extended, prefix, - &graph->packet_end_notif_pool); + format_object_pool(buf_ch, extended, tmp_prefix, + &graph->packet_end_msg_pool); } -static inline void format_notification_iterator(char **buf_ch, +static inline void format_message_iterator(char **buf_ch, bool extended, const char *prefix, - struct bt_notification_iterator *iterator) + const struct bt_message_iterator *iterator) { const char *type; char tmp_prefix[64]; - if (iterator->type == BT_NOTIFICATION_ITERATOR_TYPE_PRIVATE_CONNECTION) { - type = "BT_NOTIFICATION_ITERATOR_TYPE_PRIVATE_CONNECTION"; - } else if (iterator->type == BT_NOTIFICATION_ITERATOR_TYPE_OUTPUT_PORT) { - type = "BT_NOTIFICATION_ITERATOR_TYPE_OUTPUT_PORT"; + if (iterator->type == BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT) { + type = "BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT"; + } else if (iterator->type == BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT) { + type = "BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT"; } else { type = "(unknown)"; } @@ -1261,41 +1156,47 @@ static inline void format_notification_iterator(char **buf_ch, BUF_APPEND(", %stype=%s", PRFIELD(type)); switch (iterator->type) { - case BT_NOTIFICATION_ITERATOR_TYPE_PRIVATE_CONNECTION: + case BT_MESSAGE_ITERATOR_TYPE_SELF_COMPONENT_PORT_INPUT: { - struct bt_notification_iterator_private_connection * - iter_priv_conn = (void *) iterator; + const struct bt_self_component_port_input_message_iterator * + port_in_iter = (const void *) iterator; - if (iter_priv_conn->upstream_component) { + if (port_in_iter->upstream_component) { SET_TMP_PREFIX("upstream-comp-"); format_component(buf_ch, false, tmp_prefix, - iter_priv_conn->upstream_component); + port_in_iter->upstream_component); } - if (iter_priv_conn->upstream_port) { + if (port_in_iter->upstream_port) { SET_TMP_PREFIX("upstream-port-"); format_port(buf_ch, false, tmp_prefix, - iter_priv_conn->upstream_port); + port_in_iter->upstream_port); } - if (iter_priv_conn->connection) { + if (port_in_iter->connection) { SET_TMP_PREFIX("upstream-conn-"); format_connection(buf_ch, false, tmp_prefix, - iter_priv_conn->connection); + port_in_iter->connection); } break; } - case BT_NOTIFICATION_ITERATOR_TYPE_OUTPUT_PORT: + case BT_MESSAGE_ITERATOR_TYPE_PORT_OUTPUT: { - struct bt_notification_iterator_output_port *iter_output_port = - (void *) iterator; - - SET_TMP_PREFIX("graph-"); - format_graph(buf_ch, false, tmp_prefix, - iter_output_port->graph); - SET_TMP_PREFIX("colander-comp-"); - format_component(buf_ch, false, tmp_prefix, - iter_output_port->colander); + const struct bt_port_output_message_iterator *port_out_iter = + (const void *) iterator; + + if (port_out_iter->graph) { + SET_TMP_PREFIX("graph-"); + format_graph(buf_ch, false, tmp_prefix, + port_out_iter->graph); + } + + if (port_out_iter->colander) { + SET_TMP_PREFIX("colander-comp-"); + format_component(buf_ch, false, tmp_prefix, + (void *) port_out_iter->colander); + } + break; } default: @@ -1304,7 +1205,7 @@ static inline void format_notification_iterator(char **buf_ch, } static inline void format_plugin(char **buf_ch, bool extended, - const char *prefix, struct bt_plugin *plugin) + const char *prefix, const struct bt_plugin *plugin) { char tmp_prefix[64]; @@ -1312,12 +1213,12 @@ static inline void format_plugin(char **buf_ch, bool extended, if (plugin->info.path_set) { BUF_APPEND(", %spath=\"%s\"", - PRFIELD(plugin->info.path->str)); + PRFIELD_GSTRING(plugin->info.path)); } if (plugin->info.name_set) { BUF_APPEND(", %sname=\"%s\"", - PRFIELD(plugin->info.name->str)); + PRFIELD_GSTRING(plugin->info.name)); } if (!extended) { @@ -1326,12 +1227,12 @@ static inline void format_plugin(char **buf_ch, bool extended, if (plugin->info.author_set) { BUF_APPEND(", %sauthor=\"%s\"", - PRFIELD(plugin->info.author->str)); + PRFIELD_GSTRING(plugin->info.author)); } if (plugin->info.license_set) { BUF_APPEND(", %slicense=\"%s\"", - PRFIELD(plugin->info.license->str)); + PRFIELD_GSTRING(plugin->info.license)); } if (plugin->info.version_set) { @@ -1343,13 +1244,15 @@ static inline void format_plugin(char **buf_ch, bool extended, plugin->info.version.extra->str : ""); } - BUF_APPEND(", %sis-frozen=%d, %scomp-class-count=%u", - PRFIELD(plugin->frozen), - PRFIELD(plugin->comp_classes->len)); + BUF_APPEND(", %ssrc-comp-class-count=%u, %sflt-comp-class-count=%u, " + "%ssink-comp-class-count=%u", + PRFIELD(plugin->src_comp_classes->len), + PRFIELD(plugin->flt_comp_classes->len), + PRFIELD(plugin->sink_comp_classes->len)); if (plugin->spec_data) { - struct bt_plugin_so_spec_data *spec_data = - (void *) plugin->spec_data; + const struct bt_plugin_so_spec_data *spec_data = + (const void *) plugin->spec_data; if (spec_data->shared_lib_handle) { SET_TMP_PREFIX("so-handle-"); @@ -1359,47 +1262,6 @@ static inline void format_plugin(char **buf_ch, bool extended, } } -static inline void format_ctf_writer(char **buf_ch, bool extended, - const char *prefix, struct bt_ctf_writer *writer) -{ - /* TODO */ -} - -static inline void format_stream_class_common_common(char **buf_ch, - bool extended, const char *prefix, - struct bt_stream_class_common *stream_class) -{ - format_stream_class_common(buf_ch, extended, prefix, stream_class, - (format_func) format_trace_common); -} - -static inline void format_event_class_common_common(char **buf_ch, - bool extended, const char *prefix, - struct bt_event_class_common *event_class) -{ - format_event_class_common(buf_ch, extended, prefix, event_class, - (format_func) format_stream_class_common, - (format_func) format_trace_common); -} - -static inline void format_event_common_common(char **buf_ch, - bool extended, const char *prefix, - struct bt_event_common *event) -{ - format_event_common(buf_ch, extended, prefix, event, - (format_func) format_event_class_common, - (format_func) format_stream_class_common, - (format_func) format_trace_common); -} - -static inline void format_stream_common_common(char **buf_ch, bool extended, - const char *prefix, struct bt_stream_common *stream) -{ - format_stream_common(buf_ch, extended, prefix, stream, - (format_func) format_stream_class_common, - (format_func) format_trace_common); -} - static inline void handle_conversion_specifier_bt(void *priv_data, char **buf_ch, size_t avail_size, const char **out_fmt_ch, va_list *args) @@ -1408,16 +1270,18 @@ static inline void handle_conversion_specifier_bt(void *priv_data, bool extended = false; char prefix[64]; char *prefix_ch = prefix; - void *obj; - enum { - CAT_DEFAULT, - CAT_WRITER, - CAT_COMMON, - } cat = CAT_DEFAULT; + const void *obj; /* skip "%!" */ fmt_ch += 2; + if (*fmt_ch == 'u') { + /* UUID */ + obj = va_arg(*args, void *); + format_uuid(buf_ch, obj); + goto update_fmt; + } + if (*fmt_ch == '[') { /* local prefix */ fmt_ch++; @@ -1442,14 +1306,6 @@ static inline void handle_conversion_specifier_bt(void *priv_data, fmt_ch++; } - if (*fmt_ch == 'w') { - cat = CAT_WRITER; - fmt_ch++; - } else if (*fmt_ch == '_') { - cat = CAT_COMMON; - fmt_ch++; - } - obj = va_arg(*args, void *); BUF_APPEND("%saddr=%p", prefix, obj); @@ -1457,136 +1313,78 @@ static inline void handle_conversion_specifier_bt(void *priv_data, goto update_fmt; } - switch (cat) { - case CAT_DEFAULT: - switch (*fmt_ch) { - case 'F': - format_field_type(buf_ch, extended, prefix, obj); - break; - case 'f': - format_field(buf_ch, extended, prefix, obj); - break; - case 'P': - format_field_path(buf_ch, extended, prefix, obj); - break; - case 'E': - format_event_class(buf_ch, extended, prefix, obj); - break; - case 'e': - format_event(buf_ch, extended, prefix, obj); - break; - case 'S': - format_stream_class(buf_ch, extended, prefix, obj); - break; - case 's': - format_stream(buf_ch, extended, prefix, obj); - break; - case 'a': - format_packet(buf_ch, extended, prefix, obj); - break; - case 't': - format_trace(buf_ch, extended, prefix, obj); - break; - case 'K': - format_clock_class(buf_ch, extended, prefix, obj); - break; - case 'k': - format_clock_value(buf_ch, extended, prefix, obj); - break; - case 'v': - format_value(buf_ch, extended, prefix, obj); - break; - case 'n': - format_notification(buf_ch, extended, prefix, obj); - break; - case 'i': - format_notification_iterator(buf_ch, extended, prefix, obj); - break; - case 'C': - format_component_class(buf_ch, extended, prefix, obj); - break; - case 'c': - format_component(buf_ch, extended, prefix, obj); - break; - case 'p': - format_port(buf_ch, extended, prefix, obj); - break; - case 'x': - format_connection(buf_ch, extended, prefix, obj); - break; - case 'u': - format_plugin(buf_ch, extended, prefix, obj); - break; - case 'g': - format_graph(buf_ch, extended, prefix, obj); - break; - case 'o': - format_object_pool(buf_ch, extended, prefix, obj); - break; - case 'O': - format_object(buf_ch, extended, prefix, obj); - break; - default: - abort(); - } + switch (*fmt_ch) { + case 'F': + format_field_class(buf_ch, extended, prefix, obj); break; - case CAT_WRITER: - switch (*fmt_ch) { - case 'F': - format_writer_field_type(buf_ch, extended, prefix, obj); - break; - case 'f': - format_writer_field(buf_ch, extended, prefix, obj); - break; - case 'E': - format_writer_event_class(buf_ch, extended, prefix, obj); - break; - case 'e': - format_writer_event(buf_ch, extended, prefix, obj); - break; - case 'S': - format_writer_stream_class(buf_ch, extended, prefix, obj); - break; - case 's': - format_writer_stream(buf_ch, extended, prefix, obj); - break; - case 't': - format_writer_trace(buf_ch, extended, prefix, obj); - break; - case 'w': - format_ctf_writer(buf_ch, extended, prefix, obj); - break; - default: - abort(); - } + case 'f': + format_field(buf_ch, extended, prefix, obj); break; - case CAT_COMMON: - switch (*fmt_ch) { - case 'F': - format_field_type_common(buf_ch, extended, prefix, obj); - break; - case 'f': - format_field_common(buf_ch, extended, prefix, obj); - break; - case 'E': - format_event_class_common_common(buf_ch, extended, prefix, obj); - break; - case 'e': - format_event_common_common(buf_ch, extended, prefix, obj); - break; - case 'S': - format_stream_class_common_common(buf_ch, extended, prefix, obj); - break; - case 's': - format_stream_common_common(buf_ch, extended, prefix, obj); - break; - case 't': - format_trace_common(buf_ch, extended, prefix, obj); - break; - default: - abort(); - } + case 'P': + format_field_path(buf_ch, extended, prefix, obj); + break; + case 'E': + format_event_class(buf_ch, extended, prefix, obj); break; + case 'e': + format_event(buf_ch, extended, prefix, obj); + break; + case 'S': + format_stream_class(buf_ch, extended, prefix, obj); + break; + case 's': + format_stream(buf_ch, extended, prefix, obj); + break; + case 'a': + format_packet(buf_ch, extended, prefix, obj); + break; + case 't': + format_trace(buf_ch, extended, prefix, obj); + break; + case 'T': + format_trace_class(buf_ch, extended, prefix, obj); + break; + case 'K': + format_clock_class(buf_ch, extended, prefix, obj); + break; + case 'k': + format_clock_snapshot(buf_ch, extended, prefix, obj); + break; + case 'v': + format_value(buf_ch, extended, prefix, obj); + break; + case 'n': + format_message(buf_ch, extended, prefix, obj); + break; + case 'i': + format_message_iterator(buf_ch, extended, prefix, obj); + break; + case 'C': + format_component_class(buf_ch, extended, prefix, obj); + break; + case 'c': + format_component(buf_ch, extended, prefix, obj); + break; + case 'p': + format_port(buf_ch, extended, prefix, obj); + break; + case 'x': + format_connection(buf_ch, extended, prefix, obj); + break; + case 'l': + format_plugin(buf_ch, extended, prefix, obj); + break; + case 'g': + format_graph(buf_ch, extended, prefix, obj); + break; + case 'o': + format_object_pool(buf_ch, extended, prefix, obj); + break; + case 'O': + format_object(buf_ch, extended, prefix, obj); + break; + default: + abort(); } update_fmt: @@ -1594,7 +1392,6 @@ update_fmt: *out_fmt_ch = fmt_ch; } -BT_HIDDEN void bt_lib_log(const char *func, const char *file, unsigned line, int lvl, const char *tag, const char *fmt, ...) {