Make API CTF-agnostic
[babeltrace.git] / lib / lib-logging.c
index 65d3313892dcfd4bbf7dffbe69f2c1ff1a4a39a3..d09b176d41dde24d38995f96a75c6e45f8adc73c 100644 (file)
@@ -20,6 +20,8 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_TAG "LIB-LOGGING"
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -30,9 +32,8 @@
 #include <glib.h>
 #include <babeltrace/common-internal.h>
 #include <babeltrace/lib-logging-internal.h>
-#include <babeltrace/object-internal.h>
-#include <babeltrace/ref-internal.h>
 #include <babeltrace/values-internal.h>
+#include <babeltrace/object-pool-internal.h>
 #include <babeltrace/ctf-ir/field-types-internal.h>
 #include <babeltrace/ctf-ir/fields-internal.h>
 #include <babeltrace/ctf-ir/event-class-internal.h>
@@ -44,7 +45,7 @@
 #include <babeltrace/ctf-ir/clock-class-internal.h>
 #include <babeltrace/ctf-ir/clock-value-internal.h>
 #include <babeltrace/ctf-ir/field-path-internal.h>
-#include <babeltrace/graph/clock-class-priority-map-internal.h>
+#include <babeltrace/ctf-ir/utils-internal.h>
 #include <babeltrace/graph/component-class-internal.h>
 #include <babeltrace/graph/component-class-sink-colander-internal.h>
 #include <babeltrace/graph/component-filter-internal.h>
@@ -53,9 +54,7 @@
 #include <babeltrace/graph/component-source-internal.h>
 #include <babeltrace/graph/connection-internal.h>
 #include <babeltrace/graph/graph-internal.h>
-#include <babeltrace/graph/notification-discarded-elements-internal.h>
 #include <babeltrace/graph/notification-event-internal.h>
-#include <babeltrace/graph/notification-heap-internal.h>
 #include <babeltrace/graph/notification-inactivity-internal.h>
 #include <babeltrace/graph/notification-internal.h>
 #include <babeltrace/graph/notification-iterator-internal.h>
@@ -64,8 +63,6 @@
 #include <babeltrace/graph/port-internal.h>
 #include <babeltrace/plugin/plugin-internal.h>
 #include <babeltrace/plugin/plugin-so-internal.h>
-#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/ctf-writer/clock-internal.h>
 
 #define LIB_LOGGING_BUF_SIZE   (4096 * 4)
 
@@ -85,24 +82,10 @@ 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)
 
@@ -121,99 +104,176 @@ 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);
 
