X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fplugins%2Ftext%2Fdetails%2Fwrite.c;h=1eab46b24e09977f8a76eedc575d06464c2768ef;hb=fe4df857056b4a03898f1031f136359ce733b0f5;hp=7c05d1458013581502ad020fdbe2210c9220ac9a;hpb=48be9a9176ef8d3a81390d43769093d91e9d5227;p=babeltrace.git diff --git a/src/plugins/text/details/write.c b/src/plugins/text/details/write.c index 7c05d145..1eab46b2 100644 --- a/src/plugins/text/details/write.c +++ b/src/plugins/text/details/write.c @@ -424,7 +424,7 @@ void write_value(struct details_write_ctx *ctx, const bt_value *value, break; case BT_VALUE_TYPE_ARRAY: { - uint64_t length = bt_value_array_get_size(value); + uint64_t length = bt_value_array_get_length(value); if (length == 0) { write_sp(ctx); @@ -931,8 +931,11 @@ void write_field_class(struct details_write_ctx *ctx, const bt_field_class *fc) case BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION: type = "Signed enumeration"; break; - case BT_FIELD_CLASS_TYPE_REAL: - type = "Real"; + case BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL: + type = "Single-precision real"; + break; + case BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL: + type = "Double-precision real"; break; case BT_FIELD_CLASS_TYPE_STRING: type = "String"; @@ -986,14 +989,6 @@ void write_field_class(struct details_write_ctx *ctx, const bt_field_class *fc) plural(mapping_count)); break; } - case BT_FIELD_CLASS_TYPE_REAL: - if (bt_field_class_real_is_single_precision(fc)) { - g_string_append(ctx->str, " (Single precision)"); - } else { - g_string_append(ctx->str, " (Double precision)"); - } - - break; case BT_FIELD_CLASS_TYPE_STRUCTURE: { uint64_t member_count = @@ -1596,7 +1591,6 @@ int try_write_meta(struct details_write_ctx *ctx, const bt_trace_class *tc, * rewrite `sc`. */ write_trace_class(ctx, tc); - write_nl(ctx); /* * Mark this trace class as written, as well as all @@ -1648,7 +1642,6 @@ int try_write_meta(struct details_write_ctx *ctx, const bt_trace_class *tc, * classes, so we don't need to rewrite `ec`. */ write_stream_class(ctx, sc); - write_nl(ctx); /* * Mark this stream class as written, as well as all its @@ -1681,7 +1674,6 @@ int try_write_meta(struct details_write_ctx *ctx, const bt_trace_class *tc, } write_event_class(ctx, ec); - write_nl(ctx); details_did_write_meta_object(ctx, tc, ec); goto end; } @@ -1857,9 +1849,13 @@ void write_field(struct details_write_ctx *ctx, const bt_field *field, break; } - case BT_FIELD_CLASS_TYPE_REAL: + case BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL: write_sp(ctx); - write_float_prop_value(ctx, bt_field_real_get_value(field)); + write_float_prop_value(ctx, bt_field_real_single_precision_get_value(field)); + break; + case BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL: + write_sp(ctx); + write_float_prop_value(ctx, bt_field_real_double_precision_get_value(field)); break; case BT_FIELD_CLASS_TYPE_STRING: write_sp(ctx); @@ -1982,6 +1978,18 @@ int write_event_message(struct details_write_ctx *ctx, goto end; } + if (!ctx->details_comp->cfg.with_data) { + goto end; + } + + if (ctx->str->len > 0) { + /* + * Output buffer contains metadata: separate blocks with + * newline. + */ + write_nl(ctx); + } + /* Write time */ if (bt_stream_class_borrow_default_clock_class_const(sc)) { write_time(ctx, @@ -2038,7 +2046,6 @@ int write_event_message(struct details_write_ctx *ctx, decr_indent(ctx); end: - return ret; } @@ -2219,6 +2226,18 @@ int write_stream_beginning_message(struct details_write_ctx *ctx, goto end; } + if (!ctx->details_comp->cfg.with_data) { + goto end; + } + + if (ctx->str->len > 0) { + /* + * Output buffer contains metadata: separate blocks with + * newline. + */ + write_nl(ctx); + } + /* Write time */ if (cc) { const bt_clock_snapshot *cs; @@ -2282,6 +2301,10 @@ int write_stream_end_message(struct details_write_ctx *ctx, const bt_clock_class *cc = bt_stream_class_borrow_default_clock_class_const(sc); + if (!ctx->details_comp->cfg.with_data) { + goto end; + } + /* Write time */ if (cc) { const bt_clock_snapshot *cs; @@ -2319,6 +2342,10 @@ int write_packet_beginning_message(struct details_write_ctx *ctx, const bt_stream_class *sc = bt_stream_borrow_class_const(stream); const bt_field *field; + if (!ctx->details_comp->cfg.with_data) { + goto end; + } + /* Write time */ if (bt_stream_class_packets_have_beginning_default_clock_snapshot(sc)) { write_time(ctx, @@ -2340,15 +2367,16 @@ int write_packet_beginning_message(struct details_write_ctx *ctx, } /* Write field */ - g_string_append(ctx->str, ":\n"); - incr_indent(ctx); field = bt_packet_borrow_context_field_const(packet); if (field) { + g_string_append(ctx->str, ":\n"); + incr_indent(ctx); write_root_field(ctx, "Context", field); + decr_indent(ctx); + } else { + write_nl(ctx); } - decr_indent(ctx); - end: return ret; } @@ -2395,6 +2423,7 @@ static int write_discarded_events_message(struct details_write_ctx *ctx, const bt_message *msg) { + int ret = 0; const bt_stream *stream = bt_message_discarded_events_borrow_stream_const( msg); const bt_stream_class *sc = bt_stream_borrow_class_const(stream); @@ -2402,6 +2431,10 @@ int write_discarded_events_message(struct details_write_ctx *ctx, const bt_clock_snapshot *end_cs = NULL; uint64_t count; + if (!ctx->details_comp->cfg.with_data) { + goto end; + } + if (bt_stream_class_discarded_events_have_default_clock_snapshots(sc)) { beginning_cs = bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const( @@ -2416,14 +2449,18 @@ int write_discarded_events_message(struct details_write_ctx *ctx, count = UINT64_C(-1); } - return write_discarded_items_message(ctx, "events", stream, + ret = write_discarded_items_message(ctx, "events", stream, beginning_cs, end_cs, count); + +end: + return ret; } static int write_discarded_packets_message(struct details_write_ctx *ctx, const bt_message *msg) { + int ret = 0; const bt_stream *stream = bt_message_discarded_packets_borrow_stream_const( msg); const bt_stream_class *sc = bt_stream_borrow_class_const(stream); @@ -2431,6 +2468,10 @@ int write_discarded_packets_message(struct details_write_ctx *ctx, const bt_clock_snapshot *end_cs = NULL; uint64_t count; + if (!ctx->details_comp->cfg.with_data) { + goto end; + } + if (bt_stream_class_discarded_packets_have_default_clock_snapshots(sc)) { beginning_cs = bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const( @@ -2445,8 +2486,11 @@ int write_discarded_packets_message(struct details_write_ctx *ctx, count = UINT64_C(-1); } - return write_discarded_items_message(ctx, "packets", stream, + ret = write_discarded_items_message(ctx, "packets", stream, beginning_cs, end_cs, count); + +end: + return ret; } static @@ -2459,6 +2503,10 @@ int write_packet_end_message(struct details_write_ctx *ctx, const bt_stream *stream = bt_packet_borrow_stream_const(packet); const bt_stream_class *sc = bt_stream_borrow_class_const(stream); + if (!ctx->details_comp->cfg.with_data) { + goto end; + } + /* Write time */ if (bt_stream_class_packets_have_end_default_clock_snapshot(sc)) { write_time(ctx, @@ -2527,10 +2575,6 @@ int details_write_message(struct details_comp *details_comp, /* Reset output buffer */ g_string_assign(details_comp->str, ""); - if (details_comp->printed_something && !details_comp->cfg.compact) { - write_nl(&ctx); - } - switch (bt_message_get_type(msg)) { case BT_MESSAGE_TYPE_EVENT: ret = write_event_message(&ctx, msg); @@ -2560,5 +2604,17 @@ int details_write_message(struct details_comp *details_comp, abort(); } + /* + * If this component printed at least one character so far, and + * we're not in compact mode, and there's something in the + * output buffer for this message, then prepend a newline to the + * output buffer to visually separate message blocks. + */ + if (details_comp->printed_something && !details_comp->cfg.compact && + details_comp->str->len > 0) { + /* TODO: Optimize this */ + g_string_prepend_c(details_comp->str, '\n'); + } + return ret; }