X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=lib%2Flib-logging.c;h=7e897fa38e457c3ae7ba1321662d6b6028dd965c;hb=11cd69be12a8f694b9ddc9b8d8cc6936b7f51596;hp=096428e1de4d268bbc261c0402e8261d55660348;hpb=5df26c89c52ed58a96fc1bce64d6e49d69b655ee;p=babeltrace.git diff --git a/lib/lib-logging.c b/lib/lib-logging.c index 096428e1..7e897fa3 100644 --- a/lib/lib-logging.c +++ b/lib/lib-logging.c @@ -62,12 +62,13 @@ #include #include #include -#include +#include #include #include #include #include #include +#include #include #include #include @@ -408,24 +409,34 @@ static inline void format_field_path(char **buf_ch, bool extended, { uint64_t i; - if (field_path->indexes) { - BT_ASSERT(field_path->indexes); - BUF_APPEND(", %sindex-count=%u", - PRFIELD(field_path->indexes->len)); + if (field_path->items) { + BT_ASSERT(field_path->items); + BUF_APPEND(", %sitem-count=%u", + PRFIELD(field_path->items->len)); } - if (!extended || !field_path->indexes) { + if (!extended || !field_path->items) { return; } BUF_APPEND(", %spath=[%s", PRFIELD(bt_common_scope_string(field_path->root))); - for (i = 0; i < field_path->indexes->len; i++) { - uint64_t index = bt_field_path_get_index_by_index_inline( - field_path, i); - - BUF_APPEND(", %" PRIu64, index); + 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); + + 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(); + } } BUF_APPEND("%s", "]"); @@ -478,8 +489,6 @@ static inline void format_trace(char **buf_ch, bool extended, PRFIELD(trace->streams->len)); } - BUF_APPEND(", %sis-static=%d", PRFIELD(trace->is_static)); - if (!trace->class) { return; } @@ -523,22 +532,14 @@ static inline void format_stream_class(char **buf_ch, bool extended, 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-cs=%d, " - "%spackets-have-default-end-cs=%d", + 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), - PRFIELD(stream_class->packets_have_discarded_event_counter_snapshot), - PRFIELD(stream_class->packets_have_packet_counter_snapshot), - PRFIELD(stream_class->packets_have_default_beginning_cs), - PRFIELD(stream_class->packets_have_default_end_cs)); + 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); } @@ -594,7 +595,8 @@ static inline void format_event_class(char **buf_ch, bool extended, 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_stream(char **buf_ch, bool extended, @@ -637,7 +639,7 @@ static inline void format_stream(char **buf_ch, bool extended, } SET_TMP_PREFIX("packet-pool-"); - format_object_pool(buf_ch, extended, prefix, &stream->packet_pool); + format_object_pool(buf_ch, extended, tmp_prefix, &stream->packet_pool); } static inline void format_packet(char **buf_ch, bool extended, @@ -659,28 +661,6 @@ static inline void format_packet(char **buf_ch, bool extended, return; } - 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_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) { - 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); @@ -741,12 +721,6 @@ static inline void format_event(char **buf_ch, bool extended, } } - 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_const(event); if (!packet) { return; @@ -791,16 +765,17 @@ static inline void format_clock_class(char **buf_ch, bool extended, BUF_APPEND(", %sis-frozen=%d, %sprecision=%" PRIu64 ", " "%soffset-s=%" PRId64 ", " - "%soffset-cycles=%" PRIu64 ", %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_seconds), PRFIELD(clock_class->offset_cycles), - PRFIELD(clock_class->is_absolute), + 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, prefix, &clock_class->cs_pool); + format_object_pool(buf_ch, extended, tmp_prefix, + &clock_class->cs_pool); } static inline void format_clock_snapshot(char **buf_ch, bool extended, @@ -913,6 +888,12 @@ static inline void format_message(char **buf_ch, bool extended, 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); + } + break; } case BT_MESSAGE_TYPE_STREAM_BEGINNING: @@ -963,6 +944,43 @@ static inline void format_message(char **buf_ch, bool extended, 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); + } + + break; + } + case BT_MESSAGE_TYPE_DISCARDED_EVENTS: + case BT_MESSAGE_TYPE_DISCARDED_PACKETS: + { + 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)); + } + break; } default: @@ -1084,7 +1102,11 @@ static inline void format_graph(char **buf_ch, bool extended, { 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; @@ -1101,13 +1123,13 @@ static inline void format_graph(char **buf_ch, bool extended, } SET_TMP_PREFIX("en-pool-"); - format_object_pool(buf_ch, extended, prefix, + format_object_pool(buf_ch, extended, tmp_prefix, &graph->event_msg_pool); SET_TMP_PREFIX("pbn-pool-"); - format_object_pool(buf_ch, extended, prefix, + 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, + format_object_pool(buf_ch, extended, tmp_prefix, &graph->packet_end_msg_pool); } @@ -1365,7 +1387,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, ...) {