Skip to content

Commit

Permalink
lib: msg. iter. inactivity message has a simple CS, not a default CS
Browse files Browse the repository at this point in the history
The "default clock snapshot" properties of some types of messages come
from the fact that a stream class has a default clock class, and
therefore its streams have a default clock.

A message iterator inactivity message is not related to any stream, so
it doesn't have a "default" clock class: it has a simple clock class,
and therefore a simple clock snapshot.

Update the C and Python APIs to show this.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I0142c4f91217791e3157d37a32f4e2f234afa8d2
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2801
Tested-by: jenkins <jenkins@lttng.org>
  • Loading branch information
eepp authored and jgalar committed Jan 20, 2020
1 parent e1b15e5 commit 62988c5
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern "C" {
#endif

extern const bt_clock_snapshot *
bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(
bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(
const bt_message *msg);

#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extern "C" {
extern
bt_message *bt_message_message_iterator_inactivity_create(
bt_self_message_iterator *message_iterator,
const bt_clock_class *default_clock_class, uint64_t raw_value);
const bt_clock_class *clock_class, uint64_t raw_value);

#ifdef __cplusplus
}
Expand Down
10 changes: 5 additions & 5 deletions src/bindings/python/bt2/bt2/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ class _StreamEndMessage(_StreamMessage):
class _MessageIteratorInactivityMessageConst(
_MessageConst, _MessageWithDefaultClockSnapshot
):
_borrow_default_clock_snapshot_ptr = staticmethod(
native_bt.message_message_iterator_inactivity_borrow_default_clock_snapshot_const
_borrow_clock_snapshot_ptr = staticmethod(
native_bt.message_message_iterator_inactivity_borrow_clock_snapshot_const
)

@property
def default_clock_snapshot(self):
# This kind of message always has a default clock class: no
def clock_snapshot(self):
# This kind of message always has a clock class: no
# need to call self._check_has_default_clock_class() here.
return self._get_default_clock_snapshot(self._borrow_default_clock_snapshot_ptr)
return self._get_default_clock_snapshot(self._borrow_clock_snapshot_ptr)


class _MessageIteratorInactivityMessage(
Expand Down
4 changes: 2 additions & 2 deletions src/lib/graph/iterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ bool clock_snapshots_are_monotonic_one(
{
struct bt_message_message_iterator_inactivity *inactivity_msg =
(struct bt_message_message_iterator_inactivity *) msg;
clock_snapshot = inactivity_msg->default_cs;
clock_snapshot = inactivity_msg->cs;
break;
}
case BT_MESSAGE_TYPE_PACKET_BEGINNING:
Expand Down Expand Up @@ -1261,7 +1261,7 @@ int auto_seek_handle_message(
const struct bt_message_message_iterator_inactivity *inactivity_msg =
(const void *) msg;

clk_snapshot = inactivity_msg->default_cs;
clk_snapshot = inactivity_msg->cs;
BT_ASSERT_DBG(clk_snapshot);
break;
}
Expand Down
26 changes: 13 additions & 13 deletions src/lib/graph/message/message-iterator-inactivity.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ void bt_message_message_iterator_inactivity_destroy(struct bt_object *obj)
BT_LIB_LOGD("Destroying message iterator inactivity message: %!+n",
message);

if (message->default_cs) {
bt_clock_snapshot_recycle(message->default_cs);
message->default_cs = NULL;
if (message->cs) {
bt_clock_snapshot_recycle(message->cs);
message->cs = NULL;
}

g_free(message);
}

struct bt_message *bt_message_message_iterator_inactivity_create(
struct bt_self_message_iterator *self_msg_iter,
const struct bt_clock_class *default_clock_class,
const struct bt_clock_class *clock_class,
uint64_t value_cycles)
{
struct bt_message_iterator *msg_iter =
Expand All @@ -63,10 +63,10 @@ struct bt_message *bt_message_message_iterator_inactivity_create(

BT_ASSERT_PRE_DEV_NO_ERROR();
BT_ASSERT_PRE_NON_NULL(msg_iter, "Message iterator");
BT_ASSERT_PRE_NON_NULL(default_clock_class, "Default clock class");
BT_ASSERT_PRE_NON_NULL(clock_class, "Default clock class");
BT_LIB_LOGD("Creating message iterator inactivity message object: "
"%![iter-]+i, %![default-cc-]+K, value=%" PRIu64, msg_iter,
default_clock_class, value_cycles);
"%![iter-]+i, %![cc-]+K, value=%" PRIu64, msg_iter,
clock_class, value_cycles);
message = g_new0(struct bt_message_message_iterator_inactivity, 1);
if (!message) {
BT_LIB_LOGE_APPEND_CAUSE(
Expand All @@ -78,12 +78,12 @@ struct bt_message *bt_message_message_iterator_inactivity_create(
BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY,
bt_message_message_iterator_inactivity_destroy, NULL);
ret_msg = &message->parent;
message->default_cs = bt_clock_snapshot_create(
(void *) default_clock_class);
if (!message->default_cs) {
message->cs = bt_clock_snapshot_create(
(void *) clock_class);
if (!message->cs) {
goto error;
}
bt_clock_snapshot_set_raw_value(message->default_cs, value_cycles);
bt_clock_snapshot_set_raw_value(message->cs, value_cycles);

BT_LIB_LOGD("Created message iterator inactivity message object: %!+n",
ret_msg);
Expand All @@ -97,13 +97,13 @@ struct bt_message *bt_message_message_iterator_inactivity_create(
}

extern const struct bt_clock_snapshot *
bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(
bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(
const bt_message *msg)
{
struct bt_message_message_iterator_inactivity *inactivity = (void *) msg;

BT_ASSERT_PRE_DEV_NON_NULL(msg, "Message");
BT_ASSERT_PRE_DEV_MSG_IS_TYPE(msg,
BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY);
return inactivity->default_cs;
return inactivity->cs;
}
2 changes: 1 addition & 1 deletion src/lib/graph/message/message-iterator-inactivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

struct bt_message_message_iterator_inactivity {
struct bt_message parent;
struct bt_clock_snapshot *default_cs;
struct bt_clock_snapshot *cs;
};

#endif /* BABELTRACE_GRAPH_MESSAGE_MESSAGE_ITERATOR_INACTIVITY_INTERNAL_H */
4 changes: 2 additions & 2 deletions src/plugins/common/muxing/muxing.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,9 +820,9 @@ int compare_messages_same_type(struct messages_to_compare *msgs)
case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY:
{
const bt_clock_snapshot *left_cs =
bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(msgs->left.msg);
bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(msgs->left.msg);
const bt_clock_snapshot *right_cs =
bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(msgs->right.msg);
bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(msgs->right.msg);

ret = compare_clock_snapshots_and_clock_classes(
left_cs, right_cs);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/ctf/lttng-live/lttng-live.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ int live_get_msg_ts_ns(struct lttng_live_stream_iterator *stream_iter,
msg);
break;
case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY:
clock_snapshot = bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(
clock_snapshot = bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(
msg);
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/text/details/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -2512,7 +2512,7 @@ int write_message_iterator_inactivity_message(struct details_write_ctx *ctx,
{
int ret = 0;
const bt_clock_snapshot *cs =
bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(
bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(
msg);

/* Write time */
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/utils/muxer/muxer.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ int get_msg_ts_ns(struct muxer_comp *muxer_comp,

break;
case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY:
clock_snapshot = bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(
clock_snapshot = bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(
msg);
break;
default:
Expand Down Expand Up @@ -852,7 +852,7 @@ muxer_msg_iter_youngest_upstream_msg_iter(
BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY)) {
const bt_clock_snapshot *cs;

cs = bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(
cs = bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(
msg);
ret = validate_clock_class(muxer_msg_iter, muxer_comp,
bt_clock_snapshot_borrow_clock_class_const(cs));
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/utils/trimmer/trimmer.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ int get_msg_ns_from_origin(const bt_message *msg, int64_t *ns_from_origin,
break;
case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY:
clock_snapshot =
bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(
bt_message_message_iterator_inactivity_borrow_clock_snapshot_const(
msg);
break;
default:
Expand Down
5 changes: 2 additions & 3 deletions tests/bindings/python/bt2/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,9 @@ def test_all_msg_with_cc(self):
elif i == 3:
self.assertIs(type(msg), bt2._MessageIteratorInactivityMessageConst)
self.assertIs(
type(msg.default_clock_snapshot),
bt2_clock_snapshot._ClockSnapshotConst,
type(msg.clock_snapshot), bt2_clock_snapshot._ClockSnapshotConst
)
self.assertEqual(msg.default_clock_snapshot.value, i)
self.assertEqual(msg.clock_snapshot.value, i)
elif i == 4:
self.assertIs(type(msg), bt2._DiscardedEventsMessageConst)
self.assertIs(type(msg.stream), bt2_stream._StreamConst)
Expand Down

0 comments on commit 62988c5

Please sign in to comment.