X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=lib%2Flib-logging.c;h=017f2540bc1c9cdae7b96d7d5b0ac7596afe0710;hb=f03c28eb4f2d7996d63c8a2cea118c1acfc7c1dc;hp=3207c3d0b00ccb0bf1f47c0c8128a92854f2e1fb;hpb=44514773a92ed494fc9dc8637edcdaa3359baa54;p=babeltrace.git diff --git a/lib/lib-logging.c b/lib/lib-logging.c index 3207c3d0..017f2540 100644 --- a/lib/lib-logging.c +++ b/lib/lib-logging.c @@ -30,20 +30,27 @@ #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 @@ -54,12 +61,12 @@ #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -89,6 +96,8 @@ static char __thread lib_logging_buf[LIB_LOGGING_BUF_SIZE]; #define PRFIELD(_expr) prefix, (_expr) +#define PRFIELD_GSTRING(_expr) PRFIELD((_expr) ? (_expr)->str : NULL) + #define SET_TMP_PREFIX(_prefix2) \ do { \ strcpy(tmp_prefix, prefix); \ @@ -96,22 +105,22 @@ static char __thread lib_logging_buf[LIB_LOGGING_BUF_SIZE]; } while (0) 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, struct bt_field_path *field_path); + 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); } @@ -138,7 +147,7 @@ static inline void format_uuid(char **buf_ch, bt_uuid uuid) } 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)); @@ -149,9 +158,10 @@ static inline void format_object_pool(char **buf_ch, bool extended, static inline void format_integer_field_class(char **buf_ch, bool extended, const char *prefix, - struct bt_field_class *field_class) + const struct bt_field_class *field_class) { - struct bt_field_class_integer *int_fc = (void *) 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), @@ -160,9 +170,10 @@ static inline void format_integer_field_class(char **buf_ch, static inline void format_array_field_class(char **buf_ch, bool extended, const char *prefix, - struct bt_field_class *field_class) + const struct bt_field_class *field_class) { - struct bt_field_class_array *array_fc = (void *) 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), @@ -170,7 +181,7 @@ static inline void format_array_field_class(char **buf_ch, } static inline void format_field_class(char **buf_ch, bool extended, - const char *prefix, struct bt_field_class *field_class) + const char *prefix, const struct bt_field_class *field_class) { char tmp_prefix[64]; @@ -179,8 +190,8 @@ static inline void format_field_class(char **buf_ch, bool extended, if (extended) { BUF_APPEND(", %sis-frozen=%d", PRFIELD(field_class->frozen)); - BUF_APPEND(", %sis-part-of-trace=%d", - PRFIELD(field_class->part_of_trace)); + BUF_APPEND(", %sis-part-of-trace-class=%d", + PRFIELD(field_class->part_of_trace_class)); } else { return; } @@ -194,7 +205,7 @@ static inline void format_field_class(char **buf_ch, bool extended, } case BT_FIELD_CLASS_TYPE_REAL: { - struct bt_field_class_real *real_fc = (void *) field_class; + const struct bt_field_class_real *real_fc = (void *) field_class; BUF_APPEND(", %sis-single-precision=%d", PRFIELD(real_fc->is_single_precision)); @@ -203,8 +214,8 @@ static inline void format_field_class(char **buf_ch, bool extended, case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION: { - struct bt_field_class_enumeration *enum_fc = - (void *) field_class; + 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", @@ -213,8 +224,8 @@ static inline void format_field_class(char **buf_ch, bool extended, } case BT_FIELD_CLASS_TYPE_STRUCTURE: { - struct bt_field_class_structure *struct_fc = - (void *) field_class; + const struct bt_field_class_structure *struct_fc = + (const void *) field_class; if (struct_fc->common.named_fcs) { BUF_APPEND(", %smember-count=%u", @@ -225,8 +236,8 @@ static inline void format_field_class(char **buf_ch, bool extended, } case BT_FIELD_CLASS_TYPE_STATIC_ARRAY: { - struct bt_field_class_static_array *array_fc = - (void *) field_class; + const struct bt_field_class_static_array *array_fc = + (const void *) field_class; format_array_field_class(buf_ch, extended, prefix, field_class); BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_fc->length)); @@ -234,8 +245,8 @@ static inline void format_field_class(char **buf_ch, bool extended, } case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY: { - struct bt_field_class_dynamic_array *array_fc = - (void *) field_class; + const struct bt_field_class_dynamic_array *array_fc = + (const void *) field_class; format_array_field_class(buf_ch, extended, prefix, field_class); @@ -255,7 +266,8 @@ static inline void format_field_class(char **buf_ch, bool extended, } case BT_FIELD_CLASS_TYPE_VARIANT: { - struct bt_field_class_variant *var_fc = (void *) field_class; + const struct bt_field_class_variant *var_fc = + (const void *) field_class; if (var_fc->common.named_fcs) { BUF_APPEND(", %soption-count=%u", @@ -282,10 +294,11 @@ static inline void format_field_class(char **buf_ch, bool extended, } static inline void format_field_integer_extended(char **buf_ch, - const char *prefix, struct bt_field *field) + const char *prefix, const struct bt_field *field) { - struct bt_field_integer *integer = (void *) field; - struct bt_field_class_integer *field_class = (void *) field->class; + 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_class); @@ -313,7 +326,7 @@ static inline void format_field_integer_extended(char **buf_ch, } static inline void format_field(char **buf_ch, bool extended, - const char *prefix, struct bt_field *field) + const char *prefix, const struct bt_field *field) { BUF_APPEND(", %sis-set=%d", PRFIELD(field->is_set)); @@ -345,14 +358,14 @@ static inline void format_field(char **buf_ch, bool extended, } case BT_FIELD_CLASS_TYPE_REAL: { - struct bt_field_real *real_field = (void *) field; + const struct bt_field_real *real_field = (const void *) field; BUF_APPEND(", %svalue=%f", PRFIELD(real_field->value)); break; } case BT_FIELD_CLASS_TYPE_STRING: { - struct bt_field_string *str = (void *) field; + const struct bt_field_string *str = (const void *) field; if (str->buf) { BT_ASSERT(str->buf->data); @@ -365,7 +378,7 @@ static inline void format_field(char **buf_ch, bool extended, case BT_FIELD_CLASS_TYPE_STATIC_ARRAY: case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY: { - struct bt_field_array *array_field = (void *) field; + const struct bt_field_array *array_field = (const void *) field; BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_field->length)); @@ -378,7 +391,7 @@ static inline void format_field(char **buf_ch, bool extended, } case BT_FIELD_CLASS_TYPE_VARIANT: { - struct bt_field_variant *var_field = (void *) field; + const struct bt_field_variant *var_field = (const void *) field; BUF_APPEND(", %sselected-field-index=%" PRIu64, PRFIELD(var_field->selected_index)); @@ -390,7 +403,7 @@ static inline void format_field(char **buf_ch, bool extended, } static inline void format_field_path(char **buf_ch, bool extended, - const char *prefix, struct bt_field_path *field_path) + const char *prefix, const struct bt_field_path *field_path) { uint64_t i; @@ -417,8 +430,35 @@ static inline void format_field_path(char **buf_ch, bool extended, BUF_APPEND("%s", "]"); } +static inline void format_trace_class(char **buf_ch, bool extended, + const char *prefix, const struct bt_trace_class *trace_class) +{ + if (trace_class->name.value) { + BUF_APPEND(", %sname=\"%s\"", + PRFIELD(trace_class->name.value)); + } + + if (!extended) { + return; + } + + BUF_APPEND(", %sis-frozen=%d", PRFIELD(trace_class->frozen)); + + if (trace_class->uuid.value) { + BUF_APPEND_UUID(trace_class->uuid.value); + } + + if (trace_class->stream_classes) { + BUF_APPEND(", %sstream-class-count=%u", + PRFIELD(trace_class->stream_classes->len)); + } + + BUF_APPEND(", %sassigns-auto-sc-id=%d", + PRFIELD(trace_class->assigns_automatic_stream_class_id)); +} + static inline void format_trace(char **buf_ch, bool extended, - const char *prefix, struct bt_trace *trace) + const char *prefix, const struct bt_trace *trace) { char tmp_prefix[64]; @@ -432,34 +472,27 @@ static inline void format_trace(char **buf_ch, bool extended, 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->streams) { BUF_APPEND(", %sstream-count=%u", PRFIELD(trace->streams->len)); } - BUF_APPEND(", %spacket-header-fc-addr=%p, %sis-static=%d, " - "%sassigns-auto-sc-id=%d", - PRFIELD(trace->packet_header_fc), - 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); + BUF_APPEND(", %sis-static=%d", PRFIELD(trace->is_static)); + + 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); } static inline void format_stream_class(char **buf_ch, bool extended, - const char *prefix, struct bt_stream_class *stream_class) + const char *prefix, + const struct bt_stream_class *stream_class) { - struct bt_trace *trace; + const struct bt_trace_class *trace_class; char tmp_prefix[64]; BUF_APPEND(", %sid=%" PRIu64, PRFIELD(stream_class->id)); @@ -481,42 +514,38 @@ static inline void format_stream_class(char **buf_ch, bool extended, } BUF_APPEND(", %spacket-context-fc-addr=%p, " - "%sevent-header-fc-addr=%p, %sevent-common-context-fc-addr=%p", + "%sevent-common-context-fc-addr=%p", PRFIELD(stream_class->packet_context_fc), - PRFIELD(stream_class->event_header_fc), PRFIELD(stream_class->event_common_context_fc)); - trace = bt_stream_class_borrow_trace_inline(stream_class); - if (!trace) { + trace_class = bt_stream_class_borrow_trace_class_inline(stream_class); + if (!trace_class) { 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", + "%spackets-have-default-begin-cs=%d, " + "%spackets-have-default-end-cs=%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); + PRFIELD(stream_class->packets_have_default_beginning_cs), + PRFIELD(stream_class->packets_have_default_end_cs)); + 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, &stream_class->packet_context_field_pool); } static inline void format_event_class(char **buf_ch, bool extended, - const char *prefix, struct bt_event_class *event_class) + const char *prefix, const struct bt_event_class *event_class) { - struct bt_stream_class *stream_class; - struct bt_trace *trace; + const struct bt_stream_class *stream_class; + const struct bt_trace_class *trace_class; char tmp_prefix[64]; BUF_APPEND(", %sid=%" PRIu64, PRFIELD(event_class->id)); @@ -547,7 +576,7 @@ static inline void format_event_class(char **buf_ch, bool extended, PRFIELD(event_class->specific_context_fc), PRFIELD(event_class->payload_fc)); - stream_class = bt_event_class_borrow_stream_class(event_class); + stream_class = bt_event_class_borrow_stream_class_const(event_class); if (!stream_class) { return; } @@ -555,23 +584,24 @@ 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_inline(stream_class); - if (!trace) { + 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-"); - 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); 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, - const char *prefix, struct bt_stream *stream) + const char *prefix, const struct bt_stream *stream) { - struct bt_stream_class *stream_class; - struct bt_trace *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=%" PRIu64, PRFIELD(stream->id)); @@ -584,62 +614,60 @@ static inline void format_stream(char **buf_ch, bool extended, return; } - stream_class = bt_stream_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(buf_ch, false, tmp_prefix, stream_class); - trace = bt_stream_class_borrow_trace_inline(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(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, - 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_field ? packet->header_field->field : NULL), PRFIELD(packet->context_field ? packet->context_field->field : NULL)); - stream = bt_packet_borrow_stream(packet); + stream = bt_packet_borrow_stream_const(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_beginning_cs) { + SET_TMP_PREFIX("default-begin-cs-"); + format_clock_snapshot(buf_ch, true, tmp_prefix, + packet->default_beginning_cs); } - 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->default_end_cs) { + SET_TMP_PREFIX("default-end-cs-"); + format_clock_snapshot(buf_ch, true, tmp_prefix, + packet->default_end_cs); } if (packet->discarded_event_counter_snapshot.base.avail) { @@ -655,36 +683,34 @@ 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->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(char **buf_ch, bool extended, - const char *prefix, struct bt_event *event) + const char *prefix, const struct bt_event *event) { - struct bt_packet *packet; - struct bt_stream *stream; - struct bt_trace *trace; - struct bt_stream_class *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, " + BUF_APPEND(", %sis-frozen=%d, " "%scommon-context-field-addr=%p, " - "%specific-scontext-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->common_context_field), PRFIELD(event->specific_context_field), PRFIELD(event->payload_field)); @@ -703,21 +729,24 @@ static inline void format_event(char **buf_ch, bool extended, format_stream_class(buf_ch, false, tmp_prefix, stream_class); - trace = bt_stream_class_borrow_trace_inline(stream_class); - if (trace) { - BUF_APPEND(", %strace-addr=%p", PRFIELD(trace)); - SET_TMP_PREFIX("trace-"); - format_trace(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); } } - if (event->default_cv) { - SET_TMP_PREFIX("default-cv-"); - format_clock_value(buf_ch, true, tmp_prefix, - event->default_cv); + if (event->default_cs) { + SET_TMP_PREFIX("default-cs-"); + format_clock_snapshot(buf_ch, true, tmp_prefix, + event->default_cs); } - packet = bt_event_borrow_packet(event); + packet = bt_event_borrow_packet_const(event); if (!packet) { return; } @@ -725,7 +754,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; } @@ -736,7 +765,7 @@ 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) + const char *prefix, const struct bt_clock_class *clock_class) { char tmp_prefix[64]; @@ -769,34 +798,38 @@ static inline void format_clock_class(char **buf_ch, bool extended, PRFIELD(clock_class->is_absolute), PRFIELD(clock_class->base_offset.value_ns)); - SET_TMP_PREFIX("cv-pool-"); - format_object_pool(buf_ch, extended, prefix, &clock_class->cv_pool); + SET_TMP_PREFIX("cs-pool-"); + format_object_pool(buf_ch, extended, 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(", %svalue=%" PRIu64 ", %sns-from-origin=%" PRId64, - PRFIELD(clock_value->value_cycles), - PRFIELD(clock_value->ns_from_origin)); + PRFIELD(clock_snapshot->value_cycles), + PRFIELD(clock_snapshot->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-"); - 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; @@ -805,33 +838,29 @@ 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: { - int64_t val; + int64_t val = bt_value_integer_get(value); - (void) bt_value_integer_get(value, &val); BUF_APPEND(", %svalue=%" PRId64, PRFIELD(val)); break; } case BT_VALUE_TYPE_REAL: { - double val; + double val = bt_value_real_get(value); - (void) bt_value_real_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; } @@ -856,64 +885,80 @@ 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); + } - 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: { - struct bt_notification_stream_begin *notif_stream = - (void *) notif; + const struct bt_message_stream_beginning *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_END: { - struct bt_notification_stream_end *notif_stream = - (void *) notif; + const struct bt_message_stream_end *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_PACKET_BEGIN: + case BT_MESSAGE_TYPE_PACKET_BEGINNING: { - struct bt_notification_packet_begin *notif_packet = - (void *) notif; + const struct bt_message_packet_beginning *msg_packet = + (const void *) msg; + + if (msg_packet->packet) { + SET_TMP_PREFIX("packet-"); + format_packet(buf_ch, true, tmp_prefix, msg_packet->packet); + } - 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_PACKET_END: { - struct bt_notification_packet_end *notif_packet = - (void *) notif; + const struct bt_message_packet_end *msg_packet = + (const void *) msg; + + if (msg_packet->packet) { + SET_TMP_PREFIX("packet-"); + format_packet(buf_ch, true, tmp_prefix, msg_packet->packet); + } - SET_TMP_PREFIX("packet-"); - format_packet(buf_ch, true, tmp_prefix, notif_packet->packet); break; } default: @@ -923,27 +968,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) { @@ -960,13 +1006,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; @@ -984,13 +1035,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; @@ -1003,7 +1054,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]; @@ -1025,7 +1076,7 @@ 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]; @@ -1047,26 +1098,26 @@ 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); + &graph->event_msg_pool); SET_TMP_PREFIX("pbn-pool-"); format_object_pool(buf_ch, extended, prefix, - &graph->packet_begin_notif_pool); + &graph->packet_begin_msg_pool); SET_TMP_PREFIX("pen-pool-"); format_object_pool(buf_ch, extended, prefix, - &graph->packet_end_notif_pool); + &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)"; } @@ -1074,41 +1125,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: @@ -1117,7 +1174,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]; @@ -1125,12 +1182,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) { @@ -1139,12 +1196,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) { @@ -1156,13 +1213,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-"); @@ -1180,7 +1239,7 @@ static inline void handle_conversion_specifier_bt(void *priv_data, bool extended = false; char prefix[64]; char *prefix_ch = prefix; - void *obj; + const void *obj; /* skip "%!" */ fmt_ch += 2; @@ -1251,20 +1310,23 @@ static inline void handle_conversion_specifier_bt(void *priv_data, 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_value(buf_ch, extended, prefix, obj); + format_clock_snapshot(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); + format_message(buf_ch, extended, prefix, obj); break; case 'i': - format_notification_iterator(buf_ch, extended, prefix, obj); + format_message_iterator(buf_ch, extended, prefix, obj); break; case 'C': format_component_class(buf_ch, extended, prefix, obj);