lib: make packets and packet messages optional, disabled by default
[babeltrace.git] / src / plugins / ctf / common / msg-iter / msg-iter.c
index 9bf8225de8a9d2ae17f7c3b90ec8f96fc3a7eb57..27d51779251e049a5c90d3f27035d5ff97f9df80 100644 (file)
@@ -88,7 +88,6 @@ enum state {
        STATE_AFTER_STREAM_PACKET_CONTEXT,
        STATE_CHECK_EMIT_MSG_STREAM_BEGINNING,
        STATE_EMIT_MSG_STREAM_BEGINNING,
-       STATE_EMIT_MSG_STREAM_ACTIVITY_BEGINNING,
        STATE_CHECK_EMIT_MSG_DISCARDED_EVENTS,
        STATE_CHECK_EMIT_MSG_DISCARDED_PACKETS,
        STATE_EMIT_MSG_DISCARDED_EVENTS,
@@ -107,8 +106,7 @@ enum state {
        STATE_SKIP_PACKET_PADDING,
        STATE_EMIT_MSG_PACKET_END_MULTI,
        STATE_EMIT_MSG_PACKET_END_SINGLE,
-       STATE_CHECK_EMIT_MSG_STREAM_ACTIVITY_END,
-       STATE_EMIT_MSG_STREAM_ACTIVITY_END,
+       STATE_CHECK_EMIT_MSG_STREAM_END,
        STATE_EMIT_MSG_STREAM_END,
        STATE_DONE,
 };
@@ -128,13 +126,10 @@ struct bt_msg_iter {
        /* Current message iterator to create messages (weak) */
        bt_self_message_iterator *msg_iter;
 
-       /*
-        * True to emit stream beginning and stream activity beginning
-        * messages.
-        */
+       /* True to emit a stream beginning message. */
        bool emit_stream_begin_msg;
 
-       /* True to emit stream end and stream activity end messages */
+       /* True to emit a stream end message. */
        bool emit_stream_end_msg;
 
        /* True to set the stream */
@@ -278,8 +273,6 @@ const char *state_string(enum state state)
                return "STATE_AFTER_STREAM_PACKET_CONTEXT";
        case STATE_EMIT_MSG_STREAM_BEGINNING:
                return "STATE_EMIT_MSG_STREAM_BEGINNING";
-       case STATE_EMIT_MSG_STREAM_ACTIVITY_BEGINNING:
-               return "STATE_EMIT_MSG_STREAM_ACTIVITY_BEGINNING";
        case STATE_EMIT_MSG_PACKET_BEGINNING:
                return "STATE_EMIT_MSG_PACKET_BEGINNING";
        case STATE_EMIT_MSG_DISCARDED_EVENTS:
@@ -312,8 +305,6 @@ const char *state_string(enum state state)
                return "STATE_EMIT_MSG_PACKET_END_MULTI";
        case STATE_EMIT_MSG_PACKET_END_SINGLE:
                return "STATE_EMIT_MSG_PACKET_END_SINGLE";
-       case STATE_EMIT_MSG_STREAM_ACTIVITY_END:
-               return "STATE_EMIT_MSG_STREAM_ACTIVITY_END";
        case STATE_EMIT_MSG_STREAM_END:
                return "STATE_EMIT_MSG_STREAM_END";
        case STATE_DONE:
@@ -380,7 +371,7 @@ void stack_push(struct stack *stack, bt_field *base)
        BT_ASSERT(stack);
        notit = stack->notit;
        BT_ASSERT(base);
-       BT_COMP_LOGV("Pushing base field on stack: stack-addr=%p, "
+       BT_COMP_LOGT("Pushing base field on stack: stack-addr=%p, "
                "stack-size-before=%zu, stack-size-after=%zu",
                stack, stack->size, stack->size + 1);
 
@@ -409,7 +400,7 @@ void stack_pop(struct stack *stack)
        BT_ASSERT(stack);
        BT_ASSERT(stack_size(stack));
        notit = stack->notit;
-       BT_COMP_LOGV("Popping from stack: "
+       BT_COMP_LOGT("Popping from stack: "
                "stack-addr=%p, stack-size-before=%zu, stack-size-after=%zu",
                stack, stack->size, stack->size - 1);
        stack->size--;
@@ -466,7 +457,7 @@ size_t packet_at(struct bt_msg_iter *notit)
 static inline
 void buf_consume_bits(struct bt_msg_iter *notit, size_t incr)
 {
-       BT_COMP_LOGV("Advancing cursor: notit-addr=%p, cur-before=%zu, cur-after=%zu",
+       BT_COMP_LOGT("Advancing cursor: notit-addr=%p, cur-before=%zu, cur-after=%zu",
                notit, notit->buf.at, notit->buf.at + incr);
        notit->buf.at += incr;
 }
@@ -579,21 +570,21 @@ enum bt_msg_iter_status read_dscope_begin_state(
        size_t consumed_bits;
 
        notit->cur_dscope_field = dscope_field;
-       BT_COMP_LOGV("Starting BFCR: notit-addr=%p, bfcr-addr=%p, fc-addr=%p",
+       BT_COMP_LOGT("Starting BFCR: notit-addr=%p, bfcr-addr=%p, fc-addr=%p",
                notit, notit->bfcr, dscope_fc);
        consumed_bits = bt_bfcr_start(notit->bfcr, dscope_fc,
                notit->buf.addr, notit->buf.at, packet_at(notit),
                notit->buf.sz, &bfcr_status);
-       BT_COMP_LOGV("BFCR consumed bits: size=%zu", consumed_bits);
+       BT_COMP_LOGT("BFCR consumed bits: size=%zu", consumed_bits);
 
        switch (bfcr_status) {
        case BT_BFCR_STATUS_OK:
                /* Field class was read completely */
-               BT_COMP_LOGV_STR("Field was completely decoded.");
+               BT_COMP_LOGT_STR("Field was completely decoded.");
                notit->state = done_state;
                break;
        case BT_BFCR_STATUS_EOF:
-               BT_COMP_LOGV_STR("BFCR needs more data to decode field completely.");
+               BT_COMP_LOGT_STR("BFCR needs more data to decode field completely.");
                notit->state = continue_state;
                break;
        default:
@@ -619,7 +610,7 @@ enum bt_msg_iter_status read_dscope_continue_state(
        enum bt_bfcr_status bfcr_status;
        size_t consumed_bits;
 
-       BT_COMP_LOGV("Continuing BFCR: notit-addr=%p, bfcr-addr=%p",
+       BT_COMP_LOGT("Continuing BFCR: notit-addr=%p, bfcr-addr=%p",
                notit, notit->bfcr);
 
        status = buf_ensure_available_bits(notit);
@@ -629,7 +620,7 @@ enum bt_msg_iter_status read_dscope_continue_state(
                                "msg-addr=%p, status=%s",
                                notit, bt_msg_iter_status_string(status));
                } else {
-                       BT_COMP_LOGV("Cannot ensure that buffer has at least one byte: "
+                       BT_COMP_LOGT("Cannot ensure that buffer has at least one byte: "
                                "msg-addr=%p, status=%s",
                                notit, bt_msg_iter_status_string(status));
                }
@@ -639,17 +630,17 @@ enum bt_msg_iter_status read_dscope_continue_state(
 
        consumed_bits = bt_bfcr_continue(notit->bfcr, notit->buf.addr,
                notit->buf.sz, &bfcr_status);
-       BT_COMP_LOGV("BFCR consumed bits: size=%zu", consumed_bits);
+       BT_COMP_LOGT("BFCR consumed bits: size=%zu", consumed_bits);
 
        switch (bfcr_status) {
        case BT_BFCR_STATUS_OK:
                /* Type was read completely. */
-               BT_COMP_LOGV_STR("Field was completely decoded.");
+               BT_COMP_LOGT_STR("Field was completely decoded.");
                notit->state = done_state;
                break;
        case BT_BFCR_STATUS_EOF:
                /* Stay in this continue state. */
-               BT_COMP_LOGV_STR("BFCR needs more data to decode field completely.");
+               BT_COMP_LOGT_STR("BFCR needs more data to decode field completely.");
                break;
        default:
                BT_COMP_LOGW("BFCR failed to continue: notit-addr=%p, bfcr-addr=%p, "
@@ -710,7 +701,7 @@ enum bt_msg_iter_status read_packet_header_begin_state(
                break;
        case BT_MSG_ITER_STATUS_EOF:
                ret = BT_MSG_ITER_STATUS_OK;
-               notit->state = STATE_CHECK_EMIT_MSG_STREAM_ACTIVITY_END;
+               notit->state = STATE_CHECK_EMIT_MSG_STREAM_END;
                goto end;
        default:
                goto end;
@@ -1206,11 +1197,11 @@ enum bt_msg_iter_status set_current_event_message(
        BT_ASSERT(notit->meta.sc);
 
        if (bt_stream_class_borrow_default_clock_class(notit->meta.sc->ir_sc)) {
-               msg = bt_message_event_create_with_default_clock_snapshot(
+               msg = bt_message_event_create_with_packet_and_default_clock_snapshot(
                        notit->msg_iter, notit->meta.ec->ir_ec,
                        notit->packet, notit->default_clock_snapshot);
        } else {
-               msg = bt_message_event_create(notit->msg_iter,
+               msg = bt_message_event_create_with_packet(notit->msg_iter,
                        notit->meta.ec->ir_ec, notit->packet);
        }
 
@@ -1281,7 +1272,7 @@ enum bt_msg_iter_status read_event_common_context_begin_state(
                BT_ASSERT(notit->dscopes.event_common_context);
        }
 
-       BT_COMP_LOGV("Decoding event common context field: "
+       BT_COMP_LOGT("Decoding event common context field: "
                "notit-addr=%p, stream-class-addr=%p, "
                "stream-class-id=%" PRId64 ", "
                "fc-addr=%p",
@@ -1334,7 +1325,7 @@ enum bt_msg_iter_status read_event_spec_context_begin_state(
                BT_ASSERT(notit->dscopes.event_spec_context);
        }
 
-       BT_COMP_LOGV("Decoding event specific context field: "
+       BT_COMP_LOGT("Decoding event specific context field: "
                "notit-addr=%p, event-class-addr=%p, "
                "event-class-name=\"%s\", event-class-id=%" PRId64 ", "
                "fc-addr=%p",
@@ -1390,7 +1381,7 @@ enum bt_msg_iter_status read_event_payload_begin_state(
                BT_ASSERT(notit->dscopes.event_payload);
        }
 
-       BT_COMP_LOGV("Decoding event payload field: "
+       BT_COMP_LOGT("Decoding event payload field: "
                "notit-addr=%p, event-class-addr=%p, "
                "event-class-name=\"%s\", event-class-id=%" PRId64 ", "
                "fc-addr=%p",
@@ -1570,11 +1561,11 @@ end:
 }
 
 static
-enum bt_msg_iter_status check_emit_msg_stream_activity_end(
+enum bt_msg_iter_status check_emit_msg_stream_end(
                struct bt_msg_iter *notit)
 {
        if (notit->emit_stream_end_msg) {
-               notit->state = STATE_EMIT_MSG_STREAM_ACTIVITY_END;
+               notit->state = STATE_EMIT_MSG_STREAM_END;
        } else {
                notit->state = STATE_DONE;
        }
@@ -1588,7 +1579,7 @@ enum bt_msg_iter_status handle_state(struct bt_msg_iter *notit)
        enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK;
        const enum state state = notit->state;
 
-       BT_COMP_LOGV("Handling state: notit-addr=%p, state=%s",
+       BT_COMP_LOGT("Handling state: notit-addr=%p, state=%s",
                notit, state_string(state));
 
        // TODO: optimalize!
@@ -1618,9 +1609,6 @@ enum bt_msg_iter_status handle_state(struct bt_msg_iter *notit)
                status = check_emit_msg_stream_beginning_state(notit);
                break;
        case STATE_EMIT_MSG_STREAM_BEGINNING:
-               notit->state = STATE_EMIT_MSG_STREAM_ACTIVITY_BEGINNING;
-               break;
-       case STATE_EMIT_MSG_STREAM_ACTIVITY_BEGINNING:
                notit->state = STATE_CHECK_EMIT_MSG_DISCARDED_EVENTS;
                break;
        case STATE_CHECK_EMIT_MSG_DISCARDED_EVENTS:
@@ -1675,13 +1663,10 @@ enum bt_msg_iter_status handle_state(struct bt_msg_iter *notit)
                notit->state = STATE_SKIP_PACKET_PADDING;
                break;
        case STATE_EMIT_MSG_PACKET_END_SINGLE:
-               notit->state = STATE_CHECK_EMIT_MSG_STREAM_ACTIVITY_END;
+               notit->state = STATE_CHECK_EMIT_MSG_STREAM_END;
                break;
-       case STATE_CHECK_EMIT_MSG_STREAM_ACTIVITY_END:
-               status = check_emit_msg_stream_activity_end(notit);
-               break;
-       case STATE_EMIT_MSG_STREAM_ACTIVITY_END:
-               notit->state = STATE_EMIT_MSG_STREAM_END;
+       case STATE_CHECK_EMIT_MSG_STREAM_END:
+               status = check_emit_msg_stream_end(notit);
                break;
        case STATE_EMIT_MSG_STREAM_END:
                notit->state = STATE_DONE;
@@ -1694,7 +1679,7 @@ enum bt_msg_iter_status handle_state(struct bt_msg_iter *notit)
                abort();
        }
 
-       BT_COMP_LOGV("Handled state: notit-addr=%p, status=%s, "
+       BT_COMP_LOGT("Handled state: notit-addr=%p, status=%s, "
                "prev-state=%s, cur-state=%s",
                notit, bt_msg_iter_status_string(status),
                state_string(state), state_string(notit->state));
@@ -1901,7 +1886,7 @@ void update_default_clock(struct bt_msg_iter *notit, uint64_t new_val,
        notit->default_clock_snapshot |= new_val;
 
 end:
-       BT_COMP_LOGV("Updated default clock's value from integer field's value: "
+       BT_COMP_LOGT("Updated default clock's value from integer field's value: "
                "value=%" PRIu64, notit->default_clock_snapshot);
 }
 
@@ -1914,7 +1899,7 @@ enum bt_bfcr_status bfcr_unsigned_int_cb(uint64_t value,
        bt_field *field = NULL;
        struct ctf_field_class_int *int_fc = (void *) fc;
 
-       BT_COMP_LOGV("Unsigned integer function called from BFCR: "
+       BT_COMP_LOGT("Unsigned integer function called from BFCR: "
                "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
                "fc-type=%d, fc-in-ir=%d, value=%" PRIu64,
                notit, notit->bfcr, fc, fc->type, fc->in_ir, value);
@@ -2003,7 +1988,7 @@ enum bt_bfcr_status bfcr_unsigned_int_char_cb(uint64_t value,
        struct ctf_field_class_int *int_fc = (void *) fc;
        char str[2] = {'\0', '\0'};
 
-       BT_COMP_LOGV("Unsigned integer character function called from BFCR: "
+       BT_COMP_LOGT("Unsigned integer character function called from BFCR: "
                "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
                "fc-type=%d, fc-in-ir=%d, value=%" PRIu64,
                notit, notit->bfcr, fc, fc->type, fc->in_ir, value);
@@ -2052,7 +2037,7 @@ enum bt_bfcr_status bfcr_signed_int_cb(int64_t value,
        struct bt_msg_iter *notit = data;
        struct ctf_field_class_int *int_fc = (void *) fc;
 
-       BT_COMP_LOGV("Signed integer function called from BFCR: "
+       BT_COMP_LOGT("Signed integer function called from BFCR: "
                "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
                "fc-type=%d, fc-in-ir=%d, value=%" PRId64,
                notit, notit->bfcr, fc, fc->type, fc->in_ir, value);
@@ -2089,7 +2074,7 @@ enum bt_bfcr_status bfcr_floating_point_cb(double value,
        bt_field *field = NULL;
        struct bt_msg_iter *notit = data;
 
-       BT_COMP_LOGV("Floating point number function called from BFCR: "
+       BT_COMP_LOGT("Floating point number function called from BFCR: "
                "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
                "fc-type=%d, fc-in-ir=%d, value=%f",
                notit, notit->bfcr, fc, fc->type, fc->in_ir, value);
@@ -2116,9 +2101,8 @@ enum bt_bfcr_status bfcr_string_begin_cb(
 {
        bt_field *field = NULL;
        struct bt_msg_iter *notit = data;
-       int ret;
 
-       BT_COMP_LOGV("String (beginning) function called from BFCR: "
+       BT_COMP_LOGT("String (beginning) function called from BFCR: "
                "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
                "fc-type=%d, fc-in-ir=%d",
                notit, notit->bfcr, fc, fc->type, fc->in_ir);
@@ -2132,8 +2116,7 @@ enum bt_bfcr_status bfcr_string_begin_cb(
        BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
        BT_ASSERT(bt_field_get_class_type(field) ==
                  BT_FIELD_CLASS_TYPE_STRING);
-       ret = bt_field_string_clear(field);
-       BT_ASSERT(ret == 0);
+       bt_field_string_clear(field);
 
        /*
         * Push on stack. Not a compound class per se, but we know that
@@ -2155,7 +2138,7 @@ enum bt_bfcr_status bfcr_string_cb(const char *value,
        struct bt_msg_iter *notit = data;
        int ret;
 
-       BT_COMP_LOGV("String (substring) function called from BFCR: "
+       BT_COMP_LOGT("String (substring) function called from BFCR: "
                "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
                "fc-type=%d, fc-in-ir=%d, string-length=%zu",
                notit, notit->bfcr, fc, fc->type, fc->in_ir,
@@ -2188,7 +2171,7 @@ enum bt_bfcr_status bfcr_string_end_cb(
 {
        struct bt_msg_iter *notit = data;
 
-       BT_COMP_LOGV("String (end) function called from BFCR: "
+       BT_COMP_LOGT("String (end) function called from BFCR: "
                "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
                "fc-type=%d, fc-in-ir=%d",
                notit, notit->bfcr, fc, fc->type, fc->in_ir);
@@ -2213,7 +2196,7 @@ enum bt_bfcr_status bfcr_compound_begin_cb(
        struct bt_msg_iter *notit = data;
        bt_field *field;
 
-       BT_COMP_LOGV("Compound (beginning) function called from BFCR: "
+       BT_COMP_LOGT("Compound (beginning) function called from BFCR: "
                "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
                "fc-type=%d, fc-in-ir=%d",
                notit, notit->bfcr, fc, fc->type, fc->in_ir);
@@ -2245,13 +2228,10 @@ enum bt_bfcr_status bfcr_compound_begin_cb(
                struct ctf_field_class_array_base *array_fc = (void *) fc;
 
                if (array_fc->is_text) {
-                       int ret;
-
                        BT_ASSERT(bt_field_get_class_type(field) ==
                                  BT_FIELD_CLASS_TYPE_STRING);
                        notit->done_filling_string = false;
-                       ret = bt_field_string_clear(field);
-                       BT_ASSERT(ret == 0);
+                       bt_field_string_clear(field);
                        bt_bfcr_set_unsigned_int_cb(notit->bfcr,
                                bfcr_unsigned_int_char_cb);
                }
@@ -2266,7 +2246,7 @@ enum bt_bfcr_status bfcr_compound_end_cb(
 {
        struct bt_msg_iter *notit = data;
 
-       BT_COMP_LOGV("Compound (end) function called from BFCR: "
+       BT_COMP_LOGT("Compound (end) function called from BFCR: "
                "notit-addr=%p, bfcr-addr=%p, fc-addr=%p, "
                "fc-type=%d, fc-in-ir=%d",
                notit, notit->bfcr, fc, fc->type, fc->in_ir);
@@ -2442,52 +2422,6 @@ void create_msg_stream_beginning(struct bt_msg_iter *notit,
        *message = ret;
 }
 
-static
-void create_msg_stream_activity_beginning(struct bt_msg_iter *notit,
-               bt_message **message)
-{
-       bt_message *ret = NULL;
-
-       BT_ASSERT(notit->stream);
-       BT_ASSERT(notit->msg_iter);
-       ret = bt_message_stream_activity_beginning_create(notit->msg_iter,
-               notit->stream);
-       if (!ret) {
-               BT_COMP_LOGE("Cannot create stream activity beginning message: "
-                       "notit-addr=%p, stream-addr=%p",
-                       notit, notit->stream);
-               return;
-       }
-
-       *message = ret;
-}
-
-static
-void create_msg_stream_activity_end(struct bt_msg_iter *notit,
-               bt_message **message)
-{
-       bt_message *ret = NULL;
-
-       if (!notit->stream) {
-               BT_COMP_LOGE("Cannot create stream for stream message: "
-                       "notit-addr=%p", notit);
-               return;
-       }
-
-       BT_ASSERT(notit->stream);
-       BT_ASSERT(notit->msg_iter);
-       ret = bt_message_stream_activity_end_create(notit->msg_iter,
-               notit->stream);
-       if (!ret) {
-               BT_COMP_LOGE("Cannot create stream activity end message: "
-                       "notit-addr=%p, stream-addr=%p",
-                       notit, notit->stream);
-               return;
-       }
-
-       *message = ret;
-}
-
 static
 void create_msg_stream_end(struct bt_msg_iter *notit, bt_message **message)
 {
@@ -2867,24 +2801,6 @@ enum bt_msg_iter_status bt_msg_iter_get_next_message(
                                status = BT_MSG_ITER_STATUS_ERROR;
                        }
 
-                       goto end;
-               case STATE_EMIT_MSG_STREAM_ACTIVITY_BEGINNING:
-                       /* create_msg_stream_activity_beginning() logs errors */
-                       create_msg_stream_activity_beginning(notit, message);
-
-                       if (!*message) {
-                               status = BT_MSG_ITER_STATUS_ERROR;
-                       }
-
-                       goto end;
-               case STATE_EMIT_MSG_STREAM_ACTIVITY_END:
-                       /* create_msg_stream_activity_end() logs errors */
-                       create_msg_stream_activity_end(notit, message);
-
-                       if (!*message) {
-                               status = BT_MSG_ITER_STATUS_ERROR;
-                       }
-
                        goto end;
                case STATE_EMIT_MSG_STREAM_BEGINNING:
                        /* create_msg_stream_beginning() logs errors */
@@ -2959,7 +2875,6 @@ enum bt_msg_iter_status read_packet_header_context_fields(
                case STATE_AFTER_STREAM_PACKET_CONTEXT:
                case STATE_CHECK_EMIT_MSG_STREAM_BEGINNING:
                case STATE_EMIT_MSG_STREAM_BEGINNING:
-               case STATE_EMIT_MSG_STREAM_ACTIVITY_BEGINNING:
                case STATE_CHECK_EMIT_MSG_DISCARDED_EVENTS:
                case STATE_EMIT_MSG_DISCARDED_EVENTS:
                case STATE_CHECK_EMIT_MSG_DISCARDED_PACKETS:
This page took 0.034143 seconds and 4 git commands to generate.