extern bt_bool bt_stream_class_assigns_automatic_stream_id(
const bt_stream_class *stream_class);
+extern bt_bool bt_stream_class_packets_have_default_beginning_clock_snapshot(
+ const bt_stream_class *stream_class);
+
+extern bt_bool bt_stream_class_packets_have_default_end_clock_snapshot(
+ const bt_stream_class *stream_class);
+
extern uint64_t bt_stream_class_get_id(
const bt_stream_class *stream_class);
uint64_t id;
bool assigns_automatic_event_class_id;
bool assigns_automatic_stream_id;
+ bool packets_have_default_beginning_clock_snapshot;
+ bool packets_have_default_end_clock_snapshot;
struct bt_field_class *packet_context_fc;
struct bt_field_class *event_common_context_fc;
struct bt_clock_class *default_clock_class;
extern void bt_stream_class_set_assigns_automatic_stream_id(
bt_stream_class *stream_class, bt_bool value);
+extern void bt_stream_class_set_packets_have_default_beginning_clock_snapshot(
+ bt_stream_class *stream_class, bt_bool value);
+
+extern void bt_stream_class_set_packets_have_default_end_clock_snapshot(
+ bt_stream_class *stream_class, bt_bool value);
+
extern bt_stream_class_status
bt_stream_class_set_packet_context_field_class(
bt_stream_class *stream_class,
struct bt_message *create_packet_message(
struct bt_self_component_port_input_message_iterator *msg_iter,
struct bt_packet *packet, struct bt_object_pool *pool,
- bool with_cs, uint64_t raw_value)
+ bool with_cs, bool is_beginning, uint64_t raw_value)
{
struct bt_message_packet *message = NULL;
struct bt_stream *stream;
struct bt_stream_class *stream_class;
+ bool packet_has_default_clock_snapshot;
BT_ASSERT(msg_iter);
BT_ASSERT_PRE_NON_NULL(packet, "Packet");
BT_ASSERT(stream);
stream_class = bt_stream_borrow_class(stream);
BT_ASSERT(stream_class);
- BT_ASSERT_PRE((with_cs && stream_class->default_clock_class) ||
- (!with_cs && !stream_class->default_clock_class),
+
+ if (is_beginning) {
+ packet_has_default_clock_snapshot =
+ stream_class->packets_have_default_beginning_clock_snapshot;
+ } else {
+ packet_has_default_clock_snapshot =
+ stream_class->packets_have_default_end_clock_snapshot;
+ }
+
+ /*
+ * `packet_has_default_clock_snapshot` implies that the stream
+ * class has a default clock class (precondition).
+ */
+ BT_ASSERT_PRE((with_cs && packet_has_default_clock_snapshot) ||
+ (!with_cs && !packet_has_default_clock_snapshot),
"Creating a packet message with a default clock snapshot, but without "
"a default clock class, or without a default clock snapshot, "
"but with a default clock class: ",
BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator");
return create_packet_message(msg_iter, (void *) packet,
- &msg_iter->graph->packet_begin_msg_pool, false, 0);
+ &msg_iter->graph->packet_begin_msg_pool, false, true, 0);
}
struct bt_message *bt_message_packet_beginning_create_with_default_clock_snapshot(
BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator");
return create_packet_message(msg_iter, (void *) packet,
- &msg_iter->graph->packet_begin_msg_pool, true, raw_value);
+ &msg_iter->graph->packet_begin_msg_pool, true, true, raw_value);
}
struct bt_message *bt_message_packet_end_create(
BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator");
return create_packet_message(msg_iter, (void *) packet,
- &msg_iter->graph->packet_end_msg_pool, false, 0);
+ &msg_iter->graph->packet_end_msg_pool, false, false, 0);
}
struct bt_message *bt_message_packet_end_create_with_default_clock_snapshot(
BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator");
return create_packet_message(msg_iter, (void *) packet,
- &msg_iter->graph->packet_end_msg_pool, true, raw_value);
+ &msg_iter->graph->packet_end_msg_pool, true, false, raw_value);
}
BT_HIDDEN
"assignment property: %!+S", stream_class);
}
+bt_bool bt_stream_class_packets_have_default_beginning_clock_snapshot(
+ const struct bt_stream_class *stream_class)
+{
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ return (bt_bool) stream_class->packets_have_default_beginning_clock_snapshot;
+}
+
+void bt_stream_class_set_packets_have_default_beginning_clock_snapshot(
+ struct bt_stream_class *stream_class, bt_bool value)
+{
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
+ BT_ASSERT_PRE(!value || stream_class->default_clock_class,
+ "Stream class has no default clock class: %!+S", stream_class);
+ stream_class->packets_have_default_beginning_clock_snapshot =
+ (bool) value;
+ BT_LIB_LOGV("Set stream class's \"packets have default beginning "
+ "clock snapshot\" property: %!+S", stream_class);
+}
+
+bt_bool bt_stream_class_packets_have_default_end_clock_snapshot(
+ const struct bt_stream_class *stream_class)
+{
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ return (bt_bool) stream_class->packets_have_default_end_clock_snapshot;
+}
+
+void bt_stream_class_set_packets_have_default_end_clock_snapshot(
+ struct bt_stream_class *stream_class, bt_bool value)
+{
+ BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+ BT_ASSERT_PRE_STREAM_CLASS_HOT(stream_class);
+ BT_ASSERT_PRE(!value || stream_class->default_clock_class,
+ "Stream class has no default clock class: %!+S", stream_class);
+ stream_class->packets_have_default_end_clock_snapshot =
+ (bool) value;
+ BT_LIB_LOGV("Set stream class's \"packets have default end "
+ "clock snapshot\" property: %!+S", stream_class);
+}
+
bt_bool bt_stream_class_assigns_automatic_stream_id(
const struct bt_stream_class *stream_class)
{
ret = bt_stream_class_set_default_clock_class(ctx->ir_sc,
ctx->sc->default_clock_class->ir_cc);
BT_ASSERT(ret == 0);
+ bt_stream_class_set_packets_have_default_beginning_clock_snapshot(
+ ctx->ir_sc, BT_TRUE);
+ bt_stream_class_set_packets_have_default_end_clock_snapshot(
+ ctx->ir_sc, BT_TRUE);
}
ctx->sc->is_translated = true;
bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
const bt_stream *ir_stream =
bt_message_stream_beginning_borrow_stream_const(msg);
+ const bt_stream_class *ir_sc =
+ bt_stream_borrow_class_const(ir_stream);
struct fs_sink_stream *stream;
+ /*
+ * Temporary: if the stream's class has a default clock class,
+ * make sure packet beginning and end messages have default
+ * clock snapshots until the support for not having them is
+ * implemented.
+ */
+ if (bt_stream_class_borrow_default_clock_class_const(ir_sc)) {
+ if (!bt_stream_class_packets_have_default_beginning_clock_snapshot(
+ ir_sc)) {
+ BT_LOGE("Unsupported stream: packets have "
+ "no beginning clock snapshot: "
+ "stream-addr=%p, "
+ "stream-id=%" PRIu64 ", "
+ "stream-name=\"%s\"",
+ ir_stream, bt_stream_get_id(ir_stream),
+ bt_stream_get_name(ir_stream));
+ status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
+ goto end;
+ }
+
+ if (!bt_stream_class_packets_have_default_end_clock_snapshot(
+ ir_sc)) {
+ BT_LOGE("Unsupported stream: packets have "
+ "no end clock snapshot: "
+ "stream-addr=%p, "
+ "stream-id=%" PRIu64 ", "
+ "stream-name=\"%s\"",
+ ir_stream, bt_stream_get_id(ir_stream),
+ bt_stream_get_name(ir_stream));
+ status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
+ goto end;
+ }
+ }
+
stream = borrow_stream(fs_sink, ir_stream);
if (!stream) {
status = BT_SELF_COMPONENT_STATUS_ERROR;
bt_message *handle_packet_begin_message(struct debug_info_msg_iter *debug_it,
const bt_message *in_message)
{
- const bt_clock_class *default_cc;
+ 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 = bt_message_packet_beginning_borrow_default_clock_snapshot_const(
in_message);
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_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 = bt_message_packet_end_borrow_default_clock_snapshot_const(
in_message);
}
+ bt_stream_class_set_packets_have_default_beginning_clock_snapshot(
+ out_stream_class,
+ bt_stream_class_packets_have_default_beginning_clock_snapshot(
+ in_stream_class));
+ bt_stream_class_set_packets_have_default_end_clock_snapshot(
+ out_stream_class,
+ bt_stream_class_packets_have_default_end_clock_snapshot(
+ in_stream_class));
+
in_name = bt_stream_class_get_name(in_stream_class);
if (in_name) {
status = bt_stream_class_set_name(out_stream_class, in_name);
BT_LOGE_STR("Cannot set stream class's default clock class.");
goto error;
}
+
+ bt_stream_class_set_packets_have_default_beginning_clock_snapshot(
+ dmesg_comp->stream_class, BT_TRUE);
+ bt_stream_class_set_packets_have_default_end_clock_snapshot(
+ dmesg_comp->stream_class, BT_TRUE);
}
dmesg_comp->event_class = bt_event_class_create(
const bt_clock_snapshot *clock_snapshot = NULL;
int ret = 0;
bt_message_stream_activity_clock_snapshot_state sa_cs_state;
+ const bt_stream_class *stream_class = NULL;
+ bt_message_type msg_type;
BT_ASSERT(msg);
BT_ASSERT(ts_ns);
goto end;
}
- switch (bt_message_get_type(msg)) {
+ msg_type = bt_message_get_type(msg);
+
+ if (unlikely(msg_type == BT_MESSAGE_TYPE_PACKET_BEGINNING)) {
+ stream_class = bt_stream_borrow_class_const(
+ bt_packet_borrow_stream_const(
+ bt_message_packet_beginning_borrow_packet_const(
+ msg)));
+ } else if (unlikely(msg_type == BT_MESSAGE_TYPE_PACKET_END)) {
+ stream_class = bt_stream_borrow_class_const(
+ bt_packet_borrow_stream_const(
+ bt_message_packet_end_borrow_packet_const(
+ msg)));
+ }
+
+ switch (msg_type) {
case BT_MESSAGE_TYPE_EVENT:
BT_ASSERT(bt_message_event_borrow_stream_class_default_clock_class_const(
msg));
msg);
break;
case BT_MESSAGE_TYPE_PACKET_BEGINNING:
- BT_ASSERT(bt_message_packet_beginning_borrow_stream_class_default_clock_class_const(
- msg));
- clock_snapshot = bt_message_packet_beginning_borrow_default_clock_snapshot_const(
- msg);
+ if (bt_stream_class_packets_have_default_beginning_clock_snapshot(
+ stream_class)) {
+ clock_snapshot = bt_message_packet_beginning_borrow_default_clock_snapshot_const(
+ msg);
+ } else {
+ goto no_clock_snapshot;
+ }
+
break;
case BT_MESSAGE_TYPE_PACKET_END:
- BT_ASSERT(bt_message_packet_end_borrow_stream_class_default_clock_class_const(
- msg));
- clock_snapshot = bt_message_packet_end_borrow_default_clock_snapshot_const(
- msg);
+ if (bt_stream_class_packets_have_default_end_clock_snapshot(
+ stream_class)) {
+ clock_snapshot = bt_message_packet_end_borrow_default_clock_snapshot_const(
+ msg);
+ } else {
+ goto no_clock_snapshot;
+ }
+
break;
case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
BT_ASSERT(bt_message_discarded_events_borrow_stream_class_default_clock_class_const(
goto end;
}
+ /*
+ * Temporary: make sure packet beginning and end
+ * messages have default clock snapshots until
+ * the support for not having them is
+ * implemented.
+ */
+ if (!bt_stream_class_packets_have_default_beginning_clock_snapshot(
+ sc)) {
+ BT_LOGE("Unsupported stream: packets have "
+ "no beginning clock snapshot: "
+ "stream-addr=%p, "
+ "stream-id=%" PRIu64 ", "
+ "stream-name=\"%s\"",
+ stream, bt_stream_get_id(stream),
+ bt_stream_get_name(stream));
+ status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
+ goto end;
+ }
+
+ if (!bt_stream_class_packets_have_default_end_clock_snapshot(
+ sc)) {
+ BT_LOGE("Unsupported stream: packets have "
+ "no end clock snapshot: "
+ "stream-addr=%p, "
+ "stream-id=%" PRIu64 ", "
+ "stream-name=\"%s\"",
+ stream, bt_stream_get_id(stream),
+ bt_stream_get_name(stream));
+ status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
+ goto end;
+ }
+
sstate = g_new0(struct trimmer_iterator_stream_state,
1);
if (!sstate) {