X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Fgraph%2Fiterator.c;h=1cb1e6a074f19af053650d58acdbe049987eda8b;hb=879e4affa41282c93773c01801343db28e36980f;hp=39746df3dcac71fa3f9779b96a87f9fb363be792;hpb=217fd08c67b8c038176241aef4bb658297d8beae;p=babeltrace.git diff --git a/src/lib/graph/iterator.c b/src/lib/graph/iterator.c index 39746df3..1cb1e6a0 100644 --- a/src/lib/graph/iterator.c +++ b/src/lib/graph/iterator.c @@ -65,7 +65,7 @@ (_iter)->state == BT_MESSAGE_ITERATOR_STATE_LAST_SEEKING_RETURNED_ERROR, \ "Message iterator is in the wrong state: %!+i", (_iter)) -#ifdef BT_DEV_MODE +BT_IF_DEV_MODE( struct per_stream_state { bt_packet *cur_packet; @@ -73,7 +73,7 @@ struct per_stream_state /* Bit mask of expected message types. */ guint expected_msg_types; }; -#endif +) static void clear_per_stream_state (struct bt_message_iterator *iterator) @@ -160,9 +160,7 @@ void bt_message_iterator_destroy(struct bt_object *obj) iterator->msgs = NULL; } -#ifdef BT_DEV_MODE - g_hash_table_destroy(iterator->per_stream_state); -#endif + BT_IF_DEV_MODE(g_hash_table_destroy(iterator->per_stream_state)); g_free(iterator); } @@ -371,14 +369,12 @@ int create_self_component_input_port_message_iterator( g_ptr_array_set_size(iterator->msgs, MSG_BATCH_SIZE); iterator->last_ns_from_origin = INT64_MIN; -#ifdef BT_DEV_MODE /* The per-stream state is only used for dev assertions right now. */ - iterator->per_stream_state = g_hash_table_new_full( + BT_IF_DEV_MODE(iterator->per_stream_state = g_hash_table_new_full( g_direct_hash, g_direct_equal, NULL, - g_free); -#endif + g_free)); iterator->auto_seek.msgs = g_queue_new(); if (!iterator->auto_seek.msgs) { @@ -681,97 +677,113 @@ void assert_post_dev_clock_classes_are_compatible_one( struct bt_message_iterator *iterator, const struct bt_message *msg) { - enum bt_message_type message_type = bt_message_get_type(msg); + const struct bt_clock_class *clock_class = NULL; + bt_uuid clock_class_uuid = NULL; - if (message_type == BT_MESSAGE_TYPE_STREAM_BEGINNING) { - const struct bt_message_stream *stream_msg = (struct bt_message_stream *) msg; - const struct bt_clock_class *clock_class = stream_msg->stream->class->default_clock_class; - bt_uuid clock_class_uuid = NULL; + switch (bt_message_get_type(msg)) { + case BT_MESSAGE_TYPE_STREAM_BEGINNING: + { + const struct bt_message_stream *stream_msg = + (struct bt_message_stream *) msg; - if (clock_class) { - clock_class_uuid = bt_clock_class_get_uuid(clock_class); - } + clock_class = stream_msg->stream->class->default_clock_class; + break; + } + case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY: + { + const struct bt_message_message_iterator_inactivity *mii_msg = + (struct bt_message_message_iterator_inactivity *) msg; - switch (iterator->clock_expectation.type) { - case CLOCK_EXPECTATION_UNSET: - /* - * This is the first time we see a message with a clock - * snapshot: record the properties of that clock, against - * which we'll compare the clock properties of the following - * messages. - */ + clock_class = mii_msg->cs->clock_class; + break; + } + default: + return; + } - if (!clock_class) { - iterator->clock_expectation.type = CLOCK_EXPECTATION_NONE; - } else if (bt_clock_class_origin_is_unix_epoch(clock_class)) { - iterator->clock_expectation.type = CLOCK_EXPECTATION_ORIGIN_UNIX; - } else if (clock_class_uuid) { - iterator->clock_expectation.type = CLOCK_EXPECTATION_ORIGIN_OTHER_UUID; - bt_uuid_copy(iterator->clock_expectation.uuid, clock_class_uuid); - } else { - iterator->clock_expectation.type = CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID; - iterator->clock_expectation.clock_class = clock_class; - bt_clock_class_get_ref(iterator->clock_expectation.clock_class); - } - break; + if (clock_class) { + clock_class_uuid = bt_clock_class_get_uuid(clock_class); + } - case CLOCK_EXPECTATION_NONE: - BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, - "stream-class-has-no-clock-class", !clock_class, - "Expecting no clock class, got one: %![cc-]+K", - clock_class); - break; + switch (iterator->clock_expectation.type) { + case CLOCK_EXPECTATION_UNSET: + /* + * This is the first time we see a message with a clock + * snapshot: record the properties of that clock, against + * which we'll compare the clock properties of the following + * messages. + */ - case CLOCK_EXPECTATION_ORIGIN_UNIX: - BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, - "stream-class-has-clock-class-with-unix-epoch-origin", clock_class, - "Expecting a clock class with Unix epoch origin, got none."); + if (!clock_class) { + iterator->clock_expectation.type = CLOCK_EXPECTATION_NONE; + } else if (bt_clock_class_origin_is_unix_epoch(clock_class)) { + iterator->clock_expectation.type = CLOCK_EXPECTATION_ORIGIN_UNIX; + } else if (clock_class_uuid) { + iterator->clock_expectation.type = CLOCK_EXPECTATION_ORIGIN_OTHER_UUID; + bt_uuid_copy(iterator->clock_expectation.uuid, clock_class_uuid); + } else { + iterator->clock_expectation.type = CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID; + iterator->clock_expectation.clock_class = clock_class; + bt_clock_class_get_ref(iterator->clock_expectation.clock_class); + } + break; - BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, - "clock-class-has-unix-epoch-origin", - bt_clock_class_origin_is_unix_epoch(clock_class), - "Expecting a clock class with Unix epoch origin: %![cc-]+K", - clock_class); - break; + case CLOCK_EXPECTATION_NONE: + BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, + "stream-class-has-no-clock-class", !clock_class, + "Expecting no clock class, got one: %![cc-]+K", + clock_class); + break; - case CLOCK_EXPECTATION_ORIGIN_OTHER_UUID: - BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, - "stream-class-has-clock-class-with-uuid", clock_class, - "Expecting a clock class with UUID, got none."); + case CLOCK_EXPECTATION_ORIGIN_UNIX: + BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, + "stream-class-has-clock-class-with-unix-epoch-origin", clock_class, + "Expecting a clock class with Unix epoch origin, got none."); - BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, - "clock-class-has-non-unix-epoch-origin", - !bt_clock_class_origin_is_unix_epoch(clock_class), - "Expecting a clock class without Unix epoch origin: %![cc-]+K", - clock_class); + BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, + "clock-class-has-unix-epoch-origin", + bt_clock_class_origin_is_unix_epoch(clock_class), + "Expecting a clock class with Unix epoch origin: %![cc-]+K", + clock_class); + break; - BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, - "clock-class-has-uuid", - clock_class_uuid, - "Expecting a clock class with UUID, got one without UUID: %![cc-]+K", - clock_class); + case CLOCK_EXPECTATION_ORIGIN_OTHER_UUID: + BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, + "stream-class-has-clock-class-with-uuid", clock_class, + "Expecting a clock class with UUID, got none."); - BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, - "clock-class-has-expected-uuid", - !bt_uuid_compare(iterator->clock_expectation.uuid, clock_class_uuid), - "Expecting a clock class with UUID, got one " - "with a different UUID: %![cc-]+K, expected-uuid=%!u", - clock_class, iterator->clock_expectation.uuid); - break; + BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, + "clock-class-has-non-unix-epoch-origin", + !bt_clock_class_origin_is_unix_epoch(clock_class), + "Expecting a clock class without Unix epoch origin: %![cc-]+K", + clock_class); - case CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID: - BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, - "stream-class-has-clock-class", clock_class, - "Expecting a clock class, got none."); + BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, + "clock-class-has-uuid", + clock_class_uuid, + "Expecting a clock class with UUID, got one without UUID: %![cc-]+K", + clock_class); - BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, - "clock-class-is-expected", - clock_class == iterator->clock_expectation.clock_class, - "Expecting clock class %![cc-]+K, got %![cc-]+K.", - iterator->clock_expectation.clock_class, - clock_class); - break; - } + BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, + "clock-class-has-expected-uuid", + !bt_uuid_compare(iterator->clock_expectation.uuid, clock_class_uuid), + "Expecting a clock class with UUID, got one " + "with a different UUID: %![cc-]+K, expected-uuid=%!u", + clock_class, iterator->clock_expectation.uuid); + break; + + case CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID: + BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, + "stream-class-has-clock-class", clock_class, + "Expecting a clock class, got none."); + + BT_ASSERT_POST_DEV(NEXT_METHOD_NAME, + "clock-class-is-expected", + clock_class == iterator->clock_expectation.clock_class, + "Expecting clock class %![cc-]+K, got %![cc-]+K.", + iterator->clock_expectation.clock_class, + clock_class); + break; } } @@ -1151,9 +1163,8 @@ call_iterator_next_method( "Clock snapshots are not monotonic"); } -#ifdef BT_DEV_MODE - assert_post_dev_next(iterator, status, msgs, *user_count); -#endif + BT_IF_DEV_MODE(assert_post_dev_next(iterator, status, msgs, + *user_count)); BT_ASSERT_POST_DEV_NO_ERROR_IF_NO_ERROR_STATUS(NEXT_METHOD_NAME, status); @@ -1434,7 +1445,6 @@ void reset_iterator_expectations( struct bt_message_iterator *iterator) { iterator->last_ns_from_origin = INT64_MIN; - iterator->clock_expectation.type = CLOCK_EXPECTATION_UNSET; } static