struct stack *stack;
/* Current notification iterator to create notifications (weak) */
- struct bt_private_connection_private_notification_iterator *notif_iter;
+ struct bt_self_notification_iterator *notif_iter;
/*
* Current dynamic scope field pointer.
goto end;
}
- /* Packet header class is common to the whole trace. */
+ /* Packet header class is common to the whole trace class. */
packet_header_fc = notit->meta.tc->packet_header_fc;
if (!packet_header_fc) {
notit->state = STATE_AFTER_TRACE_PACKET_HEADER;
if (packet_header_fc->in_ir) {
/*
- * Create free packet header field from trace. This
- * field is going to be moved to the packet once we
+ * Create free packet header field from trace class.
+ * This field is going to be moved to the packet once we
* create it. We cannot create the packet now because:
*
* 1. A packet is created from a stream.
* 3. We need the packet header field's content to know
* the ID of the stream class to select.
*/
- notit->packet_header_field = bt_packet_header_field_create(
- notit->meta.tc->ir_tc);
+ notit->packet_header_field =
+ bt_packet_header_field_create(
+ notit->meta.tc->ir_tc);
if (!notit->packet_header_field) {
- BT_LOGE_STR("Cannot create packet header field wrapper from trace.");
+ BT_LOGE_STR("Cannot create packet header field wrapper from trace class.");
ret = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
notit->dscopes.trace_packet_header =
- bt_packet_header_field_borrow_field(notit->packet_header_field);
+ bt_packet_header_field_borrow_field(
+ notit->packet_header_field);
BT_ASSERT(notit->dscopes.trace_packet_header);
}
notit->cur_event_class_id = -1;
notit->cur_data_stream_id = -1;
BT_LOGV("Decoding packet header field:"
- "notit-addr=%p, trace-addr=%p, trace-name=\"%s\", fc-addr=%p",
- notit, notit->meta.tc,
- notit->meta.tc->name->str, packet_header_fc);
+ "notit-addr=%p, trace-class-addr=%p, fc-addr=%p",
+ notit, notit->meta.tc, packet_header_fc);
ret = read_dscope_begin_state(notit, packet_header_fc,
STATE_AFTER_TRACE_PACKET_HEADER,
STATE_DSCOPE_TRACE_PACKET_HEADER_CONTINUE,
notit->dscopes.trace_packet_header);
if (ret < 0) {
BT_LOGW("Cannot decode packet header field: "
- "notit-addr=%p, trace-addr=%p, "
- "trace-name=\"%s\", fc-addr=%p",
- notit, notit->meta.tc,
- notit->meta.tc->name->str,
- packet_header_fc);
+ "notit-addr=%p, trace-class-addr=%p, "
+ "fc-addr=%p",
+ notit, notit->meta.tc, packet_header_fc);
}
end:
if (notit->meta.tc->stream_classes->len != 1) {
BT_LOGW("Need exactly one stream class since there's "
"no stream class ID field: "
- "notit-addr=%p, trace-name=\"%s\"",
- notit, notit->meta.tc->name->str);
+ "notit-addr=%p", notit);
status = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
new_stream_class = notit->meta.tc->stream_classes->pdata[0];
notit->cur_stream_class_id = new_stream_class->id;
- goto end;
}
new_stream_class = ctf_trace_class_borrow_stream_class_by_id(
notit->meta.tc, notit->cur_stream_class_id);
if (!new_stream_class) {
- BT_LOGW("No stream class with ID of stream class ID to use in trace: "
+ BT_LOGW("No stream class with ID of stream class ID to use in trace class: "
"notit-addr=%p, stream-class-id=%" PRIu64 ", "
- "trace-addr=%p, trace-name=\"%s\"",
- notit, notit->cur_stream_class_id, notit->meta.tc,
- notit->meta.tc->name->str);
+ "trace-class-addr=%p",
+ notit, notit->cur_stream_class_id, notit->meta.tc);
status = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
"prev-stream-class-id=%" PRId64 ", "
"next-stream-class-addr=%p, "
"next-stream-class-id=%" PRId64 ", "
- "trace-addr=%p, trace-name=\"%s\"",
+ "trace-addr=%p",
notit, notit->meta.sc,
notit->meta.sc->id,
new_stream_class,
new_stream_class->id,
- notit->meta.tc,
- notit->meta.tc->name->str);
+ notit->meta.tc);
status = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
"stream-class-addr=%p, stream-class-id=%" PRId64,
notit, notit->meta.sc,
notit->meta.sc->id);
- stream = bt_get(notit->medium.medops.borrow_stream(
+ stream = notit->medium.medops.borrow_stream(
notit->meta.sc->ir_sc, notit->cur_data_stream_id,
- notit->medium.data));
+ notit->medium.data);
+ bt_stream_get_ref(stream);
BT_LOGV("User function returned: stream-addr=%p", stream);
if (!stream) {
BT_LOGW_STR("User function failed to return a stream object "
goto end;
}
- BT_MOVE(notit->stream, stream);
+ BT_STREAM_MOVE_REF(notit->stream, stream);
end:
- bt_put(stream);
+ bt_stream_put_ref(stream);
return status;
}
goto end;
error:
- BT_PUT(packet);
+ BT_PACKET_PUT_REF_AND_RESET(packet);
status = BT_NOTIF_ITER_STATUS_ERROR;
end:
- BT_MOVE(notit->packet, packet);
+ BT_PACKET_MOVE_REF(notit->packet, packet);
return status;
}
* (bt_notif_iter_borrow_packet_header_context_fields()).
*/
notit->packet_context_field =
- bt_packet_context_field_create(notit->meta.sc->ir_sc);
+ bt_packet_context_field_create(
+ notit->meta.sc->ir_sc);
if (!notit->packet_context_field) {
BT_LOGE_STR("Cannot create packet context field wrapper from stream class.");
status = BT_NOTIF_ITER_STATUS_ERROR;
}
notit->dscopes.stream_packet_context =
- bt_packet_context_field_borrow_field(notit->packet_context_field);
+ bt_packet_context_field_borrow_field(
+ notit->packet_context_field);
BT_ASSERT(notit->dscopes.stream_packet_context);
}
if (event_header_fc->in_ir) {
BT_ASSERT(!notit->event_header_field);
- notit->event_header_field = bt_event_header_field_create(
- notit->meta.sc->ir_sc);
+ notit->event_header_field =
+ bt_event_header_field_create(
+ notit->meta.sc->ir_sc);
if (!notit->event_header_field) {
- BT_LOGE_STR("Cannot create event header field wrapper from trace.");
+ BT_LOGE_STR("Cannot create event header field wrapper from trace class.");
status = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
notit->dscopes.event_header =
- bt_event_header_field_borrow_field(notit->event_header_field);
+ bt_event_header_field_borrow_field(
+ notit->event_header_field);
BT_ASSERT(notit->dscopes.event_header);
}
if (notit->meta.sc->event_classes->len != 1) {
BT_LOGW("Need exactly one event class since there's "
"no event class ID field: "
- "notit-addr=%p, trace-name=\"%s\"",
- notit, notit->meta.tc->name->str);
+ "notit-addr=%p", notit);
status = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
new_event_class = notit->meta.sc->event_classes->pdata[0];
notit->cur_event_class_id = new_event_class->id;
- goto end;
}
new_event_class = ctf_stream_class_borrow_event_class_by_id(
BT_LOGW("No event class with ID of event class ID to use in stream class: "
"notit-addr=%p, stream-class-id=%" PRIu64 ", "
"event-class-id=%" PRIu64 ", "
- "trace-addr=%p, trace-name=\"%s\"",
+ "trace-class-addr=%p",
notit, notit->meta.sc->id, notit->cur_event_class_id,
- notit->meta.tc, notit->meta.tc->name->str);
+ notit->meta.tc);
status = BT_NOTIF_ITER_STATUS_ERROR;
goto end;
}
goto end;
error:
- BT_PUT(notif);
+ BT_NOTIFICATION_PUT_REF_AND_RESET(notif);
status = BT_NOTIF_ITER_STATUS_ERROR;
end:
- BT_MOVE(notit->event_notif, notif);
+ BT_NOTIFICATION_MOVE_REF(notit->event_notif, notif);
return status;
}
goto end;
}
- notit->event = bt_notification_event_borrow_event(notit->event_notif);
+ notit->event = bt_notification_event_borrow_event(
+ notit->event_notif);
BT_ASSERT(notit->event);
if (notit->event_header_field) {
int ret;
BT_ASSERT(notit->event);
- ret = bt_event_move_header(notit->event,
+ ret = bt_event_move_header_field(notit->event,
notit->event_header_field);
if (ret) {
status = BT_NOTIF_ITER_STATUS_ERROR;
* the same value as the event header field within
* notit->event.
*/
- BT_ASSERT(bt_event_borrow_header_field(notit->event) ==
- notit->dscopes.event_header);
+ BT_ASSERT(bt_event_borrow_header_field(
+ notit->event) == notit->dscopes.event_header);
}
notit->state = STATE_DSCOPE_EVENT_COMMON_CONTEXT_BEGIN;
if (event_common_context_fc->in_ir) {
BT_ASSERT(!notit->dscopes.event_common_context);
notit->dscopes.event_common_context =
- bt_event_borrow_common_context_field(notit->event);
+ bt_event_borrow_common_context_field(
+ notit->event);
BT_ASSERT(notit->dscopes.event_common_context);
}
if (event_spec_context_fc->in_ir) {
BT_ASSERT(!notit->dscopes.event_spec_context);
- notit->dscopes.event_spec_context = bt_event_borrow_specific_context_field(
- notit->event);
+ notit->dscopes.event_spec_context =
+ bt_event_borrow_specific_context_field(
+ notit->event);
BT_ASSERT(notit->dscopes.event_spec_context);
}
if (event_payload_fc->in_ir) {
BT_ASSERT(!notit->dscopes.event_payload);
- notit->dscopes.event_payload = bt_event_borrow_payload_field(
- notit->event);
+ notit->dscopes.event_payload =
+ bt_event_borrow_payload_field(
+ notit->event);
BT_ASSERT(notit->dscopes.event_payload);
}
stack_clear(notit->stack);
notit->meta.sc = NULL;
notit->meta.ec = NULL;
- BT_PUT(notit->packet);
- BT_PUT(notit->stream);
- BT_PUT(notit->event_notif);
+ BT_PACKET_PUT_REF_AND_RESET(notit->packet);
+ BT_STREAM_PUT_REF_AND_RESET(notit->stream);
+ BT_NOTIFICATION_PUT_REF_AND_RESET(notit->event_notif);
release_all_dscopes(notit);
notit->cur_dscope_field = NULL;
notit->cur_packet_offset);
stack_clear(notit->stack);
notit->meta.ec = NULL;
- BT_PUT(notit->packet);
- BT_PUT(notit->event_notif);
+ BT_PACKET_PUT_REF_AND_RESET(notit->packet);
+ BT_NOTIFICATION_PUT_REF_AND_RESET(notit->event_notif);
release_all_dscopes(notit);
notit->cur_dscope_field = NULL;
{
struct bt_field *next_field = NULL;
struct bt_field *base_field;
- struct bt_field_class *base_fc;
+ const struct bt_field_class *base_fc;
size_t index;
BT_ASSERT(!stack_empty(notit->stack));
index = stack_top(notit->stack)->index;
base_field = stack_top(notit->stack)->base;
BT_ASSERT(base_field);
- base_fc = bt_field_borrow_class(base_field);
+ base_fc = bt_field_borrow_class_const(base_field);
BT_ASSERT(base_fc);
switch (bt_field_class_get_type(base_fc)) {
{
BT_ASSERT(index <
bt_field_class_structure_get_member_count(
- bt_field_borrow_class(base_field)));
- next_field = bt_field_structure_borrow_member_field_by_index(
- base_field, index);
+ bt_field_borrow_class_const(
+ base_field)));
+ next_field =
+ bt_field_structure_borrow_member_field_by_index(
+ base_field, index);
break;
}
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
field = borrow_next_field(notit);
BT_ASSERT(field);
- BT_ASSERT(bt_field_borrow_class(field) == fc->ir_fc);
- BT_ASSERT(bt_field_get_class_type(field) == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER ||
- bt_field_get_class_type(field) == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION);
+ BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
+ BT_ASSERT(bt_field_get_class_type(field) ==
+ BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER ||
+ bt_field_get_class_type(field) ==
+ BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION);
bt_field_unsigned_integer_set_value(field, value);
stack_top(notit->stack)->index++;
}
string_field = stack_top(notit->stack)->base;
- BT_ASSERT(bt_field_get_class_type(string_field) == BT_FIELD_CLASS_TYPE_STRING);
+ BT_ASSERT(bt_field_get_class_type(string_field) ==
+ BT_FIELD_CLASS_TYPE_STRING);
/* Append character */
str[0] = (char) value;
field = borrow_next_field(notit);
BT_ASSERT(field);
- BT_ASSERT(bt_field_borrow_class(field) == fc->ir_fc);
- BT_ASSERT(bt_field_get_class_type(field) == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER ||
- bt_field_get_class_type(field) == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION);
+ BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
+ BT_ASSERT(bt_field_get_class_type(field) ==
+ BT_FIELD_CLASS_TYPE_SIGNED_INTEGER ||
+ bt_field_get_class_type(field) ==
+ BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION);
bt_field_signed_integer_set_value(field, value);
stack_top(notit->stack)->index++;
BT_ASSERT(fc->in_ir);
field = borrow_next_field(notit);
BT_ASSERT(field);
- BT_ASSERT(bt_field_borrow_class(field) == fc->ir_fc);
- BT_ASSERT(bt_field_get_class_type(field) == BT_FIELD_CLASS_TYPE_REAL);
+ BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
+ BT_ASSERT(bt_field_get_class_type(field) ==
+ BT_FIELD_CLASS_TYPE_REAL);
bt_field_real_set_value(field, value);
stack_top(notit->stack)->index++;
return status;
BT_ASSERT(fc->in_ir);
field = borrow_next_field(notit);
BT_ASSERT(field);
- BT_ASSERT(bt_field_borrow_class(field) == fc->ir_fc);
- BT_ASSERT(bt_field_get_class_type(field) == BT_FIELD_CLASS_TYPE_STRING);
+ 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);
/* Push field */
BT_ASSERT(field);
- BT_ASSERT(bt_field_borrow_class(field) == fc->ir_fc);
+ BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
stack_push(notit->stack, field);
/*
int ret;
BT_ASSERT(bt_field_get_class_type(field) ==
- BT_FIELD_CLASS_TYPE_STRING);
+ BT_FIELD_CLASS_TYPE_STRING);
notit->done_filling_string = false;
ret = bt_field_string_clear(field);
BT_ASSERT(ret == 0);
}
BT_ASSERT(!stack_empty(notit->stack));
- BT_ASSERT(bt_field_borrow_class(stack_top(notit->stack)->base) ==
+ BT_ASSERT(bt_field_borrow_class_const(stack_top(notit->stack)->base) ==
fc->ir_fc);
/*
if (array_fc->is_text) {
BT_ASSERT(bt_field_get_class_type(
stack_top(notit->stack)->base) ==
- BT_FIELD_CLASS_TYPE_STRING);
+ BT_FIELD_CLASS_TYPE_STRING);
bt_bfcr_set_unsigned_int_cb(notit->bfcr,
bfcr_unsigned_int_cb);
}
if (selected_option->fc->in_ir) {
struct bt_field *var_field = stack_top(notit->stack)->base;
- ret = bt_field_variant_select_option_field(var_field,
- option_index);
+ ret = bt_field_variant_select_option_field(
+ var_field, option_index);
if (ret) {
BT_LOGW("Cannot select variant field's option field: "
"notit-addr=%p, var-field-addr=%p, "
static
void set_event_default_clock_value(struct bt_notif_iter *notit)
{
- struct bt_event *event = bt_notification_event_borrow_event(
- notit->event_notif);
+ struct bt_event *event =
+ bt_notification_event_borrow_event(
+ notit->event_notif);
struct bt_stream_class *sc = notit->meta.sc->ir_sc;
BT_ASSERT(event);
if (bt_stream_class_borrow_default_clock_class(sc)) {
- int ret = bt_event_set_default_clock_value(event,
+ bt_event_set_default_clock_value(event,
notit->default_clock_val);
-
- BT_ASSERT(ret == 0);
}
}
status = set_current_stream(notit);
if (status != BT_NOTIF_ITER_STATUS_OK) {
- BT_PUT(ret);
+ BT_NOTIFICATION_PUT_REF_AND_RESET(ret);
goto end;
}
BT_ASSERT(notit->stream);
BT_ASSERT(notit->notif_iter);
- ret = bt_notification_stream_begin_create(notit->notif_iter,
+ ret = bt_notification_stream_beginning_create(notit->notif_iter,
notit->stream);
if (!ret) {
BT_LOGE("Cannot create stream beginning notification: "
int ret;
enum bt_notif_iter_status status;
struct bt_notification *notif = NULL;
- struct bt_stream_class *sc;
+ const struct bt_stream_class *sc;
status = set_current_packet(notit);
if (status != BT_NOTIF_ITER_STATUS_OK) {
if (bt_stream_class_packets_have_discarded_event_counter_snapshot(sc)) {
BT_ASSERT(notit->snapshots.discarded_events != UINT64_C(-1));
- ret = bt_packet_set_discarded_event_counter_snapshot(
+ bt_packet_set_discarded_event_counter_snapshot(
notit->packet, notit->snapshots.discarded_events);
- BT_ASSERT(ret == 0);
}
if (bt_stream_class_packets_have_packet_counter_snapshot(sc)) {
BT_ASSERT(notit->snapshots.packets != UINT64_C(-1));
- ret = bt_packet_set_packet_counter_snapshot(
+ bt_packet_set_packet_counter_snapshot(
notit->packet, notit->snapshots.packets);
- BT_ASSERT(ret == 0);
}
if (bt_stream_class_packets_have_default_beginning_clock_value(sc)) {
BT_ASSERT(notit->snapshots.beginning_clock != UINT64_C(-1));
- ret = bt_packet_set_default_beginning_clock_value(
+ bt_packet_set_default_beginning_clock_value(
notit->packet, notit->snapshots.beginning_clock);
- BT_ASSERT(ret == 0);
}
if (bt_stream_class_packets_have_default_end_clock_value(sc)) {
BT_ASSERT(notit->snapshots.end_clock != UINT64_C(-1));
- ret = bt_packet_set_default_end_clock_value(
+ bt_packet_set_default_end_clock_value(
notit->packet, notit->snapshots.end_clock);
- BT_ASSERT(ret == 0);
}
if (notit->packet_header_field) {
- ret = bt_packet_move_header_field(notit->packet,
- notit->packet_header_field);
+ ret = bt_packet_move_header_field(
+ notit->packet, notit->packet_header_field);
if (ret) {
goto end;
}
* the same value as the packet header field within
* notit->packet.
*/
- BT_ASSERT(bt_packet_borrow_header_field(notit->packet) ==
+ BT_ASSERT(bt_packet_borrow_header_field(
+ notit->packet) ==
notit->dscopes.trace_packet_header);
}
if (notit->packet_context_field) {
- ret = bt_packet_move_context_field(notit->packet,
- notit->packet_context_field);
+ ret = bt_packet_move_context_field(
+ notit->packet, notit->packet_context_field);
if (ret) {
goto end;
}
* the same value as the packet header field within
* notit->packet.
*/
- BT_ASSERT(bt_packet_borrow_context_field(notit->packet) ==
+ BT_ASSERT(bt_packet_borrow_context_field(
+ notit->packet) ==
notit->dscopes.stream_packet_context);
}
BT_ASSERT(notit->notif_iter);
- notif = bt_notification_packet_begin_create(notit->notif_iter,
+ notif = bt_notification_packet_beginning_create(notit->notif_iter,
notit->packet);
if (!notif) {
BT_LOGE("Cannot create packet beginning notification: "
}
- BT_PUT(notit->packet);
+ BT_PACKET_PUT_REF_AND_RESET(notit->packet);
*notification = notif;
}
BT_ASSERT(medops.request_bytes);
BT_ASSERT(medops.borrow_stream);
BT_LOGD("Creating CTF plugin notification iterator: "
- "trace-addr=%p, trace-name=\"%s\", max-request-size=%zu, "
- "data=%p", tc, tc->name->str, max_request_sz, data);
+ "trace-addr=%p, max-request-size=%zu, "
+ "data=%p", tc, max_request_sz, data);
notit = g_new0(struct bt_notif_iter, 1);
if (!notit) {
BT_LOGE_STR("Failed to allocate one CTF plugin notification iterator.");
bt_notif_iter_reset(notit);
BT_LOGD("Created CTF plugin notification iterator: "
- "trace-addr=%p, trace-name=\"%s\", max-request-size=%zu, "
+ "trace-addr=%p, max-request-size=%zu, "
"data=%p, notit-addr=%p",
- tc, tc->name->str, max_request_sz, data,
- notit);
+ tc, max_request_sz, data, notit);
notit->cur_packet_offset = 0;
end:
void bt_notif_iter_destroy(struct bt_notif_iter *notit)
{
- BT_PUT(notit->packet);
- BT_PUT(notit->stream);
+ BT_PACKET_PUT_REF_AND_RESET(notit->packet);
+ BT_STREAM_PUT_REF_AND_RESET(notit->stream);
release_all_dscopes(notit);
BT_LOGD("Destroying CTF plugin notification iterator: addr=%p", notit);
enum bt_notif_iter_status bt_notif_iter_get_next_notification(
struct bt_notif_iter *notit,
- struct bt_private_connection_private_notification_iterator *notif_iter,
+ struct bt_self_notification_iterator *notif_iter,
struct bt_notification **notification)
{
enum bt_notif_iter_status status = BT_NOTIF_ITER_STATUS_OK;