bool done_filling_string;
/* Trace and classes */
+ /* True to set IR fields */
+ bool set_ir_fields;
+
struct {
struct ctf_trace_class *tc;
struct ctf_stream_class *sc;
off_t cur_packet_offset;
/* Default clock's current value */
- uint64_t default_clock_val;
+ uint64_t default_clock_snapshot;
/* End of packet snapshots */
struct {
* packet is created from a stream, and this API must be
* able to return the packet header and context fields
* without creating a stream
- * (bt_msg_iter_borrow_packet_header_context_fields()).
+ * (read_packet_header_context_fields()).
*/
notit->packet_context_field =
bt_packet_context_field_create(
* current value directly.
*/
if (new_val_size == 64) {
- notit->default_clock_val = new_val;
+ notit->default_clock_snapshot = new_val;
goto end;
}
new_val_mask = (1ULL << new_val_size) - 1;
- cur_value_masked = notit->default_clock_val & new_val_mask;
+ cur_value_masked = notit->default_clock_snapshot & new_val_mask;
if (new_val < cur_value_masked) {
/*
* of the requested new value. Assume that the clock
* value wrapped only one time.
*/
- notit->default_clock_val += new_val_mask + 1;
+ notit->default_clock_snapshot += new_val_mask + 1;
}
/* Clear the low bits of the current clock value. */
- notit->default_clock_val &= ~new_val_mask;
+ notit->default_clock_snapshot &= ~new_val_mask;
/* Set the low bits of the current clock value. */
- notit->default_clock_val |= new_val;
+ notit->default_clock_snapshot |= new_val;
end:
BT_LOGV("Updated default clock's value from integer field's value: "
- "value=%" PRIu64, notit->default_clock_val);
+ "value=%" PRIu64, notit->default_clock_snapshot);
}
static
"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);
- BT_ASSERT(fc->in_ir);
+
+ if (unlikely(!fc->in_ir)) {
+ goto end;
+ }
+
field = borrow_next_field(notit);
BT_ASSERT(field);
BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
BT_FIELD_CLASS_TYPE_REAL);
bt_field_real_set_value(field, value);
stack_top(notit->stack)->index++;
+
+end:
return status;
}
"fc-type=%d, fc-in-ir=%d",
notit, notit->bfcr, fc, fc->type, fc->in_ir);
- BT_ASSERT(fc->in_ir);
+ if (unlikely(!fc->in_ir)) {
+ goto end;
+ }
+
field = borrow_next_field(notit);
BT_ASSERT(field);
BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
* subsequent call to bfcr_string_end_cb().
*/
stack_push(notit->stack, field);
+
+end:
return BT_BFCR_STATUS_OK;
}
"fc-type=%d, fc-in-ir=%d, string-length=%zu",
notit, notit->bfcr, fc, fc->type, fc->in_ir,
len);
- BT_ASSERT(fc->in_ir);
+
+ if (unlikely(!fc->in_ir)) {
+ goto end;
+ }
+
field = stack_top(notit->stack)->base;
BT_ASSERT(field);
"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);
- BT_ASSERT(fc->in_ir);
+
+ if (unlikely(!fc->in_ir)) {
+ goto end;
+ }
/* Pop string field */
stack_pop(notit->stack);
/* Go to next field */
stack_top(notit->stack)->index++;
+
+end:
return BT_BFCR_STATUS_OK;
}
}
static
-void set_event_default_clock_value(struct bt_msg_iter *notit)
+void set_event_default_clock_snapshot(struct bt_msg_iter *notit)
{
bt_event *event =
bt_message_event_borrow_event(
BT_ASSERT(event);
if (bt_stream_class_borrow_default_clock_class(sc)) {
- bt_event_set_default_clock_value(event,
- notit->default_clock_val);
+ bt_event_set_default_clock_snapshot(event,
+ notit->default_clock_snapshot);
}
}
notit->packet, notit->snapshots.packets);
}
- if (bt_stream_class_packets_have_default_beginning_clock_value(sc)) {
+ if (bt_stream_class_packets_have_default_beginning_clock_snapshot(sc)) {
BT_ASSERT(notit->snapshots.beginning_clock != UINT64_C(-1));
- bt_packet_set_default_beginning_clock_value(
+ bt_packet_set_default_beginning_clock_snapshot(
notit->packet, notit->snapshots.beginning_clock);
}
- if (bt_stream_class_packets_have_default_end_clock_value(sc)) {
+ if (bt_stream_class_packets_have_default_end_clock_snapshot(sc)) {
BT_ASSERT(notit->snapshots.end_clock != UINT64_C(-1));
- bt_packet_set_default_end_clock_value(
+ bt_packet_set_default_end_clock_snapshot(
notit->packet, notit->snapshots.end_clock);
}
/* Update default clock from packet's end time */
if (notit->snapshots.end_clock != UINT64_C(-1)) {
- notit->default_clock_val = notit->snapshots.end_clock;
+ notit->default_clock_snapshot = notit->snapshots.end_clock;
}
BT_ASSERT(notit->msg_iter);
goto end;
case STATE_EMIT_MSG_EVENT:
BT_ASSERT(notit->event_msg);
- set_event_default_clock_value(notit);
+ set_event_default_clock_snapshot(notit);
*message = notit->event_msg;
notit->event_msg = NULL;
goto end;
return status;
}
-BT_HIDDEN
-enum bt_msg_iter_status bt_msg_iter_borrow_packet_header_context_fields(
- struct bt_msg_iter *notit,
- bt_field **packet_header_field,
- bt_field **packet_context_field)
+static
+enum bt_msg_iter_status read_packet_header_context_fields(
+ struct bt_msg_iter *notit)
{
int ret;
enum bt_msg_iter_status status = BT_MSG_ITER_STATUS_OK;
if (notit->state == STATE_EMIT_MSG_NEW_PACKET) {
/* We're already there */
- goto set_fields;
+ goto end;
}
while (true) {
* Packet header and context fields are
* potentially decoded (or they don't exist).
*/
- goto set_fields;
+ goto end;
case STATE_INIT:
case STATE_EMIT_MSG_NEW_STREAM:
case STATE_DSCOPE_TRACE_PACKET_HEADER_BEGIN:
}
}
-set_fields:
+end:
ret = set_current_packet_content_sizes(notit);
if (ret) {
status = BT_MSG_ITER_STATUS_ERROR;
goto end;
}
- if (packet_header_field) {
- *packet_header_field = notit->dscopes.trace_packet_header;
- }
-
- if (packet_context_field) {
- *packet_context_field = notit->dscopes.stream_packet_context;
- }
-
-end:
return status;
}
struct bt_msg_iter *notit,
struct bt_msg_iter_packet_properties *props)
{
+ enum bt_msg_iter_status status;
+
BT_ASSERT(notit);
BT_ASSERT(props);
+ status = read_packet_header_context_fields(notit);
+ if (status != BT_MSG_ITER_STATUS_OK) {
+ goto end;
+ }
props->exp_packet_total_size =
(uint64_t) notit->cur_exp_packet_total_size;
props->snapshots.packets = notit->snapshots.packets;
props->snapshots.beginning_clock = notit->snapshots.beginning_clock;
props->snapshots.end_clock = notit->snapshots.end_clock;
- return BT_MSG_ITER_STATUS_OK;
+
+end:
+ return status;
}