-static inline void format_ref_count(char **buf_ch, bool extended,
+static inline void format_clock_value(char **buf_ch, bool extended,
+               const char *prefix, struct bt_clock_value *clock_value);
+
+static inline void format_field_path(char **buf_ch, bool extended,
+               const char *prefix, struct bt_field_path *field_path);
+
+static inline void format_object(char **buf_ch, bool extended,
                const char *prefix, struct bt_object *obj)
 {
-       BUF_APPEND(", %sref-count=%lu", prefix, obj->ref_count.count);
+       BUF_APPEND(", %sref-count=%llu", prefix, obj->ref_count);
+}
+
+static inline void format_uuid(char **buf_ch, bt_uuid uuid)
+{
+       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)
+{
+       BUF_APPEND(", %ssize=%zu", PRFIELD(pool->size));
+
+       if (pool->objects) {
+               BUF_APPEND(", %scap=%u", PRFIELD(pool->objects->len));
+       }
+}
+
+static inline void format_integer_field_type(char **buf_ch,
+               bool extended, const char *prefix,
+               struct bt_field_type *field_type)
+{
+       struct bt_field_type_integer *int_ft = (void *) field_type;
+
+       BUF_APPEND(", %srange-size=%" PRIu64 ", %sbase=%s",
+               PRFIELD(int_ft->range),
+               PRFIELD(bt_common_field_type_integer_preferred_display_base_string(int_ft->base)));
+}
+
+static inline void format_array_field_type(char **buf_ch,
+               bool extended, const char *prefix,
+               struct bt_field_type *field_type)
+{
+       struct bt_field_type_array *array_ft = (void *) field_type;
+
+       BUF_APPEND(", %selement-ft-addr=%p, %selement-ft-id=%s",
+               PRFIELD(array_ft->element_ft),
+               PRFIELD(bt_common_field_type_id_string(array_ft->element_ft->id)));
 }
 
 static inline void format_field_type(char **buf_ch, bool extended,
                const char *prefix, struct bt_field_type *field_type)
 {
-       BUF_APPEND(", %stype-id=%s, %salignment=%u",
-               PRFIELD(bt_field_type_id_string(field_type->id)),
-               PRFIELD(field_type->alignment));
+       char tmp_prefix[64];
+
+       BUF_APPEND(", %sid=%s",
+               PRFIELD(bt_common_field_type_id_string(field_type->id)));
 
        if (extended) {
                BUF_APPEND(", %sis-frozen=%d", PRFIELD(field_type->frozen));
+               BUF_APPEND(", %sis-part-of-trace=%d",
+                       PRFIELD(field_type->part_of_trace));
        } else {
                return;
        }
 
-       if (field_type->id == BT_FIELD_TYPE_ID_UNKNOWN) {
-               return;
-       }
-
        switch (field_type->id) {
-       case BT_FIELD_TYPE_ID_INTEGER:
+       case BT_FIELD_TYPE_ID_UNSIGNED_INTEGER:
+       case BT_FIELD_TYPE_ID_SIGNED_INTEGER:
        {
-               struct bt_field_type_integer *integer = (void *) 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_byte_order_string(integer->user_byte_order)),
-                       PRFIELD(integer->base),
-                       PRFIELD(bt_string_encoding_string(integer->encoding)),
-                       PRFIELD(integer->mapped_clock));
-
-               if (integer->mapped_clock) {
-                       BUF_APPEND(", %smapped-clock-class-name=\"%s\"",
-                               PRFIELD(bt_clock_class_get_name(integer->mapped_clock)));
-               }
+               format_integer_field_type(buf_ch, extended, prefix, field_type);
                break;
        }
-       case BT_FIELD_TYPE_ID_FLOAT:
+       case BT_FIELD_TYPE_ID_REAL:
        {
-               struct bt_field_type_floating_point *flt = (void *) field_type;
+               struct bt_field_type_real *real_ft = (void *) field_type;
 
-               BUF_APPEND(", %sexp-dig=%u, %smant-dig=%u, %sbyte-order=%s",
-                       PRFIELD(flt->exp_dig), PRFIELD(flt->mant_dig),
-                       PRFIELD(bt_byte_order_string(flt->user_byte_order)));
+               BUF_APPEND(", %sis-single-precision=%d",
+                       PRFIELD(real_ft->is_single_precision));
                break;
        }
-       case BT_FIELD_TYPE_ID_ENUM:
+       case BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION:
+       case BT_FIELD_TYPE_ID_SIGNED_ENUMERATION:
        {
-               struct bt_field_type_enumeration *enm = (void *) field_type;
+               struct bt_field_type_enumeration *enum_ft =
+                       (void *) field_type;
 
+               format_integer_field_type(buf_ch, extended, prefix, field_type);
                BUF_APPEND(", %smapping-count=%u",
-                       PRFIELD(enm->entries->len));
+                       PRFIELD(enum_ft->mappings->len));
                break;
        }
-       case BT_FIELD_TYPE_ID_STRING:
+       case BT_FIELD_TYPE_ID_STRUCTURE:
        {
-               struct bt_field_type_string *str = (void *) field_type;
+               struct bt_field_type_structure *struct_ft =
+                       (void *) field_type;
+
+               if (struct_ft->common.named_fts) {
+                       BUF_APPEND(", %smember-count=%u",
+                               PRFIELD(struct_ft->common.named_fts->len));
+               }
 
-               BUF_APPEND(", %sencoding=%s",
-                       PRFIELD(bt_string_encoding_string(str->encoding)));
                break;
        }
-       case BT_FIELD_TYPE_ID_STRUCT:
+       case BT_FIELD_TYPE_ID_STATIC_ARRAY:
        {
-               struct bt_field_type_structure *structure = (void *) field_type;
+               struct bt_field_type_static_array *array_ft =
+                       (void *) field_type;
 
-               BUF_APPEND(", %sfield-count=%u",
-                       PRFIELD(structure->fields->len));
+               format_array_field_type(buf_ch, extended, prefix, field_type);
+               BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_ft->length));
                break;
        }
