X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Ftrace-ir%2Fpacket.c;h=a5c3fc7a196e61878b88fe3da34040446120ae83;hb=c4f23e30bf67d2523163614bc9461d84cbe1ae80;hp=d32da65a8a155bd176309168ddc2dd6317c6c9ba;hpb=d24d56638469189904fb6ddbb3c725817b3e9417;p=babeltrace.git diff --git a/src/lib/trace-ir/packet.c b/src/lib/trace-ir/packet.c index d32da65a..a5c3fc7a 100644 --- a/src/lib/trace-ir/packet.c +++ b/src/lib/trace-ir/packet.c @@ -32,6 +32,7 @@ #include "lib/object.h" #include "common/assert.h" #include +#include #include "field.h" #include "field-wrapper.h" @@ -41,12 +42,9 @@ #include "trace.h" #include "lib/func-status.h" -#define BT_ASSERT_PRE_PACKET_HOT(_packet) \ - BT_ASSERT_PRE_HOT((_packet), "Packet", ": %!+a", (_packet)) - struct bt_stream *bt_packet_borrow_stream(struct bt_packet *packet) { - BT_ASSERT_PRE_NON_NULL(packet, "Packet"); + BT_ASSERT_PRE_DEV_NON_NULL(packet, "Packet"); return packet->stream; } @@ -58,7 +56,7 @@ const struct bt_stream *bt_packet_borrow_stream_const( struct bt_field *bt_packet_borrow_context_field(struct bt_packet *packet) { - BT_ASSERT_PRE_NON_NULL(packet, "Packet"); + BT_ASSERT_PRE_DEV_NON_NULL(packet, "Packet"); return packet->context_field ? packet->context_field->field : NULL; } @@ -147,7 +145,7 @@ void bt_packet_recycle(struct bt_packet *packet) BT_ASSERT(stream); packet->stream = NULL; bt_object_pool_recycle_object(&stream->packet_pool, packet); - bt_object_put_no_null_check(&stream->base); + bt_object_put_ref_no_null_check(&stream->base); } BT_HIDDEN @@ -182,14 +180,15 @@ struct bt_packet *bt_packet_new(struct bt_stream *stream) BT_LIB_LOGD("Creating packet object: %![stream-]+s", stream); packet = g_new0(struct bt_packet, 1); if (!packet) { - BT_LOGE_STR("Failed to allocate one packet object."); + BT_LIB_LOGE_APPEND_CAUSE( + "Failed to allocate one packet object."); goto error; } bt_object_init_shared(&packet->base, (bt_object_release_func) bt_packet_recycle); packet->stream = stream; - bt_object_get_no_null_check(stream); + bt_object_get_ref_no_null_check(stream); trace_class = bt_stream_class_borrow_trace_class_inline(stream->class); BT_ASSERT(trace_class); @@ -199,7 +198,8 @@ struct bt_packet *bt_packet_new(struct bt_stream *stream) &stream->class->packet_context_field_pool, stream->class->packet_context_fc); if (!packet->context_field) { - BT_LOGE_STR("Cannot create packet context field wrapper."); + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot create packet context field wrapper."); goto error; } } @@ -220,16 +220,20 @@ struct bt_packet *bt_packet_create(const struct bt_stream *c_stream) struct bt_stream *stream = (void *) c_stream; BT_ASSERT_PRE_NON_NULL(stream, "Stream"); + BT_ASSERT_PRE(stream->class->supports_packets, + "Stream class does not support packets: %![sc-]+S", + stream->class); packet = bt_object_pool_create_object(&stream->packet_pool); if (G_UNLIKELY(!packet)) { - BT_LIB_LOGE("Cannot allocate one packet from stream's packet pool: " + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot allocate one packet from stream's packet pool: " "%![stream-]+s", stream); goto end; } if (G_LIKELY(!packet->stream)) { packet->stream = stream; - bt_object_get_no_null_check_no_parent_check( + bt_object_get_ref_no_null_check_no_parent_check( &packet->stream->base); } @@ -244,14 +248,14 @@ enum bt_packet_move_context_field_status bt_packet_move_context_field( struct bt_stream_class *stream_class; struct bt_field_wrapper *field_wrapper = (void *) context_field; - BT_ASSERT_PRE_NON_NULL(packet, "Packet"); - BT_ASSERT_PRE_NON_NULL(field_wrapper, "Context field"); - BT_ASSERT_PRE_HOT(packet, "Packet", ": %!+a", packet); + BT_ASSERT_PRE_DEV_NON_NULL(packet, "Packet"); + BT_ASSERT_PRE_DEV_NON_NULL(field_wrapper, "Context field"); + BT_ASSERT_PRE_DEV_HOT(packet, "Packet", ": %!+a", packet); stream_class = packet->stream->class; - BT_ASSERT_PRE(stream_class->packet_context_fc, + BT_ASSERT_PRE_DEV(stream_class->packet_context_fc, "Stream class has no packet context field class: %!+S", stream_class); - BT_ASSERT_PRE(field_wrapper->field->class == + BT_ASSERT_PRE_DEV(field_wrapper->field->class == stream_class->packet_context_fc, "Unexpected packet context field's class: " "%![fc-]+F, %![expected-fc-]+F", field_wrapper->field->class,