From 60d02328261d37044d37a7d77b3d3847db5c72bf Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Tue, 14 Jan 2020 13:36:51 -0500 Subject: [PATCH] lib: msg. iter. inactivity message has a simple CS, not a default CS 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 Change-Id: I0142c4f91217791e3157d37a32f4e2f234afa8d2 Reviewed-on: https://review.lttng.org/c/babeltrace/+/2801 Tested-by: jenkins --- ...essage-message-iterator-inactivity-const.h | 2 +- .../message-message-iterator-inactivity.h | 2 +- src/bindings/python/bt2/bt2/message.py | 10 +++---- src/lib/graph/iterator.c | 4 +-- .../message/message-iterator-inactivity.c | 26 +++++++++---------- .../message/message-iterator-inactivity.h | 2 +- src/plugins/common/muxing/muxing.c | 4 +-- src/plugins/ctf/lttng-live/lttng-live.c | 2 +- src/plugins/text/details/write.c | 2 +- src/plugins/utils/muxer/muxer.c | 4 +-- src/plugins/utils/trimmer/trimmer.c | 2 +- tests/bindings/python/bt2/test_message.py | 5 ++-- 12 files changed, 32 insertions(+), 33 deletions(-) diff --git a/include/babeltrace2/graph/message-message-iterator-inactivity-const.h b/include/babeltrace2/graph/message-message-iterator-inactivity-const.h index 43b29da7..ce5ed337 100644 --- a/include/babeltrace2/graph/message-message-iterator-inactivity-const.h +++ b/include/babeltrace2/graph/message-message-iterator-inactivity-const.h @@ -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 diff --git a/include/babeltrace2/graph/message-message-iterator-inactivity.h b/include/babeltrace2/graph/message-message-iterator-inactivity.h index 5edffd0a..dba7c4a4 100644 --- a/include/babeltrace2/graph/message-message-iterator-inactivity.h +++ b/include/babeltrace2/graph/message-message-iterator-inactivity.h @@ -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 } diff --git a/src/bindings/python/bt2/bt2/message.py b/src/bindings/python/bt2/bt2/message.py index cdf18879..fd92361d 100644 --- a/src/bindings/python/bt2/bt2/message.py +++ b/src/bindings/python/bt2/bt2/message.py @@ -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( diff --git a/src/lib/graph/iterator.c b/src/lib/graph/iterator.c index 61537319..5b2ebfbd 100644 --- a/src/lib/graph/iterator.c +++ b/src/lib/graph/iterator.c @@ -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: @@ -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; } diff --git a/src/lib/graph/message/message-iterator-inactivity.c b/src/lib/graph/message/message-iterator-inactivity.c index 94964019..d0c27e3d 100644 --- a/src/lib/graph/message/message-iterator-inactivity.c +++ b/src/lib/graph/message/message-iterator-inactivity.c @@ -43,9 +43,9 @@ 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); @@ -53,7 +53,7 @@ void bt_message_message_iterator_inactivity_destroy(struct bt_object *obj) 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 = @@ -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( @@ -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); @@ -97,7 +97,7 @@ end: } 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; @@ -105,5 +105,5 @@ bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const( 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; } diff --git a/src/lib/graph/message/message-iterator-inactivity.h b/src/lib/graph/message/message-iterator-inactivity.h index 12806bfb..6e8c1fdd 100644 --- a/src/lib/graph/message/message-iterator-inactivity.h +++ b/src/lib/graph/message/message-iterator-inactivity.h @@ -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 */ diff --git a/src/plugins/common/muxing/muxing.c b/src/plugins/common/muxing/muxing.c index 93ba1a34..cd97798a 100644 --- a/src/plugins/common/muxing/muxing.c +++ b/src/plugins/common/muxing/muxing.c @@ -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); diff --git a/src/plugins/ctf/lttng-live/lttng-live.c b/src/plugins/ctf/lttng-live/lttng-live.c index d812e818..35e1037f 100644 --- a/src/plugins/ctf/lttng-live/lttng-live.c +++ b/src/plugins/ctf/lttng-live/lttng-live.c @@ -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: diff --git a/src/plugins/text/details/write.c b/src/plugins/text/details/write.c index b98efb78..6d555a5f 100644 --- a/src/plugins/text/details/write.c +++ b/src/plugins/text/details/write.c @@ -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 */ diff --git a/src/plugins/utils/muxer/muxer.c b/src/plugins/utils/muxer/muxer.c index 2554d270..26fb3b6e 100644 --- a/src/plugins/utils/muxer/muxer.c +++ b/src/plugins/utils/muxer/muxer.c @@ -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: @@ -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)); diff --git a/src/plugins/utils/trimmer/trimmer.c b/src/plugins/utils/trimmer/trimmer.c index e46884de..ce69f971 100644 --- a/src/plugins/utils/trimmer/trimmer.c +++ b/src/plugins/utils/trimmer/trimmer.c @@ -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: diff --git a/tests/bindings/python/bt2/test_message.py b/tests/bindings/python/bt2/test_message.py index 012c851f..7c26a935 100644 --- a/tests/bindings/python/bt2/test_message.py +++ b/tests/bindings/python/bt2/test_message.py @@ -215,10 +215,9 @@ class AllMessagesTestCase(unittest.TestCase): 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) -- 2.34.1