-       case BT_FIELD_TYPE_ID_SEQUENCE:
+       case BT_FIELD_TYPE_ID_DYNAMIC_ARRAY:
        {
-               struct bt_field_type_sequence *seq = (void *) field_type;
+               struct bt_field_type_dynamic_array *array_ft =
+                       (void *) field_type;
+
+               format_array_field_type(buf_ch, extended, prefix, field_type);
+
+               if (array_ft->length_ft) {
+                       SET_TMP_PREFIX("length-ft-");
+                       format_field_type(buf_ch, extended, tmp_prefix,
+                               array_ft->length_ft);
+               }
+
+               if (array_ft->length_field_path) {
+                       SET_TMP_PREFIX("length-field-path-");
+                       format_field_path(buf_ch, extended, tmp_prefix,
+                               array_ft->length_field_path);
+               }
 
-               BUF_APPEND(", %slength-ft-addr=\"%s\", %selem-ft-addr=%p",
-                       PRFIELD(seq->length_field_name->str),
-                       PRFIELD(seq->element_type));
                break;
        }
        case BT_FIELD_TYPE_ID_VARIANT:
        {
-               struct bt_field_type_variant *variant = (void *) field_type;
+               struct bt_field_type_variant *var_ft = (void *) field_type;
+
+               if (var_ft->common.named_fts) {
+                       BUF_APPEND(", %soption-count=%u",
+                               PRFIELD(var_ft->common.named_fts->len));
+               }
+
+               if (var_ft->selector_ft) {
+                       SET_TMP_PREFIX("selector-ft-");
+                       format_field_type(buf_ch, extended, tmp_prefix,
+                               var_ft->selector_ft);
+               }
+
+               if (var_ft->selector_field_path) {
+                       SET_TMP_PREFIX("selector-field-path-");
+                       format_field_path(buf_ch, extended, tmp_prefix,
+                               var_ft->selector_field_path);
+               }
 
-               BUF_APPEND(", %stag-name=\"%s\", %stag-ft-addr=%p, "
-                       "%sfield-count=%u",
-                       PRFIELD(variant->tag_name->str),
-                       PRFIELD(variant->tag), PRFIELD(variant->fields->len));
                break;
        }
        default:
