X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Fctf%2Fcommon%2Fmsg-iter%2Fmsg-iter.c;h=0671d9c3344bfb4c275f4552cbc51d0a69414a7d;hb=3fadfbc0c91f82c46bd36e6e0657ea93570c9db1;hp=d7cb7f37a88d47dbddfad3a1326617eba0769467;hpb=2c091c0465f433cc37e0042254c9132bac70a181;p=babeltrace.git diff --git a/plugins/ctf/common/msg-iter/msg-iter.c b/plugins/ctf/common/msg-iter/msg-iter.c index d7cb7f37..0671d9c3 100644 --- a/plugins/ctf/common/msg-iter/msg-iter.c +++ b/plugins/ctf/common/msg-iter/msg-iter.c @@ -31,10 +31,10 @@ #include #include #include -#include +#include #include -#include -#include +#include +#include #include #include @@ -969,14 +969,8 @@ enum bt_msg_iter_status set_current_packet_content_sizes( if (notit->cur_exp_packet_total_size == -1) { if (notit->cur_exp_packet_content_size != -1) { - BT_LOGW("Content size is set, but packet size is not: " - "notit-addr=%p, packet-context-field-addr=%p, " - "packet-size=%" PRId64 ", content-size=%" PRId64, - notit, notit->dscopes.stream_packet_context, - notit->cur_exp_packet_total_size, - notit->cur_exp_packet_content_size); - status = BT_MSG_ITER_STATUS_ERROR; - goto end; + notit->cur_exp_packet_total_size = + notit->cur_exp_packet_content_size; } } else { if (notit->cur_exp_packet_content_size == -1) { @@ -985,6 +979,11 @@ enum bt_msg_iter_status set_current_packet_content_sizes( } } + BT_ASSERT((notit->cur_exp_packet_total_size >= 0 && + notit->cur_exp_packet_content_size >= 0) || + (notit->cur_exp_packet_total_size < 0 && + notit->cur_exp_packet_content_size < 0)); + if (notit->cur_exp_packet_content_size > notit->cur_exp_packet_total_size) { BT_LOGW("Invalid packet or content size: " @@ -1471,6 +1470,11 @@ enum bt_msg_iter_status check_emit_msg_discarded_events( { notit->state = STATE_EMIT_MSG_DISCARDED_EVENTS; + if (!notit->meta.sc->has_discarded_events) { + notit->state = STATE_CHECK_EMIT_MSG_DISCARDED_PACKETS; + goto end; + } + if (notit->prev_packet_snapshots.discarded_events == UINT64_C(-1)) { if (notit->snapshots.discarded_events == 0 || notit->snapshots.discarded_events == UINT64_C(-1)) { @@ -1498,6 +1502,7 @@ enum bt_msg_iter_status check_emit_msg_discarded_events( } } +end: return BT_MSG_ITER_STATUS_OK; } @@ -1507,6 +1512,11 @@ enum bt_msg_iter_status check_emit_msg_discarded_packets( { notit->state = STATE_EMIT_MSG_DISCARDED_PACKETS; + if (!notit->meta.sc->has_discarded_packets) { + notit->state = STATE_EMIT_MSG_PACKET_BEGINNING; + goto end; + } + if (notit->prev_packet_snapshots.packets == UINT64_C(-1)) { /* * Stream's first packet or no information about @@ -1534,6 +1544,7 @@ enum bt_msg_iter_status check_emit_msg_discarded_packets( } } +end: return BT_MSG_ITER_STATUS_OK; } @@ -2289,11 +2300,23 @@ int64_t bfcr_get_sequence_length_cb(struct ctf_field_class *fc, void *data) seq_fc->stored_length_index); seq_field = stack_top(notit->stack)->base; BT_ASSERT(seq_field); - ret = bt_field_dynamic_array_set_length(seq_field, (uint64_t) length); - if (ret) { - BT_LOGE("Cannot set dynamic array field's length field: " - "notit-addr=%p, field-addr=%p, " - "length=%" PRIu64, notit, seq_field, length); + + /* + * bfcr_get_sequence_length_cb() also gets called back for a + * text sequence, but the destination field is a string field. + * Only set the field's sequence length if the destination field + * is a sequence field. + */ + if (!seq_fc->base.is_text) { + BT_ASSERT(bt_field_get_class_type(seq_field) == + BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY); + ret = bt_field_dynamic_array_set_length(seq_field, + (uint64_t) length); + if (ret) { + BT_LOGE("Cannot set dynamic array field's length field: " + "notit-addr=%p, field-addr=%p, " + "length=%" PRIu64, notit, seq_field, length); + } } return length; @@ -2507,13 +2530,14 @@ void create_msg_packet_beginning(struct bt_msg_iter *notit, BT_ASSERT(notit->msg_iter); - if (notit->snapshots.beginning_clock == UINT64_C(-1)) { - msg = bt_message_packet_beginning_create(notit->msg_iter, - notit->packet); - } else { + if (notit->meta.sc->packets_have_ts_begin) { + BT_ASSERT(notit->snapshots.beginning_clock != UINT64_C(-1)); msg = bt_message_packet_beginning_create_with_default_clock_snapshot( notit->msg_iter, notit->packet, notit->snapshots.beginning_clock); + } else { + msg = bt_message_packet_beginning_create(notit->msg_iter, + notit->packet); } if (!msg) { @@ -2545,13 +2569,14 @@ void create_msg_packet_end(struct bt_msg_iter *notit, bt_message **message) BT_ASSERT(notit->msg_iter); - if (notit->snapshots.end_clock == UINT64_C(-1)) { - msg = bt_message_packet_end_create(notit->msg_iter, - notit->packet); - } else { + if (notit->meta.sc->packets_have_ts_end) { + BT_ASSERT(notit->snapshots.end_clock != UINT64_C(-1)); msg = bt_message_packet_end_create_with_default_clock_snapshot( notit->msg_iter, notit->packet, notit->snapshots.end_clock); + } else { + msg = bt_message_packet_end_create(notit->msg_iter, + notit->packet); } if (!msg) { @@ -2573,29 +2598,27 @@ void create_msg_discarded_events(struct bt_msg_iter *notit, bt_message *msg; uint64_t beginning_raw_value = UINT64_C(-1); uint64_t end_raw_value = UINT64_C(-1); - uint64_t count = UINT64_C(-1); BT_ASSERT(notit->msg_iter); BT_ASSERT(notit->stream); + BT_ASSERT(notit->meta.sc->has_discarded_events); - if (notit->prev_packet_snapshots.discarded_events == UINT64_C(-1)) { - /* - * We discarded events, but before (and possibly - * including) the current packet: use this packet's time - * range, and do not have a specific count. - */ - beginning_raw_value = notit->snapshots.beginning_clock; - end_raw_value = notit->snapshots.end_clock; - } else { - count = notit->snapshots.discarded_events - - notit->prev_packet_snapshots.discarded_events; - BT_ASSERT(count > 0); - beginning_raw_value = notit->prev_packet_snapshots.end_clock; - end_raw_value = notit->snapshots.end_clock; - } + if (notit->meta.sc->discarded_events_have_default_cs) { + if (notit->prev_packet_snapshots.discarded_events == UINT64_C(-1)) { + /* + * We discarded events, but before (and possibly + * including) the current packet: use this packet's time + * range, and do not have a specific count. + */ + beginning_raw_value = notit->snapshots.beginning_clock; + end_raw_value = notit->snapshots.end_clock; + } else { + beginning_raw_value = notit->prev_packet_snapshots.end_clock; + end_raw_value = notit->snapshots.end_clock; + } - if (beginning_raw_value != UINT64_C(-1) && - end_raw_value != UINT64_C(-1)) { + BT_ASSERT(beginning_raw_value != UINT64_C(-1)); + BT_ASSERT(end_raw_value != UINT64_C(-1)); msg = bt_message_discarded_events_create_with_default_clock_snapshots( notit->msg_iter, notit->stream, beginning_raw_value, end_raw_value); @@ -2611,8 +2634,10 @@ void create_msg_discarded_events(struct bt_msg_iter *notit, return; } - if (count != UINT64_C(-1)) { - bt_message_discarded_events_set_count(msg, count); + if (notit->prev_packet_snapshots.discarded_events != UINT64_C(-1)) { + bt_message_discarded_events_set_count(msg, + notit->snapshots.discarded_events - + notit->prev_packet_snapshots.discarded_events); } *message = msg; @@ -2626,11 +2651,13 @@ void create_msg_discarded_packets(struct bt_msg_iter *notit, BT_ASSERT(notit->msg_iter); BT_ASSERT(notit->stream); + BT_ASSERT(notit->meta.sc->has_discarded_packets); BT_ASSERT(notit->prev_packet_snapshots.packets != UINT64_C(-1)); - if (notit->prev_packet_snapshots.end_clock != UINT64_C(-1) && - notit->snapshots.beginning_clock != UINT64_C(-1)) { + if (notit->meta.sc->discarded_packets_have_default_cs) { + BT_ASSERT(notit->prev_packet_snapshots.end_clock != UINT64_C(-1)); + BT_ASSERT(notit->snapshots.beginning_clock != UINT64_C(-1)); msg = bt_message_discarded_packets_create_with_default_clock_snapshots( notit->msg_iter, notit->stream, notit->prev_packet_snapshots.end_clock, @@ -2926,7 +2953,6 @@ end: ret = set_current_packet_content_sizes(notit); if (ret) { status = BT_MSG_ITER_STATUS_ERROR; - goto end; } return status; @@ -2994,7 +3020,6 @@ enum bt_msg_iter_status bt_msg_iter_get_packet_properties( props->exp_packet_total_size = notit->cur_exp_packet_total_size; props->exp_packet_content_size = notit->cur_exp_packet_content_size; - BT_ASSERT(props->stream_class_id >= 0); props->stream_class_id = (uint64_t) notit->cur_stream_class_id; props->data_stream_id = notit->cur_data_stream_id; props->snapshots.discarded_events = notit->snapshots.discarded_events;