#include <babeltrace/graph/port.h>
#include <babeltrace/graph/graph-internal.h>
#include <babeltrace/types.h>
+#include <babeltrace/assert-internal.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
static
void destroy_action(struct action *action)
{
- assert(action);
+ BT_ASSERT(action);
switch (action->type) {
case ACTION_TYPE_PUSH_NOTIF:
{
struct bt_notification_iterator_private_connection *iterator;
- assert(obj);
+ BT_ASSERT(obj);
/*
* The notification iterator's reference count is 0 if we're
g_hash_table_iter_init(&ht_iter, iterator->stream_states);
while (g_hash_table_iter_next(&ht_iter, &stream_gptr, &stream_state_gptr)) {
- assert(stream_gptr);
+ BT_ASSERT(stream_gptr);
BT_LOGD_STR("Removing stream's destroy listener for notification iterator.");
bt_stream_remove_destroy_listener(
bt_component_class_notification_iterator_finalize_method
finalize_method = NULL;
- assert(iterator);
+ BT_ASSERT(iterator);
switch (iterator->state) {
case BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_NON_INITIALIZED:
iterator->state = BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_FINALIZED;
}
- assert(iterator->upstream_component);
+ BT_ASSERT(iterator->upstream_component);
comp_class = iterator->upstream_component->class;
/* Call user-defined destroy method */
struct bt_notification_iterator_private_connection *iterator,
struct bt_connection *connection)
{
- assert(iterator);
+ BT_ASSERT(iterator);
iterator->connection = connection;
BT_LOGV("Set notification iterator's connection: "
"iter-addr=%p, conn-addr=%p", iterator, connection);
const enum bt_notification_type *notif_type;
int ret = 0;
- assert(notif_types);
+ BT_ASSERT(notif_types);
iterator->subscription_mask = 0;
for (notif_type = notif_types;
enum bt_component_class_type type;
struct bt_notification_iterator_private_connection *iterator = NULL;
- assert(upstream_comp);
- assert(upstream_port);
- assert(notification_types);
- assert(bt_port_is_connected(upstream_port));
- assert(user_iterator);
+ BT_ASSERT(upstream_comp);
+ BT_ASSERT(upstream_port);
+ BT_ASSERT(notification_types);
+ BT_ASSERT(bt_port_is_connected(upstream_port));
+ BT_ASSERT(user_iterator);
BT_LOGD("Creating notification iterator on private connection: "
"upstream-comp-addr=%p, upstream-comp-name=\"%s\", "
"upstream-port-addr=%p, upstream-port-name=\"%s\", "
upstream_port, bt_port_get_name(upstream_port),
connection);
type = bt_component_get_class_type(upstream_comp);
- assert(type == BT_COMPONENT_CLASS_TYPE_SOURCE ||
+ BT_ASSERT(type == BT_COMPONENT_CLASS_TYPE_SOURCE ||
type == BT_COMPONENT_CLASS_TYPE_FILTER);
iterator = g_new0(struct bt_notification_iterator_private_connection, 1);
if (!iterator) {
struct stream_state *stream_state;
struct bt_port *stream_comp_cur_port;
- assert(notif_stream);
+ BT_ASSERT(notif_stream);
stream_comp_cur_port =
bt_stream_port_for_component(notif_stream,
iterator->upstream_component);
.type = ACTION_TYPE_PUSH_NOTIF,
};
- assert(notif);
+ BT_ASSERT(notif);
if (!is_subscribed_to_notification_type(iterator, notif->type)) {
return;
goto end;
}
- assert(stream);
+ BT_ASSERT(stream);
stream_begin_notif = bt_notification_stream_begin_create(stream);
if (!stream_begin_notif) {
BT_LOGE_STR("Cannot create stream beginning notification.");
goto end;
}
- assert(stream);
+ BT_ASSERT(stream);
stream_end_notif = bt_notification_stream_end_create(stream);
if (!stream_end_notif) {
BT_LOGE_STR("Cannot create stream end notification.");
goto end;
}
- assert(packet);
+ BT_ASSERT(packet);
packet_begin_notif = bt_notification_packet_begin_create(packet);
if (!packet_begin_notif) {
BT_LOGE_STR("Cannot create packet beginning notification.");
goto end;
}
- assert(packet);
+ BT_ASSERT(packet);
packet_end_notif = bt_notification_packet_end_create(packet);
if (!packet_end_notif) {
BT_LOGE_STR("Cannot create packet end notification.");
},
};
- assert(stream_state);
+ BT_ASSERT(stream_state);
add_action(iterator, &action);
BT_LOGV("Added \"set stream state's ended\" action: "
"stream-state-addr=%p", stream_state);
},
};
- assert(stream_state);
+ BT_ASSERT(stream_state);
add_action(iterator, &action);
BT_LOGV("Added \"set stream state's current packet\" action: "
"stream-state-addr=%p, packet-addr=%p",
},
};
- assert(stream_state);
- assert(type == ACTION_TYPE_UPDATE_STREAM_STATE_DISCARDED_PACKETS ||
+ BT_ASSERT(stream_state);
+ BT_ASSERT(type == ACTION_TYPE_UPDATE_STREAM_STATE_DISCARDED_PACKETS ||
type == ACTION_TYPE_UPDATE_STREAM_STATE_DISCARDED_EVENTS);
add_action(iterator, &action);
if (type == ACTION_TYPE_UPDATE_STREAM_STATE_DISCARDED_PACKETS) {
}
ft = bt_field_get_type(field);
- assert(ft);
+ BT_ASSERT(ft);
if (bt_field_type_integer_is_signed(ft)) {
BT_LOGV("Skipping `%s` integer field because its type is signed: "
goto end;
}
- assert(bt_field_is_integer(field));
+ BT_ASSERT(bt_field_is_integer(field));
ret = bt_field_unsigned_integer_get_value(field, &retval);
if (ret) {
BT_LOGV("Cannot get raw value of packet's context field's `events_discarded` integer field: "
goto end;
}
- assert(bt_field_is_integer(field));
+ BT_ASSERT(bt_field_is_integer(field));
ret = bt_field_unsigned_integer_get_value(field, &retval);
if (ret) {
BT_LOGV("Cannot get raw value of packet's context field's `packet_seq_num` integer field: "
}
ft = bt_field_get_type(field);
- assert(ft);
+ BT_ASSERT(ft);
clock_class = bt_field_type_integer_get_mapped_clock_class(ft);
if (!clock_class) {
BT_LOGW("Integer field type has no mapped clock class but it's expected to have one: "
int ret = 0;
struct stream_state *stream_state;
- assert(notif->type == BT_NOTIFICATION_TYPE_STREAM_BEGIN);
- assert(notif_stream);
+ BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_STREAM_BEGIN);
+ BT_ASSERT(notif_stream);
ret = ensure_stream_state_exists(iterator, notif, notif_stream,
&stream_state);
if (ret) {
int ret = 0;
struct stream_state *stream_state;
- assert(notif->type == BT_NOTIFICATION_TYPE_STREAM_END);
- assert(notif_stream);
+ BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_STREAM_END);
+ BT_ASSERT(notif_stream);
ret = ensure_stream_state_exists(iterator, NULL, notif_stream,
&stream_state);
if (ret) {
int ret = 0;
struct stream_state *stream_state;
- assert(notif->type == BT_NOTIFICATION_TYPE_DISCARDED_EVENTS ||
+ BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_DISCARDED_EVENTS ||
notif->type == BT_NOTIFICATION_TYPE_DISCARDED_PACKETS);
- assert(notif_stream);
+ BT_ASSERT(notif_stream);
ret = ensure_stream_state_exists(iterator, NULL, notif_stream,
&stream_state);
if (ret) {
int ret = 0;
struct stream_state *stream_state;
- assert(notif->type == BT_NOTIFICATION_TYPE_PACKET_BEGIN);
- assert(notif_packet);
+ BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_PACKET_BEGIN);
+ BT_ASSERT(notif_packet);
ret = ensure_stream_state_exists(iterator, NULL, notif_stream,
&stream_state);
if (ret) {
int ret = 0;
struct stream_state *stream_state;
- assert(notif->type == BT_NOTIFICATION_TYPE_PACKET_END);
- assert(notif_packet);
+ BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_PACKET_END);
+ BT_ASSERT(notif_packet);
ret = ensure_stream_state_exists(iterator, NULL, notif_stream,
&stream_state);
if (ret) {
int ret = 0;
struct stream_state *stream_state;
- assert(notif->type == BT_NOTIFICATION_TYPE_EVENT);
- assert(notif_packet);
+ BT_ASSERT(notif->type == BT_NOTIFICATION_TYPE_EVENT);
+ BT_ASSERT(notif_packet);
ret = ensure_stream_state_exists(iterator, NULL, notif_stream,
&stream_state);
if (ret) {
struct bt_stream *notif_stream = NULL;
struct bt_packet *notif_packet = NULL;
- assert(notif);
+ BT_ASSERT(notif);
BT_LOGV("Enqueuing user notification and automatic notifications: "
"iter-addr=%p, notif-addr=%p", iterator, notif);
switch (notif->type) {
case BT_NOTIFICATION_TYPE_EVENT:
notif_event = bt_notification_event_borrow_event(notif);
- assert(notif_event);
+ BT_ASSERT(notif_event);
notif_packet = bt_event_borrow_packet(notif_event);
- assert(notif_packet);
+ BT_ASSERT(notif_packet);
break;
case BT_NOTIFICATION_TYPE_STREAM_BEGIN:
notif_stream =
bt_notification_stream_begin_borrow_stream(notif);
- assert(notif_stream);
+ BT_ASSERT(notif_stream);
break;
case BT_NOTIFICATION_TYPE_STREAM_END:
notif_stream = bt_notification_stream_end_borrow_stream(notif);
- assert(notif_stream);
+ BT_ASSERT(notif_stream);
break;
case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
notif_packet =
bt_notification_packet_begin_borrow_packet(notif);
- assert(notif_packet);
+ BT_ASSERT(notif_packet);
break;
case BT_NOTIFICATION_TYPE_PACKET_END:
notif_packet = bt_notification_packet_end_borrow_packet(notif);
- assert(notif_packet);
+ BT_ASSERT(notif_packet);
break;
case BT_NOTIFICATION_TYPE_INACTIVITY:
/* Always valid */
if (notif_packet) {
notif_stream = bt_packet_borrow_stream(notif_packet);
- assert(notif_stream);
+ BT_ASSERT(notif_stream);
}
if (!notif_stream) {
&stream_state_gptr)) {
struct stream_state *stream_state = stream_state_gptr;
- assert(stream_state_gptr);
+ BT_ASSERT(stream_state_gptr);
if (stream_state->is_ended) {
continue;
BT_NOTIFICATION_ITERATOR_STATUS_OK;
int ret;
- assert(iterator);
+ BT_ASSERT(iterator);
BT_LOGD("Ensuring that notification iterator's queue has at least one notification: "
"iter-addr=%p, queue-size=%u, iter-state=%s",
iterator, iterator->queue->length,
break;
}
- assert(iterator->upstream_component);
- assert(iterator->upstream_component->class);
+ BT_ASSERT(iterator->upstream_component);
+ BT_ASSERT(iterator->upstream_component->class);
/* Pick the appropriate "next" method */
switch (iterator->upstream_component->class->type) {
container_of(iterator->upstream_component->class,
struct bt_component_class_source, parent);
- assert(source_class->methods.iterator.next);
+ BT_ASSERT(source_class->methods.iterator.next);
next_method = source_class->methods.iterator.next;
break;
}
container_of(iterator->upstream_component->class,
struct bt_component_class_filter, parent);
- assert(filter_class->methods.iterator.next);
+ BT_ASSERT(filter_class->methods.iterator.next);
next_method = filter_class->methods.iterator.next;
break;
}
* Call the user's "next" method to get the next notification
* and status.
*/
- assert(next_method);
+ BT_ASSERT(next_method);
while (iterator->queue->length == 0) {
BT_LOGD_STR("Calling user's \"next\" method.");
goto end;
}
- assert(iterator->state ==
+ BT_ASSERT(iterator->state ==
BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ACTIVE);
iterator->state = BT_PRIVATE_CONNECTION_NOTIFICATION_ITERATOR_STATE_ENDED;
* Move the notification at the tail of the queue to the
* iterator's current notification.
*/
- assert(priv_conn_iter->queue->length > 0);
+ BT_ASSERT(priv_conn_iter->queue->length > 0);
notif = g_queue_pop_tail(priv_conn_iter->queue);
bt_notification_iterator_replace_current_notification(
iterator, notif);
break;
case BT_GRAPH_STATUS_OK:
status = BT_NOTIFICATION_ITERATOR_STATUS_OK;
- assert(bt_notification_iterator_borrow_current_notification(iterator));
+ BT_ASSERT(bt_notification_iterator_borrow_current_notification(iterator));
break;
default:
/* Other errors */
}
graph = bt_component_get_graph(output_port_comp);
- assert(graph);
+ BT_ASSERT(graph);
/* Create notification iterator */
BT_LOGD("Creating notification iterator on output port: "
*/
colander_in_port = bt_component_sink_get_input_port_by_index(
iterator->colander, 0);
- assert(colander_in_port);
+ BT_ASSERT(colander_in_port);
graph_status = bt_graph_connect_ports(iterator->graph,
output_port, colander_in_port, NULL);
if (graph_status != BT_GRAPH_STATUS_OK) {
*/
ret = bt_graph_remove_unconnected_component(iterator->graph,
colander_comp);
- assert(ret == 0);
+ BT_ASSERT(ret == 0);
}
BT_PUT(iterator);