@@ -228,90 +288,100 @@ static inline void format_field_integer_extended(char **buf_ch,
        struct bt_field_type_integer *field_type = (void *) field->type;
        const char *fmt = NULL;
 
-       if (field_type->base == 8) {
+       BT_ASSERT(field_type);
+
+       if (field_type->base == BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL) {
                fmt = ", %svalue=%" PRIo64;
-       } else if (field_type->base == 16) {
+       } else if (field_type->base == BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL) {
                fmt = ", %svalue=%" PRIx64;
        }
 
-       if (field_type->is_signed) {
+       if (field_type->common.id == BT_FIELD_TYPE_ID_SIGNED_INTEGER ||
+                       field_type->common.id == BT_FIELD_TYPE_ID_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(char **buf_ch, bool extended,
                const char *prefix, 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, %stype-id=%s",
-               PRFIELD(field->type),
-               PRFIELD(bt_field_type_id_string(field->type->id)));
+       BUF_APPEND(", %stype-addr=%p", PRFIELD(field->type));
+
+       if (!field->type) {
+               return;
+       }
+
+       BUF_APPEND(", %stype-id=%s",
+               PRFIELD(bt_common_field_type_id_string(field->type->id)));
 
-       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:
+       case BT_FIELD_TYPE_ID_UNSIGNED_INTEGER:
+       case BT_FIELD_TYPE_ID_SIGNED_INTEGER:
+       case BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION:
+       case BT_FIELD_TYPE_ID_SIGNED_ENUMERATION:
        {
                format_field_integer_extended(buf_ch, prefix, field);
                break;
        }
-       case BT_FIELD_TYPE_ID_FLOAT:
-       {
-               struct bt_field_floating_point *flt = (void *) field;
-
-               BUF_APPEND(", %svalue=%f", PRFIELD(flt->payload));
-               break;
-       }
-       case BT_FIELD_TYPE_ID_ENUM:
+       case BT_FIELD_TYPE_ID_REAL:
        {
-               struct bt_field_enumeration *enm = (void *) field;
+               struct bt_field_real *real_field = (void *) field;
 
-               if (enm->payload) {
-                       format_field_integer_extended(buf_ch, prefix,
-                               enm->payload);
-               }
+               BUF_APPEND(", %svalue=%f", PRFIELD(real_field->value));
                break;
        }
        case BT_FIELD_TYPE_ID_STRING:
        {
                struct bt_field_string *str = (void *) field;
 
-               BT_ASSERT(str->payload);
-               BUF_APPEND(", %spartial-value=\"%.32s\"",
-                       PRFIELD(str->payload->str));
+               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_TYPE_ID_STATIC_ARRAY:
+       case BT_FIELD_TYPE_ID_DYNAMIC_ARRAY:
        {
-               struct bt_field_sequence *seq = (void *) field;
+               struct bt_field_array *array_field = (void *) field;
+
+               BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_field->length));
+
+               if (array_field->fields) {
+                       BUF_APPEND(", %sallocated-length=%u",
+                               PRFIELD(array_field->fields->len));
+               }
 
-               BUF_APPEND(", %slength-field-addr=%p", PRFIELD(seq->length));
                break;
        }
        case BT_FIELD_TYPE_ID_VARIANT:
        {
-               struct bt_field_variant *variant = (void *) field;
+               struct bt_field_variant *var_field = (void *) field;
 
-               BUF_APPEND(", %stag-field-addr=%p, %svalue-field-addr=%p",
-                       PRFIELD(variant->tag), PRFIELD(variant->payload));
+               BUF_APPEND(", %sselected-field-index=%" PRIu64,
+                       PRFIELD(var_field->selected_index));
                break;
        }
        default:
@@ -324,19 +394,24 @@ static inline void format_field_path(char **buf_ch, bool extended,
 {
        uint64_t i;
 
-       BT_ASSERT(field_path->indexes);
-       BUF_APPEND(", %sindex-count=%u", PRFIELD(field_path->indexes->len));
+       if (field_path->indexes) {
+               BT_ASSERT(field_path->indexes);
+               BUF_APPEND(", %sindex-count=%u",
+                       PRFIELD(field_path->indexes->len));
+       }
 
-       if (!extended) {
+       if (!extended || !field_path->indexes) {
                return;
        }
 
-       BUF_APPEND(", %spath=[%s", PRFIELD(bt_scope_string(field_path->root)));
+       BUF_APPEND(", %spath=[%s",
+               PRFIELD(bt_common_scope_string(field_path->root)));
 
        for (i = 0; i < field_path->indexes->len; i++) {
-               int index = g_array_index(field_path->indexes, int, i);
+               uint64_t index = bt_field_path_get_index_by_index_inline(
+                       field_path, i);
 
-               BUF_APPEND(", %d", index);
+               BUF_APPEND(", %" PRIu64, index);
        }
 
        BUF_APPEND("%s", "]");
@@ -345,29 +420,40 @@ static inline void format_field_path(char **buf_ch, bool extended,
 static inline void format_trace(char **buf_ch, bool extended,
                const char *prefix, 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) {
                return;
        }
 
-       BUF_APPEND(", %sis-frozen=%d, %sis-static=%d",
-               PRFIELD(trace->frozen), PRFIELD(trace->is_static));
+       BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace->frozen));
+
+       if (trace->uuid.value) {
+               BUF_APPEND_UUID(trace->uuid.value);
+       }
+
+       if (trace->stream_classes) {
+               BUF_APPEND(", %sstream-class-count=%u",
+                       PRFIELD(trace->stream_classes->len));
+       }
 
-       if (trace->uuid_set) {
-               BUF_APPEND_UUID(trace->uuid);
+       if (trace->streams) {
+               BUF_APPEND(", %sstream-count=%u",
+                       PRFIELD(trace->streams->len));
        }
 
-       BUF_APPEND(", %sclock-class-count=%u, %sstream-class-count=%u, "
-               "%sstream-count=%u, %sis-ctf-writer-trace=%d, "
-               "%spacket-header-ft-addr=%p",
-               PRFIELD(trace->clocks->len),
-               PRFIELD(trace->stream_classes->len),
-               PRFIELD(trace->streams->len),
-               PRFIELD(trace->is_created_by_writer),
-               PRFIELD(trace->packet_header_type));
+       BUF_APPEND(", %spacket-header-ft-addr=%p, %sis-static=%d, "
+               "%sassigns-auto-sc-id=%d",
+               PRFIELD(trace->packet_header_ft),
+               PRFIELD(trace->is_static),
+               PRFIELD(trace->assigns_automatic_stream_class_id));
+       SET_TMP_PREFIX("phf-pool-");
+       format_object_pool(buf_ch, extended, prefix,
+               &trace->packet_header_field_pool);
 }
 
 static inline void format_stream_class(char **buf_ch, bool extended,
@@ -376,12 +462,11 @@ static inline void format_stream_class(char **buf_ch, bool extended,
        struct bt_trace *trace;
        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) {
@@ -390,27 +475,41 @@ static inline void format_stream_class(char **buf_ch, bool extended,
 
        BUF_APPEND(", %sis-frozen=%d", PRFIELD(stream_class->frozen));
 
-       if (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(stream_class->clock->clock_class)));
+       if (stream_class->event_classes) {
+               BUF_APPEND(", %sevent-class-count=%u",
+                       PRFIELD(stream_class->event_classes->len));
        }
 
-       BUF_APPEND(", %sevent-class-count=%u, %spacket-context-ft-addr=%p, "
-               "%sevent-header-ft-addr=%p, %sevent-context-ft-addr=%p",
-               PRFIELD(stream_class->event_classes->len),
-               PRFIELD(stream_class->packet_context_type),
-               PRFIELD(stream_class->event_header_type),
-               PRFIELD(stream_class->event_context_type));
-       trace = bt_stream_class_borrow_trace(stream_class);
+       BUF_APPEND(", %spacket-context-ft-addr=%p, "
+               "%sevent-header-ft-addr=%p, %sevent-common-context-ft-addr=%p",
+               PRFIELD(stream_class->packet_context_ft),
+               PRFIELD(stream_class->event_header_ft),
+               PRFIELD(stream_class->event_common_context_ft));
+       trace = bt_stream_class_borrow_trace_inline(stream_class);
        if (!trace) {
                return;
        }
 
+       BUF_APPEND(", %sassigns-auto-ec-id=%d, %sassigns-auto-stream-id=%d, "
+               "%spackets-have-discarded-ev-counter-snapshot=%d, "
+               "%spackets-have-packet-counter-snapshot=%d, "
+               "%spackets-have-default-begin-cv=%d, "
+               "%spackets-have-default-end-cv=%d",
+               PRFIELD(stream_class->assigns_automatic_event_class_id),
+               PRFIELD(stream_class->assigns_automatic_stream_id),
+               PRFIELD(stream_class->packets_have_discarded_event_counter_snapshot),
+               PRFIELD(stream_class->packets_have_packet_counter_snapshot),
+               PRFIELD(stream_class->packets_have_default_beginning_cv),
+               PRFIELD(stream_class->packets_have_default_end_cv));
        BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
        SET_TMP_PREFIX("trace-");
        format_trace(buf_ch, false, tmp_prefix, trace);
+       SET_TMP_PREFIX("ehf-pool-");
+       format_object_pool(buf_ch, extended, prefix,
+               &stream_class->event_header_field_pool);
+       SET_TMP_PREFIX("pcf-pool-");
+       format_object_pool(buf_ch, extended, prefix,
+               &stream_class->packet_context_field_pool);
 }
 
 static inline void format_event_class(char **buf_ch, bool extended,
@@ -420,28 +519,33 @@ static inline void format_event_class(char **buf_ch, bool extended,
        struct bt_trace *trace;
        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_event_class_log_level_string(event_class->log_level)));
+       BUF_APPEND(", %sis-frozen=%d", PRFIELD(event_class->frozen));
+
+       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) {
+       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),
-               PRFIELD(event_class->fields));
+       BUF_APPEND(", %sspecific-context-ft-addr=%p, %spayload-ft-addr=%p",
+               PRFIELD(event_class->specific_context_ft),
+               PRFIELD(event_class->payload_ft));
 
        stream_class = bt_event_class_borrow_stream_class(event_class);
        if (!stream_class) {
@@ -451,7 +555,7 @@ static inline void format_event_class(char **buf_ch, bool extended,
        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 = bt_stream_class_borrow_trace(stream_class);
+       trace = bt_stream_class_borrow_trace_inline(stream_class);
        if (!trace) {
                return;
        }
@@ -459,6 +563,8 @@ static inline void format_event_class(char **buf_ch, bool extended,
        BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
        SET_TMP_PREFIX("trace-");
        format_trace(buf_ch, false, tmp_prefix, trace);
+       SET_TMP_PREFIX("event-pool-");
+       format_object_pool(buf_ch, extended, prefix, &event_class->event_pool);
 }
 
 static inline void format_stream(char **buf_ch, bool extended,
@@ -468,41 +574,17 @@ static inline void format_stream(char **buf_ch, bool extended,
        struct bt_trace *trace;
        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));
        }
 
-       BUF_APPEND(", %sis-ctf-writer-stream=%d",
-               PRFIELD(stream->pos.fd != -1));
-
        if (!extended) {
                return;
        }
 
-       if (stream->pos.fd != -1) {
-               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));
-       }
-
-       stream_class = bt_stream_borrow_stream_class(stream);
+       stream_class = bt_stream_borrow_class(stream);
        if (!stream_class) {
                return;
        }
@@ -510,12 +592,12 @@ static inline void format_stream(char **buf_ch, bool extended,
        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 = bt_stream_class_borrow_trace(stream_class);
+       trace = bt_stream_class_borrow_trace_inline(stream_class);
        if (!trace) {
                return;
        }
 
-       trace = (struct bt_trace *) bt_object_borrow_parent(stream);
+       trace = (void *) bt_object_borrow_parent(&stream->base);
        if (!trace) {
                return;
        }
@@ -523,6 +605,8 @@ static inline void format_stream(char **buf_ch, bool extended,
        BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
        SET_TMP_PREFIX("trace-");
        format_trace(buf_ch, false, tmp_prefix, trace);
+       SET_TMP_PREFIX("packet-pool-");
+       format_object_pool(buf_ch, extended, prefix, &stream->packet_pool);
 }
 
 static inline void format_packet(char **buf_ch, bool extended,
@@ -539,17 +623,39 @@ static inline void format_packet(char **buf_ch, bool extended,
        BUF_APPEND(", %sis-frozen=%d, %sheader-field-addr=%p, "
                "%scontext-field-addr=%p",
                PRFIELD(packet->frozen),
-               PRFIELD(packet->header),
-               PRFIELD(packet->context));
+               PRFIELD(packet->header_field ? packet->header_field->field : NULL),
+               PRFIELD(packet->context_field ? packet->context_field->field : NULL));
        stream = bt_packet_borrow_stream(packet);
        if (!stream) {
                return;
        }
 
+       if (packet->default_beginning_cv) {
+               SET_TMP_PREFIX("default-begin-cv-");
+               format_clock_value(buf_ch, true, tmp_prefix,
+                       packet->default_beginning_cv);
+       }
+
+       if (packet->default_end_cv) {
+               SET_TMP_PREFIX("default-end-cv-");
+               format_clock_value(buf_ch, true, tmp_prefix,
+                       packet->default_end_cv);
+       }
+
+       if (packet->discarded_event_counter_snapshot.base.avail) {
+               BUF_APPEND(", %sdiscarded-ev-counter-snapshot=%" PRIu64,
+                       PRFIELD(packet->discarded_event_counter_snapshot.value));
+       }
+
+       if (packet->packet_counter_snapshot.base.avail) {
+               BUF_APPEND(", %spacket-counter-snapshot=%" PRIu64,
+                       PRFIELD(packet->packet_counter_snapshot.value));
+       }
+
        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);
+       trace = (struct bt_trace *) bt_object_borrow_parent(&stream->base);
        if (!trace) {
                return;
        }
@@ -562,10 +668,10 @@ static inline void format_packet(char **buf_ch, bool extended,
 static inline void format_event(char **buf_ch, bool extended,
                const char *prefix, struct bt_event *event)
 {
-       struct bt_trace *trace;
-       struct bt_stream_class *stream_class;
        struct bt_packet *packet;
        struct bt_stream *stream;
+       struct bt_trace *trace;
+       struct bt_stream_class *stream_class;
        char tmp_prefix[64];
 
        if (!extended) {
@@ -573,25 +679,31 @@ static inline void format_event(char **buf_ch, bool extended,
        }
 
        BUF_APPEND(", %sis-frozen=%d, %sheader-field-addr=%p, "
-               "%sstream-context-field-addr=%p, "
-               "%scontext-field-addr=%p, %spayload-field-addr=%p, "
-               "%sclock-value-count=%u",
+               "%scommon-context-field-addr=%p, "
+               "%specific-scontext-field-addr=%p, "
+               "%spayload-field-addr=%p, ",
                PRFIELD(event->frozen),
-               PRFIELD(event->event_header),
-               PRFIELD(event->stream_event_context),
-               PRFIELD(event->context_payload),
-               PRFIELD(event->fields_payload),
-               PRFIELD(g_hash_table_size(event->clock_values)));
-       BUF_APPEND(", %sevent-class-addr=%p", PRFIELD(event->event_class));
+               PRFIELD(event->header_field ?
+                       event->header_field->field : NULL),
+               PRFIELD(event->common_context_field),
+               PRFIELD(event->specific_context_field),
+               PRFIELD(event->payload_field));
+       BUF_APPEND(", %sevent-class-addr=%p", PRFIELD(event->class));
+
+       if (!event->class) {
+               return;
+       }
+
        SET_TMP_PREFIX("event-class-");
-       format_event_class(buf_ch, false, tmp_prefix, event->event_class);
-       stream_class = bt_event_class_borrow_stream_class(event->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(buf_ch, false, tmp_prefix, stream_class);
+               format_stream_class(buf_ch, false, tmp_prefix,
+                       stream_class);
 
-               trace = bt_stream_class_borrow_trace(stream_class);
+               trace = bt_stream_class_borrow_trace_inline(stream_class);
                if (trace) {
                        BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
                        SET_TMP_PREFIX("trace-");
@@ -599,6 +711,12 @@ static inline void format_event(char **buf_ch, bool extended,
                }
        }
 
+       if (event->default_cv) {
+               SET_TMP_PREFIX("default-cv-");
+               format_clock_value(buf_ch, true, tmp_prefix,
+                       event->default_cv);
+       }
+
        packet = bt_event_borrow_packet(event);
        if (!packet) {
                return;
@@ -620,43 +738,54 @@ static inline void format_event(char **buf_ch, bool extended,
 static inline void format_clock_class(char **buf_ch, bool extended,
                const char *prefix, struct bt_clock_class *clock_class)
 {
-       BUF_APPEND(", %sname=\"%s\", %sfreq=%" PRIu64,
-               PRFIELD(clock_class->name->str),
-               PRFIELD(clock_class->frequency));
+       char tmp_prefix[64];
+
+       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 ", %sis-absolute=%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));
+               PRFIELD(clock_class->offset_seconds),
+               PRFIELD(clock_class->offset_cycles),
+               PRFIELD(clock_class->is_absolute),
+               PRFIELD(clock_class->base_offset.value_ns));
 
-       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);
 }
 
 static inline void format_clock_value(char **buf_ch, bool extended,
                const char *prefix, struct bt_clock_value *clock_value)
 {
        char tmp_prefix[64];
-       BUF_APPEND(", %svalue=%" 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_value->value_cycles),
+               PRFIELD(clock_value->ns_from_origin));
 
        if (!extended) {
                return;
        }
 
+       BUF_APPEND(", %sis-set=%d", PRFIELD(clock_value->is_set));
        BUF_APPEND(", %sclock-class-addr=%p",
                PRFIELD(clock_value->clock_class));
        SET_TMP_PREFIX("clock-class-");
@@ -739,7 +868,8 @@ static inline void format_notification(char **buf_ch, bool extended,
                return;
        }
 
-       BUF_APPEND(", %sis-frozen=%d", PRFIELD(notif->frozen));
+       BUF_APPEND(", %sis-frozen=%d, %sgraph-addr=%p",
+               PRFIELD(notif->frozen), PRFIELD(notif->graph));
 
        switch (notif->type) {
        case BT_NOTIFICATION_TYPE_EVENT:
@@ -748,28 +878,6 @@ static inline void format_notification(char **buf_ch, bool extended,
 
                SET_TMP_PREFIX("event-");
                format_event(buf_ch, true, tmp_prefix, notif_event->event);
-
-               if (!notif_event->cc_prio_map) {
-                       return;
-               }
-
-               BUF_APPEND(", %scc-prio-map-addr=%p, %scc-prio-map-cc-count=%u",
-                       PRFIELD(notif_event->cc_prio_map),
-                       PRFIELD(notif_event->cc_prio_map->entries->len));
-               break;
-       }
-       case BT_NOTIFICATION_TYPE_INACTIVITY:
-       {
-               struct bt_notification_inactivity *notif_inactivity =
-                       (void *) notif;
-
-               if (!notif_inactivity->cc_prio_map) {
-                       return;
-               }
-
-               BUF_APPEND(", %scc-prio-map-addr=%p, %scc-prio-map-cc-count=%u",
-                       PRFIELD(notif_inactivity->cc_prio_map),
-                       PRFIELD(notif_inactivity->cc_prio_map->entries->len));
                break;
        }
        case BT_NOTIFICATION_TYPE_STREAM_BEGIN:
@@ -808,28 +916,6 @@ static inline void format_notification(char **buf_ch, bool extended,
                format_packet(buf_ch, true, tmp_prefix, notif_packet->packet);
                break;
        }
-       case BT_NOTIFICATION_TYPE_DISCARDED_EVENTS:
-       case BT_NOTIFICATION_TYPE_DISCARDED_PACKETS:
-       {
-               struct bt_notification_discarded_elements *notif_discarded =
-                       (void *) notif;
-
-               BUF_APPEND(", %scount=%" PRId64,
-                       PRFIELD(notif_discarded->count));
-
-               if (notif_discarded->begin_clock_value) {
-                       SET_TMP_PREFIX("begin-clock-value-");
-                       format_clock_value(buf_ch, true, tmp_prefix,
-                               notif_discarded->begin_clock_value);
-               }
-
-               if (notif_discarded->end_clock_value) {
-                       SET_TMP_PREFIX("end-clock-value-");
-                       format_clock_value(buf_ch, true, tmp_prefix,
-                               notif_discarded->end_clock_value);
-               }
-               break;
-       }
        default:
                break;
        }
@@ -853,7 +939,7 @@ static inline void format_component_class(char **buf_ch, bool extended,
 
        BUF_APPEND(", %stype=%s, %sname=\"%s\"",
                PRFIELD(bt_component_class_type_string(comp_class->type)),
-               PRFIELD(comp_class->name->str));
+               PRFIELD(comp_class->name ? comp_class->name->str : NULL));
 
        if (comp_class->description) {
                BUF_APPEND(", %spartial-descr=\"%.32s\"",
@@ -886,9 +972,15 @@ static inline void format_component(char **buf_ch, bool extended,
                return;
        }
 
-       BUF_APPEND(", %sinput-port-count=%u, %soutput-port-count=%u",
-               PRFIELD(component->input_ports ? component->input_ports->len : 0),
-               PRFIELD(component->output_ports ? component->output_ports->len : 0));
+       if (component->input_ports) {
+               BUF_APPEND(", %sinput-port-count=%u",
+                       PRFIELD(component->input_ports->len));
+       }
+
+       if (component->output_ports) {
+               BUF_APPEND(", %soutput-port-count=%u",
+                       PRFIELD(component->output_ports->len));
+       }
 }
 
 static inline void format_port(char **buf_ch, bool extended,
@@ -935,15 +1027,33 @@ 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)
 {
+       char tmp_prefix[64];
+
        BUF_APPEND(", %sis-canceled=%d", PRFIELD(graph->canceled));
 
        if (!extended) {
                return;
        }
 
-       BUF_APPEND(", %scomp-count=%u, %sconn-count=%u",
-               PRFIELD(graph->components->len),
-               PRFIELD(graph->connections->len));
+       if (graph->components) {
+               BUF_APPEND(", %scomp-count=%u",
+                       PRFIELD(graph->components->len));
+       }
+
+       if (graph->connections) {
+               BUF_APPEND(", %sconn-count=%u",
+                       PRFIELD(graph->connections->len));
+       }
+
+       SET_TMP_PREFIX("en-pool-");
+       format_object_pool(buf_ch, extended, prefix,
+               &graph->event_notif_pool);
+       SET_TMP_PREFIX("pbn-pool-");
+       format_object_pool(buf_ch, extended, prefix,
+               &graph->packet_begin_notif_pool);
+       SET_TMP_PREFIX("pen-pool-");
+       format_object_pool(buf_ch, extended, prefix,
+               &graph->packet_end_notif_pool);
 }
 
 static inline void format_notification_iterator(char **buf_ch,
@@ -999,9 +1109,6 @@ static inline void format_notification_iterator(char **buf_ch,
                SET_TMP_PREFIX("colander-comp-");
                format_component(buf_ch, false, tmp_prefix,
                        iter_output_port->colander);
-               SET_TMP_PREFIX("output-port-");
-               format_port(buf_ch, false, tmp_prefix,
-                       iter_output_port->output_port);
                break;
        }
        default:
@@ -1065,12 +1172,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 handle_conversion_specifier_bt(void *priv_data,
                char **buf_ch, size_t avail_size,
                const char **out_fmt_ch, va_list *args)
@@ -1084,6 +1185,13 @@ static inline void handle_conversion_specifier_bt(void *priv_data,
        /* 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++;
@@ -1116,9 +1224,6 @@ static inline void handle_conversion_specifier_bt(void *priv_data,
        }
 
        switch (*fmt_ch) {
-       case 'r':
-               format_ref_count(buf_ch, extended, prefix, obj);
-               break;
        case 'F':
                format_field_type(buf_ch, extended, prefix, obj);
                break;
@@ -1173,14 +1278,17 @@ static inline void handle_conversion_specifier_bt(void *priv_data,
        case 'x':
                format_connection(buf_ch, extended, prefix, obj);
                break;
-       case 'u':
+       case 'l':
                format_plugin(buf_ch, extended, prefix, obj);
                break;
        case 'g':
                format_graph(buf_ch, extended, prefix, obj);
                break;
-       case 'w':
-               format_ctf_writer(buf_ch, extended, prefix, obj);
+       case 'o':
+               format_object_pool(buf_ch, extended, prefix, obj);
+               break;
+       case 'O':
+               format_object(buf_ch, extended, prefix, obj);
                break;
        default:
                abort();
This page took 0.039485 seconds and 4 git commands to generate.