curr_field);
}
- status = bt_field_string_append(curr_field, ":");
- if (status != BT_FIELD_STATUS_OK) {
- BT_LOGE("Cannot set colon component of \"bin\" "
- "curr_field field's value: str-fc-addr=%p",
- curr_field);
- }
-
status = bt_field_string_append(curr_field, dbg_info_src->bin_loc);
if (status != BT_FIELD_STATUS_OK) {
BT_LOGE("Cannot set bin location component of \"bin\" "
const bt_clock_snapshot *cs;
const bt_clock_class *default_cc;
const bt_packet *in_packet;
- bt_clock_snapshot_state cs_state;
bt_event_class *out_event_class;
bt_packet *out_packet;
bt_event *out_event;
bt_event_class_borrow_stream_class_const(in_event_class));
if (default_cc) {
/* Borrow event clock snapshot. */
- cs_state =
- bt_message_event_borrow_default_clock_snapshot_const(
- in_message, &cs);
+ cs = bt_message_event_borrow_default_clock_snapshot_const(
+ in_message);
/* Create an output event message. */
- BT_ASSERT (cs_state == BT_CLOCK_SNAPSHOT_STATE_KNOWN);
out_message = bt_message_event_create_with_default_clock_snapshot(
debug_it->input_iterator,
out_event_class, out_packet,
bt_message *handle_packet_begin_message(struct debug_info_msg_iter *debug_it,
const bt_message *in_message)
{
- const bt_clock_class *default_cc;
- bt_clock_snapshot_state cs_state;
+ bool has_default_clock_snapshot;
const bt_clock_snapshot *cs;
bt_message *out_message = NULL;
bt_packet *out_packet;
BT_ASSERT(out_packet);
- default_cc = bt_stream_class_borrow_default_clock_class_const(
+ has_default_clock_snapshot =
+ bt_stream_class_packets_have_default_beginning_clock_snapshot(
bt_stream_borrow_class_const(
bt_packet_borrow_stream_const(in_packet)));
- if (default_cc) {
+ if (has_default_clock_snapshot) {
/* Borrow clock snapshot. */
- cs_state =
- bt_message_packet_beginning_borrow_default_clock_snapshot_const(
- in_message, &cs);
+ cs = bt_message_packet_beginning_borrow_default_clock_snapshot_const(
+ in_message);
/* Create an output packet beginning message. */
- BT_ASSERT(cs_state == BT_CLOCK_SNAPSHOT_STATE_KNOWN);
out_message = bt_message_packet_beginning_create_with_default_clock_snapshot(
debug_it->input_iterator, out_packet,
bt_clock_snapshot_get_value(cs));
bt_message *handle_packet_end_message(struct debug_info_msg_iter *debug_it,
const bt_message *in_message)
{
+ bool has_default_clock_snapshot;
const bt_clock_snapshot *cs;
const bt_packet *in_packet;
- const bt_clock_class *default_cc;
- bt_clock_snapshot_state cs_state;
bt_message *out_message = NULL;
bt_packet *out_packet;
out_packet = trace_ir_mapping_borrow_mapped_packet(debug_it->ir_maps, in_packet);
BT_ASSERT(out_packet);
- default_cc = bt_stream_class_borrow_default_clock_class_const(
+ has_default_clock_snapshot =
+ bt_stream_class_packets_have_default_end_clock_snapshot(
bt_stream_borrow_class_const(
bt_packet_borrow_stream_const(in_packet)));
- if (default_cc) {
+ if (has_default_clock_snapshot) {
/* Borrow clock snapshot. */
- cs_state =
- bt_message_packet_end_borrow_default_clock_snapshot_const(
- in_message, &cs);
+ cs = bt_message_packet_end_borrow_default_clock_snapshot_const(
+ in_message);
/* Create an outpute packet end message. */
- BT_ASSERT(cs_state == BT_CLOCK_SNAPSHOT_STATE_KNOWN);
out_message = bt_message_packet_end_create_with_default_clock_snapshot(
debug_it->input_iterator, out_packet,
bt_clock_snapshot_get_value(cs));
in_message);
BT_ASSERT(in_stream);
- out_stream = trace_ir_mapping_borrow_mapped_stream(debug_it->ir_maps, in_stream);
+ out_stream = trace_ir_mapping_borrow_mapped_stream(debug_it->ir_maps,
+ in_stream);
BT_ASSERT(out_stream);
out_message = bt_message_stream_activity_end_create(
{
const bt_clock_snapshot *begin_cs, *end_cs;
const bt_stream *in_stream;
- const bt_clock_class *default_cc;
+ bool has_default_clock_snapshots;
uint64_t discarded_events, begin_cs_value, end_cs_value;
- bt_clock_snapshot_state begin_cs_state, end_cs_state;
bt_property_availability prop_avail;
bt_message *out_message = NULL;
bt_stream *out_stream;
debug_it->ir_maps, in_stream);
BT_ASSERT(out_stream);
- default_cc = bt_stream_class_borrow_default_clock_class_const(
+ has_default_clock_snapshots =
+ bt_stream_class_discarded_events_have_default_clock_snapshots(
bt_stream_borrow_class_const(in_stream));
- if (default_cc) {
- begin_cs_state =
+ if (has_default_clock_snapshots) {
+ begin_cs =
bt_message_discarded_events_borrow_default_beginning_clock_snapshot_const(
- in_message, &begin_cs);
- end_cs_state =
+ in_message);
+ end_cs =
bt_message_discarded_events_borrow_default_end_clock_snapshot_const(
- in_message, &end_cs);
- /*
- * Both clock snapshots should be known as we check that the
- * all input stream classes have an always known clock. Unknown
- * clock is not yet supported.
- */
- BT_ASSERT(begin_cs_state == BT_CLOCK_SNAPSHOT_STATE_KNOWN &&
- end_cs_state == BT_CLOCK_SNAPSHOT_STATE_KNOWN);
+ in_message);
begin_cs_value = bt_clock_snapshot_get_value(begin_cs);
end_cs_value = bt_clock_snapshot_get_value(end_cs);
const bt_message *in_message)
{
const bt_clock_snapshot *begin_cs, *end_cs;
- const bt_clock_class *default_cc;
+ bool has_default_clock_snapshots;
const bt_stream *in_stream;
uint64_t discarded_packets, begin_cs_value, end_cs_value;
- bt_clock_snapshot_state begin_cs_state, end_cs_state;
bt_property_availability prop_avail;
bt_message *out_message = NULL;
bt_stream *out_stream;
debug_it->ir_maps, in_stream);
BT_ASSERT(out_stream);
- default_cc = bt_stream_class_borrow_default_clock_class_const(
+ has_default_clock_snapshots =
+ bt_stream_class_discarded_packets_have_default_clock_snapshots(
bt_stream_borrow_class_const(in_stream));
- if (default_cc) {
- begin_cs_state =
+ if (has_default_clock_snapshots) {
+ begin_cs =
bt_message_discarded_packets_borrow_default_beginning_clock_snapshot_const(
- in_message, &begin_cs);
+ in_message);
- end_cs_state =
+ end_cs =
bt_message_discarded_packets_borrow_default_end_clock_snapshot_const(
- in_message, &end_cs);
-
- /*
- * Both clock snapshots should be known as we check that the
- * all input stream classes have an always known clock. Unknown
- * clock is not yet supported.
- */
- BT_ASSERT(begin_cs_state == BT_CLOCK_SNAPSHOT_STATE_KNOWN &&
- end_cs_state == BT_CLOCK_SNAPSHOT_STATE_KNOWN);
+ in_message);
begin_cs_value = bt_clock_snapshot_get_value(begin_cs);
end_cs_value = bt_clock_snapshot_get_value(end_cs);
return status;
}
+static
+void debug_info_msg_iter_destroy(struct debug_info_msg_iter *debug_info_msg_iter)
+{
+ if (!debug_info_msg_iter) {
+ goto end;
+ }
+
+ if (debug_info_msg_iter->msg_iter) {
+ bt_self_component_port_input_message_iterator_put_ref(
+ debug_info_msg_iter->msg_iter);
+ }
+
+ if (debug_info_msg_iter->ir_maps) {
+ trace_ir_maps_destroy(debug_info_msg_iter->ir_maps);
+ }
+
+ if (debug_info_msg_iter->debug_info_map) {
+ g_hash_table_destroy(debug_info_msg_iter->debug_info_map);
+ }
+
+ bt_fd_cache_fini(&debug_info_msg_iter->fd_cache);
+ g_free(debug_info_msg_iter);
+
+end:
+ return;
+}
+
BT_HIDDEN
bt_self_message_iterator_status debug_info_msg_iter_init(
bt_self_message_iterator *self_msg_iter,
bt_self_component_port_output *self_port)
{
bt_self_message_iterator_status status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
- struct bt_self_component_port_input *input_port;
- bt_self_component_port_input_message_iterator *upstream_iterator;
- struct debug_info_msg_iter *debug_info_msg_iter;
+ struct bt_self_component_port_input *input_port = NULL;
+ bt_self_component_port_input_message_iterator *upstream_iterator = NULL;
+ struct debug_info_msg_iter *debug_info_msg_iter = NULL;
gchar *debug_info_field_name;
int ret;
/* Borrow the upstream input port. */
input_port = bt_self_component_filter_borrow_input_port_by_name(
- self_comp, "in");
+ self_comp, "in");
if (!input_port) {
status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
- goto end;
+ goto error;
+ }
+
+ debug_info_msg_iter = g_new0(struct debug_info_msg_iter, 1);
+ if (!debug_info_msg_iter) {
+ status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
+ goto error;
}
/* Create an iterator on the upstream component. */
input_port);
if (!upstream_iterator) {
status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
- goto end;
+ goto error;
}
- debug_info_msg_iter = g_new0(struct debug_info_msg_iter, 1);
- if (!debug_info_msg_iter) {
- status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
- goto end;
- }
+ BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_MOVE_REF(
+ debug_info_msg_iter->msg_iter, upstream_iterator);
- /* Create hashtable to will contain debug info mapping. */
+ /* Create hashtable that will contain debug info mapping. */
debug_info_msg_iter->debug_info_map = g_hash_table_new_full(
- g_direct_hash, g_direct_equal,
- (GDestroyNotify) NULL,
- (GDestroyNotify) debug_info_destroy);
+ g_direct_hash, g_direct_equal, (GDestroyNotify) NULL,
+ (GDestroyNotify) debug_info_destroy);
if (!debug_info_msg_iter->debug_info_map) {
- g_free(debug_info_msg_iter);
status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
- goto end;
+ goto error;
}
debug_info_msg_iter->self_comp =
bt_self_component_filter_as_self_component(self_comp);
- BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_MOVE_REF(
- debug_info_msg_iter->msg_iter, upstream_iterator);
-
debug_info_msg_iter->debug_info_component = bt_self_component_get_data(
- bt_self_component_filter_as_self_component(
- self_comp));
+ bt_self_component_filter_as_self_component(
+ self_comp));
debug_info_field_name =
debug_info_msg_iter->debug_info_component->arg_debug_info_field_name;
debug_info_msg_iter->ir_maps = trace_ir_maps_create(
- bt_self_component_filter_as_self_component(self_comp),
- debug_info_field_name);
+ bt_self_component_filter_as_self_component(self_comp),
+ debug_info_field_name);
if (!debug_info_msg_iter->ir_maps) {
- g_hash_table_destroy(debug_info_msg_iter->debug_info_map);
- g_free(debug_info_msg_iter);
status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
- goto end;
+ goto error;
}
ret = bt_fd_cache_init(&debug_info_msg_iter->fd_cache);
if (ret) {
- trace_ir_maps_destroy(debug_info_msg_iter->ir_maps);
- g_hash_table_destroy(debug_info_msg_iter->debug_info_map);
- g_free(debug_info_msg_iter);
status = BT_SELF_MESSAGE_ITERATOR_STATUS_NOMEM;
- goto end;
+ goto error;
}
-
bt_self_message_iterator_set_data(self_msg_iter, debug_info_msg_iter);
-
debug_info_msg_iter->input_iterator = self_msg_iter;
+ goto end;
+
+error:
+ debug_info_msg_iter_destroy(debug_info_msg_iter);
end:
return status;
}
debug_info_msg_iter = bt_self_message_iterator_get_data(it);
BT_ASSERT(debug_info_msg_iter);
- bt_self_component_port_input_message_iterator_put_ref(
- debug_info_msg_iter->msg_iter);
-
- trace_ir_maps_destroy(debug_info_msg_iter->ir_maps);
- g_hash_table_destroy(debug_info_msg_iter->debug_info_map);
-
- bt_fd_cache_fini(&debug_info_msg_iter->fd_cache);
-
- g_free(debug_info_msg_iter);
+ debug_info_msg_iter_destroy(debug_info_msg_iter);
}